File tree Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Expand file tree Collapse file tree 4 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 287
287
#define CSR_SIE 0x104
288
288
#define CSR_STVEC 0x105
289
289
#define CSR_SCOUNTEREN 0x106
290
+ #define CSR_SENVCFG 0x10a
290
291
#define CSR_SSCRATCH 0x140
291
292
#define CSR_SEPC 0x141
292
293
#define CSR_SCAUSE 0x142
Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ struct kvm_vcpu_csr {
162
162
unsigned long hvip ;
163
163
unsigned long vsatp ;
164
164
unsigned long scounteren ;
165
+ unsigned long senvcfg ;
165
166
};
166
167
167
168
struct kvm_vcpu_config {
@@ -188,6 +189,7 @@ struct kvm_vcpu_arch {
188
189
unsigned long host_sscratch ;
189
190
unsigned long host_stvec ;
190
191
unsigned long host_scounteren ;
192
+ unsigned long host_senvcfg ;
191
193
192
194
/* CPU context of Host */
193
195
struct kvm_cpu_context host_context ;
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ struct kvm_riscv_csr {
80
80
unsigned long sip ;
81
81
unsigned long satp ;
82
82
unsigned long scounteren ;
83
+ unsigned long senvcfg ;
83
84
};
84
85
85
86
/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
Original file line number Diff line number Diff line change @@ -619,6 +619,20 @@ static void kvm_riscv_update_hvip(struct kvm_vcpu *vcpu)
619
619
kvm_riscv_vcpu_aia_update_hvip (vcpu );
620
620
}
621
621
622
+ static __always_inline void kvm_riscv_vcpu_swap_in_guest_state (struct kvm_vcpu * vcpu )
623
+ {
624
+ struct kvm_vcpu_csr * csr = & vcpu -> arch .guest_csr ;
625
+
626
+ vcpu -> arch .host_senvcfg = csr_swap (CSR_SENVCFG , csr -> senvcfg );
627
+ }
628
+
629
+ static __always_inline void kvm_riscv_vcpu_swap_in_host_state (struct kvm_vcpu * vcpu )
630
+ {
631
+ struct kvm_vcpu_csr * csr = & vcpu -> arch .guest_csr ;
632
+
633
+ csr -> senvcfg = csr_swap (CSR_SENVCFG , vcpu -> arch .host_senvcfg );
634
+ }
635
+
622
636
/*
623
637
* Actually run the vCPU, entering an RCU extended quiescent state (EQS) while
624
638
* the vCPU is running.
@@ -628,10 +642,12 @@ static void kvm_riscv_update_hvip(struct kvm_vcpu *vcpu)
628
642
*/
629
643
static void noinstr kvm_riscv_vcpu_enter_exit (struct kvm_vcpu * vcpu )
630
644
{
645
+ kvm_riscv_vcpu_swap_in_guest_state (vcpu );
631
646
guest_state_enter_irqoff ();
632
647
__kvm_riscv_switch_to (& vcpu -> arch );
633
648
vcpu -> arch .last_exit_cpu = vcpu -> cpu ;
634
649
guest_state_exit_irqoff ();
650
+ kvm_riscv_vcpu_swap_in_host_state (vcpu );
635
651
}
636
652
637
653
int kvm_arch_vcpu_ioctl_run (struct kvm_vcpu * vcpu )
You can’t perform that action at this time.
0 commit comments