tools/testing/selftests/powerpc/mce/inject-ra-err.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/mce/inject-ra-err.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/mce/inject-ra-err.c- Extension
.c- Size
- 1253 bytes
- Lines
- 66
- 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
errno.hfcntl.hsignal.hstdio.hstring.hsys/ioctl.hsys/mman.hsys/stat.hsys/types.hunistd.hvas-api.hutils.h
Detected Declarations
function sigbus_handlerfunction test_ra_errorfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "vas-api.h"
#include "utils.h"
static bool faulted;
static void sigbus_handler(int n, siginfo_t *info, void *ctxt_v)
{
ucontext_t *ctxt = (ucontext_t *)ctxt_v;
struct pt_regs *regs = ctxt->uc_mcontext.regs;
faulted = true;
regs->nip += 4;
}
static int test_ra_error(void)
{
struct vas_tx_win_open_attr attr;
int fd, *paste_addr;
char *devname = "/dev/crypto/nx-gzip";
struct sigaction act = {
.sa_sigaction = sigbus_handler,
.sa_flags = SA_SIGINFO,
};
memset(&attr, 0, sizeof(attr));
attr.version = 1;
attr.vas_id = 0;
SKIP_IF(access(devname, F_OK));
fd = open(devname, O_RDWR);
FAIL_IF(fd < 0);
FAIL_IF(ioctl(fd, VAS_TX_WIN_OPEN, &attr) < 0);
FAIL_IF(sigaction(SIGBUS, &act, NULL) != 0);
paste_addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0ULL);
/* The following assignment triggers exception */
mb();
*paste_addr = 1;
mb();
FAIL_IF(!faulted);
return 0;
}
int main(void)
{
return test_harness(test_ra_error, "inject-ra-err");
}
Annotation
- Immediate include surface: `errno.h`, `fcntl.h`, `signal.h`, `stdio.h`, `string.h`, `sys/ioctl.h`, `sys/mman.h`, `sys/stat.h`.
- Detected declarations: `function sigbus_handler`, `function test_ra_error`, `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.