From: Sven Schnelle <svens@linux.ibm.com>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 8/8] s390: Add support for DCACHE_WORD_ACCESS (again)
Date: Tue, 21 Jul 2026 11:59:11 +0200 [thread overview]
Message-ID: <yt9dmrvkll3k.fsf@linux.ibm.com> (raw)
In-Reply-To: <20260720085834.898025-9-hca@linux.ibm.com>
Heiko Carstens <hca@linux.ibm.com> writes:
> Implement load_unaligned_zeropad() and enable DCACHE_WORD_ACCESS to
> speed up string operations in fs/dcache.c and fs/namei.c.
>
> With the secure storage access exception cases addressed, add support
> for DCACHE_WORD_ACCESS again.
>
> Tested-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
> arch/s390/Kconfig | 1 +
> arch/s390/include/asm/asm-extable.h | 4 ++++
> arch/s390/include/asm/word-at-a-time.h | 22 ++++++++++++++++++++++
> arch/s390/mm/extable.c | 18 ++++++++++++++++++
> 4 files changed, 45 insertions(+)
>
> diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
> index 84404e6778d5..fe81c539ef2f 100644
> --- a/arch/s390/Kconfig
> +++ b/arch/s390/Kconfig
> @@ -163,6 +163,7 @@ config S390
> select ARCH_WANTS_THP_SWAP
> select BUILDTIME_TABLE_SORT
> select CLONE_BACKWARDS2
> + select DCACHE_WORD_ACCESS if !KMSAN
> select DYNAMIC_FTRACE if FUNCTION_TRACER
> select FUNCTION_ALIGNMENT_8B if CC_IS_GCC
> select FUNCTION_ALIGNMENT_16B if !CC_IS_GCC
> diff --git a/arch/s390/include/asm/asm-extable.h b/arch/s390/include/asm/asm-extable.h
> index 99748c20e767..d23ea0c94e4e 100644
> --- a/arch/s390/include/asm/asm-extable.h
> +++ b/arch/s390/include/asm/asm-extable.h
> @@ -12,6 +12,7 @@
> #define EX_TYPE_UA_FAULT 3
> #define EX_TYPE_UA_LOAD_REG 5
> #define EX_TYPE_UA_LOAD_REGPAIR 6
> +#define EX_TYPE_ZEROPAD 7
> #define EX_TYPE_FPC 8
> #define EX_TYPE_UA_MVCOS_TO 9
> #define EX_TYPE_UA_MVCOS_FROM 10
> @@ -79,6 +80,9 @@
> #define EX_TABLE_UA_LOAD_REGPAIR(_fault, _target, _regerr, _regzero) \
> __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REGPAIR, _regerr, _regzero, 0)
>
> +#define EX_TABLE_ZEROPAD(_fault, _target, _regdata, _regaddr) \
> + __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_ZEROPAD, _regdata, _regaddr, 0)
> +
> #define EX_TABLE_FPC(_fault, _target) \
> __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FPC, __stringify(%%r0), __stringify(%%r0), 0)
>
> diff --git a/arch/s390/include/asm/word-at-a-time.h b/arch/s390/include/asm/word-at-a-time.h
> index e9287036392d..eaa19dee7699 100644
> --- a/arch/s390/include/asm/word-at-a-time.h
> +++ b/arch/s390/include/asm/word-at-a-time.h
> @@ -4,6 +4,7 @@
>
> #include <linux/bitops.h>
> #include <linux/wordpart.h>
> +#include <asm/asm-extable.h>
> #include <asm/bitsperlong.h>
>
> struct word_at_a_time {
> @@ -40,4 +41,25 @@ static inline unsigned long zero_bytemask(unsigned long data)
> return ~1UL << data;
> }
>
> +/*
> + * Load an unaligned word from kernel space.
> + *
> + * In the (very unlikely) case of the word being a page-crosser
> + * and the next page not being mapped, take the exception and
> + * return zeroes in the non-existing part.
> + */
> +static inline unsigned long load_unaligned_zeropad(const void *addr)
> +{
> + unsigned long data;
> +
> + asm_inline volatile(
> + "0: lg %[data],0(%[addr])\n"
> + "1: nopr %%r7\n"
> + EX_TABLE_ZEROPAD(0b, 1b, %[data], %[addr])
> + EX_TABLE_ZEROPAD(1b, 1b, %[data], %[addr])
> + : [data] "=d" (data)
> + : [addr] "a" (addr), "m" (*(unsigned long *)addr));
> + return data;
> +}
> +
> #endif /* _ASM_WORD_AT_A_TIME_H */
> diff --git a/arch/s390/mm/extable.c b/arch/s390/mm/extable.c
> index 063b4346742d..7498e858c401 100644
> --- a/arch/s390/mm/extable.c
> +++ b/arch/s390/mm/extable.c
> @@ -50,6 +50,22 @@ static bool ex_handler_ua_load_reg(const struct exception_table_entry *ex,
> return true;
> }
>
> +static bool ex_handler_zeropad(const struct exception_table_entry *ex, struct pt_regs *regs)
> +{
> + unsigned int reg_addr = FIELD_GET(EX_DATA_REG_ADDR, ex->data);
> + unsigned int reg_data = FIELD_GET(EX_DATA_REG_ERR, ex->data);
> + unsigned long data, addr, offset;
> +
> + addr = regs->gprs[reg_addr];
> + offset = addr & (sizeof(unsigned long) - 1);
> + addr &= ~(sizeof(unsigned long) - 1);
> + data = *(unsigned long *)addr;
> + data <<= BITS_PER_BYTE * offset;
> + regs->gprs[reg_data] = data;
> + regs->psw.addr = extable_fixup(ex);
> + return true;
> +}
> +
> static bool ex_handler_fpc(const struct exception_table_entry *ex, struct pt_regs *regs)
> {
> fpu_sfpc(0);
> @@ -118,6 +134,8 @@ bool fixup_exception(struct pt_regs *regs)
> return ex_handler_ua_load_reg(ex, false, regs);
> case EX_TYPE_UA_LOAD_REGPAIR:
> return ex_handler_ua_load_reg(ex, true, regs);
> + case EX_TYPE_ZEROPAD:
> + return ex_handler_zeropad(ex, regs);
> case EX_TYPE_FPC:
> return ex_handler_fpc(ex, regs);
> case EX_TYPE_UA_MVCOS_TO:
Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
next prev parent reply other threads:[~2026-07-21 9:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 8:58 [PATCH v4 0/8] s390: Reintroduce support for DCACHE_WORD_ACCESS Heiko Carstens
2026-07-20 8:58 ` [PATCH v4 1/8] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area Heiko Carstens
2026-07-20 9:56 ` Christian Borntraeger
2026-07-20 10:15 ` Heiko Carstens
2026-07-20 8:58 ` [PATCH v4 2/8] s390/mm: Add missing mm check to do_secure_storage_access() Heiko Carstens
2026-07-20 10:44 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 3/8] s390/mm: Use lock_mm_and_find_vma() in do_secure_storage_access() Heiko Carstens
2026-07-20 10:45 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 4/8] s390/mm: Fix handling of vmalloc area " Heiko Carstens
2026-07-20 10:22 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 5/8] s390/mm: Remove folio handling for kernel faults " Heiko Carstens
2026-07-20 10:53 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 6/8] s390/mm: Use handle_fault_error() " Heiko Carstens
2026-07-20 8:58 ` [PATCH v4 7/8] s390/mm: Use goto statement " Heiko Carstens
2026-07-20 10:36 ` Christian Borntraeger
2026-07-20 8:58 ` [PATCH v4 8/8] s390: Add support for DCACHE_WORD_ACCESS (again) Heiko Carstens
2026-07-21 9:59 ` Sven Schnelle [this message]
2026-07-20 9:03 ` [PATCH v4 0/8] s390: Reintroduce support for DCACHE_WORD_ACCESS Christian Borntraeger
2026-07-20 9:40 ` Heiko Carstens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yt9dmrvkll3k.fsf@linux.ibm.com \
--to=svens@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox