File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ struct kvm_vcpu_arch {
176176 /* Pointers stored here for easy accessing from assembly code */
177177 int (* handle_exit )(struct kvm_run * run , struct kvm_vcpu * vcpu );
178178
179+ /* GPA (=HVA) of PGD for secondary mmu */
180+ unsigned long kvm_pgd ;
181+
179182 /* Host registers preserved across guest mode execution */
180183 unsigned long host_sp ;
181184 unsigned long host_tp ;
Original file line number Diff line number Diff line change @@ -296,6 +296,7 @@ static void __used output_kvm_defines(void)
296296 OFFSET (KVM_ARCH_HSP , kvm_vcpu_arch , host_sp );
297297 OFFSET (KVM_ARCH_HTP , kvm_vcpu_arch , host_tp );
298298 OFFSET (KVM_ARCH_HPGD , kvm_vcpu_arch , host_pgd );
299+ OFFSET (KVM_ARCH_KVMPGD , kvm_vcpu_arch , kvm_pgd );
299300 OFFSET (KVM_ARCH_HANDLE_EXIT , kvm_vcpu_arch , handle_exit );
300301 OFFSET (KVM_ARCH_HEENTRY , kvm_vcpu_arch , host_eentry );
301302 OFFSET (KVM_ARCH_GEENTRY , kvm_vcpu_arch , guest_eentry );
Original file line number Diff line number Diff line change 6060 ld.d t0, a2, KVM_ARCH_GPC
6161 csrwr t0, LOONGARCH_CSR_ERA
6262
63- /* Save host PGDL */
64- csrrd t0, LOONGARCH_CSR_PGDL
65- st.d t0, a2, KVM_ARCH_HPGD
66-
67- /* Switch to kvm */
68- ld.d t1, a2, KVM_VCPU_KVM - KVM_VCPU_ARCH
69-
70- /* Load guest PGDL */
71- li.w t0, KVM_GPGD
72- ldx.d t0, t1, t0
63+ /* Load PGD for KVM hypervisor */
64+ ld.d t0, a2, KVM_ARCH_KVMPGD
7365 csrwr t0, LOONGARCH_CSR_PGDL
7466
7567 /* Mix GID and RID */
Original file line number Diff line number Diff line change @@ -1462,6 +1462,15 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
14621462 hrtimer_init (& vcpu -> arch .swtimer , CLOCK_MONOTONIC , HRTIMER_MODE_ABS_PINNED_HARD );
14631463 vcpu -> arch .swtimer .function = kvm_swtimer_wakeup ;
14641464
1465+ /* Get GPA (=HVA) of PGD for kvm hypervisor */
1466+ vcpu -> arch .kvm_pgd = __pa (vcpu -> kvm -> arch .pgd );
1467+
1468+ /*
1469+ * Get PGD for primary mmu, virtual address is used since there is
1470+ * memory access after loading from CSR_PGD in tlb exception fast path.
1471+ */
1472+ vcpu -> arch .host_pgd = (unsigned long )vcpu -> kvm -> mm -> pgd ;
1473+
14651474 vcpu -> arch .handle_exit = kvm_handle_exit ;
14661475 vcpu -> arch .guest_eentry = (unsigned long )kvm_loongarch_ops -> exc_entry ;
14671476 vcpu -> arch .csr = kzalloc (sizeof (struct loongarch_csrs ), GFP_KERNEL );
You can’t perform that action at this time.
0 commit comments