tools/testing/selftests/arm64/tags/tags_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/tags/tags_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/arm64/tags/tags_test.c- Extension
.c- Size
- 860 bytes
- Lines
- 38
- 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.hunistd.hstdint.hsys/prctl.hsys/utsname.hkselftest.h
Detected Declarations
function SHIFT_TAG
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/prctl.h>
#include <sys/utsname.h>
#include "kselftest.h"
#define SHIFT_TAG(tag) ((uint64_t)(tag) << 56)
#define SET_TAG(ptr, tag) (((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
SHIFT_TAG(tag))
int main(void)
{
static int tbi_enabled = 0;
unsigned long tag = 0;
struct utsname *ptr;
ksft_print_header();
ksft_set_plan(1);
if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
tbi_enabled = 1;
ptr = (struct utsname *)malloc(sizeof(*ptr));
if (!ptr)
ksft_exit_fail_perror("Failed to allocate utsname buffer");
if (tbi_enabled)
tag = 0x42;
ptr = (struct utsname *)SET_TAG(ptr, tag);
ksft_test_result(!uname(ptr), "Syscall successful with tagged address\n");
free(ptr);
ksft_finished();
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `unistd.h`, `stdint.h`, `sys/prctl.h`, `sys/utsname.h`, `kselftest.h`.
- Detected declarations: `function SHIFT_TAG`.
- 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.