Skip to contentSkip to conversation

KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler

PATCH Applied Binbin Wu 2 participants 2 messages Apr 4, 2023 – Apr 5, 2023

Subsystems (3)
lore
Share & tools
lore

Binbin Wu

author
#0 lore raw

PATCH 1/1 KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler

sgx_get_encls_gva() uses is_long_mode() to check 64-bit mode, however, SGX system leaf instructions are valid in compatibility mode, should use is_64_bit_mode() instead.

Fixes 70210c044b4e ("KVM: VMX: Add SGX ENCLS[ECREATE] handler to enforce CPUID restrictions")
---
 arch/x86/kvm/vmx/sgx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/vmx/sgx.c +2 -2
index aa53c98034bf..0574030b071f 100644
@@ -29,14 +29,14 @@ static int sgx_get_encls_gva(struct kvm_vcpu *vcpu, unsigned long offset,
 
 	/* Skip vmcs.GUEST_DS retrieval for 64-bit mode to avoid VMREADs. */
 	*gva = offset;
-	if (!is_long_mode(vcpu)) {
+	if (!is_64_bit_mode(vcpu)) {
 		vmx_get_segment(vcpu, &s, VCPU_SREG_DS);
 		*gva += s.base;
 	}
 
 	if (!IS_ALIGNED(*gva, alignment)) {
 		fault = true;
-	} else if (likely(is_long_mode(vcpu))) {
+	} else if (likely(is_64_bit_mode(vcpu))) {
 		fault = is_noncanonical_address(*gva, vcpu);
 	} else {
 		*gva &= 0xffffffff;

base-commit: 99b30869804ea59d9596cdbefa5cc3aabd588521

Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Binbin Wu

sgx_get_encls_gva() uses is_long_mode() to check 64-bit mode, however, SGX system leaf instructions are valid in compatibility mode, should use is_64_bit_mode() instead.

Applied to kvm-x86 vmx, thanks! I'm still dumbfounded that ENCLS is allowed in compatibility mode :-)

[1/1] KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler

      https://github.com/kvm-x86/linux/commit/548bd27428b9

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes