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] [day] [month] [year] [list]
Message-ID: <CY4PR11MB195721D5477F548C1FC56E83E3ED0@CY4PR11MB1957.namprd11.prod.outlook.com>
Date:   Fri, 6 Nov 2020 06:47:48 +0000
From:   "Qi, Yadong" <yadong.qi@...el.com>
To:     Paolo Bonzini <pbonzini@...hat.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "x86@...nel.org" <x86@...nel.org>
CC:     "Christopherson, Sean J" <sean.j.christopherson@...el.com>,
        "vkuznets@...hat.com" <vkuznets@...hat.com>,
        "wanpengli@...cent.com" <wanpengli@...cent.com>,
        "jmattson@...gle.com" <jmattson@...gle.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>, "hpa@...or.com" <hpa@...or.com>,
        "liran.alon@...cle.com" <liran.alon@...cle.com>,
        "nikita.leshchenko@...cle.com" <nikita.leshchenko@...cle.com>,
        "Gao, Chao" <chao.gao@...el.com>,
        "Tian, Kevin" <kevin.tian@...el.com>,
        "Chen, Luhai" <luhai.chen@...el.com>,
        "Zhu, Bing" <bing.zhu@...el.com>,
        "Wang, Kai Z" <kai.z.wang@...el.com>
Subject: RE: [PATCH] KVM: x86: emulate wait-for-SIPI and SIPI-VMExit

> There is a problem in this patch, in that this change is incorrect:
> 
> >
> > @@ -2847,7 +2847,8 @@ void kvm_apic_accept_events(struct kvm_vcpu
> *vcpu)
> >  	 */
> >  	if (kvm_vcpu_latch_init(vcpu)) {
> >  		WARN_ON_ONCE(vcpu->arch.mp_state ==
> KVM_MP_STATE_INIT_RECEIVED);
> > -		if (test_bit(KVM_APIC_SIPI, &apic->pending_events))
> > +		if (test_bit(KVM_APIC_SIPI, &apic->pending_events) &&
> > +		    !is_guest_mode(vcpu))
> >  			clear_bit(KVM_APIC_SIPI, &apic->pending_events);
> >  		return;
> >  	}
> 
> Here you're not trying to process a latched INIT; you just want to delay the
> processing of the SIPI until check_nested_events.
> 
> The change does have a correct part in it.  In particular,
> vmx_apic_init_signal_blocked should have been
> 
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index
> 47b8357b9751..64339121a4f0 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7558,7 +7558,7 @@ static void enable_smi_window(struct kvm_vcpu
> *vcpu)
> 
>   static bool vmx_apic_init_signal_blocked(struct kvm_vcpu *vcpu)
>   {
> -	return to_vmx(vcpu)->nested.vmxon;
> +	return to_vmx(vcpu)->nested.vmxon && !is_guest_mode(vcpu);
>   }
> 
>   static void vmx_migrate_timers(struct kvm_vcpu *vcpu)
> 
> to only latch INIT signals in root mode.  However, SIPI must be cleared
> unconditionally on SVM; the "!is_guest_mode" test in that case is incorrect.
> 
> The right way to do it is to call check_nested_events from
> kvm_apic_accept_events.  This will cause an INIT or SIPI vmexit, as required.
> There is some extra complication to read pending_events
> *before* kvm_apic_accept_events and not steal from the guest any INIT or SIPI
> that is sent after kvm_apic_accept_events returns.
> 
> Thanks to your test case, I will test a patch and send it.
> 
Thanks very much, Paolo.
BTW, I noticed another issue in sync_vmcs02_to_vmcs12():
vmcs12->guest_activity_state is not set properly when mp_state is INIT_RECEIVED.
I will correct it and send v2 of Patch 2/2.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ