[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aQzp1I1D8CfUSEug@google.com>
Date: Thu, 6 Nov 2025 10:32:52 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Uros Bizjak <ubizjak@...il.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: SVM: Ensure SPEC_CTRL[63:32] is context switched
between guest and host
On Thu, Nov 06, 2025, Uros Bizjak wrote:
> On Thu, Nov 6, 2025 at 2:13 AM Sean Christopherson <seanjc@...gle.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!
Powered by blists - more mailing lists