On 3/22/2023 5:35 AM, Sean Christopherson wrote:
On Mon, Mar 20, 2023, Chao Gao wrote:
On Sun, Mar 19, 2023 at 04:49:22PM +0800, Binbin Wu wrote:
get_vmx_mem_address() and sgx_get_encls_gva() use is_long_mode()
to check 64-bit mode. Should use is_64_bit_mode() instead.
Fixes: f9eb4af67c9d ("KVM: nVMX: VMX instructions: add checks for #GP/#SS exceptions")
Fixes: 70210c044b4e ("KVM: VMX: Add SGX ENCLS[ECREATE] handler to enforce CPUID restrictions")
It is better to split this patch into two: one for nested and one for
SGX.
It is possible that there is a kernel release which has just one of
above two flawed commits, then this fix patch cannot be applied cleanly
to the release.
The nVMX code isn't buggy, VMX instructions #UD in compatibility mode, and except
for VMCALL, that #UD has higher priority than VM-Exit interception. So I'd say
just drop the nVMX side of things.
Got it.
Do you mind if I add a comment about it in code?
I could have sworn ENCLS had the same behavior, but the SDM disagrees. Though why
on earth ENCLS is allowed in compatibility mode is beyond me. ENCLU I can kinda
sorta understand, but ENCLS?!?!!
Yes, the SDM does have definition about the behavior "outside 64-bit
mode (IA32_EFER.LAM = 0 || CS.L = 0)".
IMO, the change has very little impact on performance since the two
intercepted ENCLS leaf EINIT & ECREATE will
only be called once per lifecycle of a SGX Enclave.