Skip to content

Commit 9408a23

Browse files
atishp04avpatel
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
1 parent 4e21f22 commit 9408a23

File tree

4 files changed

+54
-40
lines changed

4 files changed

+54
-40
lines changed

tools/testing/selftests/kvm/include/riscv/processor.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -154,45 +154,6 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handle
154154
#define PGTBL_PAGE_SIZE PGTBL_L0_BLOCK_SIZE
155155
#define PGTBL_PAGE_SIZE_SHIFT PGTBL_L0_BLOCK_SHIFT
156156

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-
196157
static inline void local_irq_enable(void)
197158
{
198159
csr_set(CSR_SSTATUS, SR_SIE);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 */

tools/testing/selftests/kvm/include/riscv/ucall.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define SELFTEST_KVM_UCALL_H
44

55
#include "processor.h"
6+
#include "sbi.h"
67

78
#define UCALL_EXIT_REASON KVM_EXIT_RISCV_SBI
89

tools/testing/selftests/kvm/steal_time.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <pthread.h>
1212
#include <linux/kernel.h>
1313
#include <asm/kvm.h>
14-
#ifndef __riscv
14+
#ifdef __riscv
15+
#include "sbi.h"
16+
#else
1517
#include <asm/kvm_para.h>
1618
#endif
1719

0 commit comments

Comments
 (0)