KVM: x86: Restrict get_mt_mask() to a u8, use KVM_X86_OP_OPTIONAL_RET0
authorSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 15:37:07 +0000 (15:37 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 14 Jul 2022 15:43:12 +0000 (11:43 -0400)
commitba28401bb93e5c779d5762c4eb0eb665493e5dd4
treea3e73afa2c5addc5248bfa0b4547569b799ee8fd
parent277ad7d58611b455662f2e3f7bd24ce5bfeb2fdc
KVM: x86: Restrict get_mt_mask() to a u8, use KVM_X86_OP_OPTIONAL_RET0

Restrict get_mt_mask() to a u8 and reintroduce using a RET0 static_call
for the SVM implementation.  EPT stores the memtype information in the
lower 8 bits (bits 6:3 to be precise), and even returns a shifted u8
without an explicit cast to a larger type; there's no need to return a
full u64.

Note, RET0 doesn't play nice with a u64 return on 32-bit kernels, see
commit bf07be36cd88 ("KVM: x86: do not use KVM_X86_OP_OPTIONAL_RET0 for
get_mt_mask").

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220714153707.3239119-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm-x86-ops.h
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx.c