All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] A couple of cleanups on top of for-next/e0pd
@ 2020-01-15 14:28 Will Deacon
  2020-01-15 14:28 ` [PATCH 1/2] arm64: Simplify early check for broken TX1 when KASLR is enabled Will Deacon
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Will Deacon @ 2020-01-15 14:28 UTC (permalink / raw)
  To: broonie
  Cc: kernel-team, Suzuki K Poulose, Marc Zyngier, Catalin Marinas,
	Will Deacon, linux-arm-kernel

Hi Mark,

I've queued the E0PD patches for 5.6 (thanks!), but in reading them a
final time I noticed a couple of cleanups that I think we can make to
kaslr_requires_kpti(). I don't have a TX1 to test them on, but I think
the logic is sound.

Please take a look, as I'd like to queue these on top.

Thanks.

Will

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Marc Zyngier <maz@kernel.org>

--->8

Will Deacon (2):
  arm64: Simplify early check for broken TX1 when KASLR is enabled
  arm64: Use register field helper in kaslr_requires_kpti()

 arch/arm64/kernel/cpufeature.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

-- 
2.25.0.rc1.283.g88dfdc4193-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] arm64: Simplify early check for broken TX1 when KASLR is enabled
  2020-01-15 14:28 [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Will Deacon
@ 2020-01-15 14:28 ` Will Deacon
  2020-01-15 14:29 ` [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti() Will Deacon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Will Deacon @ 2020-01-15 14:28 UTC (permalink / raw)
  To: broonie
  Cc: kernel-team, Suzuki K Poulose, Marc Zyngier, Catalin Marinas,
	Will Deacon, linux-arm-kernel

Now that the decision to use non-global mappings is stored in a variable,
the check to avoid enabling them for the terminally broken ThunderX1
platform can be simplified so that it is only keyed off the MIDR value.

Signed-off-by: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/cpufeature.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 4a031111ceb5..d5242b44dc5a 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -980,9 +980,7 @@ has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope)
  */
 bool kaslr_requires_kpti(void)
 {
-	bool tx1_bug;
 	u64 ftr;
-
 	if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
 		return false;
 
@@ -1000,18 +998,13 @@ bool kaslr_requires_kpti(void)
 	 * Systems affected by Cavium erratum 24756 are incompatible
 	 * with KPTI.
 	 */
-	if (!IS_ENABLED(CONFIG_CAVIUM_ERRATUM_27456)) {
-		tx1_bug = false;
-	} else if (!static_branch_likely(&arm64_const_caps_ready)) {
+	if (IS_ENABLED(CONFIG_CAVIUM_ERRATUM_27456)) {
 		extern const struct midr_range cavium_erratum_27456_cpus[];
 
-		tx1_bug = is_midr_in_range_list(read_cpuid_id(),
-						cavium_erratum_27456_cpus);
-	} else {
-		tx1_bug = __cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456);
+		if (is_midr_in_range_list(read_cpuid_id(),
+					  cavium_erratum_27456_cpus))
+			return false;
 	}
-	if (tx1_bug)
-		return false;
 
 	return kaslr_offset() > 0;
 }
-- 
2.25.0.rc1.283.g88dfdc4193-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti()
  2020-01-15 14:28 [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Will Deacon
  2020-01-15 14:28 ` [PATCH 1/2] arm64: Simplify early check for broken TX1 when KASLR is enabled Will Deacon
@ 2020-01-15 14:29 ` Will Deacon
  2020-01-15 17:06   ` Mark Brown
  2020-01-15 15:11 ` [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Catalin Marinas
  2020-01-15 16:47 ` Suzuki Kuruppassery Poulose
  3 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2020-01-15 14:29 UTC (permalink / raw)
  To: broonie
  Cc: kernel-team, Suzuki K Poulose, Marc Zyngier, Catalin Marinas,
	Will Deacon, linux-arm-kernel

Rather than open-code the extraction of the E0PD field from the MMFR2
register, we can use the cpuid_feature_extract_unsigned_field() helper
instead.

Signed-off-by: Will Deacon <will@kernel.org>
---
 arch/arm64/kernel/cpufeature.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index d5242b44dc5a..1ebeb5bc17d2 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -980,7 +980,6 @@ has_useable_cnp(const struct arm64_cpu_capabilities *entry, int scope)
  */
 bool kaslr_requires_kpti(void)
 {
-	u64 ftr;
 	if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE))
 		return false;
 
@@ -989,8 +988,9 @@ bool kaslr_requires_kpti(void)
 	 * where available.
 	 */
 	if (IS_ENABLED(CONFIG_ARM64_E0PD)) {
-		ftr = read_sysreg_s(SYS_ID_AA64MMFR2_EL1);
-		if ((ftr >> ID_AA64MMFR2_E0PD_SHIFT) & 0xf)
+		u64 mmfr2 = read_sysreg_s(SYS_ID_AA64MMFR2_EL1);
+		if (cpuid_feature_extract_unsigned_field(mmfr2,
+						ID_AA64MMFR2_E0PD_SHIFT))
 			return false;
 	}
 
-- 
2.25.0.rc1.283.g88dfdc4193-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] A couple of cleanups on top of for-next/e0pd
  2020-01-15 14:28 [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Will Deacon
  2020-01-15 14:28 ` [PATCH 1/2] arm64: Simplify early check for broken TX1 when KASLR is enabled Will Deacon
  2020-01-15 14:29 ` [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti() Will Deacon
@ 2020-01-15 15:11 ` Catalin Marinas
  2020-01-15 16:47 ` Suzuki Kuruppassery Poulose
  3 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2020-01-15 15:11 UTC (permalink / raw)
  To: Will Deacon
  Cc: Marc Zyngier, broonie, kernel-team, linux-arm-kernel, Suzuki K Poulose

On Wed, Jan 15, 2020 at 02:28:58PM +0000, Will Deacon wrote:
> Will Deacon (2):
>   arm64: Simplify early check for broken TX1 when KASLR is enabled
>   arm64: Use register field helper in kaslr_requires_kpti()

The clean-ups look fine to me. With the latest patches we never call
kaslr_requires_kpti() after arm64_const_caps_ready has been set.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] A couple of cleanups on top of for-next/e0pd
  2020-01-15 14:28 [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Will Deacon
                   ` (2 preceding siblings ...)
  2020-01-15 15:11 ` [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Catalin Marinas
@ 2020-01-15 16:47 ` Suzuki Kuruppassery Poulose
  3 siblings, 0 replies; 6+ messages in thread
From: Suzuki Kuruppassery Poulose @ 2020-01-15 16:47 UTC (permalink / raw)
  To: Will Deacon, broonie
  Cc: Catalin Marinas, kernel-team, linux-arm-kernel, Marc Zyngier

On 15/01/2020 14:28, Will Deacon wrote:
> Hi Mark,
> 
> I've queued the E0PD patches for 5.6 (thanks!), but in reading them a
> final time I noticed a couple of cleanups that I think we can make to
> kaslr_requires_kpti(). I don't have a TX1 to test them on, but I think
> the logic is sound.
> 
> Please take a look, as I'd like to queue these on top.
> 
> Thanks.
> 
> Will
> 
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Marc Zyngier <maz@kernel.org>

Looks good to me.

Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti()
  2020-01-15 14:29 ` [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti() Will Deacon
@ 2020-01-15 17:06   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2020-01-15 17:06 UTC (permalink / raw)
  To: Will Deacon
  Cc: Marc Zyngier, Catalin Marinas, kernel-team, linux-arm-kernel,
	Suzuki K Poulose


[-- Attachment #1.1: Type: text/plain, Size: 453 bytes --]

On Wed, Jan 15, 2020 at 02:29:00PM +0000, Will Deacon wrote:
> Rather than open-code the extraction of the E0PD field from the MMFR2
> register, we can use the cpuid_feature_extract_unsigned_field() helper
> instead.

This was suggested by Suzuki at some point but I ended up not
doing it as the helper function name is so long I couldn't work
out how to lay the code out in a satisfactory way at the time.

Reviewed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-15 17:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 14:28 [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Will Deacon
2020-01-15 14:28 ` [PATCH 1/2] arm64: Simplify early check for broken TX1 when KASLR is enabled Will Deacon
2020-01-15 14:29 ` [PATCH 2/2] arm64: Use register field helper in kaslr_requires_kpti() Will Deacon
2020-01-15 17:06   ` Mark Brown
2020-01-15 15:11 ` [PATCH 0/2] A couple of cleanups on top of for-next/e0pd Catalin Marinas
2020-01-15 16:47 ` Suzuki Kuruppassery Poulose

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.