public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: SVM: Ensure SPEC_CTRL[63:32] is context switched between guest and host
Date: Thu, 6 Nov 2025 10:32:52 -0800	[thread overview]
Message-ID: <aQzp1I1D8CfUSEug@google.com> (raw)
In-Reply-To: <CAFULd4Z=PKeyzaER51CE7Zm4a-yeiru=HcBFx8E4J5hx3io=Tw@mail.gmail.com>

On Thu, Nov 06, 2025, Uros Bizjak wrote:
> On Thu, Nov 6, 2025 at 2:13 AM Sean Christopherson <seanjc@google.com> wrote:
> >  998:
> > -
> >         /* Now restore the host value of the MSR if different from the guest's.  */
> > -       movl PER_CPU_VAR(x86_spec_ctrl_current), %eax
> > -       cmp SVM_spec_ctrl(%_ASM_DI), %eax
> > +#ifdef CONFIG_X86_64
> > +       mov SVM_spec_ctrl(%rdi), %rdx
> > +       cmp PER_CPU_VAR(x86_spec_ctrl_current), %rdx
> >         je 901b
> > -       xor %edx, %edx
> > +       mov PER_CPU_VAR(x86_spec_ctrl_current), %rdx
> > +       movl %edx, %eax
> > +       shr $32, %rdx
> 
> The above code can be written as:
> 
> mov PER_CPU_VAR(x86_spec_ctrl_current), %rdx
> cmp SVM_spec_ctrl(%rdi), %rdx

Gah, that's obvious in hindsight.

> je 901b
> movl %edx, %eax
> shr $32, %rdx
> 
> The improved code will save a memory read from x86_spec_ctrl_current.
> 
> > +#else
> > +       mov SVM_spec_ctrl(%edi), %esi
> > +       mov PER_CPU_VAR(x86_spec_ctrl_current), %eax
> 
> Can the above two instructions be swapped, just to be consistent with
> x86_64 code?
> 
> > +       xor %eax, %esi
> 
> > +       mov SVM_spec_ctrl + 4(%edi), %edi
> > +       mov PER_CPU_VAR(x86_spec_ctrl_current + 4), %edx
> 
> ... and the above two insns.

Ya, will do.  Thanks!

      reply	other threads:[~2025-11-06 18:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06  1:13 [PATCH] KVM: SVM: Ensure SPEC_CTRL[63:32] is context switched between guest and host Sean Christopherson
2025-11-06 18:21 ` Uros Bizjak
2025-11-06 18:32   ` Sean Christopherson [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=aQzp1I1D8CfUSEug@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=ubizjak@gmail.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