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]
Message-ID: <d2c5e826d4c136234500d26b48b9e48737ba389b.camel@intel.com>
Date:   Mon, 22 May 2023 23:11:38 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "Christopherson,, Sean" <seanjc@...gle.com>
CC:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Gao, Chao" <chao.gao@...el.com>,
        "andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>
Subject: Re: [PATCH v3 03/18] x86/reboot: KVM: Handle VMXOFF in KVM's reboot
 callback

On Mon, 2023-05-22 at 10:58 -0700, Sean Christopherson wrote:
> On Mon, May 22, 2023, Kai Huang wrote:
> > On Fri, 2023-05-12 at 16:50 -0700, Sean Christopherson wrote:
> > > Use KVM VMX's reboot/crash callback to do VMXOFF in an emergency instead
> > > of manually and blindly doing VMXOFF.  There's no need to attempt VMXOFF
> > > if a hypervisor, i.e. KVM, isn't loaded/active, i.e. if the CPU can't
> > > possibly be post-VMXON.
> > > 
> > > Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> > > ---
> > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> > > index fc9cdb4114cc..76cdb189f1b5 100644
> > > --- a/arch/x86/kvm/vmx/vmx.c
> > > +++ b/arch/x86/kvm/vmx/vmx.c
> > > @@ -744,7 +744,7 @@ static int vmx_set_guest_uret_msr(struct vcpu_vmx *vmx,
> > >  	return ret;
> > >  }
> > >  
> > > -static void crash_vmclear_local_loaded_vmcss(void)
> > > +static void vmx_emergency_disable(void)
> > >  {
> > >  	int cpu = raw_smp_processor_id();
> > >  	struct loaded_vmcs *v;
> > > @@ -752,6 +752,8 @@ static void crash_vmclear_local_loaded_vmcss(void)
> > >  	list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu),
> > >  			    loaded_vmcss_on_cpu_link)
> > >  		vmcs_clear(v->vmcs);
> > > +
> > > +	__cpu_emergency_vmxoff();
> > 
> > __cpu_emergency_vmxoff() internally checks whether VMX is enabled in CR4.  
> > Logically, looks it's more reasonable to do such check before VMCLEAR active
> > VMCSes, although in practice there should be no problem I think.
> > 
> > But this problem inherits from the existing code in  upstream, so not sure
> > whether it is worth fixing.
> 
> Hmm, I think it's worth fixing, if only to avoid confusing future readers.  Blindly
> doing VMCLEAR but then conditionally executing VMXOFF is nonsensical.  I'll tack on
> a patch, and also add a comment to call out that CR4.VMXE can be _cleared_
> asynchronously by NMI, but can't be set after being checked.  I.e. explain that
> checking CR4.VMXE is a "best effort" sort of thing.

Yeah looks good.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ