14d2e26a3SMauro Carvalho Chehab===================== 24d2e26a3SMauro Carvalho ChehabDAWR issues on POWER9 34d2e26a3SMauro Carvalho Chehab===================== 44d2e26a3SMauro Carvalho Chehab 5*26b78c81SReza ArbabOn older POWER9 processors, the Data Address Watchpoint Register (DAWR) can 6*26b78c81SReza Arbabcause a checkstop if it points to cache inhibited (CI) memory. Currently Linux 7*26b78c81SReza Arbabhas no way to distinguish CI memory when configuring the DAWR, so on affected 8*26b78c81SReza Arbabsystems, the DAWR is disabled. 94d2e26a3SMauro Carvalho Chehab 10*26b78c81SReza ArbabAffected processor revisions 11*26b78c81SReza Arbab============================ 12*26b78c81SReza Arbab 13*26b78c81SReza ArbabThis issue is only present on processors prior to v2.3. The revision can be 14*26b78c81SReza Arbabfound in /proc/cpuinfo:: 15*26b78c81SReza Arbab 16*26b78c81SReza Arbab processor : 0 17*26b78c81SReza Arbab cpu : POWER9, altivec supported 18*26b78c81SReza Arbab clock : 3800.000000MHz 19*26b78c81SReza Arbab revision : 2.3 (pvr 004e 1203) 20*26b78c81SReza Arbab 21*26b78c81SReza ArbabOn a system with the issue, the DAWR is disabled as detailed below. 224d2e26a3SMauro Carvalho Chehab 234d2e26a3SMauro Carvalho ChehabTechnical Details: 244d2e26a3SMauro Carvalho Chehab================== 254d2e26a3SMauro Carvalho Chehab 264d2e26a3SMauro Carvalho ChehabDAWR has 6 different ways of being set. 274d2e26a3SMauro Carvalho Chehab1) ptrace 284d2e26a3SMauro Carvalho Chehab2) h_set_mode(DAWR) 294d2e26a3SMauro Carvalho Chehab3) h_set_dabr() 304d2e26a3SMauro Carvalho Chehab4) kvmppc_set_one_reg() 314d2e26a3SMauro Carvalho Chehab5) xmon 324d2e26a3SMauro Carvalho Chehab 334d2e26a3SMauro Carvalho ChehabFor ptrace, we now advertise zero breakpoints on POWER9 via the 344d2e26a3SMauro Carvalho ChehabPPC_PTRACE_GETHWDBGINFO call. This results in GDB falling back to 354d2e26a3SMauro Carvalho Chehabsoftware emulation of the watchpoint (which is slow). 364d2e26a3SMauro Carvalho Chehab 374d2e26a3SMauro Carvalho Chehabh_set_mode(DAWR) and h_set_dabr() will now return an error to the 384d2e26a3SMauro Carvalho Chehabguest on a POWER9 host. Current Linux guests ignore this error, so 394d2e26a3SMauro Carvalho Chehabthey will silently not get the DAWR. 404d2e26a3SMauro Carvalho Chehab 414d2e26a3SMauro Carvalho Chehabkvmppc_set_one_reg() will store the value in the vcpu but won't 424d2e26a3SMauro Carvalho Chehabactually set it on POWER9 hardware. This is done so we don't break 434d2e26a3SMauro Carvalho Chehabmigration from POWER8 to POWER9, at the cost of silently losing the 444d2e26a3SMauro Carvalho ChehabDAWR on the migration. 454d2e26a3SMauro Carvalho Chehab 464d2e26a3SMauro Carvalho ChehabFor xmon, the 'bd' command will return an error on P9. 474d2e26a3SMauro Carvalho Chehab 484d2e26a3SMauro Carvalho ChehabConsequences for users 494d2e26a3SMauro Carvalho Chehab====================== 504d2e26a3SMauro Carvalho Chehab 514d2e26a3SMauro Carvalho ChehabFor GDB watchpoints (ie 'watch' command) on POWER9 bare metal , GDB 524d2e26a3SMauro Carvalho Chehabwill accept the command. Unfortunately since there is no hardware 534d2e26a3SMauro Carvalho Chehabsupport for the watchpoint, GDB will software emulate the watchpoint 544d2e26a3SMauro Carvalho Chehabmaking it run very slowly. 554d2e26a3SMauro Carvalho Chehab 564d2e26a3SMauro Carvalho ChehabThe same will also be true for any guests started on a POWER9 574d2e26a3SMauro Carvalho Chehabhost. The watchpoint will fail and GDB will fall back to software 584d2e26a3SMauro Carvalho Chehabemulation. 594d2e26a3SMauro Carvalho Chehab 604d2e26a3SMauro Carvalho ChehabIf a guest is started on a POWER8 host, GDB will accept the watchpoint 614d2e26a3SMauro Carvalho Chehaband configure the hardware to use the DAWR. This will run at full 624d2e26a3SMauro Carvalho Chehabspeed since it can use the hardware emulation. Unfortunately if this 634d2e26a3SMauro Carvalho Chehabguest is migrated to a POWER9 host, the watchpoint will be lost on the 644d2e26a3SMauro Carvalho ChehabPOWER9. Loads and stores to the watchpoint locations will not be 654d2e26a3SMauro Carvalho Chehabtrapped in GDB. The watchpoint is remembered, so if the guest is 664d2e26a3SMauro Carvalho Chehabmigrated back to the POWER8 host, it will start working again. 674d2e26a3SMauro Carvalho Chehab 684d2e26a3SMauro Carvalho ChehabForce enabling the DAWR 694d2e26a3SMauro Carvalho Chehab======================= 704d2e26a3SMauro Carvalho ChehabKernels (since ~v5.2) have an option to force enable the DAWR via:: 714d2e26a3SMauro Carvalho Chehab 724d2e26a3SMauro Carvalho Chehab echo Y > /sys/kernel/debug/powerpc/dawr_enable_dangerous 734d2e26a3SMauro Carvalho Chehab 744d2e26a3SMauro Carvalho ChehabThis enables the DAWR even on POWER9. 754d2e26a3SMauro Carvalho Chehab 764d2e26a3SMauro Carvalho ChehabThis is a dangerous setting, USE AT YOUR OWN RISK. 774d2e26a3SMauro Carvalho Chehab 784d2e26a3SMauro Carvalho ChehabSome users may not care about a bad user crashing their box 794d2e26a3SMauro Carvalho Chehab(ie. single user/desktop systems) and really want the DAWR. This 804d2e26a3SMauro Carvalho Chehaballows them to force enable DAWR. 814d2e26a3SMauro Carvalho Chehab 824d2e26a3SMauro Carvalho ChehabThis flag can also be used to disable DAWR access. Once this is 834d2e26a3SMauro Carvalho Chehabcleared, all DAWR access should be cleared immediately and your 844d2e26a3SMauro Carvalho Chehabmachine once again safe from crashing. 854d2e26a3SMauro Carvalho Chehab 864d2e26a3SMauro Carvalho ChehabUserspace may get confused by toggling this. If DAWR is force 874d2e26a3SMauro Carvalho Chehabenabled/disabled between getting the number of breakpoints (via 884d2e26a3SMauro Carvalho ChehabPTRACE_GETHWDBGINFO) and setting the breakpoint, userspace will get an 894d2e26a3SMauro Carvalho Chehabinconsistent view of what's available. Similarly for guests. 904d2e26a3SMauro Carvalho Chehab 914d2e26a3SMauro Carvalho ChehabFor the DAWR to be enabled in a KVM guest, the DAWR needs to be force 924d2e26a3SMauro Carvalho Chehabenabled in the host AND the guest. For this reason, this won't work on 934d2e26a3SMauro Carvalho ChehabPOWERVM as it doesn't allow the HCALL to work. Writes of 'Y' to the 944d2e26a3SMauro Carvalho Chehabdawr_enable_dangerous file will fail if the hypervisor doesn't support 954d2e26a3SMauro Carvalho Chehabwriting the DAWR. 964d2e26a3SMauro Carvalho Chehab 974d2e26a3SMauro Carvalho ChehabTo double check the DAWR is working, run this kernel selftest: 984d2e26a3SMauro Carvalho Chehab 994d2e26a3SMauro Carvalho Chehab tools/testing/selftests/powerpc/ptrace/ptrace-hwbreak.c 1004d2e26a3SMauro Carvalho Chehab 1014d2e26a3SMauro Carvalho ChehabAny errors/failures/skips mean something is wrong. 102