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

kvm: selftests: move ucall declarations into ucall_common.h

Now that core kvm_util declarations have special home in
kvm_util_base.h, move ucall-related declarations out into a separate
header.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Message-Id: <20211210164620.11636-3-michael.roth@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Michael Roth and committed by
Paolo Bonzini
96c1a628 7d9a662e

+60 -49
+1
tools/testing/selftests/kvm/include/kvm_util.h
··· 8 8 #define SELFTEST_KVM_UTIL_H 9 9 10 10 #include "kvm_util_base.h" 11 + #include "ucall_common.h" 11 12 12 13 #endif /* SELFTEST_KVM_UTIL_H */
-49
tools/testing/selftests/kvm/include/kvm_util_base.h
··· 389 389 390 390 void assert_on_unhandled_exception(struct kvm_vm *vm, uint32_t vcpuid); 391 391 392 - /* Common ucalls */ 393 - enum { 394 - UCALL_NONE, 395 - UCALL_SYNC, 396 - UCALL_ABORT, 397 - UCALL_DONE, 398 - UCALL_UNHANDLED, 399 - }; 400 - 401 - #define UCALL_MAX_ARGS 6 402 - 403 - struct ucall { 404 - uint64_t cmd; 405 - uint64_t args[UCALL_MAX_ARGS]; 406 - }; 407 - 408 - void ucall_init(struct kvm_vm *vm, void *arg); 409 - void ucall_uninit(struct kvm_vm *vm); 410 - void ucall(uint64_t cmd, int nargs, ...); 411 - uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); 412 - 413 - #define GUEST_SYNC_ARGS(stage, arg1, arg2, arg3, arg4) \ 414 - ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4) 415 - #define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage) 416 - #define GUEST_DONE() ucall(UCALL_DONE, 0) 417 - #define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \ 418 - if (!(_condition)) \ 419 - ucall(UCALL_ABORT, 2 + _nargs, \ 420 - "Failed guest assert: " \ 421 - _condstr, __LINE__, _args); \ 422 - } while (0) 423 - 424 - #define GUEST_ASSERT(_condition) \ 425 - __GUEST_ASSERT(_condition, #_condition, 0, 0) 426 - 427 - #define GUEST_ASSERT_1(_condition, arg1) \ 428 - __GUEST_ASSERT(_condition, #_condition, 1, (arg1)) 429 - 430 - #define GUEST_ASSERT_2(_condition, arg1, arg2) \ 431 - __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2)) 432 - 433 - #define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \ 434 - __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3)) 435 - 436 - #define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \ 437 - __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4)) 438 - 439 - #define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b) 440 - 441 392 int vm_get_stats_fd(struct kvm_vm *vm); 442 393 int vcpu_get_stats_fd(struct kvm_vm *vm, uint32_t vcpuid); 443 394
+59
tools/testing/selftests/kvm/include/ucall_common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* 3 + * tools/testing/selftests/kvm/include/kvm_util.h 4 + * 5 + * Copyright (C) 2018, Google LLC. 6 + */ 7 + #ifndef SELFTEST_KVM_UCALL_COMMON_H 8 + #define SELFTEST_KVM_UCALL_COMMON_H 9 + 10 + /* Common ucalls */ 11 + enum { 12 + UCALL_NONE, 13 + UCALL_SYNC, 14 + UCALL_ABORT, 15 + UCALL_DONE, 16 + UCALL_UNHANDLED, 17 + }; 18 + 19 + #define UCALL_MAX_ARGS 6 20 + 21 + struct ucall { 22 + uint64_t cmd; 23 + uint64_t args[UCALL_MAX_ARGS]; 24 + }; 25 + 26 + void ucall_init(struct kvm_vm *vm, void *arg); 27 + void ucall_uninit(struct kvm_vm *vm); 28 + void ucall(uint64_t cmd, int nargs, ...); 29 + uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); 30 + 31 + #define GUEST_SYNC_ARGS(stage, arg1, arg2, arg3, arg4) \ 32 + ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4) 33 + #define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage) 34 + #define GUEST_DONE() ucall(UCALL_DONE, 0) 35 + #define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \ 36 + if (!(_condition)) \ 37 + ucall(UCALL_ABORT, 2 + _nargs, \ 38 + "Failed guest assert: " \ 39 + _condstr, __LINE__, _args); \ 40 + } while (0) 41 + 42 + #define GUEST_ASSERT(_condition) \ 43 + __GUEST_ASSERT(_condition, #_condition, 0, 0) 44 + 45 + #define GUEST_ASSERT_1(_condition, arg1) \ 46 + __GUEST_ASSERT(_condition, #_condition, 1, (arg1)) 47 + 48 + #define GUEST_ASSERT_2(_condition, arg1, arg2) \ 49 + __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2)) 50 + 51 + #define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \ 52 + __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3)) 53 + 54 + #define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \ 55 + __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4)) 56 + 57 + #define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b) 58 + 59 + #endif /* SELFTEST_KVM_UCALL_COMMON_H */