From: Sean Christopherson <seanjc@google.com>
To: Sasha Levin <sashal@kernel.org>
Cc: stable@vger.kernel.org, Yosry Ahmed <yosry@kernel.org>
Subject: Re: [PATCH 6.12.y] KVM: x86: Always initialize EFER reserved bits on vendor initialization
Date: Fri, 11 Sep 2026 08:17:22 -0700 [thread overview]
Message-ID: <aqQbgijDnBZds1rT@google.com> (raw)
In-Reply-To: <20260911141350.763301-1-sashal@kernel.org>
On Fri, Sep 11, 2026, Sasha Levin wrote:
> From: Yosry Ahmed <yosry@kernel.org>
>
> [ Upstream commit a4b8acd428ba3f03952ef309d7f438dbc357557b ]
>
> EFER reserved bits are statically initialized, and do not reset if a
> vendor module is re-loaded. For example, loading kvm_amd with nested=1
> removes EFER.SVME (and potentially EFER.LMSLE) from the reserved bits.
> Reloading kvm_amd with nested=0 does not add them back, allowing
> userspace to set EFER.SVME with nested=0.
>
> Re-initializing EFER reserved bits before configuring them on vendor
> initialization.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Yosry Ahmed <yosry@kernel.org>
> Link: https://patch.msgid.link/20260713181020.2735367-4-yosry@kernel.org
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> [ placed EFER initialization directly in x86.c’s kvm_x86_vendor_init() because this branch lacks kvm_setup_efer_caps() ]
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> arch/x86/kvm/x86.c | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 9e7c9e3edb5b4..84f8120ac31f8 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -108,16 +108,7 @@ EXPORT_SYMBOL_GPL(kvm_host);
> #define emul_to_vcpu(ctxt) \
> ((struct kvm_vcpu *)(ctxt)->vcpu)
>
> -/* EFER defaults:
> - * - enable syscall per default because its emulated by KVM
> - * - enable LME and LMA per default on 64 bit KVM
> - */
> -#ifdef CONFIG_X86_64
> -static
> -u64 __read_mostly efer_reserved_bits = ~((u64)(EFER_SCE | EFER_LME | EFER_LMA));
> -#else
> -static u64 __read_mostly efer_reserved_bits = ~((u64)EFER_SCE);
> -#endif
> +static u64 __read_mostly efer_reserved_bits;
>
> static u64 __read_mostly cr4_reserved_bits = CR4_RESERVED_BITS;
>
> @@ -9818,6 +9809,16 @@ int kvm_x86_vendor_init(struct kvm_x86_init_ops *ops)
> if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES))
> rdmsrl(MSR_IA32_ARCH_CAPABILITIES, kvm_host.arch_capabilities);
>
> + /* EFER defaults:
> + * - enable syscall per default because its emulated by KVM
> + * - enable LME and LMA per default on 64 bit KVM
> + */
> +#ifdef CONFIG_X86_64
> + efer_reserved_bits = ~((u64)(EFER_SCE | EFER_LME | EFER_LMA));
> +#else
> + efer_reserved_bits = ~((u64)EFER_SCE);
> +#endif
This is going to conflict with "KVM: x86: Disallow EFER.LME and EFER.LMA if long
mode is not supported"[*], it probably makes sense to send a version on top of
that, both to avoid a conflict when applying and to make it obvious 6.12.y will
have the same patch ordering as upstream (though that probably doesn't matter in
this case).
[*] https://lore.kernel.org/all/20260911120502.489632-1-sashal@kernel.org
> +
> r = ops->hardware_setup();
> if (r != 0)
> goto out_mmu_exit;
> --
> 2.53.0
>
prev parent reply other threads:[~2026-09-11 15:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 10:32 FAILED: patch "[PATCH] KVM: x86: Always initialize EFER reserved bits on vendor" failed to apply to 6.12-stable tree gregkh
2026-09-11 14:13 ` [PATCH 6.12.y] KVM: x86: Always initialize EFER reserved bits on vendor initialization Sasha Levin
2026-09-11 15:17 ` 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=aqQbgijDnBZds1rT@google.com \
--to=seanjc@google.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yosry@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.