tools/testing/selftests/powerpc/dexcr/lsdexcr.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/dexcr/lsdexcr.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/dexcr/lsdexcr.c- Extension
.c- Size
- 3864 bytes
- Lines
- 173
- 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
stddef.hstdio.hstring.hsys/prctl.hdexcr.hutils.h
Detected Declarations
function print_listfunction print_dexcrfunction print_aspectfunction print_aspect_configfunction main
Annotated Snippet
if (bits & mask) {
enabled_aspects[j++] = aspects[i].name;
bits &= ~mask;
}
}
if (bits)
enabled_aspects[j++] = "unknown";
printf(" (");
print_list(enabled_aspects, j);
printf(")\n");
}
static void print_aspect(const struct dexcr_aspect *aspect)
{
const char *attributes[8] = {NULL};
size_t j = 0;
unsigned long mask;
mask = DEXCR_PR_BIT(aspect->index);
if (dexcr & mask)
attributes[j++] = "set";
if (hdexcr & mask)
attributes[j++] = "set (hypervisor)";
if (!(effective & mask))
attributes[j++] = "clear";
printf("%12s %c (%d): ", aspect->name, effective & mask ? '*' : ' ', aspect->index);
print_list(attributes, j);
printf(" \t(%s)\n", aspect->desc);
}
static void print_aspect_config(const struct dexcr_aspect *aspect)
{
const char *reason = NULL;
const char *reason_hyp = NULL;
const char *reason_prctl = "no prctl";
bool actual = effective & DEXCR_PR_BIT(aspect->index);
bool expected = actual; /* Assume it's fine if we don't expect a specific set/clear value */
if (actual)
reason = "set by unknown";
else
reason = "cleared by unknown";
if (aspect->prctl != -1) {
int ctrl = pr_get_dexcr(aspect->prctl);
if (ctrl < 0) {
reason_prctl = "failed to read prctl";
} else {
if (ctrl & PR_PPC_DEXCR_CTRL_SET) {
reason_prctl = "set by prctl";
expected = true;
} else if (ctrl & PR_PPC_DEXCR_CTRL_CLEAR) {
reason_prctl = "cleared by prctl";
expected = false;
} else {
reason_prctl = "unknown prctl";
}
reason = reason_prctl;
}
}
if (hdexcr & DEXCR_PR_BIT(aspect->index)) {
reason_hyp = "set by hypervisor";
reason = reason_hyp;
expected = true;
} else {
reason_hyp = "not modified by hypervisor";
}
printf("%12s (%d): %-28s (%s, %s)\n",
aspect->name,
aspect->index,
reason,
reason_hyp,
reason_prctl);
/*
* The checks are not atomic, so this can technically trigger if the
* hypervisor makes a change while we are checking each source. It's
* far more likely to be a bug if we see this though.
*/
if (actual != expected)
printf(" : ! actual %s does not match config\n", aspect->name);
}
Annotation
- Immediate include surface: `stddef.h`, `stdio.h`, `string.h`, `sys/prctl.h`, `dexcr.h`, `utils.h`.
- Detected declarations: `function print_list`, `function print_dexcr`, `function print_aspect`, `function print_aspect_config`, `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.