tools/testing/selftests/kvm/arm64/vgic_init.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/arm64/vgic_init.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/arm64/vgic_init.c- Extension
.c- Size
- 30082 bytes
- Lines
- 1022
- 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
linux/kernel.hsys/syscall.hasm/kvm.hasm/kvm_para.harm64/gic_v3.htest_util.hkvm_util.hprocessor.hvgic.hgic_v3.h
Detected Declarations
struct vm_gicstruct vgic_region_attrstruct sr_deffunction ioctlfunction v3_redist_reg_getfunction guest_codefunction run_vcpufunction vm_gic_create_with_vcpusfunction vm_gic_create_barebonesfunction vm_gic_destroyfunction ARM_VGICfunction subtest_v3_redist_regionsfunction test_vgic_then_vcpusfunction test_vcpus_then_vgicfunction FIELD_PREPfunction test_v3_new_redist_regionsfunction test_v3_typer_accessesfunction vm_gic_v3_create_with_vcpuidsfunction test_v3_last_bit_redist_regionsfunction test_v3_last_bit_single_rdistfunction test_v3_redist_ipa_range_check_at_vcpu_runfunction test_v3_its_regionfunction test_v3_nassgicapfunction test_kvm_devicefunction test_sysreg_arrayfunction get_ctlr_pribitsfunction check_unaccessible_el1_regsfunction get_vtr_pribitsfunction check_unaccessible_el2_regsfunction test_v3_sysregsfunction run_testsfunction main
Annotated Snippet
struct vm_gic {
struct kvm_vm *vm;
int gic_fd;
u32 gic_dev_type;
};
static u64 max_phys_size;
/*
* Helpers to access a redistributor register and verify the ioctl() failed or
* succeeded as expected, and provided the correct value on success.
*/
static void v3_redist_reg_get_errno(int gicv3_fd, int vcpu, int offset,
int want, const char *msg)
{
u32 ignored_val;
int ret = __kvm_device_attr_get(gicv3_fd, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS,
REG_OFFSET(vcpu, offset), &ignored_val);
TEST_ASSERT(ret && errno == want, "%s; want errno = %d", msg, want);
}
static void v3_redist_reg_get(int gicv3_fd, int vcpu, int offset, u32 want,
const char *msg)
{
u32 val;
kvm_device_attr_get(gicv3_fd, KVM_DEV_ARM_VGIC_GRP_REDIST_REGS,
REG_OFFSET(vcpu, offset), &val);
TEST_ASSERT(val == want, "%s; want '0x%x', got '0x%x'", msg, want, val);
}
/* dummy guest code */
static void guest_code(void)
{
GUEST_SYNC(0);
GUEST_SYNC(1);
GUEST_SYNC(2);
GUEST_DONE();
}
/* we don't want to assert on run execution, hence that helper */
static int run_vcpu(struct kvm_vcpu *vcpu)
{
return __vcpu_run(vcpu) ? -errno : 0;
}
static struct vm_gic vm_gic_create_with_vcpus(u32 gic_dev_type,
u32 nr_vcpus,
struct kvm_vcpu *vcpus[])
{
struct vm_gic v;
v.gic_dev_type = gic_dev_type;
v.vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus);
v.gic_fd = kvm_create_device(v.vm, gic_dev_type);
return v;
}
static struct vm_gic vm_gic_create_barebones(u32 gic_dev_type)
{
struct vm_gic v;
v.gic_dev_type = gic_dev_type;
v.vm = vm_create_barebones();
v.gic_fd = kvm_create_device(v.vm, gic_dev_type);
return v;
}
static void vm_gic_destroy(struct vm_gic *v)
{
close(v->gic_fd);
kvm_vm_free(v->vm);
}
struct vgic_region_attr {
u64 attr;
u64 size;
u64 alignment;
};
struct vgic_region_attr gic_v3_dist_region = {
.attr = KVM_VGIC_V3_ADDR_TYPE_DIST,
.size = 0x10000,
.alignment = 0x10000,
};
Annotation
- Immediate include surface: `linux/kernel.h`, `sys/syscall.h`, `asm/kvm.h`, `asm/kvm_para.h`, `arm64/gic_v3.h`, `test_util.h`, `kvm_util.h`, `processor.h`.
- Detected declarations: `struct vm_gic`, `struct vgic_region_attr`, `struct sr_def`, `function ioctl`, `function v3_redist_reg_get`, `function guest_code`, `function run_vcpu`, `function vm_gic_create_with_vcpus`, `function vm_gic_create_barebones`, `function vm_gic_destroy`.
- 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.