Skip to contentSkip to conversation

x86/Hyperv: Fix check of return value from snp_set_vmsa()

PATCH Applied Tianyu Lan 3 participants 4 messages Mar 13, 2025 – Mar 14, 2025

Subsystems (4)
lore
Share & tools
lore

Tianyu Lan

author
#0 lore raw

PATCH 1/1 x86/Hyperv: Fix check of return value from snp_set_vmsa()

From: Tianyu Lan <[email protected]>

snp_set_vmsa() returns 0 as success result and so fix it.

Fixes 44676bb9d566 ("x86/hyperv: Add smp support for SEV-SNP guest")
---
 arch/x86/hyperv/ivm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/hyperv/ivm.c +1 -1
index ec7880271cf9..77bf05f06b9e 100644
@@ -338,7 +338,7 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
 	vmsa->sev_features = sev_status >> 2;
 
 	ret = snp_set_vmsa(vmsa, true);
-	if (!ret) {
+	if (ret) {
 		pr_err("RMPADJUST(%llx) failed: %llx\n", (u64)vmsa, ret);
 		free_page((u64)vmsa);
 		return ret;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

From: Tianyu Lan <[email protected]> Sent: Thursday, March 13, 2025 1:52 AM

Quoted 24 lines

snp_set_vmsa() returns 0 as success result and so fix it.

Fixes 44676bb9d566 ("x86/hyperv: Add smp support for SEV-SNP guest")
---
 arch/x86/hyperv/ivm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/hyperv/ivm.c +1 -2
index ec7880271cf9..77bf05f06b9e 100644
@@ -338,7 +338,7 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
 	vmsa->sev_features = sev_status >> 2;
 
 	ret = snp_set_vmsa(vmsa, true);
-	if (!ret) {
+	if (ret) {
 		pr_err("RMPADJUST(%llx) failed: %llx\n", (u64)vmsa, ret);
 		free_page((u64)vmsa);
 		return ret;
--
Quoted 2 lines

2.25.1

Yes, with this change the code is now consistent with other call sites for snp_set_vmsa() and for direct invocation of rmpadjust().

author
#2 lore raw
Quoted 32 lines · Michael Kelley

From: Tianyu Lan <[email protected]> Sent: Thursday, March 13, 2025 1:52 AM

Quoted 24 lines

snp_set_vmsa() returns 0 as success result and so fix it.

Fixes 44676bb9d566 ("x86/hyperv: Add smp support for SEV-SNP guest")
---
 arch/x86/hyperv/ivm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/hyperv/ivm.c +1 -2
index ec7880271cf9..77bf05f06b9e 100644
@@ -338,7 +338,7 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
      vmsa->sev_features = sev_status >> 2;
 
      ret = snp_set_vmsa(vmsa, true);
-     if (!ret) {
+     if (ret) {
              pr_err("RMPADJUST(%llx) failed: %llx\n", (u64)vmsa, ret);
              free_page((u64)vmsa);
              return ret;
--
Quoted 2 lines

2.25.1

Yes, with this change the code is now consistent with other call sites for snp_set_vmsa() and for direct invocation of rmpadjust().

Quoted 1 line

Thank you for your review, Michael!

Signature · 2 lines
Thanks
Tianyu Lan
maintainer Applied
#3 lore raw
Quoted 33 lines · Tianyu Lan
Quoted 32 lines · Michael Kelley

From: Tianyu Lan <[email protected]> Sent: Thursday, March 13, 2025 1:52 AM

Quoted 24 lines

snp_set_vmsa() returns 0 as success result and so fix it.

Fixes 44676bb9d566 ("x86/hyperv: Add smp support for SEV-SNP guest")
---
 arch/x86/hyperv/ivm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/hyperv/ivm.c +1 -2
index ec7880271cf9..77bf05f06b9e 100644
@@ -338,7 +338,7 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
      vmsa->sev_features = sev_status >> 2;
 
      ret = snp_set_vmsa(vmsa, true);
-     if (!ret) {
+     if (ret) {
              pr_err("RMPADJUST(%llx) failed: %llx\n", (u64)vmsa, ret);
              free_page((u64)vmsa);
              return ret;
--
Quoted 2 lines

2.25.1

Yes, with this change the code is now consistent with other call sites for snp_set_vmsa() and for direct invocation of rmpadjust().

Quoted 3 lines
Quoted 1 line

Thank you for your review, Michael!

Applied to hyperv-next. Thanks.

Wei.