From 745d5fb994293403df93b654c9ea04e3e4fdfef7 Mon Sep 17 00:00:00 2001 From: Jinjie Ruan Date: Mon, 4 Aug 2025 07:20:14 +0000 Subject: [PATCH 1/2] arm64: Fix '__NR_syscalls' undeclared error Fix following '__NR_syscalls' undeclared error by add asm/unistd.h header file. arch/arm64/include/asm/xcall.h:13:31: error: '__NR_syscalls' undeclared here (not in a function); did you mean 'rseq_syscall'? DECLARE_BITMAP(xcall_enable, __NR_syscalls); ^ include/uapi/linux/const.h:34:40: note: in definition of macro '__KERNEL_DIV_ROUND_UP' #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) ^ include/linux/types.h:11:21: note: in expansion of macro 'BITS_TO_LONGS' unsigned long name[BITS_TO_LONGS(bits)] ^~~~~~~~~~~~~ arch/arm64/include/asm/xcall.h:13:2: note: in expansion of macro 'DECLARE_BITMAP' DECLARE_BITMAP(xcall_enable, __NR_syscalls); Fixes: b5fb30ccdb3d ("arm64: Reserve a kabi in task_struct exclusively for xcall") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202508031142.M80c8vhN-lkp@intel.com/ Signed-off-by: Jinjie Ruan --- arch/arm64/include/asm/xcall.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/include/asm/xcall.h b/arch/arm64/include/asm/xcall.h index 5765a96eed53..83dcda82f3e3 100644 --- a/arch/arm64/include/asm/xcall.h +++ b/arch/arm64/include/asm/xcall.h @@ -10,6 +10,7 @@ #include #include +#include DECLARE_STATIC_KEY_FALSE(xcall_enable); -- Gitee From 15f64df9036e52db22e046391401c32a5a38c77d Mon Sep 17 00:00:00 2001 From: Jinjie Ruan Date: Mon, 4 Aug 2025 07:20:15 +0000 Subject: [PATCH 2/2] arm64: Do not enable hardware xcall if actlr_el1 can not set 1650 guest may have 1650 CPU id, but now actlr_el1 can not set in guest VM and hardware xcall/xint are not able to truly take effect. So use xcall/xint vectors in guest is unnecessary now. So check whether actlr_el1.xcall can set before check cpuid is 1650 in is_arch_xcall_xint_support(). So the pr_info in cpu_enable_arch_xcall_xint() can be removed to avoid log spamming when hardware xcall/xint is enabled because actlr can set or not is already known. Fixes: 7f2e02718bba ("arm64: entry: Support hardware xcall and xint") Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/cpufeature.c | 45 ++++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 672accbd5b4a..35f6efda03d9 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2435,16 +2435,27 @@ DEFINE_STATIC_KEY_FALSE(xcall_enable); static bool is_arch_xcall_xint_support(void) { + u64 old, new; + /* List of CPUs that support Xcall/Xint */ static const struct midr_range xcall_xint_cpus[] = { MIDR_ALL_VERSIONS(MIDR_HISI_HIP12), { /* sentinel */ } }; - if (is_midr_in_range_list(read_cpuid_id(), xcall_xint_cpus)) - return true; + if (!is_midr_in_range_list(read_cpuid_id(), xcall_xint_cpus)) + return false; - return false; + old = read_sysreg(actlr_el1); + write_sysreg(old | (ACTLR_ELx_XCALL | ACTLR_ELx_XINT), actlr_el1); + isb(); + new = read_sysreg(actlr_el1); + if (!(new & ACTLR_ELx_XCALL) || !(new & ACTLR_ELx_XINT)) + return false; + + write_sysreg(old, actlr_el1); + + return true; } static int __init xcall_setup(char *str) @@ -2517,30 +2528,10 @@ static void enable_xcall_xint_vectors(void) static void cpu_enable_arch_xcall_xint(const struct arm64_cpu_capabilities *__unused) { - int cpu = smp_processor_id(); - u64 actlr_el1, actlr_el2; - u64 el; - - el = read_sysreg(CurrentEL); - if (el == CurrentEL_EL2) { - /* - * Enable EL2 trap when access ACTLR_EL1 in guest kernel. - */ - write_sysreg_s(read_sysreg_s(SYS_HCR_EL2) | HCR_TACR, SYS_HCR_EL2); - actlr_el2 = read_sysreg(actlr_el2); - actlr_el2 |= ACTLR_ELx_XINT; - write_sysreg(actlr_el2, actlr_el2); - isb(); - actlr_el2 = read_sysreg(actlr_el2); - pr_info("actlr_el2: %llx, cpu:%d\n", actlr_el2, cpu); - } else { - actlr_el1 = read_sysreg(actlr_el1); - actlr_el1 |= ACTLR_ELx_XINT; - write_sysreg(actlr_el1, actlr_el1); - isb(); - actlr_el1 = read_sysreg(actlr_el1); - pr_info("actlr_el1: %llx, cpu:%d\n", actlr_el1, cpu); - } + if (read_sysreg(CurrentEL) == CurrentEL_EL2) + write_sysreg(read_sysreg(actlr_el2) | ACTLR_ELx_XINT, actlr_el2); + else + write_sysreg(read_sysreg(actlr_el1) | ACTLR_ELx_XINT, actlr_el1); enable_xcall_xint_vectors(); } -- Gitee