-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: selftests: Add arch ucall.h and inline simple arch hooks
Add an architecture specific ucall.h and inline the simple arch hooks, e.g. the init hook for everything except ARM, and the actual "do ucall" hook for everything except x86 (which should be simple, but temporarily isn't due to carrying a workaround). Having a per-arch ucall header will allow adding a #define for the expected KVM exit reason for a ucall that is colocated (for everything except x86) with the ucall itself. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20230731203026.1192091-2-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
- Loading branch information
Showing
9 changed files
with
66 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UCALL_H | ||
#define SELFTEST_KVM_UCALL_H | ||
|
||
#include "kvm_util_base.h" | ||
|
||
/* | ||
* ucall_exit_mmio_addr holds per-VM values (global data is duplicated by each | ||
* VM), it must not be accessed from host code. | ||
*/ | ||
extern vm_vaddr_t *ucall_exit_mmio_addr; | ||
|
||
static inline void ucall_arch_do_ucall(vm_vaddr_t uc) | ||
{ | ||
WRITE_ONCE(*ucall_exit_mmio_addr, uc); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UCALL_H | ||
#define SELFTEST_KVM_UCALL_H | ||
|
||
#include "processor.h" | ||
|
||
static inline void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) | ||
{ | ||
} | ||
|
||
static inline void ucall_arch_do_ucall(vm_vaddr_t uc) | ||
{ | ||
sbi_ecall(KVM_RISCV_SELFTESTS_SBI_EXT, | ||
KVM_RISCV_SELFTESTS_SBI_UCALL, | ||
uc, 0, 0, 0, 0, 0); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UCALL_H | ||
#define SELFTEST_KVM_UCALL_H | ||
|
||
#include "kvm_util_base.h" | ||
|
||
static inline void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) | ||
{ | ||
} | ||
|
||
static inline void ucall_arch_do_ucall(vm_vaddr_t uc) | ||
{ | ||
/* Exit via DIAGNOSE 0x501 (normally used for breakpoints) */ | ||
asm volatile ("diag 0,%0,0x501" : : "a"(uc) : "memory"); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UCALL_H | ||
#define SELFTEST_KVM_UCALL_H | ||
|
||
#include "kvm_util_base.h" | ||
|
||
static inline void ucall_arch_init(struct kvm_vm *vm, vm_paddr_t mmio_gpa) | ||
{ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters