mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Qian Cai <cai@lca.pw>,
	Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>
Subject: Re: [PATCH] KVM: VMX: Explicitly clear RFLAGS.CF and RFLAGS.ZF in VM-Exit RSB path
Date: Wed, 6 May 2020 12:03:45 +0200	[thread overview]
Message-ID: <1f906b20-4806-4de0-fa99-9e7607464eb0@redhat.com> (raw)
In-Reply-To: <20200506035355.2242-1-sean.j.christopherson@intel.com>

On 06/05/20 05:53, Sean Christopherson wrote:
> Clear CF and ZF in the VM-Exit path after doing __FILL_RETURN_BUFFER so
> that KVM doesn't interpret clobbered RFLAGS as a VM-Fail.  Filling the
> RSB has always clobbered RFLAGS, its current incarnation just happens
> clear CF and ZF in the processs.  Relying on the macro to clear CF and
> ZF is extremely fragile, e.g. commit 089dd8e53126e ("x86/speculation:
> Change FILL_RETURN_BUFFER to work with objtool") tweaks the loop such
> that the ZF flag is always set.
> 
> Reported-by: Qian Cai <cai@lca.pw>
> Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
> Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: stable@vger.kernel.org
> Fixes: f2fde6a5bcfcf ("KVM: VMX: Move RSB stuffing to before the first RET after VM-Exit")
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kvm/vmx/vmenter.S | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kvm/vmx/vmenter.S b/arch/x86/kvm/vmx/vmenter.S
> index 87f3f24fef37b..51d1a82742fd5 100644
> --- a/arch/x86/kvm/vmx/vmenter.S
> +++ b/arch/x86/kvm/vmx/vmenter.S
> @@ -82,6 +82,9 @@ SYM_FUNC_START(vmx_vmexit)
>  	/* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */
>  	FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE
>  
> +	/* Clear RFLAGS.CF and RFLAGS.ZF to preserve VM-Exit, i.e. !VM-Fail. */
> +	or $1, %_ASM_AX
> +
>  	pop %_ASM_AX
>  .Lvmexit_skip_rsb:
>  #endif
> 

Queued, thanks (for 5.7 so that it will never be broken in Linus's tree).

Paolo


      reply	other threads:[~2020-05-06 10:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  3:53 Sean Christopherson
2020-05-06 10:03 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f906b20-4806-4de0-fa99-9e7607464eb0@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=cai@lca.pw \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=jpoimboe@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®