Skip to contentSkip to conversation

KVM: nVMX: Replace a BUG_ON(1) with BUG() to squash clang warning

PATCH Applied Sean Christopherson 2 participants 2 messages May 4, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: nVMX: Replace a BUG_ON(1) with BUG() to squash clang warning

Use BUG() in the impossible-to-hit default case when switching on the scope of INVEPT to squash a warning with clang 11 due to clang treating the BUG_ON() as conditional.

Quoted 1 line
Quoted 1 line

arch/x86/kvm/vmx/nested.c:5246:3: warning: variable 'roots_to_free'

is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
BUG_ON(1);

Fixes ce8fe7b77bd8 ("KVM: nVMX: Free only the affected contexts when emulating INVEPT")
---
 arch/x86/kvm/vmx/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +1 -1
index 2c36f3f53108..669445136144 100644
@@ -5249,7 +5249,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 		roots_to_free = KVM_MMU_ROOTS_ALL;
 		break;
 	default:
-		BUG_ON(1);
+		BUG();
 		break;
 	}
 
Signature · 1 line
2.26.0
maintainer Applied
#1 lore raw
Quoted 22 lines · Sean Christopherson

Use BUG() in the impossible-to-hit default case when switching on the scope of INVEPT to squash a warning with clang 11 due to clang treating the BUG_ON() as conditional.

Quoted 1 line
Quoted 1 line

arch/x86/kvm/vmx/nested.c:5246:3: warning: variable 'roots_to_free'

is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
BUG_ON(1);

Fixes ce8fe7b77bd8 ("KVM: nVMX: Free only the affected contexts when emulating INVEPT")
---
 arch/x86/kvm/vmx/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/nested.c +0 -0
index 2c36f3f53108..669445136144 100644

arch/x86/kvm/vmx/nested.c static int handle_invept(struct kvm_vcpu *vcpu) · line 5255

Quoted 8 lines
arch/x86/kvm/vmx/nested.c +1 -1
@@ -5249,7 +5249,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
 		roots_to_free = KVM_MMU_ROOTS_ALL;
 		break;
 	default:
-		BUG_ON(1);
+		BUG();
 		break;
 	}
 

Queued, thanks.

Paolo