← Documents Documentation/arch/powerpc/dawr-power9.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

DAWR Issues on POWER9

POWER9 revision별 DAWR checkstop 위험과 ptrace/KVM/GDB fallback 정책을 설명합니다.

Source pathDocumentation/arch/powerpc/dawr-power9.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

dawr-power9.rst:1-101

POWER9 v2.3 이전에는 CI memory를 가리키는 DAWR이 checkstop을 만들 수 있어 기본 disable됩니다. 강제 enable은 debugfs에서 가능하지만 host/guest와 hypervisor 조건을 모두 확인해야 합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =====================
2 DAWR issues on POWER9
3 =====================
4
5 On older POWER9 processors, the Data Address Watchpoint Register (DAWR) can
6 cause a checkstop if it points to cache inhibited (CI) memory. Currently Linux
7 has no way to distinguish CI memory when configuring the DAWR, so on affected
8 systems, the DAWR is disabled.
9
10 Affected processor revisions
11 ============================
12
13 This issue is only present on processors prior to v2.3. The revision can be
14 found in /proc/cpuinfo::
15
16 processor : 0
17 cpu : POWER9, altivec supported
18 clock : 3800.000000MHz
19 revision : 2.3 (pvr 004e 1203)
20
21 On a system with the issue, the DAWR is disabled as detailed below.
22
23 Technical Details:
24 ==================
25
26 DAWR has 6 different ways of being set.
27 1) ptrace
28 2) h_set_mode(DAWR)
29 3) h_set_dabr()
30 4) kvmppc_set_one_reg()
31 5) xmon
32
33 For ptrace, we now advertise zero breakpoints on POWER9 via the
34 PPC_PTRACE_GETHWDBGINFO call. This results in GDB falling back to
35 software emulation of the watchpoint (which is slow).
36
37 h_set_mode(DAWR) and h_set_dabr() will now return an error to the
38 guest on a POWER9 host. Current Linux guests ignore this error, so
39 they will silently not get the DAWR.
40
41 kvmppc_set_one_reg() will store the value in the vcpu but won't
42 actually set it on POWER9 hardware. This is done so we don't break
43 migration from POWER8 to POWER9, at the cost of silently losing the
44 DAWR on the migration.
45
46 For xmon, the 'bd' command will return an error on P9.
47
48 Consequences for users
49 ======================
50
51 For GDB watchpoints (ie 'watch' command) on POWER9 bare metal , GDB
52 will accept the command. Unfortunately since there is no hardware
53 support for the watchpoint, GDB will software emulate the watchpoint
54 making it run very slowly.
55
56 The same will also be true for any guests started on a POWER9
57 host. The watchpoint will fail and GDB will fall back to software
58 emulation.
59
60 If a guest is started on a POWER8 host, GDB will accept the watchpoint
61 and configure the hardware to use the DAWR. This will run at full
62 speed since it can use the hardware emulation. Unfortunately if this
63 guest is migrated to a POWER9 host, the watchpoint will be lost on the
64 POWER9. Loads and stores to the watchpoint locations will not be
65 trapped in GDB. The watchpoint is remembered, so if the guest is
66 migrated back to the POWER8 host, it will start working again.
67
68 Force enabling the DAWR
69 =======================
70 Kernels (since ~v5.2) have an option to force enable the DAWR via::
71
72 echo Y > /sys/kernel/debug/powerpc/dawr_enable_dangerous
73
74 This enables the DAWR even on POWER9.
75
76 This is a dangerous setting, USE AT YOUR OWN RISK.
77
78 Some users may not care about a bad user crashing their box
79 (ie. single user/desktop systems) and really want the DAWR. This
80 allows them to force enable DAWR.
81
82 This flag can also be used to disable DAWR access. Once this is
83 cleared, all DAWR access should be cleared immediately and your
84 machine once again safe from crashing.
85
86 Userspace may get confused by toggling this. If DAWR is force
87 enabled/disabled between getting the number of breakpoints (via
88 PTRACE_GETHWDBGINFO) and setting the breakpoint, userspace will get an
89 inconsistent view of what's available. Similarly for guests.
90
91 For the DAWR to be enabled in a KVM guest, the DAWR needs to be force
92 enabled in the host AND the guest. For this reason, this won't work on
93 POWERVM as it doesn't allow the HCALL to work. Writes of 'Y' to the
94 dawr_enable_dangerous file will fail if the hypervisor doesn't support
95 writing the DAWR.
96
97 To double check the DAWR is working, run this kernel selftest:
98
99 tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c
100
101 Any errors/failures/skips mean something is wrong.
102

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

POWER9 DAWR checkstop 문제

1-9

오래된 POWER9 processor에서는 Data Address Watchpoint Register (`DAWR`)가 cache inhibited (`CI`) memory를 가리키면 checkstop이 발생할 수 있습니다. 현재 Linux는 DAWR을 설정할 때 CI memory를 구분할 방법이 없으므로 영향을 받는 system에서는 DAWR을 disable합니다.

영향받는 processor revision

10-22

이 문제는 v2.3 이전 processor에만 존재합니다. Revision은 `/proc/cpuinfo`의 `revision` field에서 확인할 수 있습니다.

processor       : 0
cpu             : POWER9, altivec supported
clock           : 3800.000000MHz
revision        : 2.3 (pvr 004e 1203)

예시는 POWER9 revision 2.3 (`pvr 004e 1203`)이며, 문제가 있는 system에서는 아래 정책에 따라 DAWR이 disable됩니다.

DAWR 설정 경로별 동작

23-47

원문은 DAWR 설정 방식이 6개라고 쓰지만 실제 목록에는 `ptrace`, `h_set_mode(DAWR)`, `h_set_dabr()`, `kvmppc_set_one_reg()`, `xmon`의 5개만 열거합니다.

설정 경로영향받는 POWER9에서의 동작
`ptrace``PPC_PTRACE_GETHWDBGINFO`에서 hardware breakpoint 수 0을 알립니다. GDB는 느린 software watchpoint emulation으로 fallback합니다.
`h_set_mode(DAWR)`POWER9 host가 guest에 error를 반환합니다. 현재 Linux guest는 error를 무시하므로 DAWR을 얻지 못한 사실이 조용히 숨겨집니다.
`h_set_dabr()``h_set_mode(DAWR)`과 같이 POWER9 host에서 guest에 error를 반환합니다.
`kvmppc_set_one_reg()`값은 vCPU에 저장하지만 POWER9 hardware에는 설정하지 않습니다. POWER8에서 POWER9로 migration을 깨지 않기 위한 대신 DAWR이 조용히 사라집니다.
`xmon`P9에서 `bd` command가 error를 반환합니다.

사용자에게 나타나는 결과

48-67

POWER9 bare-metal에서 GDB `watch` command는 받아들여지지만 hardware watchpoint가 없어 software로 emulate되므로 매우 느립니다. POWER9 host에서 시작한 guest도 watchpoint 설정이 실패하고 GDB가 software emulation으로 fallback합니다.

POWER8 host에서 시작한 guest는 DAWR hardware watchpoint를 full speed로 사용할 수 있습니다. 그러나 이 guest를 POWER9 host로 migrate하면 watchpoint가 사라져 해당 location의 load/store가 GDB에 trap되지 않습니다. Watchpoint 설정 자체는 기억되므로 POWER8 host로 다시 migrate하면 재동작합니다.

POWER8/POWER9 watchpoint 동작
상태GDB watchpoint 결과속도/위험
POWER9 bare metalSoftware emulation매우 느림
POWER9에서 시작한 guestSoftware emulation매우 느림
POWER8 guestDAWR hardware 사용Full speed
POWER8 → POWER9 migrationDAWR 소실Load/store trap 없음
다시 POWER8로 migration기억된 watchpoint 복원Full speed

Host와 migration 상태에 따라 hardware watchpoint의 유효성이 달라집니다.

DAWR 강제 enable과 검증

68-101

대략 Linux v5.2부터 debugfs option으로 POWER9에서도 DAWR을 강제로 enable할 수 있습니다.

echo Y > /sys/kernel/debug/powerpc/dawr_enable_dangerous

이 설정은 위험하며 사용자가 모든 위험을 감수해야 합니다. 악의적 user가 system을 crash할 가능성을 감수할 수 있는 single-user 또는 desktop system에서만 고려할 수 있습니다.

이 flag로 DAWR access를 다시 disable할 수도 있습니다. 값을 clear하면 모든 DAWR access가 즉시 제거되어 machine이 crash 위험에서 다시 안전해져야 합니다.

`PTRACE_GETHWDBGINFO`로 breakpoint 수를 읽은 시점과 실제 breakpoint 설정 사이에 DAWR을 toggle하면 userspace가 서로 모순된 capability를 보게 됩니다. Guest도 같은 문제가 있습니다.

KVM guest에서 DAWR을 쓰려면 host와 guest 양쪽에서 강제 enable해야 합니다. POWERVM은 필요한 HCALL을 허용하지 않으므로 이 방식이 동작하지 않습니다. Hypervisor가 DAWR write를 지원하지 않으면 `dawr_enable_dangerous`에 `Y`를 쓰는 작업도 실패합니다.

DAWR 동작은 다음 kernel selftest로 재확인합니다.

tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c

Error, failure, skip 중 하나라도 나오면 DAWR configuration에 문제가 있다는 뜻입니다.

DAWR force-enable 조건
Host `dawr_enable_dangerous=Y`Hypervisor DAWR write 지원Guest도 force enableKVM guest DAWR
POWERVMHCALL 차단Guest DAWR 사용 불가

Guest 사용에는 host와 guest 설정, hypervisor write 지원이 모두 필요합니다.