[LTP] arch_prctl: add ARCH_GET_FS, ARCH_GET_GS tests
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri Oct 9 12:12:28 CEST 2026
Hi Dmitry,
On Thu, 8 Oct 2026, Dmitry Chestnykh wrote:
> arch_prctl: add ARCH_GET_FS, ARCH_GET_GS tests
> +CFLAGS += -mfsgsbase
This directory-wide x86 option breaks supported non-x86 builds, including
the existing arch_prctl01 target; AArch64 clang rejects it. Remove the
option: the new test's inline assembly compiles without it on x86_64.
> + asm volatile("rdfsbase %0" : "=r"(__res)); \
> + asm volatile("rdgsbase %0" : "=r"(__res)); \
> + .supported_archs = (const char *const []){"x86_64", NULL}
Removing the compiler option alone is insufficient: the unconditional
assembly still fails on AArch64, and lapi/arch_prctl.h supplies no
ARCH_GET_FS/ARCH_GET_GS definitions on non-x86 targets. The supported_archs
check runs only after compilation; provide a buildable unsupported-feature
path or filter the target appropriately in the Makefile.
> +#if defined(__has_include) && __has_include(<asm/hwcap2.h>)
GCC 4.8.5, a supported compiler, cannot parse this expression: the left
operand does not protect an undefined function-like preprocessing operator.
The repository's sparse check also rejects this line. Use separately nested
checks or configured optional-header inclusion.
> +#include <asm/hwcap2.h>
> +#else
> +#warning "Cannot obtain HWCAP2_FSGSBASE from system headers"
> +#define HWCAP2_FSGSBASE (1UL << 1)
An existing older header bypasses the fallback even when it lacks this bit:
compilation against Linux 5.4's hwcap2.h fails with HWCAP2_FSGSBASE
undeclared.
Apply the fallback after optional header inclusion, independently of header
availability, and put the compatibility definition in include/lapi.
> +/arch_prctl02
The new binary has no entry in any runtest file, so normal syscall-suite
runs never execute it. Add "arch_prctl02 arch_prctl02" to runtest/syscalls.
> + TEST(arch_prctl_get(ARCH_GET_FS, &fs_prctl));
> + if (TST_RET == 0 && fs_prctl == fs)
> + tst_res(TPASS, "get fs succeed");
> + else
> + tst_res(TFAIL, "got wrong fs register value");
These messages discard errno and the expected/actual bases, and report a
syscall failure as a register mismatch. Use TST_EXP_PASS_SILENT(), then
TST_EXP_EQ_LU() only when TST_PASS is true; apply the same change to GS.
> + * Author: Dmitry Chestnykh <dm.chestnykh@gmail.com>
Add the required copyright line with year and author, for example
"Copyright (c) 2026 Dmitry Chestnykh <dm.chestnykh@gmail.com>".
> + * Simple test on arch_prctl to get FS_BASE and GS_BASE
Use the required manpage role and describe the comparison, for example:
"Check that :manpage:`arch_prctl(2)` with ``ARCH_GET_FS`` and ``ARCH_GET_GS``
returns bases matching ``rdfsbase`` and ``rdgsbase``."
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list