2019-03-29 03:00:00 -07:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
2021-12-01 07:41:52 -07:00
|
|
|
obj-y += mmu_context.o pgtable.o trace.o
|
|
|
|
ifdef CONFIG_PPC_64S_HASH_MMU
|
2019-03-29 03:00:00 -07:00
|
|
|
CFLAGS_REMOVE_slb.o = $(CC_FLAGS_FTRACE)
|
2022-04-09 10:17:31 -07:00
|
|
|
obj-y += hash_pgtable.o hash_utils.o hash_tlb.o slb.o slice.o
|
2021-12-01 07:41:37 -07:00
|
|
|
obj-$(CONFIG_PPC_HASH_MMU_NATIVE) += hash_native.o
|
2019-03-29 03:00:00 -07:00
|
|
|
obj-$(CONFIG_PPC_4K_PAGES) += hash_4k.o
|
|
|
|
obj-$(CONFIG_PPC_64K_PAGES) += hash_64k.o
|
2021-12-01 07:41:52 -07:00
|
|
|
obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hash_hugepage.o
|
|
|
|
obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage_prot.o
|
|
|
|
endif
|
|
|
|
|
2021-12-01 07:41:45 -07:00
|
|
|
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
|
2021-12-01 07:41:52 -07:00
|
|
|
|
|
|
|
obj-$(CONFIG_PPC_RADIX_MMU) += radix_pgtable.o radix_tlb.o
|
2019-03-29 03:00:00 -07:00
|
|
|
ifdef CONFIG_HUGETLB_PAGE
|
|
|
|
obj-$(CONFIG_PPC_RADIX_MMU) += radix_hugetlbpage.o
|
|
|
|
endif
|
|
|
|
obj-$(CONFIG_SPAPR_TCE_IOMMU) += iommu_api.o
|
2020-11-26 21:44:05 -07:00
|
|
|
obj-$(CONFIG_PPC_PKEY) += pkeys.o
|
2019-03-29 03:00:00 -07:00
|
|
|
|
|
|
|
# Instrumenting the SLB fault path can lead to duplicate SLB entries
|
|
|
|
KCOV_INSTRUMENT_slb.o := n
|
powerpc: Book3S 64-bit outline-only KASAN support
Implement a limited form of KASAN for Book3S 64-bit machines running under
the Radix MMU, supporting only outline mode.
- Enable the compiler instrumentation to check addresses and maintain the
shadow region. (This is the guts of KASAN which we can easily reuse.)
- Require kasan-vmalloc support to handle modules and anything else in
vmalloc space.
- KASAN needs to be able to validate all pointer accesses, but we can't
instrument all kernel addresses - only linear map and vmalloc. On boot,
set up a single page of read-only shadow that marks all iomap and
vmemmap accesses as valid.
- Document KASAN in powerpc docs.
Background
----------
KASAN support on Book3S is a bit tricky to get right:
- It would be good to support inline instrumentation so as to be able to
catch stack issues that cannot be caught with outline mode.
- Inline instrumentation requires a fixed offset.
- Book3S runs code with translations off ("real mode") during boot,
including a lot of generic device-tree parsing code which is used to
determine MMU features.
[ppc64 mm note: The kernel installs a linear mapping at effective
address c000...-c008.... This is a one-to-one mapping with physical
memory from 0000... onward. Because of how memory accesses work on
powerpc 64-bit Book3S, a kernel pointer in the linear map accesses the
same memory both with translations on (accessing as an 'effective
address'), and with translations off (accessing as a 'real
address'). This works in both guests and the hypervisor. For more
details, see s5.7 of Book III of version 3 of the ISA, in particular
the Storage Control Overview, s5.7.3, and s5.7.5 - noting that this
KASAN implementation currently only supports Radix.]
- Some code - most notably a lot of KVM code - also runs with translations
off after boot.
- Therefore any offset has to point to memory that is valid with
translations on or off.
One approach is just to give up on inline instrumentation. This way
boot-time checks can be delayed until after the MMU is set is up, and we
can just not instrument any code that runs with translations off after
booting. Take this approach for now and require outline instrumentation.
Previous attempts allowed inline instrumentation. However, they came with
some unfortunate restrictions: only physically contiguous memory could be
used and it had to be specified at compile time. Maybe we can do better in
the future.
[paulus@ozlabs.org - Rebased onto 5.17. Note that a kernel with
CONFIG_KASAN=y will crash during boot on a machine using HPT
translation because not all the entry points to the generic
KASAN code are protected with a call to kasan_arch_is_ready().]
Originally-by: Balbir Singh <bsingharora@gmail.com> # ppc64 out-of-line radix version
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
[mpe: Update copyright year and comment formatting]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/YoTE69OQwiG7z+Gu@cleo
2022-05-18 03:05:31 -07:00
|
|
|
|
|
|
|
# Parts of these can run in real mode and therefore are
|
|
|
|
# not safe with the current outline KASAN implementation
|
|
|
|
KASAN_SANITIZE_mmu_context.o := n
|
|
|
|
KASAN_SANITIZE_pgtable.o := n
|
|
|
|
KASAN_SANITIZE_radix_pgtable.o := n
|
|
|
|
KASAN_SANITIZE_radix_tlb.o := n
|
|
|
|
KASAN_SANITIZE_slb.o := n
|
|
|
|
KASAN_SANITIZE_pkeys.o := n
|