mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 12:21:22 -05:00
LoongArch: KVM: Remove PGD saving during VM context switch
PGD table for primary mmu keeps unchanged once VM is created, it is not necessary to save PGD table pointer during VM context switch. And it can be acquired when VM is created. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
@@ -176,6 +176,9 @@ struct kvm_vcpu_arch {
|
||||
/* Pointers stored here for easy accessing from assembly code */
|
||||
int (*handle_exit)(struct kvm_run *run, struct kvm_vcpu *vcpu);
|
||||
|
||||
/* GPA (=HVA) of PGD for secondary mmu */
|
||||
unsigned long kvm_pgd;
|
||||
|
||||
/* Host registers preserved across guest mode execution */
|
||||
unsigned long host_sp;
|
||||
unsigned long host_tp;
|
||||
|
||||
@@ -296,6 +296,7 @@ static void __used output_kvm_defines(void)
|
||||
OFFSET(KVM_ARCH_HSP, kvm_vcpu_arch, host_sp);
|
||||
OFFSET(KVM_ARCH_HTP, kvm_vcpu_arch, host_tp);
|
||||
OFFSET(KVM_ARCH_HPGD, kvm_vcpu_arch, host_pgd);
|
||||
OFFSET(KVM_ARCH_KVMPGD, kvm_vcpu_arch, kvm_pgd);
|
||||
OFFSET(KVM_ARCH_HANDLE_EXIT, kvm_vcpu_arch, handle_exit);
|
||||
OFFSET(KVM_ARCH_HEENTRY, kvm_vcpu_arch, host_eentry);
|
||||
OFFSET(KVM_ARCH_GEENTRY, kvm_vcpu_arch, guest_eentry);
|
||||
|
||||
@@ -60,16 +60,8 @@
|
||||
ld.d t0, a2, KVM_ARCH_GPC
|
||||
csrwr t0, LOONGARCH_CSR_ERA
|
||||
|
||||
/* Save host PGDL */
|
||||
csrrd t0, LOONGARCH_CSR_PGDL
|
||||
st.d t0, a2, KVM_ARCH_HPGD
|
||||
|
||||
/* Switch to kvm */
|
||||
ld.d t1, a2, KVM_VCPU_KVM - KVM_VCPU_ARCH
|
||||
|
||||
/* Load guest PGDL */
|
||||
li.w t0, KVM_GPGD
|
||||
ldx.d t0, t1, t0
|
||||
/* Load PGD for KVM hypervisor */
|
||||
ld.d t0, a2, KVM_ARCH_KVMPGD
|
||||
csrwr t0, LOONGARCH_CSR_PGDL
|
||||
|
||||
/* Mix GID and RID */
|
||||
|
||||
@@ -1462,6 +1462,15 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
|
||||
hrtimer_init(&vcpu->arch.swtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
|
||||
vcpu->arch.swtimer.function = kvm_swtimer_wakeup;
|
||||
|
||||
/* Get GPA (=HVA) of PGD for kvm hypervisor */
|
||||
vcpu->arch.kvm_pgd = __pa(vcpu->kvm->arch.pgd);
|
||||
|
||||
/*
|
||||
* Get PGD for primary mmu, virtual address is used since there is
|
||||
* memory access after loading from CSR_PGD in tlb exception fast path.
|
||||
*/
|
||||
vcpu->arch.host_pgd = (unsigned long)vcpu->kvm->mm->pgd;
|
||||
|
||||
vcpu->arch.handle_exit = kvm_handle_exit;
|
||||
vcpu->arch.guest_eentry = (unsigned long)kvm_loongarch_ops->exc_entry;
|
||||
vcpu->arch.csr = kzalloc(sizeof(struct loongarch_csrs), GFP_KERNEL);
|
||||
|
||||
Reference in New Issue
Block a user