mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 06:49:29 -04:00
RISC-V: KVM: Use ncsr_xyz() in kvm_riscv_vcpu_trap_redirect()
The H-extension CSRs accessed by kvm_riscv_vcpu_trap_redirect() will trap when KVM RISC-V is running as Guest/VM hence remove these traps by using ncsr_xyz() instead of csr_xyz(). Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Tested-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com> Link: https://lore.kernel.org/r/20250618113532.471448-8-apatel@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <linux/kvm_host.h>
|
||||
#include <asm/csr.h>
|
||||
#include <asm/insn-def.h>
|
||||
#include <asm/kvm_nacl.h>
|
||||
|
||||
static int gstage_page_fault(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
||||
struct kvm_cpu_trap *trap)
|
||||
@@ -135,7 +136,7 @@ unsigned long kvm_riscv_vcpu_unpriv_read(struct kvm_vcpu *vcpu,
|
||||
void kvm_riscv_vcpu_trap_redirect(struct kvm_vcpu *vcpu,
|
||||
struct kvm_cpu_trap *trap)
|
||||
{
|
||||
unsigned long vsstatus = csr_read(CSR_VSSTATUS);
|
||||
unsigned long vsstatus = ncsr_read(CSR_VSSTATUS);
|
||||
|
||||
/* Change Guest SSTATUS.SPP bit */
|
||||
vsstatus &= ~SR_SPP;
|
||||
@@ -151,15 +152,15 @@ void kvm_riscv_vcpu_trap_redirect(struct kvm_vcpu *vcpu,
|
||||
vsstatus &= ~SR_SIE;
|
||||
|
||||
/* Update Guest SSTATUS */
|
||||
csr_write(CSR_VSSTATUS, vsstatus);
|
||||
ncsr_write(CSR_VSSTATUS, vsstatus);
|
||||
|
||||
/* Update Guest SCAUSE, STVAL, and SEPC */
|
||||
csr_write(CSR_VSCAUSE, trap->scause);
|
||||
csr_write(CSR_VSTVAL, trap->stval);
|
||||
csr_write(CSR_VSEPC, trap->sepc);
|
||||
ncsr_write(CSR_VSCAUSE, trap->scause);
|
||||
ncsr_write(CSR_VSTVAL, trap->stval);
|
||||
ncsr_write(CSR_VSEPC, trap->sepc);
|
||||
|
||||
/* Set Guest PC to Guest exception vector */
|
||||
vcpu->arch.guest_context.sepc = csr_read(CSR_VSTVEC);
|
||||
vcpu->arch.guest_context.sepc = ncsr_read(CSR_VSTVEC);
|
||||
|
||||
/* Set Guest privilege mode to supervisor */
|
||||
vcpu->arch.guest_context.sstatus |= SR_SPP;
|
||||
|
||||
Reference in New Issue
Block a user