dawr-power9.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. =====================
  2. DAWR issues on POWER9
  3. =====================
  4. On POWER9 the Data Address Watchpoint Register (DAWR) can cause a checkstop
  5. if it points to cache inhibited (CI) memory. Currently Linux has no way to
  6. disinguish CI memory when configuring the DAWR, so (for now) the DAWR is
  7. disabled by this commit::
  8. commit 9654153158d3e0684a1bdb76dbababdb7111d5a0
  9. Author: Michael Neuling <mikey@neuling.org>
  10. Date: Tue Mar 27 15:37:24 2018 +1100
  11. powerpc: Disable DAWR in the base POWER9 CPU features
  12. Technical Details:
  13. ==================
  14. DAWR has 6 different ways of being set.
  15. 1) ptrace
  16. 2) h_set_mode(DAWR)
  17. 3) h_set_dabr()
  18. 4) kvmppc_set_one_reg()
  19. 5) xmon
  20. For ptrace, we now advertise zero breakpoints on POWER9 via the
  21. PPC_PTRACE_GETHWDBGINFO call. This results in GDB falling back to
  22. software emulation of the watchpoint (which is slow).
  23. h_set_mode(DAWR) and h_set_dabr() will now return an error to the
  24. guest on a POWER9 host. Current Linux guests ignore this error, so
  25. they will silently not get the DAWR.
  26. kvmppc_set_one_reg() will store the value in the vcpu but won't
  27. actually set it on POWER9 hardware. This is done so we don't break
  28. migration from POWER8 to POWER9, at the cost of silently losing the
  29. DAWR on the migration.
  30. For xmon, the 'bd' command will return an error on P9.
  31. Consequences for users
  32. ======================
  33. For GDB watchpoints (ie 'watch' command) on POWER9 bare metal , GDB
  34. will accept the command. Unfortunately since there is no hardware
  35. support for the watchpoint, GDB will software emulate the watchpoint
  36. making it run very slowly.
  37. The same will also be true for any guests started on a POWER9
  38. host. The watchpoint will fail and GDB will fall back to software
  39. emulation.
  40. If a guest is started on a POWER8 host, GDB will accept the watchpoint
  41. and configure the hardware to use the DAWR. This will run at full
  42. speed since it can use the hardware emulation. Unfortunately if this
  43. guest is migrated to a POWER9 host, the watchpoint will be lost on the
  44. POWER9. Loads and stores to the watchpoint locations will not be
  45. trapped in GDB. The watchpoint is remembered, so if the guest is
  46. migrated back to the POWER8 host, it will start working again.
  47. Force enabling the DAWR
  48. =======================
  49. Kernels (since ~v5.2) have an option to force enable the DAWR via::
  50. echo Y > /sys/kernel/debug/powerpc/dawr_enable_dangerous
  51. This enables the DAWR even on POWER9.
  52. This is a dangerous setting, USE AT YOUR OWN RISK.
  53. Some users may not care about a bad user crashing their box
  54. (ie. single user/desktop systems) and really want the DAWR. This
  55. allows them to force enable DAWR.
  56. This flag can also be used to disable DAWR access. Once this is
  57. cleared, all DAWR access should be cleared immediately and your
  58. machine once again safe from crashing.
  59. Userspace may get confused by toggling this. If DAWR is force
  60. enabled/disabled between getting the number of breakpoints (via
  61. PTRACE_GETHWDBGINFO) and setting the breakpoint, userspace will get an
  62. inconsistent view of what's available. Similarly for guests.
  63. For the DAWR to be enabled in a KVM guest, the DAWR needs to be force
  64. enabled in the host AND the guest. For this reason, this won't work on
  65. POWERVM as it doesn't allow the HCALL to work. Writes of 'Y' to the
  66. dawr_enable_dangerous file will fail if the hypervisor doesn't support
  67. writing the DAWR.
  68. To double check the DAWR is working, run this kernel selftest:
  69. tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
  70. Any errors/failures/skips mean something is wrong.