Blame SOURCES/gdb-rhbz1870029-powerpc-remove-region-limit-dawr.patch

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