* [PATCH] KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest()
@ 2024-11-27 23:46 Sean Christopherson
2024-12-19 2:40 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2024-11-27 23:46 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
Define sev_{,es_,snp_}guest() as "false" when SEV is disabled via Kconfig,
i.e. when CONFIG_KVM_AMD_SEV=n. Despite the helpers being __always_inline,
gcc-12 is somehow incapable of realizing that the return value is a
compile-time constant and generates sub-optimal code.
Opportunistically clump the paths together to reduce the amount of
ifdeffery.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/svm.h | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 43fa6a16eb19..2f5d8b105eb0 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -358,39 +358,32 @@ static __always_inline struct kvm_sev_info *to_kvm_sev_info(struct kvm *kvm)
return &to_kvm_svm(kvm)->sev_info;
}
+#ifdef CONFIG_KVM_AMD_SEV
static __always_inline bool sev_guest(struct kvm *kvm)
{
-#ifdef CONFIG_KVM_AMD_SEV
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
return sev->active;
-#else
- return false;
-#endif
}
-
static __always_inline bool sev_es_guest(struct kvm *kvm)
{
-#ifdef CONFIG_KVM_AMD_SEV
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
return sev->es_active && !WARN_ON_ONCE(!sev->active);
-#else
- return false;
-#endif
}
static __always_inline bool sev_snp_guest(struct kvm *kvm)
{
-#ifdef CONFIG_KVM_AMD_SEV
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
return (sev->vmsa_features & SVM_SEV_FEAT_SNP_ACTIVE) &&
!WARN_ON_ONCE(!sev_es_guest(kvm));
+}
#else
- return false;
+#define sev_guest(kvm) false
+#define sev_es_guest(kvm) false
+#define sev_snp_guest(kvm) false
#endif
-}
static inline bool ghcb_gpa_is_registered(struct vcpu_svm *svm, u64 val)
{
base-commit: 4d911c7abee56771b0219a9fbf0120d06bdc9c14
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest()
2024-11-27 23:46 [PATCH] KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest() Sean Christopherson
@ 2024-12-19 2:40 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2024-12-19 2:40 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
On Wed, 27 Nov 2024 15:46:59 -0800, Sean Christopherson wrote:
> Define sev_{,es_,snp_}guest() as "false" when SEV is disabled via Kconfig,
> i.e. when CONFIG_KVM_AMD_SEV=n. Despite the helpers being __always_inline,
> gcc-12 is somehow incapable of realizing that the return value is a
> compile-time constant and generates sub-optimal code.
>
> Opportunistically clump the paths together to reduce the amount of
> ifdeffery.
>
> [...]
Applied to kvm-x86 svm, thanks!
[1/1] KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest()
https://github.com/kvm-x86/linux/commit/45d522d3ee9c
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-19 2:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 23:46 [PATCH] KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest() Sean Christopherson
2024-12-19 2:40 ` Sean Christopherson
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®