Commit dcc70651 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: x86/mmu: Hoist ITLB multi-hit workaround check up a level

Move the "ITLB multi-hit workaround enabled" check into the callers of
disallowed_hugepage_adjust() to make it more obvious that the helper is
specific to the workaround, and to be consistent with the accounting,
i.e. account_huge_nx_page() is called if and only if the workaround is
enabled.

No functional change intended.
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200923183735.584-8-sean.j.christopherson@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 1d4a7372
...@@ -3329,7 +3329,6 @@ static void disallowed_hugepage_adjust(struct kvm_shadow_walk_iterator it, ...@@ -3329,7 +3329,6 @@ static void disallowed_hugepage_adjust(struct kvm_shadow_walk_iterator it,
u64 spte = *it.sptep; u64 spte = *it.sptep;
if (it.level == level && level > PG_LEVEL_4K && if (it.level == level && level > PG_LEVEL_4K &&
is_nx_huge_page_enabled() &&
is_shadow_present_pte(spte) && is_shadow_present_pte(spte) &&
!is_large_pte(spte)) { !is_large_pte(spte)) {
/* /*
...@@ -3371,7 +3370,8 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, ...@@ -3371,7 +3370,8 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
* We cannot overwrite existing page tables with an NX * We cannot overwrite existing page tables with an NX
* large page, as the leaf could be executable. * large page, as the leaf could be executable.
*/ */
disallowed_hugepage_adjust(it, gfn, &pfn, &level); if (nx_huge_page_workaround_enabled)
disallowed_hugepage_adjust(it, gfn, &pfn, &level);
base_gfn = gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1); base_gfn = gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1);
if (it.level == level) if (it.level == level)
......
...@@ -694,7 +694,8 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, ...@@ -694,7 +694,8 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr,
* We cannot overwrite existing page tables with an NX * We cannot overwrite existing page tables with an NX
* large page, as the leaf could be executable. * large page, as the leaf could be executable.
*/ */
disallowed_hugepage_adjust(it, gw->gfn, &pfn, &level); if (nx_huge_page_workaround_enabled)
disallowed_hugepage_adjust(it, gw->gfn, &pfn, &level);
base_gfn = gw->gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1); base_gfn = gw->gfn & ~(KVM_PAGES_PER_HPAGE(it.level) - 1);
if (it.level == level) if (it.level == level)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment