tools/testing/selftests/kvm/include/ucall_common.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/include/ucall_common.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/include/ucall_common.h- Extension
.h- Size
- 3709 bytes
- Lines
- 117
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
test_util.hucall.h
Detected Declarations
struct ucallenum guest_assert_builtin_args
Annotated Snippet
struct ucall {
u64 cmd;
u64 args[UCALL_MAX_ARGS];
char buffer[UCALL_BUFFER_LEN];
/* Host virtual address of this struct. */
struct ucall *hva;
};
void ucall_arch_init(struct kvm_vm *vm, gpa_t mmio_gpa);
void ucall_arch_do_ucall(gva_t uc);
void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu);
void ucall(u64 cmd, int nargs, ...);
__printf(2, 3) void ucall_fmt(u64 cmd, const char *fmt, ...);
__printf(5, 6) void ucall_assert(u64 cmd, const char *exp,
const char *file, unsigned int line,
const char *fmt, ...);
u64 get_ucall(struct kvm_vcpu *vcpu, struct ucall *uc);
void ucall_init(struct kvm_vm *vm, gpa_t mmio_gpa);
int ucall_nr_pages_required(u64 page_size);
/*
* Perform userspace call without any associated data. This bare call avoids
* allocating a ucall struct, which can be useful if the atomic operations in
* the full ucall() are problematic and/or unwanted. Note, this will come out
* as UCALL_NONE on the backend.
*/
#define GUEST_UCALL_NONE() ucall_arch_do_ucall((gva_t)NULL)
#define GUEST_SYNC_ARGS(stage, arg1, arg2, arg3, arg4) \
ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4)
#define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage)
#define GUEST_SYNC1(arg0) ucall(UCALL_SYNC, 1, arg0)
#define GUEST_SYNC2(arg0, arg1) ucall(UCALL_SYNC, 2, arg0, arg1)
#define GUEST_SYNC3(arg0, arg1, arg2) \
ucall(UCALL_SYNC, 3, arg0, arg1, arg2)
#define GUEST_SYNC4(arg0, arg1, arg2, arg3) \
ucall(UCALL_SYNC, 4, arg0, arg1, arg2, arg3)
#define GUEST_SYNC5(arg0, arg1, arg2, arg3, arg4) \
ucall(UCALL_SYNC, 5, arg0, arg1, arg2, arg3, arg4)
#define GUEST_SYNC6(arg0, arg1, arg2, arg3, arg4, arg5) \
ucall(UCALL_SYNC, 6, arg0, arg1, arg2, arg3, arg4, arg5)
#define GUEST_PRINTF(_fmt, _args...) ucall_fmt(UCALL_PRINTF, _fmt, ##_args)
#define GUEST_DONE() ucall(UCALL_DONE, 0)
#define REPORT_GUEST_PRINTF(ucall) pr_info("%s", (ucall).buffer)
enum guest_assert_builtin_args {
GUEST_ERROR_STRING,
GUEST_FILE,
GUEST_LINE,
GUEST_ASSERT_BUILTIN_NARGS
};
#define ____GUEST_ASSERT(_condition, _exp, _fmt, _args...) \
do { \
if (!(_condition)) \
ucall_assert(UCALL_ABORT, _exp, __FILE__, __LINE__, _fmt, ##_args); \
} while (0)
#define __GUEST_ASSERT(_condition, _fmt, _args...) \
____GUEST_ASSERT(_condition, #_condition, _fmt, ##_args)
#define GUEST_ASSERT(_condition) \
__GUEST_ASSERT(_condition, #_condition)
#define GUEST_FAIL(_fmt, _args...) \
ucall_assert(UCALL_ABORT, "Unconditional guest failure", \
__FILE__, __LINE__, _fmt, ##_args)
#define GUEST_ASSERT_EQ(a, b) \
do { \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
____GUEST_ASSERT(__a == __b, #a " == " #b, "%#lx != %#lx (%s != %s)", \
(unsigned long)(__a), (unsigned long)(__b), #a, #b); \
} while (0)
#define GUEST_ASSERT_NE(a, b) \
do { \
typeof(a) __a = (a); \
typeof(b) __b = (b); \
____GUEST_ASSERT(__a != __b, #a " != " #b, "%#lx == %#lx (%s == %s)", \
(unsigned long)(__a), (unsigned long)(__b), #a, #b); \
} while (0)
#define REPORT_GUEST_ASSERT(ucall) \
test_assert(false, (const char *)(ucall).args[GUEST_ERROR_STRING], \
Annotation
- Immediate include surface: `test_util.h`, `ucall.h`.
- Detected declarations: `struct ucall`, `enum guest_assert_builtin_args`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.