Commit 5c3cf228 authored by Yipeng Zou's avatar Yipeng Zou Committed by Jinjie Ruan
Browse files

arm64: Introduce xcall a faster svc exception handling

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/release-management/issues/IB6JLE



--------------------------------

The svc exception handling process in ARM64, which includes auxiliary
functions for debug/trace and core functions like KPTI, has been
identified as overly "lengthy".

This inefficiency is particularly noticeable in short syscalls such as
lseek() and getpid(), where the syscall function itself comprises a
small percentage of the total instructions executed.

To address this, we introduce the concept of xcall, a fast svc exception
handling path that only considers necessary features such as security,
context saving, and recovery.

This approach can be seen as a high-speed syscall processing mechanism
bridging the gap between vdso and traditional syscalls.

We've implemented a per-task bitmap to enable or disable xcall for
specific syscalls.

Users can enable a syscall with the following command:

    echo $syscall_nr > /proc/$PID/xcall

To disable a syscall, use:

    echo \!$syscall_nr > /proc/$PID/xcall

The current status of enabled syscalls can be viewed by:

    cat /proc/$PID/xcall

Finally, we've added a kernel boot parameter to control the xcall feature.

To enable xcall, include "xcall" in the kernel boot command.

By default, xcall is disabled.

This patch introduces basic framework and have not modified to syscall
path only copy to xcall.

Signed-off-by: default avatarYipeng Zou <zouyipeng@huawei.com>
parent e5f9cb08
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1530,4 +1530,23 @@ config FUNCTION_ALIGNMENT
	default 4 if FUNCTION_ALIGNMENT_4B
	default 0

config ARCH_SUPPORTS_FAST_SYSCALL
	bool

config FAST_SYSCALL
	bool "Fast Syscall support"
	depends on ARCH_SUPPORTS_FAST_SYSCALL
	default n
	help
	  This enable support Fast syscall feature.
	  The svc exception handling process, which includes auxiliary
	  functions for debug/trace and core functions like
	  KPTI, has been identified as overly "lengthy".
	  This inefficiency is particularly noticeable in short syscalls
	  such as lseek() and getpid(), where the syscall function itself
	  comprises a small percentage of the total instructions executed.
	  To address this, we introduce the concept of fast syscall, a fast svc
	  exception handling path that only considers necessary features
	  such as security, context saving, and recovery.

endmenu
+1 −0
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ config ARM64
	select TRACE_IRQFLAGS_SUPPORT
	select TRACE_IRQFLAGS_NMI_SUPPORT
	select HAVE_SOFTIRQ_ON_OWN_STACK
	select ARCH_SUPPORTS_FAST_SYSCALL if !ARM64_MTE && !KASAN_HW_TAGS
	help
	  ARM 64-bit (AArch64) Linux support.

+2 −0
Original line number Diff line number Diff line
@@ -891,6 +891,8 @@ CONFIG_HAVE_GCC_PLUGINS=y
CONFIG_FUNCTION_ALIGNMENT_4B=y
CONFIG_FUNCTION_ALIGNMENT_8B=y
CONFIG_FUNCTION_ALIGNMENT=8
CONFIG_ARCH_SUPPORTS_FAST_SYSCALL=y
# CONFIG_FAST_SYSCALL is not set
# end of General architecture-dependent options

CONFIG_RT_MUTEXES=y
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,9 @@

int main(void)
{
#ifdef CONFIG_FAST_SYSCALL
	DEFINE(TSK_XCALL,		offsetof(struct task_struct, xcall_enable));
#endif
  DEFINE(TSK_ACTIVE_MM,		offsetof(struct task_struct, active_mm));
  BLANK();
  DEFINE(TSK_TI_CPU,		offsetof(struct task_struct, thread_info.cpu));
+28 −0
Original line number Diff line number Diff line
@@ -2375,6 +2375,26 @@ static void mpam_extra_caps(void)
		__enable_mpam_hcr();
}

#ifdef CONFIG_FAST_SYSCALL
static bool is_xcall_support;
static int __init xcall_setup(char *str)
{
	is_xcall_support = true;
	return 1;
}
__setup("xcall", xcall_setup);

bool fast_syscall_enabled(void)
{
	return is_xcall_support;
}

static bool has_xcall_support(const struct arm64_cpu_capabilities *entry, int __unused)
{
	return is_xcall_support;
}
#endif

static const struct arm64_cpu_capabilities arm64_features[] = {
	{
		.capability = ARM64_ALWAYS_BOOT,
@@ -2891,6 +2911,14 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
		.matches = has_cpuid_feature,
		ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, TWED, IMP)
	},
#endif
#ifdef CONFIG_FAST_SYSCALL
	{
		.desc = "Xcall Support",
		.capability = ARM64_HAS_XCALL,
		.type = ARM64_CPUCAP_SYSTEM_FEATURE,
		.matches = has_xcall_support,
	},
#endif
	{},
};
Loading