]> www.infradead.org Git - users/dwmw2/linux.git/commit
KVM: x86: Replace memset() "optimization" with normal per-field writes
authorSean Christopherson <seanjc@google.com>
Wed, 18 Aug 2021 15:03:08 +0000 (08:03 -0700)
committerKees Cook <keescook@chromium.org>
Mon, 14 Feb 2022 00:48:04 +0000 (16:48 -0800)
commit73ab4a3509e6b8f93b87398db2aaabd3c9cbe487
tree1870f8db63e9f47f2d018f25951879ca3c0ce9fc
parentdfd42facf1e4ada021b939b4e19c935dcdd55566
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>
arch/x86/kvm/emulate.c
arch/x86/kvm/kvm_emulate.h