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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ff132a6-7552-a46f-5690-e73c37c805f9@csgroup.eu>
Date:   Sat, 27 Mar 2021 18:24:23 +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>, npiggin@...il.com
Cc:     linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 37/41] powerpc/32s: Move KUEP locking/unlocking in C



Le 12/03/2021 à 13:50, Christophe Leroy a écrit :
> This can be done in C, do it.
> 
> Unrolling the loop gains approx. 15% performance.
> 
>  From now on, prepare_transfer_to_handler() is only for
> interrupts from kernel.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
> ---
>   arch/powerpc/include/asm/book3s/32/kup.h | 31 -------------------
>   arch/powerpc/include/asm/interrupt.h     |  6 +++-
>   arch/powerpc/include/asm/kup.h           |  8 +++++
>   arch/powerpc/kernel/entry_32.S           | 16 ----------
>   arch/powerpc/kernel/head_32.h            |  3 ++
>   arch/powerpc/kernel/head_booke.h         |  3 ++
>   arch/powerpc/kernel/interrupt.c          |  4 +++
>   arch/powerpc/mm/book3s32/Makefile        |  1 +
>   arch/powerpc/mm/book3s32/kuep.c          | 38 ++++++++++++++++++++++++
>   9 files changed, 62 insertions(+), 48 deletions(-)
>   create mode 100644 arch/powerpc/mm/book3s32/kuep.c
> 

> diff --git a/arch/powerpc/mm/book3s32/kuep.c b/arch/powerpc/mm/book3s32/kuep.c
> new file mode 100644
> index 000000000000..c70532568a28
> --- /dev/null
> +++ b/arch/powerpc/mm/book3s32/kuep.c
> @@ -0,0 +1,38 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +#include <asm/reg.h>
> +#include <asm/task_size_32.h>
> +#include <asm/mmu.h>

Need to add <asm/kup.h> to make Robot happy (missing prototypes of kuep_lock() and kuep_unlock())

> +
> +#define KUEP_UPDATE_TWO_USER_SEGMENTS(n) do {		\
> +	if (TASK_SIZE > ((n) << 28))			\
> +		mtsr(val1, (n) << 28);			\
> +	if (TASK_SIZE > (((n) + 1) << 28))		\
> +		mtsr(val2, ((n) + 1) << 28);		\
> +	val1 = (val1 + 0x222) & 0xf0ffffff;		\
> +	val2 = (val2 + 0x222) & 0xf0ffffff;		\
> +} while (0)
> +
> +static __always_inline void kuep_update(u32 val)
> +{
> +	int val1 = val;
> +	int val2 = (val + 0x111) & 0xf0ffffff;
> +
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(0);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(2);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(4);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(6);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(8);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(10);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(12);
> +	KUEP_UPDATE_TWO_USER_SEGMENTS(14);
> +}
> +
> +void kuep_lock(void)
> +{
> +	kuep_update(mfsr(0) | SR_NX);
> +}
> +
> +void kuep_unlock(void)
> +{
> +	kuep_update(mfsr(0) & ~SR_NX);
> +}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ