Skip to content

Commit 6a82cd1

Browse files
vittyvkbonzini
authored andcommitted
x86/kvm/mmu.c: add kvm_mmu parameter to kvm_mmu_free_roots()
Add an option to specify which MMU root we want to free. This will be used when nested and non-nested MMUs for L1 are split. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
1 parent 3dc773e commit 6a82cd1

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,8 @@ void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
13391339
int kvm_mmu_load(struct kvm_vcpu *vcpu);
13401340
void kvm_mmu_unload(struct kvm_vcpu *vcpu);
13411341
void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu);
1342-
void kvm_mmu_free_roots(struct kvm_vcpu *vcpu, ulong roots_to_free);
1342+
void kvm_mmu_free_roots(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
1343+
ulong roots_to_free);
13431344
gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access,
13441345
struct x86_exception *exception);
13451346
gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva,

arch/x86/kvm/mmu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,11 +3480,11 @@ static void mmu_free_root_page(struct kvm *kvm, hpa_t *root_hpa,
34803480
}
34813481

34823482
/* roots_to_free must be some combination of the KVM_MMU_ROOT_* flags */
3483-
void kvm_mmu_free_roots(struct kvm_vcpu *vcpu, ulong roots_to_free)
3483+
void kvm_mmu_free_roots(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
3484+
ulong roots_to_free)
34843485
{
34853486
int i;
34863487
LIST_HEAD(invalid_list);
3487-
struct kvm_mmu *mmu = vcpu->arch.mmu;
34883488
bool free_active_root = roots_to_free & KVM_MMU_ROOT_CURRENT;
34893489

34903490
BUILD_BUG_ON(KVM_MMU_NUM_PREV_ROOTS >= BITS_PER_LONG);
@@ -4200,7 +4200,8 @@ static void __kvm_mmu_new_cr3(struct kvm_vcpu *vcpu, gpa_t new_cr3,
42004200
bool skip_tlb_flush)
42014201
{
42024202
if (!fast_cr3_switch(vcpu, new_cr3, new_role, skip_tlb_flush))
4203-
kvm_mmu_free_roots(vcpu, KVM_MMU_ROOT_CURRENT);
4203+
kvm_mmu_free_roots(vcpu, vcpu->arch.mmu,
4204+
KVM_MMU_ROOT_CURRENT);
42044205
}
42054206

42064207
void kvm_mmu_new_cr3(struct kvm_vcpu *vcpu, gpa_t new_cr3, bool skip_tlb_flush)
@@ -4981,7 +4982,7 @@ EXPORT_SYMBOL_GPL(kvm_mmu_load);
49814982

49824983
void kvm_mmu_unload(struct kvm_vcpu *vcpu)
49834984
{
4984-
kvm_mmu_free_roots(vcpu, KVM_MMU_ROOTS_ALL);
4985+
kvm_mmu_free_roots(vcpu, vcpu->arch.mmu, KVM_MMU_ROOTS_ALL);
49854986
WARN_ON(VALID_PAGE(vcpu->arch.mmu->root_hpa));
49864987
}
49874988
EXPORT_SYMBOL_GPL(kvm_mmu_unload);

arch/x86/kvm/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9127,7 +9127,7 @@ static int handle_invpcid(struct kvm_vcpu *vcpu)
91279127
== operand.pcid)
91289128
roots_to_free |= KVM_MMU_ROOT_PREVIOUS(i);
91299129

9130-
kvm_mmu_free_roots(vcpu, roots_to_free);
9130+
kvm_mmu_free_roots(vcpu, vcpu->arch.mmu, roots_to_free);
91319131
/*
91329132
* If neither the current cr3 nor any of the prev_roots use the
91339133
* given PCID, then nothing needs to be done here because a

0 commit comments

Comments
 (0)