kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler
@ 2023-04-04  3:25 Binbin Wu
  2023-04-05 23:16 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Binbin Wu @ 2023-04-04  3:25 UTC (permalink / raw)
  To: kvm, seanjc, pbonzini; +Cc: binbin.wu, kai.huang

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")
Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
---
 arch/x86/kvm/vmx/sgx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx/sgx.c b/arch/x86/kvm/vmx/sgx.c
index aa53c98034bf..0574030b071f 100644
--- a/arch/x86/kvm/vmx/sgx.c
+++ b/arch/x86/kvm/vmx/sgx.c
@@ -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
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler
  2023-04-04  3:25 [PATCH] KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler Binbin Wu
@ 2023-04-05 23:16 ` Sean Christopherson
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2023-04-05 23:16 UTC (permalink / raw)
  To: Sean Christopherson, kvm, pbonzini, Binbin Wu; +Cc: kai.huang

On Tue, 04 Apr 2023 11:25:02 +0800, Binbin Wu wrote:
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-05 23:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04  3:25 [PATCH] KVM: VMX: Use is_64_bit_mode() to check 64-bit mode in SGX handler Binbin Wu
2023-04-05 23:16 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).