summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/kvm_emulate.h
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-05-26 23:08:14 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-10 16:01:31 +0200
commitb443183a25ab61840a12de92f8822849e017b9c8 (patch)
treeb3f1773c38494a32c798eb5f93e037c2833938b0 /arch/x86/kvm/kvm_emulate.h
parentKVM: x86: Use 16-bit fields to track dirty/valid emulator GPRs (diff)
downloadlinux-b443183a25ab61840a12de92f8822849e017b9c8.tar.xz
linux-b443183a25ab61840a12de92f8822849e017b9c8.zip
KVM: x86: Reduce the number of emulator GPRs to '8' for 32-bit KVM
Reduce the number of GPRs emulated by 32-bit KVM from 16 to 8. KVM does not support emulating 64-bit mode on 32-bit host kernels, and so should never generate accesses to R8-15. Opportunistically use NR_EMULATOR_GPRS in rsm_load_state_{32,64}() now that it is precise and accurate for both flavors. Wrap the definition with full #ifdef ugliness; sadly, IS_ENABLED() doesn't guarantee a compile-time constant as far as BUILD_BUG_ON() is concerned. Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Message-Id: <20220526210817.3428868-6-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/kvm_emulate.h')
-rw-r--r--arch/x86/kvm/kvm_emulate.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
index 3a65d6ea7fe6..034c845b3c63 100644
--- a/arch/x86/kvm/kvm_emulate.h
+++ b/arch/x86/kvm/kvm_emulate.h
@@ -306,11 +306,12 @@ typedef void (*fastop_t)(struct fastop *);
* tracked/accessed via _eip, and except for RIP relative addressing, which
* also uses _eip, RIP cannot be a register operand nor can it be an operand in
* a ModRM or SIB byte.
- *
- * TODO: this is technically wrong for 32-bit KVM, which only supports 8 GPRs;
- * R8-R15 don't exist.
*/
+#ifdef CONFIG_X86_64
#define NR_EMULATOR_GPRS 16
+#else
+#define NR_EMULATOR_GPRS 8
+#endif
struct x86_emulate_ctxt {
void *vcpu;