linux/arch
Simon Schuster 794b0efb20 nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults
[ Upstream commit 2d8a3179ea ]

NIOS2 uses a software-managed TLB for virtual address translation. To
flush a cache line, the original mapping is replaced by one to physical
address 0x0 with no permissions (rwx mapped to 0) set. This can lead to
TLB-permission--related traps when such a nominally flushed entry is
encountered as a mapping for an otherwise valid virtual address within a
process (e.g. due to an MMU-PID-namespace rollover that previously
flushed the complete TLB including entries of existing, running
processes).

The default ptep_set_access_flags implementation from mm/pgtable-generic.c
only forces a TLB-update when the page-table entry has changed within the
page table:

	/*
	 * [...] We return whether the PTE actually changed, which in turn
	 * instructs the caller to do things like update__mmu_cache. [...]
	 */
	int ptep_set_access_flags(struct vm_area_struct *vma,
				  unsigned long address, pte_t *ptep,
				  pte_t entry, int dirty)
	{
		int changed = !pte_same(*ptep, entry);
		if (changed) {
			set_pte_at(vma->vm_mm, address, ptep, entry);
			flush_tlb_fix_spurious_fault(vma, address);
		}
		return changed;
	}

However, no cross-referencing with the TLB-state occurs, so the
flushing-induced pseudo entries that are responsible for the pagefault
in the first place are never pre-empted from TLB on this code path.

This commit fixes this behaviour by always requesting a TLB-update in
this part of the pagefault handling, fixing spurious page-faults on the
way. The handling is a straightforward port of the logic from the MIPS
architecture via an arch-specific ptep_set_access_flags function ported
from arch/mips/include/asm/pgtable.h.

Signed-off-by: Simon Schuster <schuster.simon@siemens-energy.com>
Signed-off-by: Andreas Oetken <andreas.oetken@siemens-energy.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-06-27 11:05:30 +01:00
..
alpha alpha/elf: Fix misc/setarch test of util-linux by removing 32bit support 2025-04-10 14:31:50 +02:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:28:49 +01:00
arm ARM: omap: pmic-cpcap: do not mess around without CPCAP or OMAP4 2025-06-27 11:05:24 +01:00
arm64 xen/arm: call uaccess_ttbr0_enable for dm_op hypercall 2025-06-27 11:05:22 +01:00
csky csky, hexagon: fix broken sys_sync_file_range 2024-07-05 09:14:48 +02:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:27:21 +01:00
hexagon hexagon: Fix unbalanced spinlock in die() 2025-03-13 12:50:14 +01:00
ia64 arch: Introduce CONFIG_FUNCTION_ALIGNMENT 2024-04-10 16:18:49 +02:00
m68k m68k: mac: Fix macintosh_config for Mac II 2025-06-27 11:05:11 +01:00
microblaze microblaze: don't treat zero reserved memory regions as error 2024-10-17 15:10:38 +02:00
mips mips: Add -std= flag specified in KBUILD_CFLAGS to vdso CFLAGS 2025-06-27 11:05:27 +01:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:27:20 +01:00
nios2 nios2: force update_mmu_cache on spurious tlb-permission--related pagefaults 2025-06-27 11:05:30 +01:00
openrisc openrisc: Call setup_memory() earlier in the init sequence 2024-09-04 13:23:27 +02:00
parisc parisc: fix building with gcc-15 2025-06-27 11:05:26 +01:00
powerpc powerpc/pseries/msi: Avoid reading PCI device registers in reduced power states 2025-06-27 11:05:23 +01:00
riscv riscv: Avoid fortify warning in syscall_get_arguments() 2025-05-02 07:44:13 +02:00
s390 s390/bpf: Store backchain even for leaf progs 2025-06-27 11:05:13 +01:00
sh sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2024-12-14 19:51:16 +01:00
sparc sparc/mm: disable preemption in lazy mmu mode 2025-05-02 07:44:04 +02:00
um um: let 'make clean' properly clean underlying SUBARCH as well 2025-06-04 14:38:08 +02:00
x86 x86/iopl: Cure TIF_IO_BITMAP inconsistencies 2025-06-27 11:05:22 +01:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-06 13:18:14 +02:00
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:24:48 +02:00