tools/testing/selftests/powerpc/mm/wild_bctr.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/mm/wild_bctr.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/mm/wild_bctr.c- Extension
.c- Size
- 3508 bytes
- Lines
- 171
- 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
setjmp.hstdio.hstdlib.hstring.hsys/mman.hsys/types.hsys/wait.hucontext.hunistd.hutils.h
Detected Declarations
struct opdfunction save_regsfunction segv_handlerfunction usr2_handlerfunction okfunction poison_regsfunction check_regsfunction dump_regsfunction test_wild_bctrfunction main
Annotated Snippet
struct opd {
unsigned long ip;
unsigned long toc;
unsigned long env;
};
static struct opd bad_opd = {
.ip = BAD_NIP,
};
#define BAD_FUNC (&bad_opd)
#else
#define BAD_FUNC BAD_NIP
#endif
int test_wild_bctr(void)
{
int (*func_ptr)(void);
struct sigaction segv = {
.sa_sigaction = segv_handler,
.sa_flags = SA_SIGINFO
};
struct sigaction usr2 = {
.sa_sigaction = usr2_handler,
.sa_flags = SA_SIGINFO
};
FAIL_IF(sigaction(SIGSEGV, &segv, NULL));
FAIL_IF(sigaction(SIGUSR2, &usr2, NULL));
bzero(&signal_regs, sizeof(signal_regs));
if (setjmp(setjmp_env) == 0) {
func_ptr = ok;
func_ptr();
kill(getpid(), SIGUSR2);
printf("Regs before:\n");
dump_regs();
bzero(&signal_regs, sizeof(signal_regs));
poison_regs();
func_ptr = (int (*)(void))BAD_FUNC;
func_ptr();
FAIL_IF(1); /* we didn't segv? */
}
FAIL_IF(signal_regs.nip != BAD_NIP);
printf("All good - took SEGV as expected branching to 0x%llx\n", BAD_NIP);
dump_regs();
FAIL_IF(check_regs());
return 0;
}
int main(void)
{
return test_harness(test_wild_bctr, "wild_bctr");
}
Annotation
- Immediate include surface: `setjmp.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/mman.h`, `sys/types.h`, `sys/wait.h`, `ucontext.h`.
- Detected declarations: `struct opd`, `function save_regs`, `function segv_handler`, `function usr2_handler`, `function ok`, `function poison_regs`, `function check_regs`, `function dump_regs`, `function test_wild_bctr`, `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.