aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/include/kvm_util_base.h
diff options
context:
space:
mode:
authorSean Christopherson <[email protected]>2024-03-14 18:54:57 +0000
committerSean Christopherson <[email protected]>2024-04-29 19:50:43 +0000
commit2f2bc6af6aa8cc07f84291d625f7113fd13d68e5 (patch)
tree189b0c0aee4354a9c6ab2310e892e487748c23c1 /tools/testing/selftests/kvm/include/kvm_util_base.h
parentKVM: selftests: Add global snapshot of kvm_is_forced_emulation_enabled() (diff)
downloadkernel-2f2bc6af6aa8cc07f84291d625f7113fd13d68e5.tar.gz
kernel-2f2bc6af6aa8cc07f84291d625f7113fd13d68e5.zip
KVM: selftests: Add vcpu_arch_put_guest() to do writes from guest code
Introduce a macro, vcpu_arch_put_guest(), for "putting" values to memory from guest code in "interesting" situations, e.g. when writing memory that is being dirty logged. Structure the macro so that arch code can provide a custom implementation, e.g. x86 will use the macro to force emulation of the access. Use the helper in dirty_log_test, which is of particular interest (see above), and in xen_shinfo_test, which isn't all that interesting, but provides a second usage of the macro with a different size operand (uint8_t versus uint64_t), i.e. to help verify that the macro works for more than just 64-bit values. Use "put" as the verb to align with the kernel's {get,put}_user() terminology. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
Diffstat (limited to 'tools/testing/selftests/kvm/include/kvm_util_base.h')
-rw-r--r--tools/testing/selftests/kvm/include/kvm_util_base.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index af02308e264e..e850269a3219 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -609,6 +609,9 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva);
vm_paddr_t addr_hva2gpa(struct kvm_vm *vm, void *hva);
void *addr_gpa2alias(struct kvm_vm *vm, vm_paddr_t gpa);
+#ifndef vcpu_arch_put_guest
+#define vcpu_arch_put_guest(mem, val) do { (mem) = (val); } while (0)
+#endif
static inline vm_paddr_t vm_untag_gpa(struct kvm_vm *vm, vm_paddr_t gpa)
{