Skip to content

Commit 0dcab5c

Browse files
Andrew Jonesavpatel
authored andcommitted
RISC-V: KVM: selftests: Move sbi_ecall to processor.c
sbi_ecall() isn't ucall specific and its prototype is already in processor.h. Move its implementation to processor.c. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent e9f12b5 commit 0dcab5c

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

tools/testing/selftests/kvm/lib/riscv/processor.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,29 @@ void vcpu_args_set(struct kvm_vcpu *vcpu, unsigned int num, ...)
367367
void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
368368
{
369369
}
370+
371+
struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
372+
unsigned long arg1, unsigned long arg2,
373+
unsigned long arg3, unsigned long arg4,
374+
unsigned long arg5)
375+
{
376+
register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0);
377+
register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1);
378+
register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2);
379+
register uintptr_t a3 asm ("a3") = (uintptr_t)(arg3);
380+
register uintptr_t a4 asm ("a4") = (uintptr_t)(arg4);
381+
register uintptr_t a5 asm ("a5") = (uintptr_t)(arg5);
382+
register uintptr_t a6 asm ("a6") = (uintptr_t)(fid);
383+
register uintptr_t a7 asm ("a7") = (uintptr_t)(ext);
384+
struct sbiret ret;
385+
386+
asm volatile (
387+
"ecall"
388+
: "+r" (a0), "+r" (a1)
389+
: "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7)
390+
: "memory");
391+
ret.error = a0;
392+
ret.value = a1;
393+
394+
return ret;
395+
}

tools/testing/selftests/kvm/lib/riscv/ucall.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,6 @@
1010
#include "kvm_util.h"
1111
#include "processor.h"
1212

13-
struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
14-
unsigned long arg1, unsigned long arg2,
15-
unsigned long arg3, unsigned long arg4,
16-
unsigned long arg5)
17-
{
18-
register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0);
19-
register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1);
20-
register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2);
21-
register uintptr_t a3 asm ("a3") = (uintptr_t)(arg3);
22-
register uintptr_t a4 asm ("a4") = (uintptr_t)(arg4);
23-
register uintptr_t a5 asm ("a5") = (uintptr_t)(arg5);
24-
register uintptr_t a6 asm ("a6") = (uintptr_t)(fid);
25-
register uintptr_t a7 asm ("a7") = (uintptr_t)(ext);
26-
struct sbiret ret;
27-
28-
asm volatile (
29-
"ecall"
30-
: "+r" (a0), "+r" (a1)
31-
: "r" (a2), "r" (a3), "r" (a4), "r" (a5), "r" (a6), "r" (a7)
32-
: "memory");
33-
ret.error = a0;
34-
ret.value = a1;
35-
36-
return ret;
37-
}
38-
3913
void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu)
4014
{
4115
struct kvm_run *run = vcpu->run;

0 commit comments

Comments
 (0)