tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c- Extension
.c- Size
- 26293 bytes
- Lines
- 1059
- 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
pthread.hsys/sysinfo.harch_timer.hgic.hvgic.h
Detected Declarations
struct test_vcpu_shared_datastruct test_argsenum sync_cmdenum timer_viewfunction assert_irqs_handledfunction userspace_cmdfunction userspace_migrate_vcpufunction userspace_sleepfunction set_counterfunction guest_irq_handlerfunction set_cval_irqfunction set_tval_irqfunction set_xval_irqfunction wait_for_non_spurious_irqfunction userspacefunction wait_poll_for_irqfunction wait_sched_poll_for_irqfunction wait_migrate_poll_for_irqfunction userspacefunction sleep_pollfunction sleep_sched_pollfunction sleep_migratefunction sleep_in_userspacefunction reset_timer_statefunction test_timer_xvalfunction test_timer_cvalfunction test_timer_tvalfunction test_xval_check_no_irqfunction test_cval_no_irqfunction test_tval_no_irqfunction test_timer_control_mask_then_unmaskfunction test_timer_control_masksfunction test_fire_a_timer_multiple_timesfunction test_timers_fired_multiple_timesfunction test_reprogramming_timerfunction test_reprogram_timersfunction test_basic_functionalityfunction timers_sanity_checksfunction test_timers_sanity_checksfunction test_set_cnt_after_tval_maxfunction test_timers_above_tval_maxfunction test_set_cnt_after_xvalfunction test_set_cnt_after_xval_no_irqfunction test_set_cnt_after_tvalfunction test_set_cnt_after_cvalfunction test_set_cnt_after_tval_no_irqfunction test_set_cnt_after_cval_no_irqfunction test_move_counters_ahead_of_timers
Annotated Snippet
struct test_vcpu_shared_data {
atomic_t handled;
atomic_t spurious;
} shared_data;
struct test_args {
/* Virtual or physical timer and counter tests. */
enum arch_timer timer;
/* Delay used for most timer tests. */
u64 wait_ms;
/* Delay used in the test_long_timer_delays test. */
u64 long_wait_ms;
/* Number of iterations. */
int iterations;
/* Whether to test the physical timer. */
bool test_physical;
/* Whether to test the virtual timer. */
bool test_virtual;
};
struct test_args test_args = {
.wait_ms = WAIT_TEST_MS,
.long_wait_ms = LONG_WAIT_TEST_MS,
.iterations = NR_TEST_ITERS_DEF,
.test_physical = true,
.test_virtual = true,
};
static int vtimer_irq, ptimer_irq;
enum sync_cmd {
SET_COUNTER_VALUE,
USERSPACE_USLEEP,
USERSPACE_SCHED_YIELD,
USERSPACE_MIGRATE_SELF,
NO_USERSPACE_CMD,
};
typedef void (*sleep_method_t)(enum arch_timer timer, u64 usec);
static void sleep_poll(enum arch_timer timer, u64 usec);
static void sleep_sched_poll(enum arch_timer timer, u64 usec);
static void sleep_in_userspace(enum arch_timer timer, u64 usec);
static void sleep_migrate(enum arch_timer timer, u64 usec);
sleep_method_t sleep_method[] = {
sleep_poll,
sleep_sched_poll,
sleep_migrate,
sleep_in_userspace,
};
typedef void (*irq_wait_method_t)(void);
static void wait_for_non_spurious_irq(void);
static void wait_poll_for_irq(void);
static void wait_sched_poll_for_irq(void);
static void wait_migrate_poll_for_irq(void);
irq_wait_method_t irq_wait_method[] = {
wait_for_non_spurious_irq,
wait_poll_for_irq,
wait_sched_poll_for_irq,
wait_migrate_poll_for_irq,
};
enum timer_view {
TIMER_CVAL,
TIMER_TVAL,
};
static void assert_irqs_handled(u32 n)
{
int h = atomic_read(&shared_data.handled);
__GUEST_ASSERT(h == n, "Handled %d IRQS but expected %d", h, n);
}
static void userspace_cmd(u64 cmd)
{
GUEST_SYNC_ARGS(cmd, 0, 0, 0, 0);
}
static void userspace_migrate_vcpu(void)
{
userspace_cmd(USERSPACE_MIGRATE_SELF);
}
static void userspace_sleep(u64 usecs)
{
Annotation
- Immediate include surface: `pthread.h`, `sys/sysinfo.h`, `arch_timer.h`, `gic.h`, `vgic.h`.
- Detected declarations: `struct test_vcpu_shared_data`, `struct test_args`, `enum sync_cmd`, `enum timer_view`, `function assert_irqs_handled`, `function userspace_cmd`, `function userspace_migrate_vcpu`, `function userspace_sleep`, `function set_counter`, `function guest_irq_handler`.
- 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.