Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761178AbcLUT1k (ORCPT ); Wed, 21 Dec 2016 14:27:40 -0500 Received: from mail-sn1nam01on0100.outbound.protection.outlook.com ([104.47.32.100]:60086 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757168AbcLUT1j (ORCPT ); Wed, 21 Dec 2016 14:27:39 -0500 X-Greylist: delayed 79058 seconds by postgrey-1.27 at vger.kernel.org; Wed, 21 Dec 2016 14:27:39 EST From: KY Srinivasan To: Roman Kagan , Paolo Bonzini , =?iso-8859-2?Q?Radim_Kr=E8m=E1=F8?= , Vitaly Kuznetsov CC: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86@kernel.org" , "Haiyang Zhang" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "Denis V . Lunev" Subject: RE: [PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent hypercall structures Thread-Topic: [PATCH 10/15] hyperv: uapi-fy PostMessage and SignalEvent hypercall structures Thread-Index: AQHSWtm1DhVlczreskqEGsiS4ua5XqESyfdA Date: Wed, 21 Dec 2016 19:27:36 +0000 Message-ID: References: <20161220155602.6298-1-rkagan@virtuozzo.com> <20161220155602.6298-11-rkagan@virtuozzo.com> In-Reply-To: <20161220155602.6298-11-rkagan@virtuozzo.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; x-originating-ip: [2601:600:8c00:1040:b076:3b2a:409c:285e] x-ms-office365-filtering-correlation-id: d711a6ad-dd0d-4004-a6cd-08d429d76bc2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR03MB1424; x-microsoft-exchange-diagnostics: 1;CY1PR03MB1424;7:3JygOX+0FBo8ctcJ4V2Kupn8YUx0f0fHLXMAJuXHyUgZhQKpYwV5pRiw7ubHir/ouIaanovTFsMqV2qLKd0BM0WCsVwVUsMkgrf5qYPzhX6ySj0JUAMsjOEz3Yfq9lfj8zx9/y+j0EeZF+XvFiL7ZMKWOgd1wrGzSpjr/ZqBFl6fVJBHobeYjjKZyBWHUYT2GRWl6ItNWqBDv66CkIVcL7wLRbyD9YrPLIev5rvc7uqqWw0TsYzV37gbfThYlCG6DdQQiTrIFZGTxykp9x0uALJzZFLfV1nOXPyyY0kTUY2OEhgPdwIfdVMZnA6mAfaxd7LiEgl2leMkGcfgl6VFPBvfS+oBEJ5R35ZxETiSl4debELx9UVujM8azS5beBxMAlIH2+3ZlmvElbIhcWk6HKgav4tIqUPgOeJZ/3Od3dUznMno+v6adUExOAaqzD+/NH+X2Bo2P5zWF5pSREesRUCGZ4LyY2/nOGQRs81VLVM= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(211171220733660); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123564025)(6072148)(6047074);SRVR:CY1PR03MB1424;BCL:0;PCL:0;RULEID:;SRVR:CY1PR03MB1424; x-forefront-prvs: 01630974C0 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(7916002)(39860400002)(39850400002)(39450400003)(39840400002)(39410400002)(13464003)(199003)(377454003)(189002)(97736004)(3660700001)(76576001)(122556002)(106356001)(105586002)(99286002)(8990500004)(5005710100001)(3280700002)(10290500002)(106116001)(5001770100001)(189998001)(2906002)(86362001)(4326007)(86612001)(38730400001)(74316002)(2900100001)(6436002)(6116002)(77096006)(92566002)(68736007)(5660300001)(33656002)(102836003)(2950100002)(9686002)(7696004)(8936002)(7736002)(76176999)(10090500001)(81156014)(54356999)(50986999)(229853002)(81166006)(7416002)(305945005)(6506006)(8676002)(101416001)(25786008);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR03MB1424;H:DM5PR03MB2490.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-2" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Dec 2016 19:27:36.5696 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR03MB1424 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uBLJRqmj021330 Content-Length: 8266 Lines: 259 > -----Original Message----- > From: Roman Kagan [mailto:rkagan@virtuozzo.com] > Sent: Tuesday, December 20, 2016 7:56 AM > To: Paolo Bonzini ; Radim Kr?m?? > ; KY Srinivasan ; Vitaly > Kuznetsov > Cc: Thomas Gleixner ; Ingo Molnar > ; H. Peter Anvin ; x86@kernel.org; > Haiyang Zhang ; kvm@vger.kernel.org; linux- > kernel@vger.kernel.org; devel@linuxdriverproject.org; Denis V . Lunev > ; Roman Kagan > 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 > --- > 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