Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 1 | /**************************************************************************** |
| 2 | **************************************************************************** |
| 3 | *** |
| 4 | *** This header was automatically generated from a Linux kernel header |
| 5 | *** of the same name, to make information necessary for userspace to |
| 6 | *** call into the kernel available to libc. It contains only constants, |
| 7 | *** structures, and macros generated from the original header, and thus, |
| 8 | *** contains no copyrightable information. |
| 9 | *** |
| 10 | *** To edit the content of this header, modify the corresponding |
| 11 | *** source file (e.g. under external/kernel-headers/original/) then |
| 12 | *** run bionic/libc/kernel/tools/update_all.py |
| 13 | *** |
| 14 | *** Any manual change here will be lost the next time this script will |
| 15 | *** be run. You've been warned! |
| 16 | *** |
| 17 | **************************************************************************** |
| 18 | ****************************************************************************/ |
| 19 | #ifndef __LINUX_KVM_RISCV_H |
| 20 | #define __LINUX_KVM_RISCV_H |
| 21 | #ifndef __ASSEMBLY__ |
| 22 | #include <linux/types.h> |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 23 | #include <asm/bitsperlong.h> |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 24 | #include <asm/ptrace.h> |
| 25 | #define __KVM_HAVE_READONLY_MEM |
| 26 | #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 |
| 27 | #define KVM_INTERRUPT_SET - 1U |
| 28 | #define KVM_INTERRUPT_UNSET - 2U |
| 29 | struct kvm_regs { |
| 30 | }; |
| 31 | struct kvm_fpu { |
| 32 | }; |
| 33 | struct kvm_debug_exit_arch { |
| 34 | }; |
| 35 | struct kvm_guest_debug_arch { |
| 36 | }; |
| 37 | struct kvm_sync_regs { |
| 38 | }; |
| 39 | struct kvm_sregs { |
| 40 | }; |
| 41 | struct kvm_riscv_config { |
| 42 | unsigned long isa; |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 43 | unsigned long zicbom_block_size; |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 44 | unsigned long mvendorid; |
| 45 | unsigned long marchid; |
| 46 | unsigned long mimpid; |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 47 | unsigned long zicboz_block_size; |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 48 | }; |
| 49 | struct kvm_riscv_core { |
| 50 | struct user_regs_struct regs; |
| 51 | unsigned long mode; |
| 52 | }; |
| 53 | #define KVM_RISCV_MODE_S 1 |
| 54 | #define KVM_RISCV_MODE_U 0 |
| 55 | struct kvm_riscv_csr { |
| 56 | unsigned long sstatus; |
| 57 | unsigned long sie; |
| 58 | unsigned long stvec; |
| 59 | unsigned long sscratch; |
| 60 | unsigned long sepc; |
| 61 | unsigned long scause; |
| 62 | unsigned long stval; |
| 63 | unsigned long sip; |
| 64 | unsigned long satp; |
| 65 | unsigned long scounteren; |
| 66 | }; |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 67 | struct kvm_riscv_aia_csr { |
| 68 | unsigned long siselect; |
| 69 | unsigned long iprio1; |
| 70 | unsigned long iprio2; |
| 71 | unsigned long sieh; |
| 72 | unsigned long siph; |
| 73 | unsigned long iprio1h; |
| 74 | unsigned long iprio2h; |
| 75 | }; |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 76 | struct kvm_riscv_timer { |
| 77 | __u64 frequency; |
| 78 | __u64 time; |
| 79 | __u64 compare; |
| 80 | __u64 state; |
| 81 | }; |
| 82 | enum KVM_RISCV_ISA_EXT_ID { |
| 83 | KVM_RISCV_ISA_EXT_A = 0, |
| 84 | KVM_RISCV_ISA_EXT_C, |
| 85 | KVM_RISCV_ISA_EXT_D, |
| 86 | KVM_RISCV_ISA_EXT_F, |
| 87 | KVM_RISCV_ISA_EXT_H, |
| 88 | KVM_RISCV_ISA_EXT_I, |
| 89 | KVM_RISCV_ISA_EXT_M, |
Christopher Ferris | 7447a1c | 2022-10-04 18:24:44 -0700 | [diff] [blame] | 90 | KVM_RISCV_ISA_EXT_SVPBMT, |
| 91 | KVM_RISCV_ISA_EXT_SSTC, |
Christopher Ferris | 6cd53a5 | 2022-12-12 23:39:16 +0000 | [diff] [blame] | 92 | KVM_RISCV_ISA_EXT_SVINVAL, |
| 93 | KVM_RISCV_ISA_EXT_ZIHINTPAUSE, |
| 94 | KVM_RISCV_ISA_EXT_ZICBOM, |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 95 | KVM_RISCV_ISA_EXT_ZICBOZ, |
| 96 | KVM_RISCV_ISA_EXT_ZBB, |
| 97 | KVM_RISCV_ISA_EXT_SSAIA, |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 98 | KVM_RISCV_ISA_EXT_MAX, |
| 99 | }; |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 100 | enum KVM_RISCV_SBI_EXT_ID { |
| 101 | KVM_RISCV_SBI_EXT_V01 = 0, |
| 102 | KVM_RISCV_SBI_EXT_TIME, |
| 103 | KVM_RISCV_SBI_EXT_IPI, |
| 104 | KVM_RISCV_SBI_EXT_RFENCE, |
| 105 | KVM_RISCV_SBI_EXT_SRST, |
| 106 | KVM_RISCV_SBI_EXT_HSM, |
| 107 | KVM_RISCV_SBI_EXT_PMU, |
| 108 | KVM_RISCV_SBI_EXT_EXPERIMENTAL, |
| 109 | KVM_RISCV_SBI_EXT_VENDOR, |
| 110 | KVM_RISCV_SBI_EXT_MAX, |
| 111 | }; |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 112 | #define KVM_RISCV_TIMER_STATE_OFF 0 |
| 113 | #define KVM_RISCV_TIMER_STATE_ON 1 |
| 114 | #define KVM_REG_SIZE(id) (1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT)) |
| 115 | #define KVM_REG_RISCV_TYPE_MASK 0x00000000FF000000 |
| 116 | #define KVM_REG_RISCV_TYPE_SHIFT 24 |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 117 | #define KVM_REG_RISCV_SUBTYPE_MASK 0x0000000000FF0000 |
| 118 | #define KVM_REG_RISCV_SUBTYPE_SHIFT 16 |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 119 | #define KVM_REG_RISCV_CONFIG (0x01 << KVM_REG_RISCV_TYPE_SHIFT) |
| 120 | #define KVM_REG_RISCV_CONFIG_REG(name) (offsetof(struct kvm_riscv_config, name) / sizeof(unsigned long)) |
| 121 | #define KVM_REG_RISCV_CORE (0x02 << KVM_REG_RISCV_TYPE_SHIFT) |
| 122 | #define KVM_REG_RISCV_CORE_REG(name) (offsetof(struct kvm_riscv_core, name) / sizeof(unsigned long)) |
| 123 | #define KVM_REG_RISCV_CSR (0x03 << KVM_REG_RISCV_TYPE_SHIFT) |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 124 | #define KVM_REG_RISCV_CSR_GENERAL (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) |
| 125 | #define KVM_REG_RISCV_CSR_AIA (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 126 | #define KVM_REG_RISCV_CSR_REG(name) (offsetof(struct kvm_riscv_csr, name) / sizeof(unsigned long)) |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 127 | #define KVM_REG_RISCV_CSR_AIA_REG(name) (offsetof(struct kvm_riscv_aia_csr, name) / sizeof(unsigned long)) |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 128 | #define KVM_REG_RISCV_TIMER (0x04 << KVM_REG_RISCV_TYPE_SHIFT) |
| 129 | #define KVM_REG_RISCV_TIMER_REG(name) (offsetof(struct kvm_riscv_timer, name) / sizeof(__u64)) |
| 130 | #define KVM_REG_RISCV_FP_F (0x05 << KVM_REG_RISCV_TYPE_SHIFT) |
| 131 | #define KVM_REG_RISCV_FP_F_REG(name) (offsetof(struct __riscv_f_ext_state, name) / sizeof(__u32)) |
| 132 | #define KVM_REG_RISCV_FP_D (0x06 << KVM_REG_RISCV_TYPE_SHIFT) |
| 133 | #define KVM_REG_RISCV_FP_D_REG(name) (offsetof(struct __riscv_d_ext_state, name) / sizeof(__u64)) |
| 134 | #define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT) |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame^] | 135 | #define KVM_REG_RISCV_SBI_EXT (0x08 << KVM_REG_RISCV_TYPE_SHIFT) |
| 136 | #define KVM_REG_RISCV_SBI_SINGLE (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) |
| 137 | #define KVM_REG_RISCV_SBI_MULTI_EN (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) |
| 138 | #define KVM_REG_RISCV_SBI_MULTI_DIS (0x2 << KVM_REG_RISCV_SUBTYPE_SHIFT) |
| 139 | #define KVM_REG_RISCV_SBI_MULTI_REG(__ext_id) ((__ext_id) / __BITS_PER_LONG) |
| 140 | #define KVM_REG_RISCV_SBI_MULTI_MASK(__ext_id) (1UL << ((__ext_id) % __BITS_PER_LONG)) |
| 141 | #define KVM_REG_RISCV_SBI_MULTI_REG_LAST KVM_REG_RISCV_SBI_MULTI_REG(KVM_RISCV_SBI_EXT_MAX - 1) |
Elliott Hughes | 5e7f8f1 | 2022-10-01 15:10:58 +0000 | [diff] [blame] | 142 | #endif |
| 143 | #endif |