tools/testing/selftests/kvm/s390/irq_routing.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/s390/irq_routing.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/s390/irq_routing.c- Extension
.c- Size
- 1887 bytes
- Lines
- 76
- 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
stdio.hstdlib.hstring.hsys/ioctl.htest_util.hkvm_util.hkselftest.hucall_common.h
Detected Declarations
function testfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* IRQ routing offset tests.
*
* Copyright IBM Corp. 2026
*
* Authors:
* Janosch Frank <frankja@linux.ibm.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include "test_util.h"
#include "kvm_util.h"
#include "kselftest.h"
#include "ucall_common.h"
extern char guest_code[];
asm("guest_code:\n"
"diag %r0,%r0,0\n"
"j .\n");
static void test(void)
{
struct kvm_irq_routing *routing;
struct kvm_vcpu *vcpu;
struct kvm_vm *vm;
gpa_t mem;
int ret;
struct kvm_irq_routing_entry ue = {
.type = KVM_IRQ_ROUTING_S390_ADAPTER,
.gsi = 1,
};
vm = vm_create_with_one_vcpu(&vcpu, guest_code);
mem = vm_phy_pages_alloc(vm, 2, 4096 * 42, 0);
routing = kvm_gsi_routing_create();
routing->nr = 1;
routing->entries[0] = ue;
routing->entries[0].u.adapter.summary_addr = (uintptr_t)mem;
routing->entries[0].u.adapter.ind_addr = (uintptr_t)mem;
routing->entries[0].u.adapter.summary_offset = 4096 * 8;
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
ksft_test_result(ret == -1 && errno == EINVAL, "summary offset outside of page\n");
routing->entries[0].u.adapter.summary_offset -= 4;
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
ksft_test_result(ret == 0, "summary offset inside of page\n");
routing->entries[0].u.adapter.ind_offset = 4096 * 8;
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
ksft_test_result(ret == -1 && errno == EINVAL, "ind offset outside of page\n");
routing->entries[0].u.adapter.ind_offset -= 4;
ret = __vm_ioctl(vm, KVM_SET_GSI_ROUTING, routing);
ksft_test_result(ret == 0, "ind offset inside of page\n");
kvm_vm_free(vm);
}
int main(int argc, char *argv[])
{
TEST_REQUIRE(kvm_has_cap(KVM_CAP_IRQ_ROUTING));
ksft_print_header();
ksft_set_plan(4);
test();
ksft_finished(); /* Print results and exit() accordingly */
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `test_util.h`, `kvm_util.h`, `kselftest.h`, `ucall_common.h`.
- Detected declarations: `function test`, `function main`.
- 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.