Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: riscv: selftests: Move sbi definitions to its own header file

The SBI definitions will continue to grow. Move the sbi related
definitions to its own header file from processor.h

Suggested-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20240420151741.962500-18-atishp@rivosinc.com
Signed-off-by: Anup Patel <anup@brainfault.org>

authored by

Atish Patra and committed by
Anup Patel
9408a23f 4e21f223

+54 -40
-39
tools/testing/selftests/kvm/include/riscv/processor.h
··· 154 154 #define PGTBL_PAGE_SIZE PGTBL_L0_BLOCK_SIZE 155 155 #define PGTBL_PAGE_SIZE_SHIFT PGTBL_L0_BLOCK_SHIFT 156 156 157 - /* SBI return error codes */ 158 - #define SBI_SUCCESS 0 159 - #define SBI_ERR_FAILURE -1 160 - #define SBI_ERR_NOT_SUPPORTED -2 161 - #define SBI_ERR_INVALID_PARAM -3 162 - #define SBI_ERR_DENIED -4 163 - #define SBI_ERR_INVALID_ADDRESS -5 164 - #define SBI_ERR_ALREADY_AVAILABLE -6 165 - #define SBI_ERR_ALREADY_STARTED -7 166 - #define SBI_ERR_ALREADY_STOPPED -8 167 - 168 - #define SBI_EXT_EXPERIMENTAL_START 0x08000000 169 - #define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF 170 - 171 - #define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END 172 - #define KVM_RISCV_SELFTESTS_SBI_UCALL 0 173 - #define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 174 - 175 - enum sbi_ext_id { 176 - SBI_EXT_BASE = 0x10, 177 - SBI_EXT_STA = 0x535441, 178 - }; 179 - 180 - enum sbi_ext_base_fid { 181 - SBI_EXT_BASE_PROBE_EXT = 3, 182 - }; 183 - 184 - struct sbiret { 185 - long error; 186 - long value; 187 - }; 188 - 189 - struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, 190 - unsigned long arg1, unsigned long arg2, 191 - unsigned long arg3, unsigned long arg4, 192 - unsigned long arg5); 193 - 194 - bool guest_sbi_probe_extension(int extid, long *out_val); 195 - 196 157 static inline void local_irq_enable(void) 197 158 { 198 159 csr_set(CSR_SSTATUS, SR_SIE);
+50
tools/testing/selftests/kvm/include/riscv/sbi.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * RISC-V SBI specific definitions 4 + * 5 + * Copyright (C) 2024 Rivos Inc. 6 + */ 7 + 8 + #ifndef SELFTEST_KVM_SBI_H 9 + #define SELFTEST_KVM_SBI_H 10 + 11 + /* SBI return error codes */ 12 + #define SBI_SUCCESS 0 13 + #define SBI_ERR_FAILURE -1 14 + #define SBI_ERR_NOT_SUPPORTED -2 15 + #define SBI_ERR_INVALID_PARAM -3 16 + #define SBI_ERR_DENIED -4 17 + #define SBI_ERR_INVALID_ADDRESS -5 18 + #define SBI_ERR_ALREADY_AVAILABLE -6 19 + #define SBI_ERR_ALREADY_STARTED -7 20 + #define SBI_ERR_ALREADY_STOPPED -8 21 + 22 + #define SBI_EXT_EXPERIMENTAL_START 0x08000000 23 + #define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF 24 + 25 + #define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END 26 + #define KVM_RISCV_SELFTESTS_SBI_UCALL 0 27 + #define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 28 + 29 + enum sbi_ext_id { 30 + SBI_EXT_BASE = 0x10, 31 + SBI_EXT_STA = 0x535441, 32 + }; 33 + 34 + enum sbi_ext_base_fid { 35 + SBI_EXT_BASE_PROBE_EXT = 3, 36 + }; 37 + 38 + struct sbiret { 39 + long error; 40 + long value; 41 + }; 42 + 43 + struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, 44 + unsigned long arg1, unsigned long arg2, 45 + unsigned long arg3, unsigned long arg4, 46 + unsigned long arg5); 47 + 48 + bool guest_sbi_probe_extension(int extid, long *out_val); 49 + 50 + #endif /* SELFTEST_KVM_SBI_H */
+1
tools/testing/selftests/kvm/include/riscv/ucall.h
··· 3 3 #define SELFTEST_KVM_UCALL_H 4 4 5 5 #include "processor.h" 6 + #include "sbi.h" 6 7 7 8 #define UCALL_EXIT_REASON KVM_EXIT_RISCV_SBI 8 9
+3 -1
tools/testing/selftests/kvm/steal_time.c
··· 11 11 #include <pthread.h> 12 12 #include <linux/kernel.h> 13 13 #include <asm/kvm.h> 14 - #ifndef __riscv 14 + #ifdef __riscv 15 + #include "sbi.h" 16 + #else 15 17 #include <asm/kvm_para.h> 16 18 #endif 17 19