Unverified Commit 598a1d66 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!1437 arm64: enable lrcpc feature of ARMv8.x from mainline

Merge Pull Request from: @henryze 
 
https://gitee.com/openeuler/kernel/issues/I7LP2Z?from=project-issue

Armv8.3 introduced the LDAPR instruction, which provides weaker memory
ordering semantics than LDARi (RCpc vs RCsc). Generally, we provide an
RCsc implementation when implementing the Linux memory model, but LDAPR
can be used as a useful alternative to dependency ordering, particularly
when the compiler is capable of breaking the dependencies.

Since LDAPR is not available on all CPUs, add a cpufeature to detect it at
runtime and allow the instruction to be used with alternative code
patching.


Test steps:
insmod feat_rcpc_001.ko

~~~
[root@localhost zengheng]# insmod feat_rcpc_001.ko
[root@localhost zengheng]# dmesg 
[  489.291575] rcpc test start
[  489.291576] has FEAT_RCPC capability
[  489.291577] FEAT_RCPC read pass
[root@localhost zengheng]# uname -a
Linux localhost 5.10.0+ #13 SMP Wed Jul 26 16:02:44 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
~~~ 
 
Link:https://gitee.com/openeuler/kernel/pulls/1437

 

Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 6359f4f7 9e556dcc
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1737,6 +1737,9 @@ config AS_HAS_PAC
config AS_HAS_CFI_NEGATE_RA_STATE
	def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)

config AS_HAS_LDAPR
	def_bool $(as-instr,.arch_extension rcpc)

endmenu

menu "ARMv8.4 architectural features"
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@
#define ARM64_WORKAROUND_1742098	67
#define ARM64_HAS_WFXT				68
#define ARM64_WORKAROUND_HISILICON_ERRATUM_162100125	69
#define ARM64_HAS_LDAPR                         70

#define ARM64_NCAPS				80

+10 −0
Original line number Diff line number Diff line
@@ -2285,6 +2285,16 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
		.matches = has_cpuid_feature,
		.min_field_value = ID_AA64ISAR2_WFXT_SUPPORTED,
	},
	{
		.desc = "RCpc load-acquire (LDAPR)",
		.capability = ARM64_HAS_LDAPR,
		.type = ARM64_CPUCAP_SYSTEM_FEATURE,
		.sys_reg = SYS_ID_AA64ISAR1_EL1,
		.sign = FTR_UNSIGNED,
		.field_pos = ID_AA64ISAR1_LRCPC_SHIFT,
		.matches = has_cpuid_feature,
		.min_field_value = 1,
	},
	{},
};