Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936053AbcLTRam (ORCPT ); Tue, 20 Dec 2016 12:30:42 -0500 Received: from mail-eopbgr40111.outbound.protection.outlook.com ([40.107.4.111]:47684 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934351AbcLTRae (ORCPT ); Tue, 20 Dec 2016 12:30:34 -0500 X-Greylist: delayed 3618 seconds by postgrey-1.27 at vger.kernel.org; Tue, 20 Dec 2016 12:30:33 EST Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; From: Roman Kagan To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , "K. Y. Srinivasan" , Vitaly Kuznetsov CC: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , , Haiyang Zhang , , , , "Denis V . Lunev" , Roman Kagan Subject: [PATCH 02/15] hyperv: uapi-fy synic event flags definitions Date: Tue, 20 Dec 2016 18:55:49 +0300 Message-ID: <20161220155602.6298-3-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161220155602.6298-1-rkagan@virtuozzo.com> References: <20161220155602.6298-1-rkagan@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM4PR01CA0030.eurprd01.prod.exchangelabs.com (10.164.74.168) To VI1PR0802MB2478.eurprd08.prod.outlook.com (10.175.26.21) X-MS-Office365-Filtering-Correlation-Id: b0d09d9f-6fc5-4721-f491-08d428f0ca82 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0802MB2478; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2478;3:xbfSHVZ+P1FkxBTcs9fISoii65tQ5Xuu9RdewM5JiJcLfEYZkaIWYAl1sBYcMizom5++vZaJk7Auf3PeptEuGaoQ2IDFQqe2aM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PVzdAC/TQIbqnYERJDzWm+bNxAZhse6+Ftq6hFCuKI3m5X+uEsHC3XbJg4jarq+v0d650qI2kKYiJI6SsfBHu/gwmfaib/7ViTWUmGjN+Hp3qsQ0ibCUyIL93DpdzXDc2zBCO7yb8bh1i2dl9EkgQrcAhNqguSdeYM4PiH/xsR1BtZIKFPDe/aYbib5OtMIedsQkiNjtmBMmb9nlKqryXOg/g5XDvDFKZMQ==;20:0akpJn4TyzkIxYlKfwanRbtHJHmMAoCIQLp2uTDQxxdsmP/GDt9vyRmS+vfvZoZdYUxo6fJChtg3go0eOdEbqKB56Bc5/5ZcwG+8zMPPSL0G96WEYryVeemBRmNUUqtL751XA/ScPjVYXLJ7kCB0w5R+oYCbBsHIHFW2TEP3Bc83jfBmdBWYOyWN9TTMsAOuPHjCVZMceX9tlRkhvJKxXySBE8DiWppcbjELFC/NJZ911LW19NpCl8RKUgSEYYoF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123564025)(20161123555025)(20161123560025)(20161123558021)(20161123562025)(6072148);SRVR:VI1PR0802MB2478;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0802MB2478; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2478;4:IYRybeovP9sA+yEjTseG7CmXLf7d7bADBFF/+vpg13fwgEgDxfNYtg9QH+r2PFy9cJ7jCDOPTsC8n/Jb/PCQiKxOLROR7IL3RU+p7peBL2OOHDHe1w9FEmyXxSOG1badTz2s4DqeG09fvujXBRn1Gun260r/lYA56XiEQ4jgwbJmCirxEAs6S928a9sIV9kmO95gptzIZf9NWk6r9Tn/vyIKF7z9BO6NGtznXgdWwORdIRG3WpoaksCTtuNuOjyGCTKqwE0ybEgrcVlzaL/HqWgUeCIUzut//Pxv13qW35DN6X68f3mUeUOoGxikt488o+S5PEzqhLnZWrjXoDk/ZuSltnqtljNVF72c1cCjaPuc91r2oujYB+/rVKrTbHLFpbt515Dk7nWiLU9mb1Pp2hu9dtniBONS9cJL/ybxgqguIjA8/3mCUclAkn7rF234RF+3S7Tnd0XJMJDo+Tzk7a9Va3PrC+6wQ5txZkDQKTvQ2kTgEBYXd7JL3fZoH67TAHLqS2N0+LCn1/9w/wJS5k1cDyf7JTmwv/Xcvirh8tbCTstI0LTozC4zz6eMc+SpyBDk7xJ/Ffalgmv9o4Ou+2FdnARJA/FVWIh3CsYTIcE= X-Forefront-PRVS: 0162ACCC24 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(39450400003)(199003)(189002)(97736004)(189998001)(101416001)(5001770100001)(4001430100002)(5003940100001)(36756003)(81166006)(47776003)(50986999)(66066001)(1511001)(2950100002)(50466002)(76176999)(5660300001)(81156014)(2906002)(8666005)(305945005)(69596002)(48376002)(7736002)(92566002)(7416002)(106356001)(53416004)(25786008)(6116002)(105586002)(6486002)(2421001)(6506006)(1076002)(3846002)(575784001)(86362001)(4326007)(68736007)(8676002)(50226002)(42186005)(107886002)(2561002)(38730400001)(6512006)(33646002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0802MB2478;H:rkaganb.sw.ru;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0802MB2478;23:HlbpYw8fmoOYlLc73W5kahjPSgD2M7xru+Y1EsU?= =?us-ascii?Q?CRq85WMJcWnPkSAUp3sgTz46Ppu+nd61jAE3SgWrhE1zn1DefNbDoWiEMUDU?= =?us-ascii?Q?2jzhErxw3OKt0sQKOUcyxTdc5fCVI3MRNRbdK/enD0gdpMxC1ipZ6ArzNoPQ?= =?us-ascii?Q?TRyTUUD4gymbzTZPIRrAbeg9XfC8oGgOfkG55fl83MPLPi9pTqMf9uryiGlm?= =?us-ascii?Q?ik6U0N13/C3VKLYp23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ascii?Q?4isbcMO+1uBZds46gdShHuTDnunpG8S7fN0iDuYvhw3nFqb1JfdT01dSoEc+?= =?us-ascii?Q?p65VpYVFYZD4/KR4j856c7qliLvrnUgyutbetBtdBvlkFipEOlDA9y9OCYyR?= =?us-ascii?Q?zcWl3DspscrcqB5JKyDr8tS+oMUOMOIpHSSVzhdDqB4UJTY7+Sh1Hm6c94DM?= =?us-ascii?Q?tkg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2478;6:IdUCjXwzQiYhwA4+l+rGtZrGOdjDMtZL3LUMRT0tbU4n4S0kkbhK458etD9Mgatb7LWRyu8Z56pQi51KAfywt9x0F4M/lHGpm99CJHom4LdregVKxcw3Ixs2bCFSf7SwlWnvUa1H07nQu41B5TbDa9WpY6WCEzMWgKYhrNIGzrwpzPZve1ANuxkJrafai+d3GEPwTtVbf/EhqgJhjJmLAwyKdxRKkNV6G6zHaQ9u6pVcDJAq2zvUku9iwN2j1GyAKJfrG0tBsdyWv/FxmQDnx/hJxdpgbnTF1YUFDSJlEPhuoShu/kHcWYsHoqEl8WvT9PfcuPlqgRKqOWwJQZ3S8oKIkzfTD0NzPvI6AKF7Jv1wKyLo8YSSjaNeku6Fs8n9ZxW4SNY4wdeGoxB3hauXGtul8560abwCXiM5DkuOnmA=;5:no3wOcE6LCnhul+gVX9yV1lUSjoDCkt0+sZbX2GROvZ3kGUMMhnpTQOUPKORjpKbz1Aj56KEKZ5GwmaO316wS+RvNPgvhpIyeltJeWuPAPhtsDDv2GbRwupE4lH+l76h0hYXfhbaVfrABkJ77l4FCqAKcv99b07fbAid5aAyyOQ=;24:7MuHPeKhIc8UMuRfLOfrencmXKVqPtXwDkLBwfQ1EZmIZA9282Yyhn5/GrInFi86ey3PqGmbR8HaEbfT3TFLsggwbao2uiAkoO4zPy9lIrI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0802MB2478;7:NNg5F7A8ans0LtJJHqDGZtk9p5l1un9/P1avm5x3ZjZRrq08GMgjhdRADCsHHdnxGTPtdG5u0vTee4Z6bXK7RRiPBsxhg+0aSAFAylizuUHSNKgu4UbfcEBusAfuN/e2644tmszxrV4RWAv3NFmiWA+df+Gi0wxQRmBBeVWBu41lM8gmvIU9rzeaK4xnG1lzBLCuts0n/R330hsyJocoko8X2V6GPnnrJjoXmBV1ACezlKwx8/YpQzm1ZGg136wmTnFeqG8h7BiW0z0SqmEOxATNe/lzuajexQ0ahZmL80q7twdIqwyYaa1QVUlDmTLB1d4k/gyQ7Ai3vfC1hw2X6/ffUxcliCP3tpVRzS4zoskwWN/4t63xX1o7skdJFOxJbUkf4Zz1PYVYOnVOz4vrAddG0o/ABuL71UEqS7s8FvmetY1dnkHAhTlv/MRpaXF7EMUmWf5aN0bH0ugFp7C2lA==;20:xD+oZR8PtXqGci3dx2yvvxMQicI4gAHtGJhAa7Y4EjpFEDUOrTSGZvx9dSVPpTeHyi/0/Ej0eq+hElPuWMN+8/Sb+cmQzgdjcwzAwX2OhZbFiLSc2BCO009KnRTkyTmIRA6RnyBomM8kAaE1pUmHQSuLEoMsaPWV9oiG91RLcPI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2016 15:56:41.0615 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2478 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9350 Lines: 294 Move definitions related to the Hyper-V SynIC event flags to a header where they can be consumed by userspace. While doing so, also clean up their use by switching to standard bitops and struct-based dereferencing. The latter is also done for message pages. Signed-off-by: Roman Kagan --- arch/x86/include/uapi/asm/hyperv.h | 13 +++++++++ drivers/hv/hyperv_vmbus.h | 24 ++-------------- drivers/hv/channel_mgmt.c | 10 +++---- drivers/hv/connection.c | 47 ++++++++++--------------------- drivers/hv/vmbus_drv.c | 57 ++++++++++++++------------------------ 5 files changed, 54 insertions(+), 97 deletions(-) diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h index 6098ab5..af542a3 100644 --- a/arch/x86/include/uapi/asm/hyperv.h +++ b/arch/x86/include/uapi/asm/hyperv.h @@ -363,4 +363,17 @@ struct hv_timer_message_payload { #define HV_STIMER_AUTOENABLE (1ULL << 3) #define HV_STIMER_SINT(config) (__u8)(((config) >> 16) & 0x0F) +/* Define synthetic interrupt controller flag constants. */ +#define HV_EVENT_FLAGS_COUNT (256 * 8) + +/* Define the synthetic interrupt controller event flags format. */ +struct hv_synic_event_flags { + __u64 flags[HV_EVENT_FLAGS_COUNT / 64]; +}; + +/* Define the synthetic interrupt flags page layout. */ +struct hv_synic_event_flags_page { + struct hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT]; +}; + #endif diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h index 4516498..4fab154 100644 --- a/drivers/hv/hyperv_vmbus.h +++ b/drivers/hv/hyperv_vmbus.h @@ -26,7 +26,6 @@ #define _HYPERV_VMBUS_H #include -#include #include #include @@ -75,11 +74,6 @@ enum hv_cpuid_function { #define HV_ANY_VP (0xFFFFFFFF) -/* Define synthetic interrupt controller flag constants. */ -#define HV_EVENT_FLAGS_COUNT (256 * 8) -#define HV_EVENT_FLAGS_BYTE_COUNT (256) -#define HV_EVENT_FLAGS_DWORD_COUNT (256 / sizeof(u32)) - /* Define invalid partition identifier. */ #define HV_PARTITION_ID_INVALID ((u64)0x0) @@ -146,20 +140,6 @@ union hv_timer_config { }; }; -/* Define the number of message buffers associated with each port. */ -#define HV_PORT_MESSAGE_BUFFER_COUNT (16) - -/* Define the synthetic interrupt controller event flags format. */ -union hv_synic_event_flags { - u8 flags8[HV_EVENT_FLAGS_BYTE_COUNT]; - u32 flags32[HV_EVENT_FLAGS_DWORD_COUNT]; -}; - -/* Define the synthetic interrupt flags page layout. */ -struct hv_synic_event_flags_page { - union hv_synic_event_flags sintevent_flags[HV_SYNIC_SINT_COUNT]; -}; - /* Define SynIC control register. */ union hv_synic_scontrol { u64 as_uint64; @@ -434,8 +414,8 @@ struct hv_context { bool synic_initialized; - void *synic_message_page[NR_CPUS]; - void *synic_event_page[NR_CPUS]; + struct hv_message_page *synic_message_page[NR_CPUS]; + struct hv_synic_event_flags_page *synic_event_page[NR_CPUS]; /* * Hypervisor's notion of virtual processor ID is different from * Linux' notion of CPU ID. This information can only be retrieved diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 26b4192..49eaae2 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -654,7 +654,6 @@ static void init_vp_index(struct vmbus_channel *channel, u16 dev_type) static void vmbus_wait_for_unload(void) { int cpu; - void *page_addr; struct hv_message *msg; struct vmbus_channel_message_header *hdr; u32 message_type; @@ -673,9 +672,8 @@ static void vmbus_wait_for_unload(void) break; for_each_online_cpu(cpu) { - page_addr = hv_context.synic_message_page[cpu]; - msg = (struct hv_message *)page_addr + - VMBUS_MESSAGE_SINT; + msg = &hv_context.synic_message_page[cpu]-> + sint_message[VMBUS_MESSAGE_SINT]; message_type = READ_ONCE(msg->header.message_type); if (message_type == HVMSG_NONE) @@ -699,8 +697,8 @@ static void vmbus_wait_for_unload(void) * messages after we reconnect. */ for_each_online_cpu(cpu) { - page_addr = hv_context.synic_message_page[cpu]; - msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; + msg = &hv_context.synic_message_page[cpu]-> + sint_message[VMBUS_MESSAGE_SINT]; msg->header.message_type = HVMSG_NONE; } } diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index 6ce8b87..aaa2103 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -381,17 +381,12 @@ static void process_chn_event(u32 relid) */ void vmbus_on_event(unsigned long data) { - u32 dword; - u32 maxdword; - int bit; - u32 relid; - u32 *recv_int_page = NULL; - void *page_addr; + u32 relid, max_relid; + unsigned long *recv_int_page; int cpu = smp_processor_id(); - union hv_synic_event_flags *event; if (vmbus_proto_version < VERSION_WIN8) { - maxdword = MAX_NUM_CHANNELS_SUPPORTED >> 5; + max_relid = MAX_NUM_CHANNELS_SUPPORTED; recv_int_page = vmbus_connection.recv_int_page; } else { /* @@ -399,36 +394,22 @@ void vmbus_on_event(unsigned long data) * can be directly checked to get the id of the channel * that has the interrupt pending. */ - maxdword = HV_EVENT_FLAGS_DWORD_COUNT; - page_addr = hv_context.synic_event_page[cpu]; - event = (union hv_synic_event_flags *)page_addr + - VMBUS_MESSAGE_SINT; - recv_int_page = event->flags32; + struct hv_synic_event_flags *event = + &hv_context.synic_event_page[cpu]-> + sintevent_flags[VMBUS_MESSAGE_SINT]; + max_relid = HV_EVENT_FLAGS_COUNT; + recv_int_page = (unsigned long *)event->flags; } - - /* Check events */ if (!recv_int_page) return; - for (dword = 0; dword < maxdword; dword++) { - if (!recv_int_page[dword]) - continue; - for (bit = 0; bit < 32; bit++) { - if (sync_test_and_clear_bit(bit, - (unsigned long *)&recv_int_page[dword])) { - relid = (dword << 5) + bit; - - if (relid == 0) - /* - * Special case - vmbus - * channel protocol msg - */ - continue; - - process_chn_event(relid); - } - } + + /* relid == 0 is vmbus channel protocol msg */ + relid = 1; + for_each_set_bit_from(relid, recv_int_page, max_relid) { + clear_bit(relid, recv_int_page); + process_chn_event(relid); } } diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 230c62e..13dd210 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -872,9 +872,8 @@ static void hv_process_timer_expiration(struct hv_message *msg, int cpu) void vmbus_on_msg_dpc(unsigned long data) { int cpu = smp_processor_id(); - void *page_addr = hv_context.synic_message_page[cpu]; - struct hv_message *msg = (struct hv_message *)page_addr + - VMBUS_MESSAGE_SINT; + struct hv_message *msg = &hv_context.synic_message_page[cpu]-> + sint_message[VMBUS_MESSAGE_SINT]; struct vmbus_channel_message_header *hdr; struct vmbus_channel_message_table_entry *entry; struct onmessage_work_context *ctx; @@ -911,54 +910,40 @@ void vmbus_on_msg_dpc(unsigned long data) static void vmbus_isr(void) { int cpu = smp_processor_id(); - void *page_addr; struct hv_message *msg; - union hv_synic_event_flags *event; - bool handled = false; + struct hv_synic_event_flags *event; - page_addr = hv_context.synic_event_page[cpu]; - if (page_addr == NULL) + if (!hv_context.synic_event_page[cpu]) return; - event = (union hv_synic_event_flags *)page_addr + - VMBUS_MESSAGE_SINT; + event = &hv_context.synic_event_page[cpu]-> + sintevent_flags[VMBUS_MESSAGE_SINT]; /* * Check for events before checking for messages. This is the order * in which events and messages are checked in Windows guests on * Hyper-V, and the Windows team suggested we do the same. */ - if ((vmbus_proto_version == VERSION_WS2008) || - (vmbus_proto_version == VERSION_WIN7)) { - + /* On win8 and above the channel interrupts are signaled directly in + * the event page and will be checked in the .event_dpc + */ + if (vmbus_proto_version >= VERSION_WIN8 || /* Since we are a child, we only need to check bit 0 */ - if (sync_test_and_clear_bit(0, - (unsigned long *) &event->flags32[0])) { - handled = true; - } - } else { - /* - * Our host is win8 or above. The signaling mechanism - * has changed and we can directly look at the event page. - * If bit n is set then we have an interrup on the channel - * whose id is n. - */ - handled = true; - } - - if (handled) + test_and_clear_bit(0, (unsigned long *)event->flags)) tasklet_schedule(hv_context.event_dpc[cpu]); - - page_addr = hv_context.synic_message_page[cpu]; - msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT; + msg = &hv_context.synic_message_page[cpu]-> + sint_message[VMBUS_MESSAGE_SINT]; /* Check if there are actual msgs to be processed */ - if (msg->header.message_type != HVMSG_NONE) { - if (msg->header.message_type == HVMSG_TIMER_EXPIRED) - hv_process_timer_expiration(msg, cpu); - else - tasklet_schedule(hv_context.msg_dpc[cpu]); + switch (READ_ONCE(msg->header.message_type)) { + case HVMSG_NONE: + break; + case HVMSG_TIMER_EXPIRED: + hv_process_timer_expiration(msg, cpu); + break; + default: + tasklet_schedule(hv_context.msg_dpc[cpu]); } add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR, 0); -- 2.9.3