Blame SOURCES/gdb-rhbz1854784-powerpc-remove-region-limit-dawr-7of7.patch

4f0e34
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4f0e34
From: Rogerio Alves <rcardoso@linux.ibm.com>
4f0e34
Date: Wed, 7 Jul 2021 19:06:52 -0400
4f0e34
Subject: gdb-rhbz1854784-powerpc-remove-region-limit-dawr-7of7.patch
4f0e34
4f0e34
;; Backport "PowerPC remove 512 bytes region limit if 2nd DAWR is available."
4f0e34
;; (Rogerio Alves, RH BZ 1854784)
4f0e34
4f0e34
Power 10 introduces the 2nd DAWR (second watchpoint) and also removed
4f0e34
a restriction that limit the watch region to 512 bytes.
4f0e34
4f0e34
2020-11-08  Rogerio A. Cardoso  <rcardoso@linux.ibm.com>
4f0e34
4f0e34
/gdb
4f0e34
4f0e34
	* ppc-linux-nat.c: (PPC_DEBUG_FEATURE_DATA_BP_ARCH_31): New define.
4f0e34
	(region_ok_for_hw_watchpoint): Check if 2nd DAWR is avaliable before
4f0e34
	set region.
4f0e34
4f0e34
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
4f0e34
--- a/gdb/ppc-linux-nat.c
4f0e34
+++ b/gdb/ppc-linux-nat.c
4f0e34
@@ -144,6 +144,11 @@ struct ppc_hw_breakpoint
4f0e34
 #define PPC_DEBUG_FEATURE_DATA_BP_DAWR	0x10
4f0e34
 #endif /* PPC_DEBUG_FEATURE_DATA_BP_DAWR */
4f0e34
 
4f0e34
+/* Feature defined on Linux kernel v5.1: Second watchpoint support.  */
4f0e34
+#ifndef PPC_DEBUG_FEATURE_DATA_BP_ARCH_31
4f0e34
+#define PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 0x20
4f0e34
+#endif /* PPC_DEBUG_FEATURE_DATA_BP_ARCH_31 */
4f0e34
+
4f0e34
 /* The version of the PowerPC HWDEBUG kernel interface that we will use, if
4f0e34
    available.  */
4f0e34
 #define PPC_DEBUG_CURRENT_VERSION 1
4f0e34
@@ -2121,9 +2126,10 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
4f0e34
      watchpoints.  */
4f0e34
   if (m_dreg_interface.hwdebug_p ())
4f0e34
     {
4f0e34
-      int region_size;
4f0e34
       const struct ppc_debug_info &hwdebug_info = (m_dreg_interface
4f0e34
 						   .hwdebug_info ());
4f0e34
+      int region_size = hwdebug_info.data_bp_alignment;
4f0e34
+      int region_align = region_size;
4f0e34
 
4f0e34
       /* Embedded DAC-based processors, like the PowerPC 440 have ranged
4f0e34
 	 watchpoints and can watch any access within an arbitrary memory
4f0e34
@@ -2135,15 +2141,19 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
4f0e34
 	return 2;
4f0e34
       /* Check if the processor provides DAWR interface.  */
4f0e34
       if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
4f0e34
-	/* DAWR interface allows to watch up to 512 byte wide ranges which
4f0e34
-	   can't cross a 512 byte boundary.  */
4f0e34
-	region_size = 512;
4f0e34
-      else
4f0e34
-	region_size = hwdebug_info.data_bp_alignment;
4f0e34
+	{
4f0e34
+	  /* DAWR interface allows to watch up to 512 byte wide ranges.  */
4f0e34
+	  region_size = 512;
4f0e34
+	  /* DAWR interface allows to watch up to 512 byte wide ranges which
4f0e34
+	     can't cross a 512 byte bondary on machines that doesn't have a
4f0e34
+	     second DAWR (P9 or less).  */
4f0e34
+	  if (!(hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_ARCH_31))
4f0e34
+	    region_align = 512;
4f0e34
+	}
4f0e34
       /* Server processors provide one hardware watchpoint and addr+len should
4f0e34
          fall in the watchable region provided by the ptrace interface.  */
4f0e34
-      if (region_size
4f0e34
-	  && (addr + len > (addr & ~(region_size - 1)) + region_size))
4f0e34
+      if (region_align
4f0e34
+	  && (addr + len > (addr & ~(region_align - 1)) + region_size))
4f0e34
 	return 0;
4f0e34
     }
4f0e34
   /* addr+len must fall in the 8 byte watchable region for DABR-based