From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752289AbeANUdR (ORCPT + 1 other); Sun, 14 Jan 2018 15:33:17 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:38378 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752186AbeANUdO (ORCPT ); Sun, 14 Jan 2018 15:33:14 -0500 Date: Sun, 14 Jan 2018 21:32:57 +0100 (CET) From: Thomas Gleixner To: Vitaly Kuznetsov cc: kvm@vger.kernel.org, x86@kernel.org, Paolo Bonzini , =?ISO-8859-2?Q?Radim_Kr=E8m=E1=F8?= , Ingo Molnar , "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Andy Lutomirski , Mohammed Gamal , Cathy Avery , Roman Kagan , linux-kernel@vger.kernel.org, devel@linuxdriverproject.org Subject: Re: [PATCH v2 1/7] x86/hyper-v: check for required priviliges in hyperv_init() In-Reply-To: <20171213150945.24054-2-vkuznets@redhat.com> Message-ID: References: <20171213150945.24054-1-vkuznets@redhat.com> <20171213150945.24054-2-vkuznets@redhat.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, 13 Dec 2017, Vitaly Kuznetsov wrote: > In hyperv_init() we presume we always have access to VP index and hypercall > MSRs while according to the specification we should check if we're allowed > to access the corresponding MSRs before accessing them. > > Signed-off-by: Vitaly Kuznetsov Reviewed-by: Thomas Gleixner > --- > arch/x86/hyperv/hv_init.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index 189a398290db..21f9d53d9f00 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -110,12 +110,19 @@ static int hv_cpu_init(unsigned int cpu) > */ > void hyperv_init(void) > { > - u64 guest_id; > + u64 guest_id, required_msrs; > union hv_x64_msr_hypercall_contents hypercall_msr; > > if (x86_hyper_type != X86_HYPER_MS_HYPERV) > return; > > + /* Absolutely required MSRs */ > + required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE | > + HV_X64_MSR_VP_INDEX_AVAILABLE; > + > + if ((ms_hyperv.features & required_msrs) != required_msrs) > + return; > + > /* Allocate percpu VP index */ > hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index), > GFP_KERNEL); > -- > 2.14.3 > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH v2 1/7] x86/hyper-v: check for required priviliges in hyperv_init() Date: Sun, 14 Jan 2018 21:32:57 +0100 (CET) Message-ID: References: <20171213150945.24054-1-vkuznets@redhat.com> <20171213150945.24054-2-vkuznets@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Stephen Hemminger , kvm@vger.kernel.org, =?ISO-8859-2?Q?Radim_Kr=E8m=E1=F8?= , Haiyang Zhang , x86@kernel.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, "Michael Kelley \(EOSG\)" , Ingo Molnar , Roman Kagan , Andy Lutomirski , "H. Peter Anvin" , Paolo Bonzini , Mohammed Gamal To: Vitaly Kuznetsov Return-path: In-Reply-To: <20171213150945.24054-2-vkuznets@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" List-Id: kvm.vger.kernel.org On Wed, 13 Dec 2017, Vitaly Kuznetsov wrote: > In hyperv_init() we presume we always have access to VP index and hypercall > MSRs while according to the specification we should check if we're allowed > to access the corresponding MSRs before accessing them. > > Signed-off-by: Vitaly Kuznetsov Reviewed-by: Thomas Gleixner > --- > arch/x86/hyperv/hv_init.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index 189a398290db..21f9d53d9f00 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -110,12 +110,19 @@ static int hv_cpu_init(unsigned int cpu) > */ > void hyperv_init(void) > { > - u64 guest_id; > + u64 guest_id, required_msrs; > union hv_x64_msr_hypercall_contents hypercall_msr; > > if (x86_hyper_type != X86_HYPER_MS_HYPERV) > return; > > + /* Absolutely required MSRs */ > + required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE | > + HV_X64_MSR_VP_INDEX_AVAILABLE; > + > + if ((ms_hyperv.features & required_msrs) != required_msrs) > + return; > + > /* Allocate percpu VP index */ > hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index), > GFP_KERNEL); > -- > 2.14.3 > >