arch/xtensa/kernel/align.S | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
access_ok() is used only in user mode and
branches to .Linvalid_instruction on fault.
Kernel mode skips access_ok().
Tested-by: Ricky Ringler <richard.rringler@gmail.com>
Signed-off-by: Ricky Ringler <richard.rringler@gmail.com>
---
v3:
- Changed kernel mode behavior to skip access_ok()
v2:
- Address Max's feedback
- Fixed formatting
- Added user mode branch
Testing:
- Built with CONFIG_MMU enabled
- objdump before/after comparison and validated code path
arch/xtensa/kernel/align.S | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S
index ee97edce2300..f2d0d831ce43 100644
--- a/arch/xtensa/kernel/align.S
+++ b/arch/xtensa/kernel/align.S
@@ -21,6 +21,9 @@
#include <asm/asm-offsets.h>
#include <asm/asmmacro.h>
#include <asm/processor.h>
+#ifdef CONFIG_MMU
+#include <asm/asm-uaccess.h>
+#endif
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || defined CONFIG_XTENSA_LOAD_STORE
#define LOAD_EXCEPTION_HANDLER
@@ -185,8 +188,11 @@ ENTRY(fast_load_store)
#ifdef CONFIG_MMU
/* l32e can't be used here even when it's available. */
- /* TODO access_ok(a3) could be used here */
- j .Linvalid_instruction
+ rsr a6, ps
+ bbci.l a6, PS_UM_BIT, 1f # kernel mode
+ movi a5, 8
+ access_ok a3, a5, a6, a2, .Linvalid_instruction
+1:
#endif
l32i a5, a3, 0
l32i a6, a3, 4
--
2.43.0
On Mon, Dec 15, 2025 at 6:33 AM Ricky Ringler <richard.rringler@gmail.com> wrote: > > access_ok() is used only in user mode and > branches to .Linvalid_instruction on fault. > Kernel mode skips access_ok(). > > Tested-by: Ricky Ringler <richard.rringler@gmail.com> > > Signed-off-by: Ricky Ringler <richard.rringler@gmail.com> > --- > v3: > - Changed kernel mode behavior to skip access_ok() > > v2: > - Address Max's feedback > - Fixed formatting > - Added user mode branch > > Testing: > - Built with CONFIG_MMU enabled > - objdump before/after comparison and validated code path > > arch/xtensa/kernel/align.S | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) Thanks. Applied to my xtensa tree. -- Max
© 2016 - 2025 Red Hat, Inc.