OSDN Git Service

KVM: SVM: Use kvm_is_cr4_bit_set() to query SMAP/SMEP in "can emulate"
authorBinbin Wu <binbin.wu@linux.intel.com>
Wed, 22 Mar 2023 04:58:23 +0000 (12:58 +0800)
committerSean Christopherson <seanjc@google.com>
Wed, 22 Mar 2023 17:18:18 +0000 (10:18 -0700)
commit627778bfcfa1ff81acfe863dcc4316edd0a51276
treea236e5eb266b114921cdc0b7b2efd297766ed972
parentbede6eb4db19424477c36dace426ae12255f4a0d
KVM: SVM: Use kvm_is_cr4_bit_set() to query SMAP/SMEP in "can emulate"

Use kvm_is_cr4_bit_set() to query SMAP and SMEP when determining whether
or not AMD's SMAP+SEV errata prevents KVM from emulating an instruction.
This eliminates an implicit cast from ulong to bool and makes the code
slightly more readable.

Note, any overhead from making multiple calls to kvm_read_cr4_bits() is
negligible, not to mention the code is question is encountered only in
rare situations, i.e. is not a remotely hot path.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com>
Link: https://lore.kernel.org/r/20230322045824.22970-4-binbin.wu@linux.intel.com
[sean: keep local smap/smep variables, massage changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c