linux/arch/powerpc/kernel
Christophe Leroy 8956c582ac powerpc/8xx: Fix kernel DTLB miss on dcbz
Following OOPS is encountered while loading test_bpf module
on powerpc 8xx:

[  218.835567] BUG: Unable to handle kernel data access on write at 0xcb000000
[  218.842473] Faulting instruction address: 0xc0017a80
[  218.847451] Oops: Kernel access of bad area, sig: 11 [#1]
[  218.852854] BE PAGE_SIZE=16K PREEMPT CMPC885
[  218.857207] SAF3000 DIE NOTIFICATION
[  218.860713] Modules linked in: test_bpf(+) test_module
[  218.865867] CPU: 0 UID: 0 PID: 527 Comm: insmod Not tainted 6.11.0-s3k-dev-09856-g3de3d71ae2e6-dirty #1280
[  218.875546] Hardware name: MIAE 8xx 0x500000 CMPC885
[  218.880521] NIP:  c0017a80 LR: beab859c CTR: 000101d4
[  218.885584] REGS: cac2bc90 TRAP: 0300   Not tainted  (6.11.0-s3k-dev-09856-g3de3d71ae2e6-dirty)
[  218.894308] MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 55005555  XER: a0007100
[  218.901290] DAR: cb000000 DSISR: c2000000
[  218.901290] GPR00: 000185d1 cac2bd50 c21b9580 caf7c030 c3883fcc 00000008 cafffffc 00000000
[  218.901290] GPR08: 00040000 18300000 20000000 00000004 99005555 100d815e ca669d08 00000369
[  218.901290] GPR16: ca730000 00000000 ca2c004c 00000000 00000000 0000035d 00000311 00000369
[  218.901290] GPR24: ca732240 00000001 00030ba3 c3800000 00000000 00185d48 caf7c000 ca2c004c
[  218.941087] NIP [c0017a80] memcpy+0x88/0xec
[  218.945277] LR [beab859c] test_bpf_init+0x22c/0x3c90 [test_bpf]
[  218.951476] Call Trace:
[  218.953916] [cac2bd50] [beab8570] test_bpf_init+0x200/0x3c90 [test_bpf] (unreliable)
[  218.962034] [cac2bde0] [c0004c04] do_one_initcall+0x4c/0x1fc
[  218.967706] [cac2be40] [c00a2ec4] do_init_module+0x68/0x360
[  218.973292] [cac2be60] [c00a5194] init_module_from_file+0x8c/0xc0
[  218.979401] [cac2bed0] [c00a5568] sys_finit_module+0x250/0x3f0
[  218.985248] [cac2bf20] [c000e390] system_call_exception+0x8c/0x15c
[  218.991444] [cac2bf30] [c00120a8] ret_from_syscall+0x0/0x28

This happens in the main loop of memcpy()

  ==>	c0017a80:	7c 0b 37 ec 	dcbz    r11,r6
	c0017a84:	80 e4 00 04 	lwz     r7,4(r4)
	c0017a88:	81 04 00 08 	lwz     r8,8(r4)
	c0017a8c:	81 24 00 0c 	lwz     r9,12(r4)
	c0017a90:	85 44 00 10 	lwzu    r10,16(r4)
	c0017a94:	90 e6 00 04 	stw     r7,4(r6)
	c0017a98:	91 06 00 08 	stw     r8,8(r6)
	c0017a9c:	91 26 00 0c 	stw     r9,12(r6)
	c0017aa0:	95 46 00 10 	stwu    r10,16(r6)
	c0017aa4:	42 00 ff dc 	bdnz    c0017a80 <memcpy+0x88>

Commit ac9f97ff8b ("powerpc/8xx: Inconditionally use task PGDIR in
DTLB misses") relies on re-reading DAR register to know if an error is
due to a missing copy of a PMD entry in task's PGDIR, allthough DAR
was already read in the exception prolog and copied into thread
struct. This is because is it done very early in the exception and
there are not enough registers available to keep a pointer to thread
struct.

However, dcbz instruction is buggy and doesn't update DAR register on
fault. That is detected and generates a call to FixupDAR workaround
which updates DAR copy in thread struct but doesn't fix DAR register.

Let's fix DAR in addition to the update of DAR copy in thread struct.

Fixes: ac9f97ff8b ("powerpc/8xx: Inconditionally use task PGDIR in DTLB misses")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/2b851399bd87e81c6ccb87ea3a7a6b32c7aa04d7.1728118396.git.christophe.leroy@csgroup.eu
2024-10-11 15:53:06 +11:00
..
ptrace
syscalls
trace
vdso powerpc/vdso: allow r30 in vDSO code generation of getrandom 2024-09-30 19:19:43 +10:00
.gitignore
85xx_entry_mapping.S
Makefile powerpc: Replace kretprobe code with rethook on powerpc 2024-09-05 22:25:36 +10:00
align.c
asm-offsets.c powerpc/vdso: Wire up getrandom() vDSO implementation on VDSO32 2024-09-13 17:28:36 +02:00
audit.c
audit_32.h
btext.c
cacheinfo.c powerpc: Constify struct kobj_type 2024-09-05 22:25:36 +10:00
cacheinfo.h
compat_audit.c
cpu_setup_6xx.S
cpu_setup_44x.S
cpu_setup_e500.S
cpu_setup_pa6t.S
cpu_setup_power.c
cpu_setup_ppc970.S
cpu_specs.h
cpu_specs_8xx.h
cpu_specs_44x.h
cpu_specs_47x.h
cpu_specs_85xx.h
cpu_specs_book3s_32.h
cpu_specs_book3s_64.h
cpu_specs_e500mc.h
cputable.c
crash_dump.c
dawr.c
dbell.c
dexcr.c
dma-iommu.c
dma-mask.c
dma-swiotlb.c
dt_cpu_ftrs.c
early_32.c
eeh.c powerpc/pseries/eeh: move pseries_eeh_err_inject() outside CONFIG_DEBUG_FS block 2024-09-20 19:06:25 +10:00
eeh_cache.c
eeh_driver.c
eeh_event.c
eeh_pe.c
eeh_sysfs.c
entry_32.S
epapr_hcalls.S
epapr_paravirt.c
exceptions-64e.S
exceptions-64s.S powerpc/64s: Remove the "fast endian switch" syscall 2024-09-05 22:30:05 +10:00
fadump.c
firmware.c
fpu.S
head_8xx.S powerpc/8xx: Fix kernel DTLB miss on dcbz 2024-10-11 15:53:06 +11:00
head_32.h
head_44x.S
head_64.S
head_85xx.S
head_book3s_32.S powerpc/603: Inconditionally use task PGDIR in DTLB misses 2024-08-30 21:29:55 +10:00
head_booke.h
hw_breakpoint.c
hw_breakpoint_constraints.c
idle.c
idle_6xx.S
idle_64e.S
idle_85xx.S
idle_book3s.S
ima_arch.c
interrupt.c treewide: context_tracking: Rename CONTEXT_* into CT_STATE_* 2024-07-29 07:33:10 +05:30
interrupt_64.S
io-workarounds.c
io.c
iomap.c
iommu.c
irq.c
irq_64.c
isa-bridge.c
jump_label.c
kdebugfs.c
kgdb.c
kprobes-ftrace.c
kprobes.c powerpc: Replace kretprobe code with rethook on powerpc 2024-09-05 22:25:36 +10:00
kvm.c
kvm_emul.S
l2cr_6xx.S
legacy_serial.c
mce.c
mce_power.c
misc.S
misc_32.S
misc_64.S
module.c
module_32.c
module_64.c powerpc/64: Convert patch_instruction() to patch_u32() 2024-08-21 20:15:13 +10:00
msi.c
note.S
nvram_64.c
of_platform.c
optprobes.c powerpc: Replace kretprobe code with rethook on powerpc 2024-09-05 22:25:36 +10:00
optprobes_head.S
paca.c
pci-common.c
pci-hotplug.c
pci_32.c
pci_64.c
pci_dn.c
pci_of_scan.c
pmc.c
ppc_save_regs.S
proc_powerpc.c
process.c powerpc/32: Implement validation of emergency stack 2024-08-30 21:30:20 +10:00
prom.c
prom_entry_64.S
prom_init.c
prom_init_check.sh
prom_parse.c
reloc_32.S
reloc_64.S
rethook.c powerpc: Replace kretprobe code with rethook on powerpc 2024-09-05 22:25:36 +10:00
rtas-proc.c
rtas-rtc.c
rtas.c
rtas_entry.S
rtas_flash.c
rtas_pci.c
rtasd.c
secure_boot.c
security.c
secvar-ops.c
secvar-sysfs.c powerpc: Constify struct kobj_type 2024-09-05 22:25:36 +10:00
setup-common.c powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL 2024-08-12 21:50:20 +10:00
setup.h
setup_32.c
setup_64.c
signal.c
signal.h
signal_32.c
signal_64.c
smp-tbsync.c
smp.c smp: Mark smp_prepare_boot_cpu() __init 2024-09-08 16:01:10 +02:00
stacktrace.c powerpc: Replace kretprobe code with rethook on powerpc 2024-09-05 22:25:36 +10:00
static_call.c powerpc/32: Convert patch_instruction() to patch_uint() 2024-08-21 20:15:13 +10:00
suspend.c
switch.S
swsusp.c
swsusp_32.S
swsusp_64.c
swsusp_85xx.S
swsusp_asm64.S
sys_ppc32.c
syscall.c treewide: context_tracking: Rename CONTEXT_* into CT_STATE_* 2024-07-29 07:33:10 +05:30
syscalls.c
sysfs.c
systbl.c
tau_6xx.c
time.c
tm.S
traps.c powerpc/traps: Use backlight power constants 2024-08-07 22:48:26 +10:00
ucall.S
udbg.c
udbg_16550.c
uprobes.c
vdso.c powerpc/vdso: refactor error handling 2024-09-01 20:26:13 -07:00
vdso32_wrapper.S
vdso64_wrapper.S
vecemu.c
vector.S
vmlinux.lds.S
watchdog.c