lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <56f6eebc9c5c1196038d17c09a5ef1f245e1167c.1644588937.git.christophe.leroy@csgroup.eu>
Date:   Fri, 11 Feb 2022 15:29:20 +0100
From:   Christophe Leroy <christophe.leroy@...roup.eu>
To:     Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Paul Mackerras <paulus@...ba.org>,
        Michael Ellerman <mpe@...erman.id.au>
Cc:     Christophe Leroy <christophe.leroy@...roup.eu>,
        linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: [PATCH] powerpc/64: Rewrite loading of AMR_KUAP_BLOCKED in assembly

Constant loading of AMR_KUAP_BLOCKED takes 5 instructions:

	c000000000016a40:       4c 00 01 2c     isync
	c000000000016a44:       3d 20 fc ff     lis     r9,-769
	c000000000016a48:       61 29 ff ff     ori     r9,r9,65535
	c000000000016a4c:       79 29 07 c6     rldicr  r9,r9,32,31
	c000000000016a50:       65 29 ff ff     oris    r9,r9,65535
	c000000000016a54:       61 29 ff ff     ori     r9,r9,65535
	c000000000016a58:       7d 3d 03 a6     mtamr   r9
	c000000000016a5c:       4c 00 01 2c     isync

Until GCC is fixed, implement it in assembly using 2 instructions:

	c000000000016a50:       4c 00 01 2c     isync
	c000000000016a54:       39 20 fc ff     li      r9,-769
	c000000000016a58:       79 29 80 02     rotldi  r9,r9,48
	c000000000016a5c:       7d 3d 03 a6     mtamr   r9
	c000000000016a60:       4c 00 01 2c     isync

With this change a ppc64_defconfig build is reduced by 15 kbytes.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94395
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
---
 arch/powerpc/include/asm/book3s/64/kup.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
index 54cf46808157..35c017ba29e1 100644
--- a/arch/powerpc/include/asm/book3s/64/kup.h
+++ b/arch/powerpc/include/asm/book3s/64/kup.h
@@ -338,6 +338,10 @@ static __always_inline void set_kuap(unsigned long value)
 	 * before and after the move to AMR. See table 6 on page 1134.
 	 */
 	isync();
+
+	if (__builtin_constant_p(value) && value == 0xfcffffffffffffff)
+		asm("li %0, %1 ; rotldi %0, %0, 48" : "=r"(value) : "i"(0xfffffffffffffcff));
+
 	mtspr(SPRN_AMR, value);
 	isync();
 }
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ