arch/s390/lib/test_kprobes.c
Source file repositories/reference/linux-study-clean/arch/s390/lib/test_kprobes.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/lib/test_kprobes.c- Extension
.c- Size
- 1810 bytes
- Lines
- 77
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/kprobes.hlinux/random.hkunit/test.htest_kprobes.h
Detected Declarations
function setup_kprobefunction test_kprobe_offsetfunction test_kprobe_oddfunction test_kprobe_in_insn4function test_kprobe_in_insn6_lofunction test_kprobe_in_insn6_hi
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include <linux/kernel.h>
#include <linux/kprobes.h>
#include <linux/random.h>
#include <kunit/test.h>
#include "test_kprobes.h"
static struct kprobe kp;
static void setup_kprobe(struct kunit *test, struct kprobe *kp,
const char *symbol, int offset)
{
kp->offset = offset;
kp->addr = NULL;
kp->symbol_name = symbol;
}
static void test_kprobe_offset(struct kunit *test, struct kprobe *kp,
const char *target, int offset)
{
int ret;
setup_kprobe(test, kp, target, 0);
ret = register_kprobe(kp);
if (!ret)
unregister_kprobe(kp);
KUNIT_EXPECT_EQ(test, 0, ret);
setup_kprobe(test, kp, target, offset);
ret = register_kprobe(kp);
KUNIT_EXPECT_EQ(test, -EINVAL, ret);
if (!ret)
unregister_kprobe(kp);
}
static void test_kprobe_odd(struct kunit *test)
{
test_kprobe_offset(test, &kp, "kprobes_target_odd",
kprobes_target_odd_offs);
}
static void test_kprobe_in_insn4(struct kunit *test)
{
test_kprobe_offset(test, &kp, "kprobes_target_in_insn4",
kprobes_target_in_insn4_offs);
}
static void test_kprobe_in_insn6_lo(struct kunit *test)
{
test_kprobe_offset(test, &kp, "kprobes_target_in_insn6_lo",
kprobes_target_in_insn6_lo_offs);
}
static void test_kprobe_in_insn6_hi(struct kunit *test)
{
test_kprobe_offset(test, &kp, "kprobes_target_in_insn6_hi",
kprobes_target_in_insn6_hi_offs);
}
static struct kunit_case kprobes_testcases[] = {
KUNIT_CASE(test_kprobe_odd),
KUNIT_CASE(test_kprobe_in_insn4),
KUNIT_CASE(test_kprobe_in_insn6_lo),
KUNIT_CASE(test_kprobe_in_insn6_hi),
{}
};
static struct kunit_suite kprobes_test_suite = {
.name = "kprobes_test_s390",
.test_cases = kprobes_testcases,
};
kunit_test_suites(&kprobes_test_suite);
MODULE_DESCRIPTION("KUnit tests for kprobes");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kprobes.h`, `linux/random.h`, `kunit/test.h`, `test_kprobes.h`.
- Detected declarations: `function setup_kprobe`, `function test_kprobe_offset`, `function test_kprobe_odd`, `function test_kprobe_in_insn4`, `function test_kprobe_in_insn6_lo`, `function test_kprobe_in_insn6_hi`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.