The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yosry Ahmed <yosry@kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/7] KVM: x86: Add a per-vendor callback to setup EFER caps
Date: Tue, 7 Jul 2026 14:56:04 -0700	[thread overview]
Message-ID: <ak119GtNZOmBpGmW@google.com> (raw)
In-Reply-To: <20260706195413.1966458-5-yosry@kernel.org>

On Mon, Jul 06, 2026, Yosry Ahmed wrote:
> Move handling EFER.SVME and EFER.LMSLE from hardware setup to a new
> optional per-vendor callback invoked from kvm_setup_efer_caps(). This
> centralizes allowed EFER bits handling to kvm_setup_efer_caps(),
> facilitating following changes to move efer_reserved_bits into kvm_caps.
> 
> Move the call to kvm_setup_efer_caps() after per-vendor ops are
> initialized.

Why?

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index a0b2c40d93c21..a297a77469b38 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6903,6 +6903,8 @@ static void kvm_setup_efer_caps(void)
>  
>  	if (kvm_cpu_cap_has(X86_FEATURE_AUTOIBRS))
>  		kvm_enable_efer_bits(EFER_AUTOIBRS);
> +
> +	kvm_x86_call(setup_efer_caps)();

I would rather move the togging to kvm_setup_efer_caps(), e.g.

  static void kvm_setup_efer_caps(void)
  {
	/* Enable syscall by default because its emulated by KVM */
	kvm_caps.supported_efer_bits = (u64)EFER_SCE;

	if (kvm_cpu_cap_has(X86_FEATURE_LM))
		kvm_caps.supported_efer_bits |= (EFER_LME | EFER_LMA);

	if (kvm_cpu_cap_has(X86_FEATURE_NX))
		kvm_caps.supported_efer_bits |= EFER_NX;

	if (kvm_cpu_cap_has(X86_FEATURE_FXSR_OPT))
		kvm_caps.supported_efer_bits |= EFER_FFXSR;

	if (kvm_cpu_cap_has(X86_FEATURE_AUTOIBRS))
		kvm_caps.supported_efer_bits |= EFER_AUTOIBRS;

	if (kvm_cpu_cap_has(X86_FEATURE_SVM)) {
		kvm_caps.supported_efer_bits |= EFER_SVME;
		if (!boot_cpu_has(X86_FEATURE_EFER_LMSLE_MBZ))
			kvm_caps.supported_efer_bits |= EFER_LMSLE;
	}
  }

  reply	other threads:[~2026-07-07 21:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 19:54 [PATCH v2 0/7] KVM: x86: EFER validity fixes and cleanups Yosry Ahmed
2026-07-06 19:54 ` [PATCH v2 1/7] KVM: x86: Check EFER validity on KVM_SET_SREGS* Yosry Ahmed
2026-07-06 19:54 ` [PATCH v2 2/7] KVM: SVM: Disallow EFER.SVME and EFER.LSMLE if nested is disabled Yosry Ahmed
2026-07-06 19:54 ` [PATCH v2 3/7] KVM: x86: Disallow EFER.LME and EFER.LMA if long mode is not supported Yosry Ahmed
2026-07-06 19:54 ` [PATCH v2 4/7] KVM: x86: Add a per-vendor callback to setup EFER caps Yosry Ahmed
2026-07-07 21:56   ` Sean Christopherson [this message]
2026-07-07 22:29     ` Yosry Ahmed
2026-07-08 14:01       ` Sean Christopherson
2026-07-08 19:12         ` Yosry Ahmed
2026-07-08 20:56           ` Sean Christopherson
2026-07-08 21:34             ` Yosry Ahmed
2026-07-06 19:54 ` [PATCH v2 5/7] KVM: x86: Reverse the polarity of efer_reserved_bits Yosry Ahmed
2026-07-10 10:23   ` Nikolay Borisov
2026-07-06 19:54 ` [PATCH v2 6/7] KVM: x86: Move supported EFER bits to kvm_caps Yosry Ahmed
2026-07-10 12:56   ` Nikolay Borisov
2026-07-06 19:54 ` [PATCH v2 7/7] KVM: selftests: Extend set_sregs test to cover EFER Yosry Ahmed

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=ak119GtNZOmBpGmW@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox