bianbu-linux-6.6/arch/um/include/asm
Rick Edgecombe 2f0584f3f4 mm: Rename arch pte_mkwrite()'s to pte_mkwrite_novma()
The x86 Shadow stack feature includes a new type of memory called shadow
stack. This shadow stack memory has some unusual properties, which requires
some core mm changes to function properly.

One of these unusual properties is that shadow stack memory is writable,
but only in limited ways. These limits are applied via a specific PTE
bit combination. Nevertheless, the memory is writable, and core mm code
will need to apply the writable permissions in the typical paths that
call pte_mkwrite(). The goal is to make pte_mkwrite() take a VMA, so
that the x86 implementation of it can know whether to create regular
writable or shadow stack mappings.

But there are a couple of challenges to this. Modifying the signatures of
each arch pte_mkwrite() implementation would be error prone because some
are generated with macros and would need to be re-implemented. Also, some
pte_mkwrite() callers operate on kernel memory without a VMA.

So this can be done in a three step process. First pte_mkwrite() can be
renamed to pte_mkwrite_novma() in each arch, with a generic pte_mkwrite()
added that just calls pte_mkwrite_novma(). Next callers without a VMA can
be moved to pte_mkwrite_novma(). And lastly, pte_mkwrite() and all callers
can be changed to take/pass a VMA.

Start the process by renaming pte_mkwrite() to pte_mkwrite_novma() and
adding the pte_mkwrite() wrapper in linux/pgtable.h. Apply the same
pattern for pmd_mkwrite(). Since not all archs have a pmd_mkwrite_novma(),
create a new arch config HAS_HUGE_PAGE that can be used to tell if
pmd_mkwrite() should be defined. Otherwise in the !HAS_HUGE_PAGE cases the
compiler would not be able to find pmd_mkwrite_novma().

No functional change.

Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/lkml/CAHk-=wiZjSu7c9sFYZb3q04108stgHff2wfbokGCCgW7riz+8Q@mail.gmail.com/
Link: https://lore.kernel.org/all/20230613001108.3040476-2-rick.p.edgecombe%40intel.com
2023-07-11 14:10:56 -07:00
..
fpu um: enable the use of optimized xor routines in UML 2021-06-17 22:01:26 +02:00
archrandom.h random: handle archrandom with multiple longs 2022-07-25 13:26:14 +02:00
asm-prototypes.h um: Restore symbol versions for __memcpy and memcpy 2018-02-19 19:38:51 +01:00
cache.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cacheflush.h um: implement flush_cache_vmap/flush_cache_vunmap 2021-06-17 22:04:40 +02:00
common.lds.S UML: add support for KASAN under x86_64 2022-07-17 23:35:22 +02:00
cpufeature.h asm goto: eradicate CC_HAS_ASM_GOTO 2022-08-21 10:06:28 -07:00
delay.h um: fix ndelay/udelay defines 2021-12-21 21:13:43 +01:00
dma.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fixmap.h highmem: Get rid of kmap_types.h 2020-11-06 23:14:58 +01:00
futex.h um: add a UML specific futex implementation 2021-06-17 22:01:45 +02:00
hardirq.h um/irqstat: Get rid of the duplicated declarations 2020-11-23 10:31:05 +01:00
io.h um: add PCI over virtio emulation driver 2021-06-17 21:45:43 +02:00
irq.h um: line: Use separate IRQs per line 2022-05-27 09:03:41 +02:00
irqflags.h um: rename set_signals() to um_set_signals() 2021-12-21 21:13:44 +01:00
kasan.h UML: add support for KASAN under x86_64 2022-07-17 23:35:22 +02:00
Kbuild um: Use asm-generic/dma-mapping.h 2022-05-27 09:00:45 +02:00
kvm_para.h kvmclock: Add functions to check if the host has stopped the vm 2012-04-08 12:48:59 +03:00
mmu.h um: Add SPDX headers for files in arch/um/include 2019-09-15 21:37:17 +02:00
mmu_context.h um: remove process stub VMA 2021-02-12 21:37:38 +01:00
msi.h um: add PCI over virtio emulation driver 2021-06-17 21:45:43 +02:00
page.h mm, arch: add generic implementation of pfn_valid() for FLATMEM 2023-02-09 16:51:41 -08:00
pci.h PCI/MSI: Get rid of PCI_MSI_IRQ_DOMAIN 2022-11-17 15:15:19 +01:00
pgalloc.h mm/thp: define default pmd_pgtable() 2021-07-01 11:06:03 -07:00
pgtable-2level.h mm: define default value for FIRST_USER_ADDRESS 2021-07-01 11:06:02 -07:00
pgtable-3level.h x86_64: Remove pointless set_64bit() usage 2022-12-15 10:37:27 -08:00
pgtable.h mm: Rename arch pte_mkwrite()'s to pte_mkwrite_novma() 2023-07-11 14:10:56 -07:00
processor-generic.h um: Make the definition of cpu_data more compatible 2023-02-10 21:36:58 +01:00
ptrace-generic.h um: Implement copy_thread_tls 2020-01-07 13:31:29 +01:00
sections.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
setup.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
smp.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stacktrace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
syscall-generic.h arch: remove unused function syscall_set_arguments() 2021-09-14 16:06:20 +02:00
sysrq.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
thread_info.h ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP 2022-05-11 14:33:33 -05:00
timex.h um: use fallback for random_get_entropy() instead of zero 2022-05-13 23:59:23 +02:00
tlb.h um: implement flush_cache_vmap/flush_cache_vunmap 2021-06-17 22:04:40 +02:00
tlbflush.h um: Add SPDX headers for files in arch/um/include 2019-09-15 21:37:17 +02:00
uaccess.h uaccess: generalize access_ok() 2022-02-25 09:36:05 +01:00
unwind.h x86/unwind: Add the ORC unwinder 2017-07-26 13:18:20 +02:00
vmalloc.h mm/vmalloc: Add empty <asm/vmalloc.h> headers and use them from <linux/vmalloc.h> 2019-12-10 10:12:55 +01:00
vmlinux.lds.h Construct init thread stack in the linker script rather than by union 2018-01-09 23:21:02 +00:00
xor.h um: Remove straying parenthesis 2022-07-17 23:24:20 +02:00