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 {
176
176
/* Pointers stored here for easy accessing from assembly code */
177
177
int (* handle_exit )(struct kvm_run * run , struct kvm_vcpu * vcpu );
178
178
179
+ /* GPA (=HVA) of PGD for secondary mmu */
180
+ unsigned long kvm_pgd ;
181
+
179
182
/* Host registers preserved across guest mode execution */
180
183
unsigned long host_sp ;
181
184
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)
296
296
OFFSET (KVM_ARCH_HSP , kvm_vcpu_arch , host_sp );
297
297
OFFSET (KVM_ARCH_HTP , kvm_vcpu_arch , host_tp );
298
298
OFFSET (KVM_ARCH_HPGD , kvm_vcpu_arch , host_pgd );
299
+ OFFSET (KVM_ARCH_KVMPGD , kvm_vcpu_arch , kvm_pgd );
299
300
OFFSET (KVM_ARCH_HANDLE_EXIT , kvm_vcpu_arch , handle_exit );
300
301
OFFSET (KVM_ARCH_HEENTRY , kvm_vcpu_arch , host_eentry );
301
302
OFFSET (KVM_ARCH_GEENTRY , kvm_vcpu_arch , guest_eentry );
Original file line number Diff line number Diff line change 60
60
ld.d t0, a2, KVM_ARCH_GPC
61
61
csrwr t0, LOONGARCH_CSR_ERA
62
62
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
73
65
csrwr t0, LOONGARCH_CSR_PGDL
74
66
75
67
/* 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)
1462
1462
hrtimer_init (& vcpu -> arch .swtimer , CLOCK_MONOTONIC , HRTIMER_MODE_ABS_PINNED_HARD );
1463
1463
vcpu -> arch .swtimer .function = kvm_swtimer_wakeup ;
1464
1464
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
+
1465
1474
vcpu -> arch .handle_exit = kvm_handle_exit ;
1466
1475
vcpu -> arch .guest_eentry = (unsigned long )kvm_loongarch_ops -> exc_entry ;
1467
1476
vcpu -> arch .csr = kzalloc (sizeof (struct loongarch_csrs ), GFP_KERNEL );
You can’t perform that action at this time.
0 commit comments