Skip to content

Commit 78f94c0

Browse files
committed
RISC-V: KVM: Add ONE_REG interface for AIA CSRs
We implement ONE_REG interface for AIA CSRs as a separate subtype under the CSR ONE_REG interface. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent 7d50dd5 commit 78f94c0

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

arch/riscv/include/uapi/asm/kvm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ struct kvm_riscv_csr {
7979
unsigned long scounteren;
8080
};
8181

82+
/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
83+
struct kvm_riscv_aia_csr {
84+
};
85+
8286
/* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
8387
struct kvm_riscv_timer {
8488
__u64 frequency;
@@ -107,6 +111,7 @@ enum KVM_RISCV_ISA_EXT_ID {
107111
KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
108112
KVM_RISCV_ISA_EXT_ZICBOM,
109113
KVM_RISCV_ISA_EXT_ZBB,
114+
KVM_RISCV_ISA_EXT_SSAIA,
110115
KVM_RISCV_ISA_EXT_MAX,
111116
};
112117

@@ -153,8 +158,11 @@ enum KVM_RISCV_SBI_EXT_ID {
153158
/* Control and status registers are mapped as type 3 */
154159
#define KVM_REG_RISCV_CSR (0x03 << KVM_REG_RISCV_TYPE_SHIFT)
155160
#define KVM_REG_RISCV_CSR_GENERAL (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT)
161+
#define KVM_REG_RISCV_CSR_AIA (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT)
156162
#define KVM_REG_RISCV_CSR_REG(name) \
157163
(offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long))
164+
#define KVM_REG_RISCV_CSR_AIA_REG(name) \
165+
(offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long))
158166

159167
/* Timer registers are mapped as type 4 */
160168
#define KVM_REG_RISCV_TIMER (0x04 << KVM_REG_RISCV_TYPE_SHIFT)

arch/riscv/kvm/vcpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static const unsigned long kvm_isa_ext_arr[] = {
5858
[KVM_RISCV_ISA_EXT_I] = RISCV_ISA_EXT_i,
5959
[KVM_RISCV_ISA_EXT_M] = RISCV_ISA_EXT_m,
6060

61+
KVM_ISA_EXT_ARR(SSAIA),
6162
KVM_ISA_EXT_ARR(SSTC),
6263
KVM_ISA_EXT_ARR(SVINVAL),
6364
KVM_ISA_EXT_ARR(SVPBMT),
@@ -97,6 +98,7 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)
9798
case KVM_RISCV_ISA_EXT_C:
9899
case KVM_RISCV_ISA_EXT_I:
99100
case KVM_RISCV_ISA_EXT_M:
101+
case KVM_RISCV_ISA_EXT_SSAIA:
100102
case KVM_RISCV_ISA_EXT_SSTC:
101103
case KVM_RISCV_ISA_EXT_SVINVAL:
102104
case KVM_RISCV_ISA_EXT_ZIHINTPAUSE:
@@ -520,6 +522,9 @@ static int kvm_riscv_vcpu_get_reg_csr(struct kvm_vcpu *vcpu,
520522
case KVM_REG_RISCV_CSR_GENERAL:
521523
rc = kvm_riscv_vcpu_general_get_csr(vcpu, reg_num, &reg_val);
522524
break;
525+
case KVM_REG_RISCV_CSR_AIA:
526+
rc = kvm_riscv_vcpu_aia_get_csr(vcpu, reg_num, &reg_val);
527+
break;
523528
default:
524529
rc = -EINVAL;
525530
break;
@@ -556,6 +561,9 @@ static int kvm_riscv_vcpu_set_reg_csr(struct kvm_vcpu *vcpu,
556561
case KVM_REG_RISCV_CSR_GENERAL:
557562
rc = kvm_riscv_vcpu_general_set_csr(vcpu, reg_num, reg_val);
558563
break;
564+
case KVM_REG_RISCV_CSR_AIA:
565+
rc = kvm_riscv_vcpu_aia_set_csr(vcpu, reg_num, reg_val);
566+
break;
559567
default:
560568
rc = -EINVAL;
561569
break;

0 commit comments

Comments
 (0)