* [PATCH 1/1] x86/kvm/svm: Implement support for PSFD
@ 2021-04-07 19:45 Ramakrishna Saripalli
2021-04-07 20:03 ` Sean Christopherson
2021-04-08 17:19 ` Tom Lendacky
0 siblings, 2 replies; 3+ messages in thread
From: Ramakrishna Saripalli @ 2021-04-07 19:45 UTC (permalink / raw)
To: Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
Jim Mattson, Joerg Roedel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, x86, H. Peter Anvin, kvm, linux-kernel
Cc: rsaripal
From: Ramakrishna Saripalli <rk.saripalli@amd.com>
Expose Predictive Store Forwarding capability to guests.
Guests enable or disable PSF via SPEC_CTRL MSR.
Signed-off-by: Ramakrishna Saripalli <rk.saripalli@amd.com>
---
arch/x86/kvm/cpuid.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 6bd2f8b830e4..9c4af0fef6d7 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -448,6 +448,8 @@ void kvm_set_cpu_caps(void)
kvm_cpu_cap_set(X86_FEATURE_INTEL_STIBP);
if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
+ if (boot_cpu_has(X86_FEATURE_AMD_PSFD))
+ kvm_cpu_cap_set(X86_FEATURE_AMD_PSFD);
kvm_cpu_cap_mask(CPUID_7_1_EAX,
F(AVX_VNNI) | F(AVX512_BF16)
@@ -482,7 +484,7 @@ void kvm_set_cpu_caps(void)
kvm_cpu_cap_mask(CPUID_8000_0008_EBX,
F(CLZERO) | F(XSAVEERPTR) |
F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
- F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON)
+ F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) | F(AMD_PSFD)
);
/*
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] x86/kvm/svm: Implement support for PSFD
2021-04-07 19:45 [PATCH 1/1] x86/kvm/svm: Implement support for PSFD Ramakrishna Saripalli
@ 2021-04-07 20:03 ` Sean Christopherson
2021-04-08 17:19 ` Tom Lendacky
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-04-07 20:03 UTC (permalink / raw)
To: Ramakrishna Saripalli
Cc: Paolo Bonzini, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, kvm, linux-kernel
On Wed, Apr 07, 2021, Ramakrishna Saripalli wrote:
> From: Ramakrishna Saripalli <rk.saripalli@amd.com>
>
> Expose Predictive Store Forwarding capability to guests.
Technically KVM is advertising the capability to userspace, e.g. userspace can
expose the feature to the guest without this patch.
> Guests enable or disable PSF via SPEC_CTRL MSR.
At a (very) quick glance, this requires extra enabling in guest_has_spec_ctrl_msr(),
otherwise a vCPU with PSF but not the existing features will not be able to set
MSR_IA32_SPEC_CTRL.PSFD.
That raises a question: should KVM do extra checks for PSFD on top of the "throw
noodles at the wall and see what sticks" approach of kvm_spec_ctrl_test_value()?
The noodle approach is there to handle the mess of cross-vendor features/bits,
but that doesn't seem to apply to PSFD.
> Signed-off-by: Ramakrishna Saripalli <rk.saripalli@amd.com>
> ---
> arch/x86/kvm/cpuid.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 6bd2f8b830e4..9c4af0fef6d7 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -448,6 +448,8 @@ void kvm_set_cpu_caps(void)
> kvm_cpu_cap_set(X86_FEATURE_INTEL_STIBP);
> if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
> kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
> + if (boot_cpu_has(X86_FEATURE_AMD_PSFD))
> + kvm_cpu_cap_set(X86_FEATURE_AMD_PSFD);
This is unnecessary, it's handled by the F(AMD_PSFD). The above features have
special handling to enumerate their Intel equivalent.
> kvm_cpu_cap_mask(CPUID_7_1_EAX,
> F(AVX_VNNI) | F(AVX512_BF16)
> @@ -482,7 +484,7 @@ void kvm_set_cpu_caps(void)
> kvm_cpu_cap_mask(CPUID_8000_0008_EBX,
> F(CLZERO) | F(XSAVEERPTR) |
> F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
> - F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON)
> + F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) | F(AMD_PSFD)
> );
>
> /*
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] x86/kvm/svm: Implement support for PSFD
2021-04-07 19:45 [PATCH 1/1] x86/kvm/svm: Implement support for PSFD Ramakrishna Saripalli
2021-04-07 20:03 ` Sean Christopherson
@ 2021-04-08 17:19 ` Tom Lendacky
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lendacky @ 2021-04-08 17:19 UTC (permalink / raw)
To: Ramakrishna Saripalli, Paolo Bonzini, Sean Christopherson,
Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
H. Peter Anvin, kvm, linux-kernel
On 4/7/21 2:45 PM, Ramakrishna Saripalli wrote:
> From: Ramakrishna Saripalli <rk.saripalli@amd.com>
>
> Expose Predictive Store Forwarding capability to guests.
> Guests enable or disable PSF via SPEC_CTRL MSR.
>
> Signed-off-by: Ramakrishna Saripalli <rk.saripalli@amd.com>
> ---
> arch/x86/kvm/cpuid.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 6bd2f8b830e4..9c4af0fef6d7 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -448,6 +448,8 @@ void kvm_set_cpu_caps(void)
> kvm_cpu_cap_set(X86_FEATURE_INTEL_STIBP);
> if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
> kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
> + if (boot_cpu_has(X86_FEATURE_AMD_PSFD))
> + kvm_cpu_cap_set(X86_FEATURE_AMD_PSFD);
>
> kvm_cpu_cap_mask(CPUID_7_1_EAX,
> F(AVX_VNNI) | F(AVX512_BF16)
> @@ -482,7 +484,7 @@ void kvm_set_cpu_caps(void)
> kvm_cpu_cap_mask(CPUID_8000_0008_EBX,
> F(CLZERO) | F(XSAVEERPTR) |
> F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
> - F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON)
> + F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) | F(AMD_PSFD)
Please note that this patch has a pre-req against the PSFD support that
defines this feature:
https://lore.kernel.org/lkml/20210406155004.230790-2-rsaripal@amd.com/#t
Thanks,
Tom
> );
>
> /*
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-08 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 19:45 [PATCH 1/1] x86/kvm/svm: Implement support for PSFD Ramakrishna Saripalli
2021-04-07 20:03 ` Sean Christopherson
2021-04-08 17:19 ` Tom Lendacky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).