diff options
author | Sean Christopherson <seanjc@google.com> | 2021-08-18 18:03:08 +0300 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2022-02-14 03:48:04 +0300 |
commit | 73ab4a3509e6b8f93b87398db2aaabd3c9cbe487 (patch) | |
tree | 1870f8db63e9f47f2d018f25951879ca3c0ce9fc /arch/x86/kvm/kvm_emulate.h | |
parent | dfd42facf1e4ada021b939b4e19c935dcdd55566 (diff) | |
download | linux-73ab4a3509e6b8f93b87398db2aaabd3c9cbe487.tar.xz |
KVM: x86: Replace memset() "optimization" with normal per-field writes
Explicitly zero select fields in the emulator's decode cache instead of
zeroing the fields via a gross memset() that spans six fields. gcc and
clang are both clever enough to batch the first five fields into a single
quadword MOV, i.e. memset() and individually zeroing generate identical
code.
Removing the wart also prepares KVM for FORTIFY_SOURCE performing
compile-time and run-time field bounds checking for memset().
No functional change intended.
Reported-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/lkml/YR0jIEzEcUom/7rd@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Diffstat (limited to 'arch/x86/kvm/kvm_emulate.h')
-rw-r--r-- | arch/x86/kvm/kvm_emulate.h | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h index 39eded2426ff..840ddb4a9302 100644 --- a/arch/x86/kvm/kvm_emulate.h +++ b/arch/x86/kvm/kvm_emulate.h @@ -336,11 +336,7 @@ struct x86_emulate_ctxt { fastop_t fop; }; int (*check_perm)(struct x86_emulate_ctxt *ctxt); - /* - * The following six fields are cleared together, - * the rest are initialized unconditionally in x86_decode_insn - * or elsewhere - */ + bool rip_relative; u8 rex_prefix; u8 lock_prefix; |