Skip to contentSkip to conversation

KVM: x86: Fix kvm/queue breakage on clang

PATCH In review Sean Christopherson 3 participants 5 messages Mar 15, 2023 – Mar 16, 2023

Subsystems (3)
lore
Share & tools
lore

Sean Christopherson

author maintainer
#0 lore raw

cover KVM: x86: Fix kvm/queue breakage on clang

Fix clang build errors for patches sitting kvm/queue. Ideally, these fixes will be squashed before the buggy commits make their way to kvm/next. If you do fixup kvm/queue, the VMX commit also has a bad SOB chain; Jim either needs to be listed as the author or his SOB needs to be deleted.

Sean Christopherson (2):
KVM: VMX: Drop unprotected-by-braces variable declaration in
case-statement
KVM: SVM: Drop unprotected-by-braces variable declaration in
case-statement

 arch/x86/kvm/svm/svm.c | 5 ++---
 arch/x86/kvm/vmx/vmx.c | 4 +---
 2 files changed, 3 insertions(+), 6 deletions(-)

base-commit: 95b9779c1758f03cf494e8550d6249a40089ed1c

Signature · 1 line
2.40.0.rc2.332.ga46443480c-goog
author maintainer
#1 lore raw

PATCH 1/2 KVM: VMX: Drop unprotected-by-braces variable declaration in case-statement

Remove the intermediate "guest_flush_l1d" boolean to fix a build error on clang due to the variable being declared inside a case-statement without curly braces to create a proper code block.

Fixes c7ed946b95cb ("kvm: vmx: Add IA32_FLUSH_CMD guest support")
Cc Emanuele Giuseppe Esposito <[email protected]>
---
 arch/x86/kvm/vmx/vmx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kvm/vmx/vmx.c +1 -3
index c63f6c786eb1..d7bf14abdba1 100644
@@ -2325,10 +2325,8 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 					   X86_FEATURE_IBPB);
 		break;
 	case MSR_IA32_FLUSH_CMD:
-		bool guest_flush_l1d = guest_cpuid_has(vcpu,
-						       X86_FEATURE_FLUSH_L1D);
 		ret = vmx_set_msr_ia32_cmd(vcpu, msr_info,
-					   guest_flush_l1d,
+					   guest_cpuid_has(vcpu, X86_FEATURE_FLUSH_L1D),
 					   L1D_FLUSH,
 					   X86_FEATURE_FLUSH_L1D);
 		break;
Signature · 1 line
2.40.0.rc2.332.ga46443480c-goog
author maintainer
#2 lore raw

PATCH 2/2 KVM: SVM: Drop unprotected-by-braces variable declaration in case-statement

In reply to Sean Christopherson

Remove the intermediate "guest_flush_l1d" boolean to fix a build error on clang due to the variable being declared inside a case-statement without curly braces to create a proper code block.

Fixes cfc1f129df06 ("kvm: svm: Add IA32_FLUSH_CMD guest support")
Cc Emanuele Giuseppe Esposito <[email protected]>
---
 arch/x86/kvm/svm/svm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kvm/svm/svm.c +2 -3
index 2780254d4362..70183d2271b5 100644
@@ -2970,9 +2970,8 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
 					 PRED_CMD_IBPB, X86_FEATURE_IBPB);
 		break;
 	case MSR_IA32_FLUSH_CMD:
-		bool guest_flush_l1d = guest_cpuid_has(vcpu,
-						       X86_FEATURE_FLUSH_L1D);
-		r = svm_set_msr_ia32_cmd(vcpu, msr, guest_flush_l1d,
+		r = svm_set_msr_ia32_cmd(vcpu, msr,
+					 guest_cpuid_has(vcpu, X86_FEATURE_FLUSH_L1D),
 					 L1D_FLUSH, X86_FEATURE_FLUSH_L1D);
 		break;
 	case MSR_AMD64_VIRT_SPEC_CTRL:
Signature · 1 line
2.40.0.rc2.332.ga46443480c-goog
Reviewed-by on the v1 series
#3 lore raw
In reply to Sean Christopherson

Am 15/03/2023 um 20:11 schrieb Sean Christopherson:

Quoted 11 lines

Fix clang build errors for patches sitting kvm/queue. Ideally, these fixes will be squashed before the buggy commits make their way to kvm/next. If you do fixup kvm/queue, the VMX commit also has a bad SOB chain; Jim either needs to be listed as the author or his SOB needs to be deleted.

Sean Christopherson (2):
KVM: VMX: Drop unprotected-by-braces variable declaration in
case-statement
KVM: SVM: Drop unprotected-by-braces variable declaration in
case-statement

Quoted 6 lines
 arch/x86/kvm/svm/svm.c | 5 ++---
 arch/x86/kvm/vmx/vmx.c | 4 +---
 2 files changed, 3 insertions(+), 6 deletions(-)

base-commit: 95b9779c1758f03cf494e8550d6249a40089ed1c

Note to self: compile patches also with clang, since gcc didn't complain about missing brackets in a switch case.

maintainer
#4 lore raw
In reply to Sean Christopherson
Quoted 4 lines · Sean Christopherson

Fix clang build errors for patches sitting kvm/queue. Ideally, these fixes will be squashed before the buggy commits make their way to kvm/next. If you do fixup kvm/queue, the VMX commit also has a bad SOB chain; Jim either needs to be listed as the author or his SOB needs to be deleted.

I added it as Co-developed-by and squashed the patches.

Paolo