KVM: x86/mmu: Use MMU's role to get EFER.NX during MMU configuration
Get the MMU's effective EFER.NX from its role instead of using the one-off, dedicated flag. This will allow dropping said flag in a future commit. No functional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210622175739.3610207-38-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
84a1622604
commit
90599c2801
@ -4212,7 +4212,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
|
|||||||
{
|
{
|
||||||
__reset_rsvds_bits_mask(&context->guest_rsvd_check,
|
__reset_rsvds_bits_mask(&context->guest_rsvd_check,
|
||||||
vcpu->arch.reserved_gpa_bits,
|
vcpu->arch.reserved_gpa_bits,
|
||||||
context->root_level, context->nx,
|
context->root_level, is_efer_nx(context),
|
||||||
guest_cpuid_has(vcpu, X86_FEATURE_GBPAGES),
|
guest_cpuid_has(vcpu, X86_FEATURE_GBPAGES),
|
||||||
is_cr4_pse(context),
|
is_cr4_pse(context),
|
||||||
guest_cpuid_is_amd_or_hygon(vcpu));
|
guest_cpuid_is_amd_or_hygon(vcpu));
|
||||||
@ -4278,7 +4278,7 @@ static void reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu,
|
|||||||
* NX can be used by any non-nested shadow MMU to avoid having to reset
|
* NX can be used by any non-nested shadow MMU to avoid having to reset
|
||||||
* MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled.
|
* MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled.
|
||||||
*/
|
*/
|
||||||
bool uses_nx = context->nx || !tdp_enabled;
|
bool uses_nx = is_efer_nx(context) || !tdp_enabled;
|
||||||
|
|
||||||
/* @amd adds a check on bit of SPTEs, which KVM shouldn't use anyways. */
|
/* @amd adds a check on bit of SPTEs, which KVM shouldn't use anyways. */
|
||||||
bool is_amd = true;
|
bool is_amd = true;
|
||||||
@ -4375,6 +4375,7 @@ static void update_permission_bitmask(struct kvm_mmu *mmu, bool ept)
|
|||||||
bool cr4_smep = is_cr4_smep(mmu);
|
bool cr4_smep = is_cr4_smep(mmu);
|
||||||
bool cr4_smap = is_cr4_smap(mmu);
|
bool cr4_smap = is_cr4_smap(mmu);
|
||||||
bool cr0_wp = is_cr0_wp(mmu);
|
bool cr0_wp = is_cr0_wp(mmu);
|
||||||
|
bool efer_nx = is_efer_nx(mmu);
|
||||||
|
|
||||||
for (byte = 0; byte < ARRAY_SIZE(mmu->permissions); ++byte) {
|
for (byte = 0; byte < ARRAY_SIZE(mmu->permissions); ++byte) {
|
||||||
unsigned pfec = byte << 1;
|
unsigned pfec = byte << 1;
|
||||||
@ -4400,7 +4401,7 @@ static void update_permission_bitmask(struct kvm_mmu *mmu, bool ept)
|
|||||||
u8 kf = (pfec & PFERR_USER_MASK) ? 0 : u;
|
u8 kf = (pfec & PFERR_USER_MASK) ? 0 : u;
|
||||||
|
|
||||||
/* Not really needed: !nx will cause pte.nx to fault */
|
/* Not really needed: !nx will cause pte.nx to fault */
|
||||||
if (!mmu->nx)
|
if (!efer_nx)
|
||||||
ff = 0;
|
ff = 0;
|
||||||
|
|
||||||
/* Allow supervisor writes if !cr0.wp */
|
/* Allow supervisor writes if !cr0.wp */
|
||||||
|
Loading…
Reference in New Issue
Block a user