[PATCH] util/cpuinfo-aarch64: Fix build with older glibc headers

Tao Tang posted 1 patch 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260826163753.459661-1-tangtao1634@phytium.com.cn
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>
util/cpuinfo-aarch64.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] util/cpuinfo-aarch64: Fix build with older glibc headers
Posted by Tao Tang 1 month ago
Commit 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
started using HWCAP2_CSSC unconditionally. This macro was added to
glibc's AArch64 bits/hwcap.h during the glibc 2.38 development cycle,
so AArch64 hosts with older headers fail to build.

Follow the existing HWCAP2_BTI handling and define HWCAP2_CSSC to
zero when it is not provided by system headers. Such environments
simply do not use FEAT_CSSC host optimizations.

This has been tested on an Ubuntu 22.04 aarch64 host with glibc 2.35.

Fixes: 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
---
 util/cpuinfo-aarch64.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c
index 4ce6deb7c82..e3446762149 100644
--- a/util/cpuinfo-aarch64.c
+++ b/util/cpuinfo-aarch64.c
@@ -16,6 +16,9 @@
 # ifndef HWCAP2_BTI
 #  define HWCAP2_BTI 0  /* added in glibc 2.32 */
 # endif
+# ifndef HWCAP2_CSSC
+#  define HWCAP2_CSSC 0  /* added in glibc 2.38 */
+# endif
 #endif
 #ifdef CONFIG_ELF_AUX_INFO
 #include <sys/auxv.h>
-- 
2.34.1
Re: [PATCH] util/cpuinfo-aarch64: Fix build with older glibc headers
Posted by Philippe Mathieu-Daudé 3 weeks, 3 days ago
On 26/8/26 18:37, Tao Tang wrote:
> Commit 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> started using HWCAP2_CSSC unconditionally. This macro was added to
> glibc's AArch64 bits/hwcap.h during the glibc 2.38 development cycle,
> so AArch64 hosts with older headers fail to build.
> 
> Follow the existing HWCAP2_BTI handling and define HWCAP2_CSSC to
> zero when it is not provided by system headers. Such environments
> simply do not use FEAT_CSSC host optimizations.
> 
> This has been tested on an Ubuntu 22.04 aarch64 host with glibc 2.35.
> 
> Fixes: 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>   util/cpuinfo-aarch64.c | 3 +++
>   1 file changed, 3 insertions(+)
Merged as 01e1455139196cc8d6bcde7d2f918348a90f7f26.
Re: [PATCH] util/cpuinfo-aarch64: Fix build with older glibc headers
Posted by Richard Henderson 1 month ago
On 8/26/26 09:37, Tao Tang wrote:
> Commit 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> started using HWCAP2_CSSC unconditionally. This macro was added to
> glibc's AArch64 bits/hwcap.h during the glibc 2.38 development cycle,
> so AArch64 hosts with older headers fail to build.
>
> Follow the existing HWCAP2_BTI handling and define HWCAP2_CSSC to
> zero when it is not provided by system headers. Such environments
> simply do not use FEAT_CSSC host optimizations.
>
> This has been tested on an Ubuntu 22.04 aarch64 host with glibc 2.35.
>
> Fixes: 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>   util/cpuinfo-aarch64.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c
> index 4ce6deb7c82..e3446762149 100644
> --- a/util/cpuinfo-aarch64.c
> +++ b/util/cpuinfo-aarch64.c
> @@ -16,6 +16,9 @@
>   # ifndef HWCAP2_BTI
>   #  define HWCAP2_BTI 0  /* added in glibc 2.32 */
>   # endif
> +# ifndef HWCAP2_CSSC
> +#  define HWCAP2_CSSC 0  /* added in glibc 2.38 */
> +# endif
>   #endif
>   #ifdef CONFIG_ELF_AUX_INFO
>   #include <sys/auxv.h>

Queued, thanks.

r~
Re: [PATCH] util/cpuinfo-aarch64: Fix build with older glibc headers
Posted by Philippe Mathieu-Daudé 1 month ago
On 26/8/26 18:37, Tao Tang wrote:
> Commit 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> started using HWCAP2_CSSC unconditionally. This macro was added to
> glibc's AArch64 bits/hwcap.h during the glibc 2.38 development cycle,
> so AArch64 hosts with older headers fail to build.
> 
> Follow the existing HWCAP2_BTI handling and define HWCAP2_CSSC to
> zero when it is not provided by system headers. Such environments
> simply do not use FEAT_CSSC host optimizations.
> 
> This has been tested on an Ubuntu 22.04 aarch64 host with glibc 2.35.
> 
> Fixes: 761bfe07b2c9 ("util/cpuinfo-aarch64: Detect FEAT_CSSC")
> Signed-off-by: Tao Tang <tangtao1634@phytium.com.cn>
> ---
>   util/cpuinfo-aarch64.c | 3 +++
>   1 file changed, 3 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>