Skip to contentSkip to conversation

couple of minor DAWR fixes

PATCH In review Nicholas Piggin 2 participants 5 messages Apr 1, 2018 – Apr 3, 2018

Subsystems (2)
lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

cover couple of minor DAWR fixes

Nicholas Piggin (2):
KVM: PPC: Book3S HV: Fix ppc_breakpoint_available compile error
powerpc: Fix DABR write in the case of DAWR disabled

 arch/powerpc/kernel/process.c | 13 +++++++++----
 arch/powerpc/kvm/book3s_hv.c  |  1 +
 2 files changed, 10 insertions(+), 4 deletions(-)
Signature · 1 line
2.16.3
author reviewer
#1 lore raw

PATCH 1/2 KVM: PPC: Book3S HV: Fix ppc_breakpoint_available compile error

arch/powerpc/kvm/book3s_hv.c: In function ‘kvmppc_h_set_mode’:
arch/powerpc/kvm/book3s_hv.c:745:8: error: implicit declaration of function ‘ppc_breakpoint_available’; did you mean ‘hw_breakpoint_disable’? [-Werror=implicit-function-declaration]
if (!ppc_breakpoint_available())

        ^~~~~~~~~~~~~~~~~~~~~~~~
        hw_breakpoint_disable
Cc Michael Neuling <[email protected]>
Fixes 398e712c00 ("KVM: PPC: Book3S HV: Return error from h_set_mode(SET_DAWR) on POWER9")
---
 arch/powerpc/kvm/book3s_hv.c | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kvm/book3s_hv.c +1 -0
index 948642e16338..81e2ea882d97 100644
@@ -49,6 +49,7 @@
 #include <asm/reg.h>
 #include <asm/ppc-opcode.h>
 #include <asm/asm-prototypes.h>
+#include <asm/debug.h>
 #include <asm/disassemble.h>
 #include <asm/cputable.h>
 #include <asm/cacheflush.h>
Signature · 1 line
2.16.3
#2 lore raw

Re: [1/2] KVM: PPC: Book3S HV: Fix ppc_breakpoint_available compile error

Quoted 9 lines · Nicholas Piggin

arch/powerpc/kvm/book3s_hv.c: In function ‘kvmppc_h_set_mode’:
arch/powerpc/kvm/book3s_hv.c:745:8: error: implicit declaration of function ‘ppc_breakpoint_available’; did you mean ‘hw_breakpoint_disable’? [-Werror=implicit-function-declaration]
if (!ppc_breakpoint_available())

        ^~~~~~~~~~~~~~~~~~~~~~~~
        hw_breakpoint_disable
Cc Michael Neuling <[email protected]>
Fixes 398e712c00 ("KVM: PPC: Book3S HV: Return error from h_set_mode(SET_DAWR) on POWER9")

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/e303c08787c4cbe1ca07912817dff2

cheers

author reviewer
#3 lore raw

PATCH 2/2 powerpc: Fix DABR write in the case of DAWR disabled

In reply to Nicholas Piggin

flush_thread will call set_breakpoint via set_debug_reg_defaults, and cause POWER8 and above CPUs without the DAWR feature to try to write to DAWR.

---
 arch/powerpc/kernel/process.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
arch/powerpc/kernel/process.c +9 -4
index 24a591b4dbe9..bfcf5437083c 100644
@@ -718,7 +718,8 @@ static void set_debug_reg_defaults(struct thread_struct *thread)
 {
 	thread->hw_brk.address = 0;
 	thread->hw_brk.type = 0;
-	set_breakpoint(&thread->hw_brk);
+	if (ppc_breakpoint_available())
+		set_breakpoint(&thread->hw_brk);
 }
 #endif /* !CONFIG_HAVE_HW_BREAKPOINT */
 #endif	/* CONFIG_PPC_ADV_DEBUG_REGS */
@@ -814,10 +815,14 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
 {
 	memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk));
 
-	if (cpu_has_feature(CPU_FTR_DAWR))
-		set_dawr(brk);
-	else
+	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
+		if (cpu_has_feature(CPU_FTR_DAWR))
+			set_dawr(brk);
+		else
+			WARN_ON_ONCE(1);
+	} else {
 		set_dabr(brk);
+	}
 }
 
 void set_breakpoint(struct arch_hw_breakpoint *brk)
Signature · 1 line
2.16.3
author reviewer
#4 lore raw

Re: [PATCH 2/2] powerpc: Fix DABR write in the case of DAWR disabled

Quoted 3 lines · On Sun, 1 Apr 2018 15:50:36 +1000 Nicholas Piggin <[email protected]> wrote:

flush_thread will call set_breakpoint via set_debug_reg_defaults, and cause POWER8 and above CPUs without the DAWR feature to try to write to DAWR.

              ^^^^
              DABR
Quoted 39 lines
---
 arch/powerpc/kernel/process.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
arch/powerpc/kernel/process.c +9 -4
index 24a591b4dbe9..bfcf5437083c 100644
@@ -718,7 +718,8 @@ static void set_debug_reg_defaults(struct thread_struct *thread)
 {
 	thread->hw_brk.address = 0;
 	thread->hw_brk.type = 0;
-	set_breakpoint(&thread->hw_brk);
+	if (ppc_breakpoint_available())
+		set_breakpoint(&thread->hw_brk);
 }
 #endif /* !CONFIG_HAVE_HW_BREAKPOINT */
 #endif	/* CONFIG_PPC_ADV_DEBUG_REGS */
@@ -814,10 +815,14 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
 {
 	memcpy(this_cpu_ptr(&current_brk), brk, sizeof(*brk));
 
-	if (cpu_has_feature(CPU_FTR_DAWR))
-		set_dawr(brk);
-	else
+	if (cpu_has_feature(CPU_FTR_ARCH_207S)) {
+		if (cpu_has_feature(CPU_FTR_DAWR))
+			set_dawr(brk);
+		else
+			WARN_ON_ONCE(1);
+	} else {
 		set_dabr(brk);
+	}
 }
 
 void set_breakpoint(struct arch_hw_breakpoint *brk)