mmu.c (6a99c6e3f52a6f0d4c6ebcfa7359c718a19ffbe6) mmu.c (a54d806688fe1e482350ce759a8a0fc9ebf814b0)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
4 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
5 */
6
7#include <linux/mman.h>
8#include <linux/kvm_host.h>

--- 196 unchanged lines hidden (view full) ---

205 *
206 * Go through the stage 2 page tables and invalidate any cache lines
207 * backing memory already mapped to the VM.
208 */
209static void stage2_flush_vm(struct kvm *kvm)
210{
211 struct kvm_memslots *slots;
212 struct kvm_memory_slot *memslot;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 - Virtual Open Systems and Columbia University
4 * Author: Christoffer Dall <c.dall@virtualopensystems.com>
5 */
6
7#include <linux/mman.h>
8#include <linux/kvm_host.h>

--- 196 unchanged lines hidden (view full) ---

205 *
206 * Go through the stage 2 page tables and invalidate any cache lines
207 * backing memory already mapped to the VM.
208 */
209static void stage2_flush_vm(struct kvm *kvm)
210{
211 struct kvm_memslots *slots;
212 struct kvm_memory_slot *memslot;
213 int idx;
213 int idx, bkt;
214
215 idx = srcu_read_lock(&kvm->srcu);
216 spin_lock(&kvm->mmu_lock);
217
218 slots = kvm_memslots(kvm);
214
215 idx = srcu_read_lock(&kvm->srcu);
216 spin_lock(&kvm->mmu_lock);
217
218 slots = kvm_memslots(kvm);
219 kvm_for_each_memslot(memslot, slots)
219 kvm_for_each_memslot(memslot, bkt, slots)
220 stage2_flush_memslot(kvm, memslot);
221
222 spin_unlock(&kvm->mmu_lock);
223 srcu_read_unlock(&kvm->srcu, idx);
224}
225
226/**
227 * free_hyp_pgds - free Hyp-mode page tables

--- 362 unchanged lines hidden (view full) ---

590 *
591 * Go through the memregions and unmap any regular RAM
592 * backing memory already mapped to the VM.
593 */
594void stage2_unmap_vm(struct kvm *kvm)
595{
596 struct kvm_memslots *slots;
597 struct kvm_memory_slot *memslot;
220 stage2_flush_memslot(kvm, memslot);
221
222 spin_unlock(&kvm->mmu_lock);
223 srcu_read_unlock(&kvm->srcu, idx);
224}
225
226/**
227 * free_hyp_pgds - free Hyp-mode page tables

--- 362 unchanged lines hidden (view full) ---

590 *
591 * Go through the memregions and unmap any regular RAM
592 * backing memory already mapped to the VM.
593 */
594void stage2_unmap_vm(struct kvm *kvm)
595{
596 struct kvm_memslots *slots;
597 struct kvm_memory_slot *memslot;
598 int idx;
598 int idx, bkt;
599
600 idx = srcu_read_lock(&kvm->srcu);
601 mmap_read_lock(current->mm);
602 spin_lock(&kvm->mmu_lock);
603
604 slots = kvm_memslots(kvm);
599
600 idx = srcu_read_lock(&kvm->srcu);
601 mmap_read_lock(current->mm);
602 spin_lock(&kvm->mmu_lock);
603
604 slots = kvm_memslots(kvm);
605 kvm_for_each_memslot(memslot, slots)
605 kvm_for_each_memslot(memslot, bkt, slots)
606 stage2_unmap_memslot(kvm, memslot);
607
608 spin_unlock(&kvm->mmu_lock);
609 mmap_read_unlock(current->mm);
610 srcu_read_unlock(&kvm->srcu, idx);
611}
612
613void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)

--- 1029 unchanged lines hidden ---
606 stage2_unmap_memslot(kvm, memslot);
607
608 spin_unlock(&kvm->mmu_lock);
609 mmap_read_unlock(current->mm);
610 srcu_read_unlock(&kvm->srcu, idx);
611}
612
613void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu)

--- 1029 unchanged lines hidden ---