162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2019 Western Digital Corporation or its affiliates. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Authors: 662306a36Sopenharmony_ci * Anup Patel <anup.patel@wdc.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __LINUX_KVM_RISCV_H 1062306a36Sopenharmony_ci#define __LINUX_KVM_RISCV_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <linux/types.h> 1562306a36Sopenharmony_ci#include <asm/bitsperlong.h> 1662306a36Sopenharmony_ci#include <asm/ptrace.h> 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define __KVM_HAVE_IRQ_LINE 1962306a36Sopenharmony_ci#define __KVM_HAVE_READONLY_MEM 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define KVM_INTERRUPT_SET -1U 2462306a36Sopenharmony_ci#define KVM_INTERRUPT_UNSET -2U 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* for KVM_GET_REGS and KVM_SET_REGS */ 2762306a36Sopenharmony_cistruct kvm_regs { 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci/* for KVM_GET_FPU and KVM_SET_FPU */ 3162306a36Sopenharmony_cistruct kvm_fpu { 3262306a36Sopenharmony_ci}; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* KVM Debug exit structure */ 3562306a36Sopenharmony_cistruct kvm_debug_exit_arch { 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* for KVM_SET_GUEST_DEBUG */ 3962306a36Sopenharmony_cistruct kvm_guest_debug_arch { 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* definition of registers in kvm_run */ 4362306a36Sopenharmony_cistruct kvm_sync_regs { 4462306a36Sopenharmony_ci}; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* for KVM_GET_SREGS and KVM_SET_SREGS */ 4762306a36Sopenharmony_cistruct kvm_sregs { 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci/* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ 5162306a36Sopenharmony_cistruct kvm_riscv_config { 5262306a36Sopenharmony_ci unsigned long isa; 5362306a36Sopenharmony_ci unsigned long zicbom_block_size; 5462306a36Sopenharmony_ci unsigned long mvendorid; 5562306a36Sopenharmony_ci unsigned long marchid; 5662306a36Sopenharmony_ci unsigned long mimpid; 5762306a36Sopenharmony_ci unsigned long zicboz_block_size; 5862306a36Sopenharmony_ci unsigned long satp_mode; 5962306a36Sopenharmony_ci}; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ 6262306a36Sopenharmony_cistruct kvm_riscv_core { 6362306a36Sopenharmony_ci struct user_regs_struct regs; 6462306a36Sopenharmony_ci unsigned long mode; 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* Possible privilege modes for kvm_riscv_core */ 6862306a36Sopenharmony_ci#define KVM_RISCV_MODE_S 1 6962306a36Sopenharmony_ci#define KVM_RISCV_MODE_U 0 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ci/* General CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ 7262306a36Sopenharmony_cistruct kvm_riscv_csr { 7362306a36Sopenharmony_ci unsigned long sstatus; 7462306a36Sopenharmony_ci unsigned long sie; 7562306a36Sopenharmony_ci unsigned long stvec; 7662306a36Sopenharmony_ci unsigned long sscratch; 7762306a36Sopenharmony_ci unsigned long sepc; 7862306a36Sopenharmony_ci unsigned long scause; 7962306a36Sopenharmony_ci unsigned long stval; 8062306a36Sopenharmony_ci unsigned long sip; 8162306a36Sopenharmony_ci unsigned long satp; 8262306a36Sopenharmony_ci unsigned long scounteren; 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci/* AIA CSR registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ 8662306a36Sopenharmony_cistruct kvm_riscv_aia_csr { 8762306a36Sopenharmony_ci unsigned long siselect; 8862306a36Sopenharmony_ci unsigned long iprio1; 8962306a36Sopenharmony_ci unsigned long iprio2; 9062306a36Sopenharmony_ci unsigned long sieh; 9162306a36Sopenharmony_ci unsigned long siph; 9262306a36Sopenharmony_ci unsigned long iprio1h; 9362306a36Sopenharmony_ci unsigned long iprio2h; 9462306a36Sopenharmony_ci}; 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci/* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ 9762306a36Sopenharmony_cistruct kvm_riscv_timer { 9862306a36Sopenharmony_ci __u64 frequency; 9962306a36Sopenharmony_ci __u64 time; 10062306a36Sopenharmony_ci __u64 compare; 10162306a36Sopenharmony_ci __u64 state; 10262306a36Sopenharmony_ci}; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* 10562306a36Sopenharmony_ci * ISA extension IDs specific to KVM. This is not the same as the host ISA 10662306a36Sopenharmony_ci * extension IDs as that is internal to the host and should not be exposed 10762306a36Sopenharmony_ci * to the guest. This should always be contiguous to keep the mapping simple 10862306a36Sopenharmony_ci * in KVM implementation. 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_cienum KVM_RISCV_ISA_EXT_ID { 11162306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_A = 0, 11262306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_C, 11362306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_D, 11462306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_F, 11562306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_H, 11662306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_I, 11762306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_M, 11862306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_SVPBMT, 11962306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_SSTC, 12062306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_SVINVAL, 12162306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZIHINTPAUSE, 12262306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZICBOM, 12362306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZICBOZ, 12462306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZBB, 12562306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_SSAIA, 12662306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_V, 12762306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_SVNAPOT, 12862306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZBA, 12962306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZBS, 13062306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZICNTR, 13162306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZICSR, 13262306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZIFENCEI, 13362306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_ZIHPM, 13462306a36Sopenharmony_ci KVM_RISCV_ISA_EXT_MAX, 13562306a36Sopenharmony_ci}; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/* 13862306a36Sopenharmony_ci * SBI extension IDs specific to KVM. This is not the same as the SBI 13962306a36Sopenharmony_ci * extension IDs defined by the RISC-V SBI specification. 14062306a36Sopenharmony_ci */ 14162306a36Sopenharmony_cienum KVM_RISCV_SBI_EXT_ID { 14262306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_V01 = 0, 14362306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_TIME, 14462306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_IPI, 14562306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_RFENCE, 14662306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_SRST, 14762306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_HSM, 14862306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_PMU, 14962306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_EXPERIMENTAL, 15062306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_VENDOR, 15162306a36Sopenharmony_ci KVM_RISCV_SBI_EXT_MAX, 15262306a36Sopenharmony_ci}; 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci/* Possible states for kvm_riscv_timer */ 15562306a36Sopenharmony_ci#define KVM_RISCV_TIMER_STATE_OFF 0 15662306a36Sopenharmony_ci#define KVM_RISCV_TIMER_STATE_ON 1 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci#define KVM_REG_SIZE(id) \ 15962306a36Sopenharmony_ci (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* If you need to interpret the index values, here is the key: */ 16262306a36Sopenharmony_ci#define KVM_REG_RISCV_TYPE_MASK 0x00000000FF000000 16362306a36Sopenharmony_ci#define KVM_REG_RISCV_TYPE_SHIFT 24 16462306a36Sopenharmony_ci#define KVM_REG_RISCV_SUBTYPE_MASK 0x0000000000FF0000 16562306a36Sopenharmony_ci#define KVM_REG_RISCV_SUBTYPE_SHIFT 16 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci/* Config registers are mapped as type 1 */ 16862306a36Sopenharmony_ci#define KVM_REG_RISCV_CONFIG (0x01 << KVM_REG_RISCV_TYPE_SHIFT) 16962306a36Sopenharmony_ci#define KVM_REG_RISCV_CONFIG_REG(name) \ 17062306a36Sopenharmony_ci (offsetof(struct kvm_riscv_config, name) / sizeof(unsigned long)) 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci/* Core registers are mapped as type 2 */ 17362306a36Sopenharmony_ci#define KVM_REG_RISCV_CORE (0x02 << KVM_REG_RISCV_TYPE_SHIFT) 17462306a36Sopenharmony_ci#define KVM_REG_RISCV_CORE_REG(name) \ 17562306a36Sopenharmony_ci (offsetof(struct kvm_riscv_core, name) / sizeof(unsigned long)) 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/* Control and status registers are mapped as type 3 */ 17862306a36Sopenharmony_ci#define KVM_REG_RISCV_CSR (0x03 << KVM_REG_RISCV_TYPE_SHIFT) 17962306a36Sopenharmony_ci#define KVM_REG_RISCV_CSR_GENERAL (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) 18062306a36Sopenharmony_ci#define KVM_REG_RISCV_CSR_AIA (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) 18162306a36Sopenharmony_ci#define KVM_REG_RISCV_CSR_REG(name) \ 18262306a36Sopenharmony_ci (offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long)) 18362306a36Sopenharmony_ci#define KVM_REG_RISCV_CSR_AIA_REG(name) \ 18462306a36Sopenharmony_ci (offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long)) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci/* Timer registers are mapped as type 4 */ 18762306a36Sopenharmony_ci#define KVM_REG_RISCV_TIMER (0x04 << KVM_REG_RISCV_TYPE_SHIFT) 18862306a36Sopenharmony_ci#define KVM_REG_RISCV_TIMER_REG(name) \ 18962306a36Sopenharmony_ci (offsetof(struct kvm_riscv_timer, name) / sizeof(__u64)) 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci/* F extension registers are mapped as type 5 */ 19262306a36Sopenharmony_ci#define KVM_REG_RISCV_FP_F (0x05 << KVM_REG_RISCV_TYPE_SHIFT) 19362306a36Sopenharmony_ci#define KVM_REG_RISCV_FP_F_REG(name) \ 19462306a36Sopenharmony_ci (offsetof(struct __riscv_f_ext_state, name) / sizeof(__u32)) 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci/* D extension registers are mapped as type 6 */ 19762306a36Sopenharmony_ci#define KVM_REG_RISCV_FP_D (0x06 << KVM_REG_RISCV_TYPE_SHIFT) 19862306a36Sopenharmony_ci#define KVM_REG_RISCV_FP_D_REG(name) \ 19962306a36Sopenharmony_ci (offsetof(struct __riscv_d_ext_state, name) / sizeof(__u64)) 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci/* ISA Extension registers are mapped as type 7 */ 20262306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT) 20362306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_SINGLE (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) 20462306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_MULTI_EN (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) 20562306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_MULTI_DIS (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT) 20662306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_MULTI_REG(__ext_id) \ 20762306a36Sopenharmony_ci ((__ext_id) / __BITS_PER_LONG) 20862306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_MULTI_MASK(__ext_id) \ 20962306a36Sopenharmony_ci (1UL << ((__ext_id) % __BITS_PER_LONG)) 21062306a36Sopenharmony_ci#define KVM_REG_RISCV_ISA_MULTI_REG_LAST \ 21162306a36Sopenharmony_ci KVM_REG_RISCV_ISA_MULTI_REG(KVM_RISCV_ISA_EXT_MAX - 1) 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* SBI extension registers are mapped as type 8 */ 21462306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_EXT (0x08 << KVM_REG_RISCV_TYPE_SHIFT) 21562306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_SINGLE (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) 21662306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_MULTI_EN (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) 21762306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_MULTI_DIS (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT) 21862306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id) \ 21962306a36Sopenharmony_ci ((__ext_id) / __BITS_PER_LONG) 22062306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id) \ 22162306a36Sopenharmony_ci (1UL << ((__ext_id) % __BITS_PER_LONG)) 22262306a36Sopenharmony_ci#define KVM_REG_RISCV_SBI_MULTI_REG_LAST \ 22362306a36Sopenharmony_ci KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1) 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci/* V extension registers are mapped as type 9 */ 22662306a36Sopenharmony_ci#define KVM_REG_RISCV_VECTOR (0x09 << KVM_REG_RISCV_TYPE_SHIFT) 22762306a36Sopenharmony_ci#define KVM_REG_RISCV_VECTOR_CSR_REG(name) \ 22862306a36Sopenharmony_ci (offsetof(struct __riscv_v_ext_state, name) / sizeof(unsigned long)) 22962306a36Sopenharmony_ci#define KVM_REG_RISCV_VECTOR_REG(n) \ 23062306a36Sopenharmony_ci ((n) + sizeof(struct __riscv_v_ext_state) / sizeof(unsigned long)) 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci/* Device Control API: RISC-V AIA */ 23362306a36Sopenharmony_ci#define KVM_DEV_RISCV_APLIC_ALIGN 0x1000 23462306a36Sopenharmony_ci#define KVM_DEV_RISCV_APLIC_SIZE 0x4000 23562306a36Sopenharmony_ci#define KVM_DEV_RISCV_APLIC_MAX_HARTS 0x4000 23662306a36Sopenharmony_ci#define KVM_DEV_RISCV_IMSIC_ALIGN 0x1000 23762306a36Sopenharmony_ci#define KVM_DEV_RISCV_IMSIC_SIZE 0x1000 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GRP_CONFIG 0 24062306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_MODE 0 24162306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_IDS 1 24262306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_SRCS 2 24362306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_GROUP_BITS 3 24462306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_GROUP_SHIFT 4 24562306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_HART_BITS 5 24662306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CONFIG_GUEST_BITS 6 24762306a36Sopenharmony_ci 24862306a36Sopenharmony_ci/* 24962306a36Sopenharmony_ci * Modes of RISC-V AIA device: 25062306a36Sopenharmony_ci * 1) EMUL (aka Emulation): Trap-n-emulate IMSIC 25162306a36Sopenharmony_ci * 2) HWACCEL (aka HW Acceleration): Virtualize IMSIC using IMSIC guest files 25262306a36Sopenharmony_ci * 3) AUTO (aka Automatic): Virtualize IMSIC using IMSIC guest files whenever 25362306a36Sopenharmony_ci * available otherwise fallback to trap-n-emulation 25462306a36Sopenharmony_ci */ 25562306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_MODE_EMUL 0 25662306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_MODE_HWACCEL 1 25762306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_MODE_AUTO 2 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IDS_MIN 63 26062306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IDS_MAX 2048 26162306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_SRCS_MAX 1024 26262306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GROUP_BITS_MAX 8 26362306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GROUP_SHIFT_MIN 24 26462306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GROUP_SHIFT_MAX 56 26562306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_HART_BITS_MAX 16 26662306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GUEST_BITS_MAX 8 26762306a36Sopenharmony_ci 26862306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GRP_ADDR 1 26962306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_ADDR_APLIC 0 27062306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_ADDR_IMSIC(__vcpu) (1 + (__vcpu)) 27162306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_ADDR_MAX \ 27262306a36Sopenharmony_ci (1 + KVM_DEV_RISCV_APLIC_MAX_HARTS) 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GRP_CTRL 2 27562306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_CTRL_INIT 0 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci/* 27862306a36Sopenharmony_ci * The device attribute type contains the memory mapped offset of the 27962306a36Sopenharmony_ci * APLIC register (range 0x0000-0x3FFF) and it must be 4-byte aligned. 28062306a36Sopenharmony_ci */ 28162306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GRP_APLIC 3 28262306a36Sopenharmony_ci 28362306a36Sopenharmony_ci/* 28462306a36Sopenharmony_ci * The lower 12-bits of the device attribute type contains the iselect 28562306a36Sopenharmony_ci * value of the IMSIC register (range 0x70-0xFF) whereas the higher order 28662306a36Sopenharmony_ci * bits contains the VCPU id. 28762306a36Sopenharmony_ci */ 28862306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_GRP_IMSIC 4 28962306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS 12 29062306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK \ 29162306a36Sopenharmony_ci ((1U << KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS) - 1) 29262306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IMSIC_MKATTR(__vcpu, __isel) \ 29362306a36Sopenharmony_ci (((__vcpu) << KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS) | \ 29462306a36Sopenharmony_ci ((__isel) & KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK)) 29562306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL(__attr) \ 29662306a36Sopenharmony_ci ((__attr) & KVM_DEV_RISCV_AIA_IMSIC_ISEL_MASK) 29762306a36Sopenharmony_ci#define KVM_DEV_RISCV_AIA_IMSIC_GET_VCPU(__attr) \ 29862306a36Sopenharmony_ci ((__attr) >> KVM_DEV_RISCV_AIA_IMSIC_ISEL_BITS) 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci/* One single KVM irqchip, ie. the AIA */ 30162306a36Sopenharmony_ci#define KVM_NR_IRQCHIPS 1 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci#endif 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci#endif /* __LINUX_KVM_RISCV_H */ 306