* [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch
@ 2025-05-29 21:17 Tom Lendacky
2025-05-29 21:17 ` [PATCH 1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled Tom Lendacky
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tom Lendacky @ 2025-05-29 21:17 UTC (permalink / raw)
To: kvm, linux-kernel, x86
Cc: Paolo Bonzini, Sean Christopherson, Borislav Petkov, Dave Hansen,
Ingo Molnar, Thomas Gleixner, Michael Roth
This series removes some guest policy checks that can be better controlled
by the SEV firmware.
- Remove the check for the SMT policy bit. Currently, a check is made to
ensure the SMT policy bit is set to 1. However, there is no reason for
KVM to do this. The SMT policy bit, when 0, is used to ensure that SMT
has been disabled *in the BIOS.* As this does not require any special
support within KVM, the check can be safely removed to allow the SEV
firmware to determine whether the system meets the policy.
- Remove the check for the SINGLE_SOCKET policy bit. Currently, a check
is made to ensure the SINGLE_SOCKET policy bit is set to 0. However,
there is no reason for KVM to do this. The SINGLE_SOCKET policy bit,
when 1, is used to ensure that an SNP guest is only run on a single
socket. When the system only consists of a single socket, the SEV
firmware allows guest activation to succeed. However, if the system
has more than one socket, the SEV firmware will fail guest activation
when the SNP_ACTIVATE command is used (which is the activation command
used by KVM).
The SMT policy patch should not be controversial. The SINGLE_SOCKET policy
patch could be a bit controversial, since, when you have the SINGLE_SOCKET
policy bit set, you can have a guest that can run without issue on a
single socket system, but suddenly fail when attempted to be started on a
system with more than one socket. But, as this is opt-in behavior from
userspace, this could be viewed as providing the protection that the guest
owner desires.
In order to support use of the SINGLE_SOCKET policy bit on a system with
more than one socket, the SNP_ACTIVATE_EX command must be used and proper
scheduling support performed.
The series is based off of:
https://github.com/kvm-x86/linux.git next
Tom Lendacky (2):
KVM: SVM: Allow SNP guest policy disallow running with SMT enabled
KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET
arch/x86/kvm/svm/sev.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
base-commit: 3f7b307757ecffc1c18ede9ee3cf9ce8101f3cc9
--
2.46.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled
2025-05-29 21:17 [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Tom Lendacky
@ 2025-05-29 21:17 ` Tom Lendacky
2025-05-29 21:18 ` [PATCH 2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET Tom Lendacky
2025-06-24 19:38 ` [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Sean Christopherson
2 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2025-05-29 21:17 UTC (permalink / raw)
To: kvm, linux-kernel, x86
Cc: Paolo Bonzini, Sean Christopherson, Borislav Petkov, Dave Hansen,
Ingo Molnar, Thomas Gleixner, Michael Roth
KVM currently returns -EINVAL when it attempts to create an SNP guest if
the SMT guest policy bit is not set. However, there is no reason to check
this, as there is no specific support in KVM that is required to support
this. The SEV firmware will determine if SMT has been enabled or disabled
in the BIOS and process the policy in the proper way:
- SMT enabled in BIOS
- Guest policy SMT == 0 ==> SNP_LAUNCH_START fails with POLICY_FAILURE
- Guest policy SMT == 1 ==> SNP_LAUNCH_START succeeds
- SMT disabled in BIOS
- Guest policy SMT == 0 ==> SNP_LAUNCH_START succeeds
- Guest policy SMT == 1 ==> SNP_LAUNCH_START succeeds
Remove the check for the SMT policy bit from snp_launch_start() and allow
the firmware to perform the proper checking.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
arch/x86/kvm/svm/sev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 978a0088a3f1..77eb036cd6d4 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2194,8 +2194,7 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
return -EINVAL;
/* Check for policy bits that must be set */
- if (!(params.policy & SNP_POLICY_MASK_RSVD_MBO) ||
- !(params.policy & SNP_POLICY_MASK_SMT))
+ if (!(params.policy & SNP_POLICY_MASK_RSVD_MBO))
return -EINVAL;
if (params.policy & SNP_POLICY_MASK_SINGLE_SOCKET)
--
2.46.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET
2025-05-29 21:17 [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Tom Lendacky
2025-05-29 21:17 ` [PATCH 1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled Tom Lendacky
@ 2025-05-29 21:18 ` Tom Lendacky
2025-06-24 19:38 ` [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Sean Christopherson
2 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2025-05-29 21:18 UTC (permalink / raw)
To: kvm, linux-kernel, x86
Cc: Paolo Bonzini, Sean Christopherson, Borislav Petkov, Dave Hansen,
Ingo Molnar, Thomas Gleixner, Michael Roth
KVM currently returns -EINVAL when it attempts to create an SNP guest if
the SINGLE_SOCKET guest policy bit is set. The reason for this action is
that KVM would need specific support (SNP_ACTIVATE_EX command support) to
achieve this when running on a system with more than one socket. However,
the SEV firmware will make the proper check and return POLICY_FAILURE
during SNP_ACTIVATE if the single socket guest policy bit is set and the
system has more than one socket:
- System with one socket
- Guest policy SINGLE_SOCKET == 0 ==> SNP_ACTIVATE succeeds
- Guest policy SINGLE_SOCKET == 1 ==> SNP_ACTIVATE succeeds
- System with more than one socket
- Guest policy SINGLE_SOCKET == 0 ==> SNP_ACTIVATE succeeds
- Guest policy SINGLE_SOCKET == 1 ==> SNP_ACTIVATE fails with
POLICY_FAILURE
Remove the check for the SINGLE_SOCKET policy bit from snp_launch_start()
and allow the firmware to perform the proper checking.
This does have the effect of allowing an SNP guest with the SINGLE_SOCKET
policy bit set to run on a single socket system, but fail when run on a
system with more than one socket. However, this should not affect existing
SNP guests as setting the SINGLE_SOCKET policy bit is not allowed today.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
arch/x86/kvm/svm/sev.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 77eb036cd6d4..4802edfc5d9e 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -2197,9 +2197,6 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp)
if (!(params.policy & SNP_POLICY_MASK_RSVD_MBO))
return -EINVAL;
- if (params.policy & SNP_POLICY_MASK_SINGLE_SOCKET)
- return -EINVAL;
-
sev->policy = params.policy;
sev->snp_context = snp_context_create(kvm, argp);
--
2.46.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch
2025-05-29 21:17 [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Tom Lendacky
2025-05-29 21:17 ` [PATCH 1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled Tom Lendacky
2025-05-29 21:18 ` [PATCH 2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET Tom Lendacky
@ 2025-06-24 19:38 ` Sean Christopherson
2025-06-24 20:31 ` Tom Lendacky
2 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2025-06-24 19:38 UTC (permalink / raw)
To: Sean Christopherson, kvm, linux-kernel, x86, Tom Lendacky
Cc: Paolo Bonzini, Borislav Petkov, Dave Hansen, Ingo Molnar,
Thomas Gleixner, Michael Roth
On Thu, 29 May 2025 16:17:58 -0500, Tom Lendacky wrote:
> This series removes some guest policy checks that can be better controlled
> by the SEV firmware.
>
> - Remove the check for the SMT policy bit. Currently, a check is made to
> ensure the SMT policy bit is set to 1. However, there is no reason for
> KVM to do this. The SMT policy bit, when 0, is used to ensure that SMT
> has been disabled *in the BIOS.* As this does not require any special
> support within KVM, the check can be safely removed to allow the SEV
> firmware to determine whether the system meets the policy.
>
> [...]
Applied to kvm-x86 svm. FWIW, I'm not entirely sure I love the idea of doing
nothing, e.g. it'd be nice to enumerate support to userspace. But adding a
bunch of code to regurgitate information that's likely available to userspace
(or more likely, the platform admin/orchestrator) doesn't seem worthwile either.
I'll make sure to flag this for Paolo's eyeballs.
[1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled
https://github.com/kvm-x86/linux/commit/9f4701e05fae
[2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET
https://github.com/kvm-x86/linux/commit/24be2b7956a5
--
https://github.com/kvm-x86/kvm-unit-tests/tree/next
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch
2025-06-24 19:38 ` [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Sean Christopherson
@ 2025-06-24 20:31 ` Tom Lendacky
0 siblings, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2025-06-24 20:31 UTC (permalink / raw)
To: Sean Christopherson, kvm, linux-kernel, x86
Cc: Paolo Bonzini, Borislav Petkov, Dave Hansen, Ingo Molnar,
Thomas Gleixner, Michael Roth
On 6/24/25 14:38, Sean Christopherson wrote:
> On Thu, 29 May 2025 16:17:58 -0500, Tom Lendacky wrote:
>> This series removes some guest policy checks that can be better controlled
>> by the SEV firmware.
>>
>> - Remove the check for the SMT policy bit. Currently, a check is made to
>> ensure the SMT policy bit is set to 1. However, there is no reason for
>> KVM to do this. The SMT policy bit, when 0, is used to ensure that SMT
>> has been disabled *in the BIOS.* As this does not require any special
>> support within KVM, the check can be safely removed to allow the SEV
>> firmware to determine whether the system meets the policy.
>>
>> [...]
>
> Applied to kvm-x86 svm. FWIW, I'm not entirely sure I love the idea of doing
> nothing, e.g. it'd be nice to enumerate support to userspace. But adding a
> bunch of code to regurgitate information that's likely available to userspace
> (or more likely, the platform admin/orchestrator) doesn't seem worthwile either.
>
> I'll make sure to flag this for Paolo's eyeballs.
Sounds good, thanks Sean!
Tom
>
> [1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled
> https://github.com/kvm-x86/linux/commit/9f4701e05fae
> [2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET
> https://github.com/kvm-x86/linux/commit/24be2b7956a5
>
> --
> https://github.com/kvm-x86/kvm-unit-tests/tree/next
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-24 20:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29 21:17 [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Tom Lendacky
2025-05-29 21:17 ` [PATCH 1/2] KVM: SVM: Allow SNP guest policy disallow running with SMT enabled Tom Lendacky
2025-05-29 21:18 ` [PATCH 2/2] KVM: SVM: Allow SNP guest policy to specify SINGLE_SOCKET Tom Lendacky
2025-06-24 19:38 ` [PATCH 0/2] Remove some hardcoded SEV-SNP guest policy checks during guest launch Sean Christopherson
2025-06-24 20:31 ` Tom Lendacky
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.