kasan.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. KASAN is supported on powerpc on 32-bit and Radix 64-bit only.
  2. 32 bit support
  3. ==============
  4. KASAN is supported on both hash and nohash MMUs on 32-bit.
  5. The shadow area sits at the top of the kernel virtual memory space above the
  6. fixmap area and occupies one eighth of the total kernel virtual memory space.
  7. Instrumentation of the vmalloc area is optional, unless built with modules,
  8. in which case it is required.
  9. 64 bit support
  10. ==============
  11. Currently, only the radix MMU is supported. There have been versions for hash
  12. and Book3E processors floating around on the mailing list, but nothing has been
  13. merged.
  14. KASAN support on Book3S is a bit tricky to get right:
  15. - It would be good to support inline instrumentation so as to be able to catch
  16. stack issues that cannot be caught with outline mode.
  17. - Inline instrumentation requires a fixed offset.
  18. - Book3S runs code with translations off ("real mode") during boot, including a
  19. lot of generic device-tree parsing code which is used to determine MMU
  20. features.
  21. - Some code - most notably a lot of KVM code - also runs with translations off
  22. after boot.
  23. - Therefore any offset has to point to memory that is valid with
  24. translations on or off.
  25. One approach is just to give up on inline instrumentation. This way boot-time
  26. checks can be delayed until after the MMU is set is up, and we can just not
  27. instrument any code that runs with translations off after booting. This is the
  28. current approach.
  29. To avoid this limitiation, the KASAN shadow would have to be placed inside the
  30. linear mapping, using the same high-bits trick we use for the rest of the linear
  31. mapping. This is tricky:
  32. - We'd like to place it near the start of physical memory. In theory we can do
  33. this at run-time based on how much physical memory we have, but this requires
  34. being able to arbitrarily relocate the kernel, which is basically the tricky
  35. part of KASLR. Not being game to implement both tricky things at once, this
  36. is hopefully something we can revisit once we get KASLR for Book3S.
  37. - Alternatively, we can place the shadow at the _end_ of memory, but this
  38. requires knowing how much contiguous physical memory a system has _at compile
  39. time_. This is a big hammer, and has some unfortunate consequences: inablity
  40. to handle discontiguous physical memory, total failure to boot on machines
  41. with less memory than specified, and that machines with more memory than
  42. specified can't use it. This was deemed unacceptable.