tools/testing/selftests/kvm/arm64/page_fault_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/arm64/page_fault_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/arm64/page_fault_test.c- Extension
.c- Size
- 34310 bytes
- Lines
- 1136
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitmap.hfcntl.htest_util.hkvm_util.hprocessor.hasm/sysreg.hlinux/bitfield.hguest_modes.huserfaultfd_util.h
Detected Declarations
struct test_descstruct test_paramsenum pf_test_memslotsfunction flush_tlb_pagefunction guest_write64function guest_check_lsefunction guest_check_dc_zvafunction guest_casfunction guest_read64function guest_atfunction guest_dc_zvafunction guest_ld_preidxfunction guest_st_preidxfunction guest_set_hafunction guest_clear_pte_affunction guest_check_pte_affunction guest_check_write_in_dirty_logfunction guest_check_no_write_in_dirty_logfunction guest_check_s1ptw_wr_in_dirty_logfunction guest_check_no_s1ptw_wr_in_dirty_logfunction guest_execfunction guest_preparefunction guest_test_checkfunction guest_codefunction no_dabt_handlerfunction no_iabt_handlerfunction uffd_generic_handlerfunction uffd_pt_handlerfunction uffd_data_handlerfunction setup_uffd_argsfunction setup_uffdfunction free_uffdfunction uffd_no_handlerfunction punch_hole_in_backing_storefunction mmio_on_test_gpa_handlerfunction mmio_no_handlerfunction check_write_in_dirty_logfunction handle_cmdfunction fail_vcpu_run_no_handlerfunction fail_vcpu_run_mmio_no_syndrome_handlerfunction __return_0x77function load_exec_code_for_testfunction setup_abort_handlersfunction setup_gva_mapsfunction setup_memslotsfunction setup_ucallfunction setup_default_handlersfunction check_event_counts
Annotated Snippet
struct test_desc {
const char *name;
u64 mem_mark_cmd;
/* Skip the test if any prepare function returns false */
bool (*guest_prepare[PREPARE_FN_NR])(void);
void (*guest_test)(void);
void (*guest_test_check[CHECK_FN_NR])(void);
uffd_handler_t uffd_pt_handler;
uffd_handler_t uffd_data_handler;
void (*dabt_handler)(struct ex_regs *regs);
void (*iabt_handler)(struct ex_regs *regs);
void (*mmio_handler)(struct kvm_vm *vm, struct kvm_run *run);
void (*fail_vcpu_run_handler)(int ret);
u32 pt_memslot_flags;
u32 data_memslot_flags;
bool skip;
struct event_cnt expected_events;
};
struct test_params {
enum vm_mem_backing_src_type src_type;
struct test_desc *test_desc;
};
static inline void flush_tlb_page(gva_t gva)
{
gva_t page = gva >> 12;
dsb(ishst);
asm volatile("tlbi vaae1is, %0" :: "r" (page));
dsb(ish);
isb();
}
static void guest_write64(void)
{
u64 val;
WRITE_ONCE(*guest_test_memory, TEST_DATA);
val = READ_ONCE(*guest_test_memory);
GUEST_ASSERT_EQ(val, TEST_DATA);
}
/* Check the system for atomic instructions. */
static bool guest_check_lse(void)
{
u64 isar0 = read_sysreg(id_aa64isar0_el1);
u64 atomic;
atomic = FIELD_GET(ID_AA64ISAR0_EL1_ATOMIC, isar0);
return atomic >= 2;
}
static bool guest_check_dc_zva(void)
{
u64 dczid = read_sysreg(dczid_el0);
u64 dzp = FIELD_GET(DCZID_EL0_DZP, dczid);
return dzp == 0;
}
/* Compare and swap instruction. */
static void guest_cas(void)
{
u64 val;
GUEST_ASSERT(guest_check_lse());
asm volatile(".arch_extension lse\n"
"casal %0, %1, [%2]\n"
:: "r" (0ul), "r" (TEST_DATA), "r" (guest_test_memory));
val = READ_ONCE(*guest_test_memory);
GUEST_ASSERT_EQ(val, TEST_DATA);
}
static void guest_read64(void)
{
u64 val;
val = READ_ONCE(*guest_test_memory);
GUEST_ASSERT_EQ(val, 0);
}
/* Address translation instruction */
static void guest_at(void)
{
u64 par;
asm volatile("at s1e1r, %0" :: "r" (guest_test_memory));
isb();
par = read_sysreg(par_el1);
Annotation
- Immediate include surface: `linux/bitmap.h`, `fcntl.h`, `test_util.h`, `kvm_util.h`, `processor.h`, `asm/sysreg.h`, `linux/bitfield.h`, `guest_modes.h`.
- Detected declarations: `struct test_desc`, `struct test_params`, `enum pf_test_memslots`, `function flush_tlb_page`, `function guest_write64`, `function guest_check_lse`, `function guest_check_dc_zva`, `function guest_cas`, `function guest_read64`, `function guest_at`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.