From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754075AbdKJUjU (ORCPT ); Fri, 10 Nov 2017 15:39:20 -0500 Received: from mail-cys01nam02on0110.outbound.protection.outlook.com ([104.47.37.110]:24736 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754011AbdKJUjR (ORCPT ); Fri, 10 Nov 2017 15:39:17 -0500 From: KY Srinivasan To: Dmitry Torokhov , Juergen Gross CC: "linux-kernel@vger.kernel.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , Haiyang Zhang , Stephen Hemminger , "akataria@vmware.com" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "boris.ostrovsky@oracle.com" , "devel@linuxdriverproject.org" , "virtualization@lists.linux-foundation.org" , "kvm@vger.kernel.org" , "xen-devel@lists.xenproject.org" , "linux-graphics-maintainer@vmware.com" , "pv-drivers@vmware.com" , "xdeguillard@vmware.com" , "moltmann@vmware.com" , "arnd@arndb.de" , "gregkh@linuxfoundation.org" , "linux-input@vger.kernel.org" Subject: RE: [PATCH v2 2/5] x86: add enum for hypervisors to replace x86_hyper Thread-Topic: [PATCH v2 2/5] x86: add enum for hypervisors to replace x86_hyper Thread-Index: AQHTWV6SA6dA6MGol06m2a1SXkC7U6MN8AeAgAAkZ7A= Date: Fri, 10 Nov 2017 20:39:14 +0000 Message-ID: References: <20171109132739.23465-1-jgross@suse.com> <20171109132739.23465-3-jgross@suse.com> <20171110182611.maikfgykek7y6xww@dtor-ws> In-Reply-To: <20171110182611.maikfgykek7y6xww@dtor-ws> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=kys@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-11-10T20:39:12.1929674Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General x-originating-ip: [167.220.0.73] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR21MB0284;6:uv2qHDMD4x1D0xzbKBUKUdlP2icZ6YevywCcQCA3yL1Zl+zIs2TNFJeNhIYIzZEGw2QxqZVgt0ZU18LlHIpFINpzdrsaeX1JjkE1ji5sRZJyt+yq/qijo5LsJVsUibfw5TTwbEjhwlbJHCyKZMOF1jD4gsbctTALWW/e5vhksQg+Fm4HpWlg2hC+o3kHCB2np3gJ6eCsJPnZxlS620fFYKA4QlnbSyx7kvTQ1sc+TCiDas72WZN2jkLfSO5g6Z8wquzl9o0k43I1FnQ/r4zQjbT7WhNAXNP8qLVUhbY/ouTFSqyXRwbGEHCfYL0Rz2q6S7/Y1DNJgUl9CtrG6UAV9sKs/NcIVug3dErVRmqiUYk=;5:0tctQXrXvlTnkZ7f7RZ8aQZyN7wKD0LshoyalyS0o5TkibDm5IpIEwJxze+Excz3LMH0KY4sqI5YMgFFKvadtTcchz8PqqRmvP9YkBunVdB1fZwXltMMCMquctO/V22p1L6MBBFLgcyuJc2gPGSkgZCWuI6qfcStPqfCjDpFthA=;24:4jkE+JTaKNypnqC/60ZxPk4HkQhUeA/jhJFS/OG0qKuJWc0wRZIUiYUCWxueVxyT0/E4Ly7nw5X6l9DhBXFrPTJ0O72O90TnpqbaUNXk2Wc=;7:7lbGmC4bF+tJhEbhe7aiFZLFHMHDP6RArQVbmU651KcToKeBlsTxJkc6q9bV5fh9/botvQlbk1QyFPlkgPmBqtcSMQzR8n88u//Ip00XnXvBB9f8EA+ZezKErNngXoNAY5YCTQM9eFiquLO52tCUeAp9BHPw1YeOQxo/DfYT+eNZvSrROYUawfPRo3KMDIanKmj2V4Y2ovOxm+jWZe93SfOfz9ueiI7LeJUEbaOa9rkiAkIsUDHB6G6HQGFlPrQ5 x-ms-office365-filtering-correlation-id: 41e6ba2c-7b78-4d3d-dc2a-08d5287b1b59 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258);SRVR:DM5PR21MB0284; x-ms-traffictypediagnostic: DM5PR21MB0284: x-exchange-antispam-report-test: UriScan:(61668805478150)(89211679590171)(9452136761055)(788757137089)(146099531331640); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(3231022)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123560025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM5PR21MB0284;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM5PR21MB0284; x-forefront-prvs: 0487C0DB7E x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(39860400002)(47760400005)(13464003)(24454002)(199003)(189002)(5660300001)(39060400002)(575784001)(6506006)(189998001)(97736004)(6436002)(10290500003)(86362001)(53546010)(53936002)(2900100001)(68736007)(478600001)(305945005)(77096006)(3846002)(6116002)(102836003)(81166006)(86612001)(74316002)(6246003)(81156014)(10090500001)(14454004)(4326008)(3280700002)(8936002)(7736002)(9686003)(55016002)(8676002)(66066001)(54356999)(229853002)(25786009)(2906002)(3660700001)(8990500004)(22452003)(101416001)(99286004)(2950100002)(316002)(33656002)(54906003)(7696004)(106356001)(50986999)(110136005)(76176999)(105586002)(7416002);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR21MB0284;H:DM5PR21MB0476.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=kys@microsoft.com; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41e6ba2c-7b78-4d3d-dc2a-08d5287b1b59 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2017 20:39:14.5099 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR21MB0284 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 nfs id vAAKdNkS023502 > -----Original Message----- > From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com] > Sent: Friday, November 10, 2017 10:26 AM > To: Juergen Gross > Cc: linux-kernel@vger.kernel.org; tglx@linutronix.de; mingo@redhat.com; > hpa@zytor.com; x86@kernel.org; KY Srinivasan ; > Haiyang Zhang ; Stephen Hemminger > ; akataria@vmware.com; > pbonzini@redhat.com; rkrcmar@redhat.com; boris.ostrovsky@oracle.com; > devel@linuxdriverproject.org; virtualization@lists.linux-foundation.org; > kvm@vger.kernel.org; xen-devel@lists.xenproject.org; linux-graphics- > maintainer@vmware.com; pv-drivers@vmware.com; > xdeguillard@vmware.com; moltmann@vmware.com; arnd@arndb.de; > gregkh@linuxfoundation.org; linux-input@vger.kernel.org > Subject: Re: [PATCH v2 2/5] x86: add enum for hypervisors to replace > x86_hyper > > On Thu, Nov 09, 2017 at 02:27:36PM +0100, Juergen Gross wrote: > > The x86_hyper pointer is only used for checking whether a virtual > > device is supporting the hypervisor the system is running on. > > > > Use an enum for that purpose instead and drop the x86_hyper pointer. > > > > Cc: kys@microsoft.com > > Cc: haiyangz@microsoft.com > > Cc: sthemmin@microsoft.com > > Cc: akataria@vmware.com > > Cc: pbonzini@redhat.com > > Cc: rkrcmar@redhat.com > > Cc: boris.ostrovsky@oracle.com > > Cc: devel@linuxdriverproject.org > > Cc: virtualization@lists.linux-foundation.org > > Cc: kvm@vger.kernel.org > > Cc: xen-devel@lists.xenproject.org > > Cc: linux-graphics-maintainer@vmware.com > > Cc: pv-drivers@vmware.com > > Cc: dmitry.torokhov@gmail.com > > Cc: xdeguillard@vmware.com > > Cc: moltmann@vmware.com > > Cc: arnd@arndb.de > > Cc: gregkh@linuxfoundation.org > > Cc: linux-input@vger.kernel.org > > > > Signed-off-by: Juergen Gross > > --- > > arch/x86/hyperv/hv_init.c | 2 +- > > arch/x86/include/asm/hypervisor.h | 23 ++++++++++++++--------- > > arch/x86/kernel/cpu/hypervisor.c | 12 +++++++++--- > > arch/x86/kernel/cpu/mshyperv.c | 4 ++-- > > arch/x86/kernel/cpu/vmware.c | 4 ++-- > > arch/x86/kernel/kvm.c | 4 ++-- > > arch/x86/xen/enlighten_hvm.c | 4 ++-- > > arch/x86/xen/enlighten_pv.c | 4 ++-- > > drivers/hv/vmbus_drv.c | 2 +- > > drivers/input/mouse/vmmouse.c | 10 ++++------ > > Acked-by: Dmitry Torokhov Acked-by: K. Y. Srinivasan > > > drivers/misc/vmw_balloon.c | 2 +- > > 11 files changed, 40 insertions(+), 31 deletions(-) > > > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > > index a5db63f728a2..a0b86cf486e0 100644 > > --- a/arch/x86/hyperv/hv_init.c > > +++ b/arch/x86/hyperv/hv_init.c > > @@ -113,7 +113,7 @@ void hyperv_init(void) > > u64 guest_id; > > union hv_x64_msr_hypercall_contents hypercall_msr; > > > > - if (x86_hyper != &x86_hyper_ms_hyperv) > > + if (x86_hyper_type != X86_HYPER_MS_HYPERV) > > return; > > > > /* Allocate percpu VP index */ > > diff --git a/arch/x86/include/asm/hypervisor.h > b/arch/x86/include/asm/hypervisor.h > > index 0eca7239a7aa..1b0a5abcd8ae 100644 > > --- a/arch/x86/include/asm/hypervisor.h > > +++ b/arch/x86/include/asm/hypervisor.h > > @@ -29,6 +29,16 @@ > > /* > > * x86 hypervisor information > > */ > > + > > +enum x86_hypervisor_type { > > + X86_HYPER_NATIVE = 0, > > + X86_HYPER_VMWARE, > > + X86_HYPER_MS_HYPERV, > > + X86_HYPER_XEN_PV, > > + X86_HYPER_XEN_HVM, > > + X86_HYPER_KVM, > > +}; > > + > > struct hypervisor_x86 { > > /* Hypervisor name */ > > const char *name; > > @@ -36,6 +46,9 @@ struct hypervisor_x86 { > > /* Detection routine */ > > uint32_t (*detect)(void); > > > > + /* Hypervisor type */ > > + enum x86_hypervisor_type type; > > + > > /* init time callbacks */ > > struct x86_hyper_init init; > > > > @@ -43,15 +56,7 @@ struct hypervisor_x86 { > > struct x86_hyper_runtime runtime; > > }; > > > > -extern const struct hypervisor_x86 *x86_hyper; > > - > > -/* Recognized hypervisors */ > > -extern const struct hypervisor_x86 x86_hyper_vmware; > > -extern const struct hypervisor_x86 x86_hyper_ms_hyperv; > > -extern const struct hypervisor_x86 x86_hyper_xen_pv; > > -extern const struct hypervisor_x86 x86_hyper_xen_hvm; > > -extern const struct hypervisor_x86 x86_hyper_kvm; > > - > > +extern enum x86_hypervisor_type x86_hyper_type; > > extern void init_hypervisor_platform(void); > > #else > > static inline void init_hypervisor_platform(void) { } > > diff --git a/arch/x86/kernel/cpu/hypervisor.c > b/arch/x86/kernel/cpu/hypervisor.c > > index 22226c1bf092..bea8d3e24f50 100644 > > --- a/arch/x86/kernel/cpu/hypervisor.c > > +++ b/arch/x86/kernel/cpu/hypervisor.c > > @@ -26,6 +26,12 @@ > > #include > > #include > > > > +extern const struct hypervisor_x86 x86_hyper_vmware; > > +extern const struct hypervisor_x86 x86_hyper_ms_hyperv; > > +extern const struct hypervisor_x86 x86_hyper_xen_pv; > > +extern const struct hypervisor_x86 x86_hyper_xen_hvm; > > +extern const struct hypervisor_x86 x86_hyper_kvm; > > + > > static const __initconst struct hypervisor_x86 * const hypervisors[] = > > { > > #ifdef CONFIG_XEN_PV > > @@ -41,8 +47,8 @@ static const __initconst struct hypervisor_x86 * const > hypervisors[] = > > #endif > > }; > > > > -const struct hypervisor_x86 *x86_hyper; > > -EXPORT_SYMBOL(x86_hyper); > > +enum x86_hypervisor_type x86_hyper_type; > > +EXPORT_SYMBOL(x86_hyper_type); > > > > static inline const struct hypervisor_x86 * __init > > detect_hypervisor_vendor(void) > > @@ -87,6 +93,6 @@ void __init init_hypervisor_platform(void) > > copy_array(&h->init, &x86_init.hyper, sizeof(h->init)); > > copy_array(&h->runtime, &x86_platform.hyper, sizeof(h- > >runtime)); > > > > - x86_hyper = h; > > + x86_hyper_type = h->type; > > x86_init.hyper.init_platform(); > > } > > diff --git a/arch/x86/kernel/cpu/mshyperv.c > b/arch/x86/kernel/cpu/mshyperv.c > > index 6bb84d655e4b..85eb5fc180c8 100644 > > --- a/arch/x86/kernel/cpu/mshyperv.c > > +++ b/arch/x86/kernel/cpu/mshyperv.c > > @@ -254,9 +254,9 @@ static void __init ms_hyperv_init_platform(void) > > #endif > > } > > > > -const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = { > > +const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = { > > .name = "Microsoft Hyper-V", > > .detect = ms_hyperv_platform, > > + .type = X86_HYPER_MS_HYPERV, > > .init.init_platform = ms_hyperv_init_platform, > > }; > > -EXPORT_SYMBOL(x86_hyper_ms_hyperv); > > diff --git a/arch/x86/kernel/cpu/vmware.c > b/arch/x86/kernel/cpu/vmware.c > > index 4804c1d063c8..8e005329648b 100644 > > --- a/arch/x86/kernel/cpu/vmware.c > > +++ b/arch/x86/kernel/cpu/vmware.c > > @@ -205,10 +205,10 @@ static bool __init > vmware_legacy_x2apic_available(void) > > (eax & (1 << VMWARE_PORT_CMD_LEGACY_X2APIC)) != 0; > > } > > > > -const __refconst struct hypervisor_x86 x86_hyper_vmware = { > > +const __initconst struct hypervisor_x86 x86_hyper_vmware = { > > .name = "VMware", > > .detect = vmware_platform, > > + .type = X86_HYPER_VMWARE, > > .init.init_platform = vmware_platform_setup, > > .init.x2apic_available = vmware_legacy_x2apic_available, > > }; > > -EXPORT_SYMBOL(x86_hyper_vmware); > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > > index 9dca8437c795..a94de09edbed 100644 > > --- a/arch/x86/kernel/kvm.c > > +++ b/arch/x86/kernel/kvm.c > > @@ -544,12 +544,12 @@ static uint32_t __init kvm_detect(void) > > return kvm_cpuid_base(); > > } > > > > -const struct hypervisor_x86 x86_hyper_kvm __refconst = { > > +const __initconst struct hypervisor_x86 x86_hyper_kvm = { > > .name = "KVM", > > .detect = kvm_detect, > > + .type = X86_HYPER_KVM, > > .init.x2apic_available = kvm_para_available, > > }; > > -EXPORT_SYMBOL_GPL(x86_hyper_kvm); > > > > static __init int activate_jump_labels(void) > > { > > diff --git a/arch/x86/xen/enlighten_hvm.c > b/arch/x86/xen/enlighten_hvm.c > > index 7b1622089f96..754d5391d9fa 100644 > > --- a/arch/x86/xen/enlighten_hvm.c > > +++ b/arch/x86/xen/enlighten_hvm.c > > @@ -226,12 +226,12 @@ static uint32_t __init xen_platform_hvm(void) > > return xen_cpuid_base(); > > } > > > > -const struct hypervisor_x86 x86_hyper_xen_hvm = { > > +const __initconst struct hypervisor_x86 x86_hyper_xen_hvm = { > > .name = "Xen HVM", > > .detect = xen_platform_hvm, > > + .type = X86_HYPER_XEN_HVM, > > .init.init_platform = xen_hvm_guest_init, > > .init.x2apic_available = xen_x2apic_para_available, > > .init.init_mem_mapping = xen_hvm_init_mem_mapping, > > .runtime.pin_vcpu = xen_pin_vcpu, > > }; > > -EXPORT_SYMBOL(x86_hyper_xen_hvm); > > diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c > > index 69d1a7054ddb..168efb2534c0 100644 > > --- a/arch/x86/xen/enlighten_pv.c > > +++ b/arch/x86/xen/enlighten_pv.c > > @@ -1460,9 +1460,9 @@ static uint32_t __init xen_platform_pv(void) > > return 0; > > } > > > > -const struct hypervisor_x86 x86_hyper_xen_pv = { > > +const __initconst struct hypervisor_x86 x86_hyper_xen_pv = { > > .name = "Xen PV", > > .detect = xen_platform_pv, > > + .type = X86_HYPER_XEN_PV, > > .runtime.pin_vcpu = xen_pin_vcpu, > > }; > > -EXPORT_SYMBOL(x86_hyper_xen_pv); > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > > index 937801ac2fe0..2cd134dd94d2 100644 > > --- a/drivers/hv/vmbus_drv.c > > +++ b/drivers/hv/vmbus_drv.c > > @@ -1534,7 +1534,7 @@ static int __init hv_acpi_init(void) > > { > > int ret, t; > > > > - if (x86_hyper != &x86_hyper_ms_hyperv) > > + if (x86_hyper_type != X86_HYPER_MS_HYPERV) > > return -ENODEV; > > > > init_completion(&probe_event); > > diff --git a/drivers/input/mouse/vmmouse.c > b/drivers/input/mouse/vmmouse.c > > index 0f586780ceb4..1ae5c1ef3f5b 100644 > > --- a/drivers/input/mouse/vmmouse.c > > +++ b/drivers/input/mouse/vmmouse.c > > @@ -316,11 +316,9 @@ static int vmmouse_enable(struct psmouse > *psmouse) > > /* > > * Array of supported hypervisors. > > */ > > -static const struct hypervisor_x86 *vmmouse_supported_hypervisors[] = > { > > - &x86_hyper_vmware, > > -#ifdef CONFIG_KVM_GUEST > > - &x86_hyper_kvm, > > -#endif > > +static enum x86_hypervisor_type vmmouse_supported_hypervisors[] = { > > + X86_HYPER_VMWARE, > > + X86_HYPER_KVM, > > }; > > > > /** > > @@ -331,7 +329,7 @@ static bool vmmouse_check_hypervisor(void) > > int i; > > > > for (i = 0; i < ARRAY_SIZE(vmmouse_supported_hypervisors); i++) > > - if (vmmouse_supported_hypervisors[i] == x86_hyper) > > + if (vmmouse_supported_hypervisors[i] == x86_hyper_type) > > return true; > > > > return false; > > diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c > > index 1e688bfec567..9047c0a529b2 100644 > > --- a/drivers/misc/vmw_balloon.c > > +++ b/drivers/misc/vmw_balloon.c > > @@ -1271,7 +1271,7 @@ static int __init vmballoon_init(void) > > * Check if we are running on VMware's hypervisor and bail out > > * if we are not. > > */ > > - if (x86_hyper != &x86_hyper_vmware) > > + if (x86_hyper_type != X86_HYPER_VMWARE) > > return -ENODEV; > > > > for (is_2m_pages = 0; is_2m_pages < > VMW_BALLOON_NUM_PAGE_SIZES; > > -- > > 2.12.3 > > > > -- > Dmitry