lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 21 Dec 2016 19:27:36 +0000
From:   KY Srinivasan <kys@...rosoft.com>
To:     Roman Kagan <rkagan@...tuozzo.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>
CC:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        "x86@...nel.org" <x86@...nel.org>,
        "Haiyang Zhang" <haiyangz@...rosoft.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "devel@...uxdriverproject.org" <devel@...uxdriverproject.org>,
        "Denis V . Lunev" <den@...nvz.org>
Subject: RE: [PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent
 hypercall structures



> -----Original Message-----
> From: Roman Kagan [mailto:rkagan@...tuozzo.com]
> Sent: Tuesday, December 20, 2016 7:56 AM
> To: Paolo Bonzini <pbonzini@...hat.com>; Radim Krčmář
> <rkrcmar@...hat.com>; KY Srinivasan <kys@...rosoft.com>; Vitaly
> Kuznetsov <vkuznets@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>; Ingo Molnar
> <mingo@...hat.com>; H. Peter Anvin <hpa@...or.com>; x86@...nel.org;
> Haiyang Zhang <haiyangz@...rosoft.com>; kvm@...r.kernel.org; linux-
> kernel@...r.kernel.org; devel@...uxdriverproject.org; Denis V . Lunev
> <den@...nvz.org>; Roman Kagan <rkagan@...tuozzo.com>
> Subject: [PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent
> hypercall structures
> 
> Expose structures used for PostMessage and SignalEvent hypercalls in a
> uapi header.  While doing so, simplify alignment handling and drop
> unnecessary complications in the connectionid field.

Split up the patch.
> 
> Signed-off-by: Roman Kagan <rkagan@...tuozzo.com>
> ---
>  arch/x86/include/uapi/asm/hyperv.h | 18 ++++++++++++++++++
>  drivers/hv/hyperv_vmbus.h          | 16 ++--------------
>  include/linux/hyperv.h             | 24 +-----------------------
>  drivers/hv/channel_mgmt.c          | 14 ++++----------
>  drivers/hv/connection.c            |  9 +++------
>  drivers/hv/hv.c                    |  2 +-
>  drivers/hv/vmbus_drv.c             |  2 +-
>  7 files changed, 30 insertions(+), 55 deletions(-)
> 
> diff --git a/arch/x86/include/uapi/asm/hyperv.h
> b/arch/x86/include/uapi/asm/hyperv.h
> index 749fbb25..eb8d42a 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -378,4 +378,22 @@ struct hv_synic_event_flags_page {
>  	struct hv_synic_event_flags
> sintevent_flags[HV_SYNIC_SINT_COUNT];
>  };
> 
> +#define HV_HYPERCALL_PARAM_ALIGN	8
> +
> +/* Definition of the hv_post_message hypercall input structure. */
> +struct hv_input_post_message {
> +	__u32 connectionid;
> +	__u32 reserved;
> +	__u32 message_type;
> +	__u32 payload_size;
> +	__u64 payload[HV_MESSAGE_PAYLOAD_BYTE_COUNT];
> +} __attribute__((aligned(HV_HYPERCALL_PARAM_ALIGN)));
> +
> +/* Definition of the hv_signal_event hypercall input structure. */
> +struct hv_input_signal_event {
> +	__u32 connectionid;
> +	__u16 flag_number;
> +	__u16 rsvdz;
> +} __attribute__((aligned(HV_HYPERCALL_PARAM_ALIGN)));
> +
>  #endif
> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> index ac73832..a96f021 100644
> --- a/drivers/hv/hyperv_vmbus.h
> +++ b/drivers/hv/hyperv_vmbus.h
> @@ -104,7 +104,7 @@ union hv_monitor_trigger_group {
>  };
> 
>  struct hv_monitor_parameter {
> -	union hv_connection_id connectionid;
> +	u32 connectionid;
>  	u16 flagnumber;
>  	u16 rsvdz;
>  };
> @@ -154,15 +154,6 @@ struct hv_monitor_page {
>  	u8 rsvdz4[1984];
>  };
> 
> -/* Definition of the hv_post_message hypercall input structure. */
> -struct hv_input_post_message {
> -	union hv_connection_id connectionid;
> -	u32 reserved;
> -	u32 message_type;
> -	u32 payload_size;
> -	u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
> -};
> -
>  /*
>   * Versioning definitions used for guests reporting themselves to the
>   * hypervisor, and visa versa.
> @@ -248,9 +239,6 @@ static inline  __u64 generate_guest_id(__u8 d_info1,
> __u32 kernel_version,
>  #define HV_CAPS_MAX			8
> 
> 
> -#define HV_HYPERCALL_PARAM_ALIGN	sizeof(u64)
> -
> -
>  /* Service definitions */
> 
>  #define HV_SERVICE_PARENT_PORT				(0)
> @@ -351,7 +339,7 @@ extern int hv_init(void);
> 
>  extern void hv_cleanup(bool crash);
> 
> -extern int hv_post_message(union hv_connection_id connection_id,
> +extern int hv_post_message(u32 connection_id,
>  			 enum hv_message_type message_type,
>  			 void *payload, size_t payload_size);
> 
> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
> index 42fe43f..e92446e 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -648,27 +648,6 @@ struct vmbus_close_msg {
>  	struct vmbus_channel_close_channel msg;
>  };
> 
> -/* Define connection identifier type. */
> -union hv_connection_id {
> -	u32 asu32;
> -	struct {
> -		u32 id:24;
> -		u32 reserved:8;
> -	} u;
> -};
> -
> -/* Definition of the hv_signal_event hypercall input structure. */
> -struct hv_input_signal_event {
> -	union hv_connection_id connectionid;
> -	u16 flag_number;
> -	u16 rsvdz;
> -};
> -
> -struct hv_input_signal_event_buffer {
> -	u64 align8;
> -	struct hv_input_signal_event event;
> -};
> -
>  enum hv_signal_policy {
>  	HV_SIGNAL_POLICY_DEFAULT = 0,
>  	HV_SIGNAL_POLICY_EXPLICIT,
> @@ -755,8 +734,7 @@ struct vmbus_channel {
>  	bool batched_reading;
> 
>  	bool is_dedicated_interrupt;
> -	struct hv_input_signal_event_buffer sig_buf;
> -	struct hv_input_signal_event *sig_event;
> +	struct hv_input_signal_event sig_event;
> 
>  	/*
>  	 * Starting with win8, this field will be used to specify
> diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
> index 49eaae2..4a5cc11 100644
> --- a/drivers/hv/channel_mgmt.c
> +++ b/drivers/hv/channel_mgmt.c
> @@ -766,20 +766,14 @@ static void vmbus_onoffer(struct
> vmbus_channel_message_header *hdr)
>  	/*
>  	 * Setup state for signalling the host.
>  	 */
> -	newchannel->sig_event = (struct hv_input_signal_event *)
> -				(ALIGN((unsigned long)
> -				&newchannel->sig_buf,
> -				HV_HYPERCALL_PARAM_ALIGN));
> -
> -	newchannel->sig_event->connectionid.asu32 = 0;
> -	newchannel->sig_event->connectionid.u.id =
> VMBUS_EVENT_CONNECTION_ID;
> -	newchannel->sig_event->flag_number = 0;
> -	newchannel->sig_event->rsvdz = 0;
> +	newchannel->sig_event.connectionid =
> VMBUS_EVENT_CONNECTION_ID;
> +	newchannel->sig_event.flag_number = 0;
> +	newchannel->sig_event.rsvdz = 0;
> 
>  	if (vmbus_proto_version != VERSION_WS2008) {
>  		newchannel->is_dedicated_interrupt =
>  				(offer->is_dedicated_interrupt != 0);
> -		newchannel->sig_event->connectionid.u.id =
> +		newchannel->sig_event.connectionid =
>  				offer->connection_id;
>  	}
> 
> diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
> index d38b27f..16ae977 100644
> --- a/drivers/hv/connection.c
> +++ b/drivers/hv/connection.c
> @@ -418,21 +418,18 @@ void vmbus_on_event(unsigned long data)
>   */
>  int vmbus_post_msg(void *buffer, size_t buflen)
>  {
> -	union hv_connection_id conn_id;
>  	int ret = 0;
>  	int retries = 0;
>  	u32 usec = 1;
> 
> -	conn_id.asu32 = 0;
> -	conn_id.u.id = VMBUS_MESSAGE_CONNECTION_ID;
> -
>  	/*
>  	 * hv_post_message() can have transient failures because of
>  	 * insufficient resources. Retry the operation a couple of
>  	 * times before giving up.
>  	 */
>  	while (retries < 20) {
> -		ret = hv_post_message(conn_id, HVMSG_VMBUS, buffer,
> buflen);
> +		ret =
> hv_post_message(VMBUS_MESSAGE_CONNECTION_ID, HVMSG_VMBUS,
> +				      buffer, buflen);
> 
>  		switch (ret) {
>  		case HV_STATUS_INVALID_CONNECTION_ID:
> @@ -472,6 +469,6 @@ void vmbus_set_event(struct vmbus_channel
> *channel)
>  		set_bit(child_relid,
>  			(unsigned long
> *)vmbus_connection.send_int_page);
> 
> -	hv_do_hypercall(HVCALL_SIGNAL_EVENT, channel->sig_event,
> NULL);
> +	hv_do_hypercall(HVCALL_SIGNAL_EVENT, &channel->sig_event,
> NULL);
>  }
>  EXPORT_SYMBOL_GPL(vmbus_set_event);
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 7d2a3d1..b9f50de 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -297,7 +297,7 @@ void hv_cleanup(bool crash)
>   *
>   * This involves a hypercall.
>   */
> -int hv_post_message(union hv_connection_id connection_id,
> +int hv_post_message(u32 connection_id,
>  		  enum hv_message_type message_type,
>  		  void *payload, size_t payload_size)
>  {
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 7564a7b..f6b626b 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -159,7 +159,7 @@ static u32 channel_conn_id(struct vmbus_channel
> *channel,
>  {
>  	u8 monitor_group = channel_monitor_group(channel);
>  	u8 monitor_offset = channel_monitor_offset(channel);
> -	return monitor_page-
> >parameter[monitor_group][monitor_offset].connectionid.u.id;
> +	return monitor_page-
> >parameter[monitor_group][monitor_offset].connectionid;
>  }
> 
>  static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr,
> --
> 2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ