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: <4ca6dc2cf030f15193efbe2b364bf196692cd167.camel@redhat.com>
Date:   Tue, 28 Nov 2023 08:41:51 +0200
From:   Maxim Levitsky <mlevitsk@...hat.com>
To:     Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        linux-kernel@...r.kernel.org, x86@...nel.org,
        Dave Hansen <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH v3 1/4] KVM: x86: refactor req_immediate_exit logic

On Fri, 2023-11-24 at 17:07 +0100, Paolo Bonzini wrote:
> On 9/28/23 12:36, Maxim Levitsky wrote:
> > @@ -4176,6 +4176,9 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
> >   	clgi();
> >   	kvm_load_guest_xsave_state(vcpu);
> >   
> > +	if (vcpu->arch.req_immediate_exit)
> > +		smp_send_reschedule(vcpu->cpu);
> > +
> 
> This code is in a non-standard situation where IF=1 but interrupts are
> effectively disabled.  Better something like:
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index beea99c8e8e0..3b945de2d880 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -4148,8 +4148,11 @@ static __no_kcsan fastpath_t svm_vcpu_run(
>   		 * is enough to force an immediate vmexit.
>   		 */
>   		disable_nmi_singlestep(svm);
> +		vcpu->arch.req_immediate_exit = true;
> +	}
> +
> +	if (vcpu->arch.req_immediate_exit)
>   		smp_send_reschedule(vcpu->cpu);
> -	}
> 
>   	pre_svm_run(vcpu);
> 
> 
> Paolo
> 


Actually IF=0 at that point. We disable IF before we call svm_vcpu_run, at
vcpu_enter_guest().

Then we disable GIF, and we re-enable IF only right before VMRUN, in fact vmrun is
in the interrupt shadow although that doesn't really matter since GIF=0.

However I don't mind implementing the change you suggested, I don't think it will
affect anything.

Best regards,
	Maxim Levitsky

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ