public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk,
	Jason Wessel <jason.wessel@windriver.com>
Subject: [ 46/78] kgdb,debug_core: pass the breakpoint struct instead of address and memory
Date: Wed, 11 Apr 2012 16:11:04 -0700	[thread overview]
Message-ID: <20120411231026.059050794@linuxfoundation.org> (raw)
In-Reply-To: <20120411231102.GA6404@kroah.com>

3.3-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jason Wessel <jason.wessel@windriver.com>

commit 98b54aa1a2241b59372468bd1e9c2d207bdba54b upstream.

There is extra state information that needs to be exposed in the
kgdb_bpt structure for tracking how a breakpoint was installed.  The
debug_core only uses the the probe_kernel_write() to install
breakpoints, but this is not enough for all the archs.  Some arch such
as x86 need to use text_poke() in order to install a breakpoint into a
read only page.

Passing the kgdb_bpt structure to kgdb_arch_set_breakpoint() and
kgdb_arch_remove_breakpoint() allows other archs to set the type
variable which indicates how the breakpoint was installed.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 include/linux/kgdb.h      |    4 +--
 kernel/debug/debug_core.c |   53 ++++++++++++++++++++--------------------------
 2 files changed, 26 insertions(+), 31 deletions(-)

--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -207,8 +207,8 @@ extern void kgdb_arch_set_pc(struct pt_r
 
 /* Optional functions. */
 extern int kgdb_validate_break_address(unsigned long addr);
-extern int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr);
-extern int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle);
+extern int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt);
+extern int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt);
 
 /**
  *	kgdb_arch_late - Perform any architecture specific initalization.
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -157,37 +157,39 @@ early_param("nokgdbroundup", opt_nokgdbr
  * Weak aliases for breakpoint management,
  * can be overriden by architectures when needed:
  */
-int __weak kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
+int __weak kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
 {
 	int err;
 
-	err = probe_kernel_read(saved_instr, (char *)addr, BREAK_INSTR_SIZE);
+	err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
+				BREAK_INSTR_SIZE);
 	if (err)
 		return err;
-
-	return probe_kernel_write((char *)addr, arch_kgdb_ops.gdb_bpt_instr,
-				  BREAK_INSTR_SIZE);
+	err = probe_kernel_write((char *)bpt->bpt_addr,
+				 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
+	return err;
 }
 
-int __weak kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
+int __weak kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
 {
-	return probe_kernel_write((char *)addr,
-				  (char *)bundle, BREAK_INSTR_SIZE);
+	return probe_kernel_write((char *)bpt->bpt_addr,
+				  (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
 }
 
 int __weak kgdb_validate_break_address(unsigned long addr)
 {
-	char tmp_variable[BREAK_INSTR_SIZE];
+	struct kgdb_bkpt tmp;
 	int err;
-	/* Validate setting the breakpoint and then removing it.  In the
+	/* Validate setting the breakpoint and then removing it.  If the
 	 * remove fails, the kernel needs to emit a bad message because we
 	 * are deep trouble not being able to put things back the way we
 	 * found them.
 	 */
-	err = kgdb_arch_set_breakpoint(addr, tmp_variable);
+	tmp.bpt_addr = addr;
+	err = kgdb_arch_set_breakpoint(&tmp);
 	if (err)
 		return err;
-	err = kgdb_arch_remove_breakpoint(addr, tmp_variable);
+	err = kgdb_arch_remove_breakpoint(&tmp);
 	if (err)
 		printk(KERN_ERR "KGDB: Critical breakpoint error, kernel "
 		   "memory destroyed at: %lx", addr);
@@ -231,7 +233,6 @@ static void kgdb_flush_swbreak_addr(unsi
  */
 int dbg_activate_sw_breakpoints(void)
 {
-	unsigned long addr;
 	int error;
 	int ret = 0;
 	int i;
@@ -240,16 +241,15 @@ int dbg_activate_sw_breakpoints(void)
 		if (kgdb_break[i].state != BP_SET)
 			continue;
 
-		addr = kgdb_break[i].bpt_addr;
-		error = kgdb_arch_set_breakpoint(addr,
-				kgdb_break[i].saved_instr);
+		error = kgdb_arch_set_breakpoint(&kgdb_break[i]);
 		if (error) {
 			ret = error;
-			printk(KERN_INFO "KGDB: BP install failed: %lx", addr);
+			printk(KERN_INFO "KGDB: BP install failed: %lx",
+			       kgdb_break[i].bpt_addr);
 			continue;
 		}
 
-		kgdb_flush_swbreak_addr(addr);
+		kgdb_flush_swbreak_addr(kgdb_break[i].bpt_addr);
 		kgdb_break[i].state = BP_ACTIVE;
 	}
 	return ret;
@@ -298,7 +298,6 @@ int dbg_set_sw_break(unsigned long addr)
 
 int dbg_deactivate_sw_breakpoints(void)
 {
-	unsigned long addr;
 	int error;
 	int ret = 0;
 	int i;
@@ -306,15 +305,14 @@ int dbg_deactivate_sw_breakpoints(void)
 	for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) {
 		if (kgdb_break[i].state != BP_ACTIVE)
 			continue;
-		addr = kgdb_break[i].bpt_addr;
-		error = kgdb_arch_remove_breakpoint(addr,
-					kgdb_break[i].saved_instr);
+		error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);
 		if (error) {
-			printk(KERN_INFO "KGDB: BP remove failed: %lx\n", addr);
+			printk(KERN_INFO "KGDB: BP remove failed: %lx\n",
+			       kgdb_break[i].bpt_addr);
 			ret = error;
 		}
 
-		kgdb_flush_swbreak_addr(addr);
+		kgdb_flush_swbreak_addr(kgdb_break[i].bpt_addr);
 		kgdb_break[i].state = BP_SET;
 	}
 	return ret;
@@ -348,7 +346,6 @@ int kgdb_isremovedbreak(unsigned long ad
 
 int dbg_remove_all_break(void)
 {
-	unsigned long addr;
 	int error;
 	int i;
 
@@ -356,12 +353,10 @@ int dbg_remove_all_break(void)
 	for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) {
 		if (kgdb_break[i].state != BP_ACTIVE)
 			goto setundefined;
-		addr = kgdb_break[i].bpt_addr;
-		error = kgdb_arch_remove_breakpoint(addr,
-				kgdb_break[i].saved_instr);
+		error = kgdb_arch_remove_breakpoint(&kgdb_break[i]);
 		if (error)
 			printk(KERN_ERR "KGDB: breakpoint remove failed: %lx\n",
-			   addr);
+			       kgdb_break[i].bpt_addr);
 setundefined:
 		kgdb_break[i].state = BP_UNDEFINED;
 	}



  parent reply	other threads:[~2012-04-11 23:57 UTC|newest]

Thread overview: 169+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11 23:11 [ 00/78] 3.3.2-stable review Greg KH
2012-04-11 23:10 ` [ 01/78] x86 bpf_jit: fix a bug in emitting the 16-bit immediate operand of AND Greg KH
2012-04-11 23:10 ` [ 02/78] via-rhine: fix wait-bit inversion Greg KH
2012-04-11 23:10 ` [ 03/78] tg3: Fix 5717 serdes powerdown problem Greg KH
2012-04-11 23:10 ` [ 04/78] sky2: dont overwrite settings for PHY Quick link Greg KH
2012-04-11 23:10 ` [ 05/78] rose_dev: fix memcpy-bug in rose_set_mac_address Greg KH
2012-04-11 23:10 ` [ 06/78] net: usb: cdc_eem: fix mtu Greg KH
2012-04-11 23:10 ` [ 07/78] Fix non TBI PHY access; a bad merge undid bug fix in a previous commit Greg KH
2012-04-11 23:10 ` [ 08/78] ALSA: hda/realtek - Fix ADC assignment with a shared HP/Mic pin Greg KH
2012-04-11 23:10 ` [ 09/78] ASoC: wm8994: Update WM8994 DCS calibration Greg KH
2012-04-11 23:10 ` [ 10/78] mtd: ixp4xx: oops in ixp4xx_flash_probe Greg KH
2012-04-11 23:10 ` [ 11/78] mtd: mips: lantiq: reintroduce support for cmdline partitions Greg KH
2012-04-11 23:10 ` [ 12/78] mtd: nand: gpmi: use correct member for checking NAND_BBT_USE_FLASH Greg KH
2012-04-11 23:10 ` [ 13/78] mtd: sst25l: initialize writebufsize Greg KH
2012-04-11 23:10 ` [ 14/78] mtd: doc2001plus: " Greg KH
2012-04-11 23:10 ` [ 15/78] mtd: doc2000: " Greg KH
2012-04-11 23:10 ` [ 16/78] mtd: doc2001: " Greg KH
2012-04-11 23:10 ` [ 17/78] mtd: docg3: " Greg KH
2012-04-11 23:10 ` [ 18/78] mtd: block2mtd: " Greg KH
2012-04-11 23:10 ` [ 19/78] mtd: lart: " Greg KH
2012-04-11 23:10 ` [ 20/78] mtd: m25p80: set writebufsize Greg KH
2012-04-11 23:10 ` [ 21/78] ACPI: Do cpufreq clamping for throttling per package v2 Greg KH
2012-04-11 23:10 ` [ 22/78] PNPACPI: Fix device ref leaking in acpi_pnp_match Greg KH
2012-04-11 23:10 ` [ 23/78] ACPICA: Fix regression in FADT revision checks Greg KH
2012-04-11 23:10 ` [ 24/78] modpost: fix ALL_INIT_DATA_SECTIONS Greg KH
2012-04-11 23:10 ` [ 25/78] genirq: Adjust irq thread affinity on IRQ_SET_MASK_OK_NOCOPY return value Greg KH
2012-04-11 23:10 ` [ 26/78] tracing: Fix ftrace stack trace entries Greg KH
2012-04-11 23:10 ` [ 27/78] tracing: Fix ent_size in trace output Greg KH
2012-04-11 23:10 ` [ 28/78] m68k/mac: Add missing platform check before registering platform devices Greg KH
2012-04-11 23:10 ` [ 29/78] mac80211: fix possible tid_rx->reorder_timer use after free Greg KH
2012-04-11 23:10 ` [ 30/78] rtlwifi: rtl8192ce: rtl8192cu: rtl8192de: Fix low-gain setting when scanning Greg KH
2012-04-11 23:10 ` [ 31/78] ath9k: fix max noise floor threshold Greg KH
2012-04-14  5:36   ` Ben Hutchings
2012-04-14  6:26     ` Rajkumar Manoharan
2012-04-11 23:10 ` [ 32/78] drm: Validate requested virtual size against allocated fb size Greg KH
2012-04-11 23:10 ` [ 33/78] drm/radeon/kms: fix fans after resume Greg KH
2012-04-11 23:10 ` [ 34/78] drm/i915: no-lvds quirk on MSI DC500 Greg KH
2012-04-11 23:10 ` [ 35/78] drm/i915: treat src w & h as fixed point in sprite handling code Greg KH
2012-04-11 23:10 ` [ 36/78] drm/i915: Sanitize BIOS debugging bits from PIPECONF Greg KH
2012-04-11 23:10 ` [ 37/78] drm/i915: Add lock on drm_helper_resume_force_mode Greg KH
2012-04-11 23:10 ` [ 38/78] drm/i915: quirk away broken OpRegion VBT Greg KH
2012-04-11 23:10 ` [ 39/78] firmware_class: Rework usermodehelper check Greg KH
2012-04-11 23:10 ` [ 40/78] firmware_class: Split _request_firmware() into three functions, v2 Greg KH
2012-04-11 23:10 ` [ 41/78] firmware_class: Do not warn that system is not ready from async loads Greg KH
2012-04-11 23:11 ` [ 42/78] PM / Runtime: dont forget to wake up waitqueue on failure Greg KH
2012-04-14  5:23   ` Ben Hutchings
2012-04-11 23:11 ` [ 43/78] PM / Hibernate: Disable usermode helpers right before freezing tasks Greg KH
2012-04-11 23:11 ` [ 44/78] PM / Sleep: Move disabling of usermode helpers to the freezer Greg KH
2012-04-11 23:11 ` [ 45/78] PM / Sleep: Mitigate race between the freezer and request_firmware() Greg KH
2012-04-11 23:11 ` Greg KH [this message]
2012-04-11 23:11 ` [ 47/78] kgdbts: Fix kernel oops with CONFIG_DEBUG_RODATA Greg KH
2012-04-11 23:11 ` [ 48/78] kgdbts: (1 of 2) fix single step awareness to work correctly with SMP Greg KH
2012-04-11 23:11 ` [ 49/78] kgdbts: (2 " Greg KH
2012-04-11 23:11 ` [ 50/78] x86,kgdb: Fix DEBUG_RODATA limitation using text_poke() Greg KH
2012-04-11 23:11 ` [ 51/78] CIFS: Fix VFS lock usage for oplocked files Greg KH
2012-04-11 23:11 ` [ 52/78] USB: ohci-at91: fix vbus_pin_active_low handling Greg KH
2012-04-11 23:11 ` [ 53/78] ARM: at91/USB host: specify and handle properly vbus_pin_active_low Greg KH
2012-04-11 23:11 ` [ 54/78] mmc: sdio: Use empty system suspend/resume callbacks at the bus level Greg KH
2012-04-11 23:11 ` [ 55/78] mmc: sdhci-dove: Fix compile error by including module.h Greg KH
2012-04-11 23:11 ` [ 56/78] mmc: atmel-mci: correct data timeout computation Greg KH
2012-04-11 23:11 ` [ 57/78] tcm_fc: Add abort flag for gracefully handling exchange timeout Greg KH
2012-04-11 23:11 ` [ 58/78] tcm_fc: Do not free tpg structure during wq allocation failure Greg KH
2012-04-11 23:11 ` [ 59/78] sysctl: fix write access to dmesg_restrict/kptr_restrict Greg KH
2012-04-11 23:11 ` [ 60/78] regmap: prevent division by zero in rbtree_show Greg KH
2012-04-11 23:11 ` [ 61/78] modpost: Fix modpost license checking of vmlinux.o Greg KH
2012-04-11 23:11 ` [ 62/78] mfd: Fix section mismatch warning for da9052-spi Greg KH
2012-04-11 23:11 ` [ 63/78] android, lowmemorykiller: remove task handoff notifier Greg KH
2012-04-11 23:11 ` [ 64/78] TOMOYO: Fix mount flags checking order Greg KH
2012-04-11 23:11 ` [ 65/78] iwlegacy: do not nulify il->vif on reset Greg KH
2012-04-11 23:11 ` [ 66/78] Revert "x86/ioapic: Add register level checks to detect bogus io-apic entries" Greg KH
2012-04-11 23:11 ` [ 67/78] acer-wmi: No wifi rfkill on Sony machines Greg KH
2012-04-11 23:11 ` [ 68/78] Fix length of buffer copied in __nfs4_get_acl_uncached Greg KH
2012-04-11 23:11 ` [ 69/78] sched/x86: Fix overflow in cyc2ns_offset Greg KH
2012-04-11 23:11 ` [ 70/78] mfd: Clear twl6030 IRQ status register only once Greg KH
2012-04-11 23:11 ` [ 71/78] USB: Add Motorola Rokr E6 Id to the USBNet driver "zaurus" Greg KH
2012-04-11 23:11 ` [ 72/78] ioat: fix size of completion for Xen Greg KH
2012-04-11 23:11 ` [ 73/78] [media] uvcvideo: Fix race-related crash in uvc_video_clock_update() Greg KH
2012-04-11 23:11 ` [ 74/78] ASoC: ak4642: fixup: mute needs +1 step Greg KH
2012-04-11 23:11 ` [ 75/78] ASoC: tegra: fix i2s compilation when !CONFIG_DEBUG_FS Greg KH
2012-04-11 23:11 ` [ 76/78] media: dvb_frontend: regression fix: userspace ABI broken for xine Greg KH
2012-04-11 23:11 ` [ 77/78] media: dvb-core: fix DVBFE_ALGO_HW retune bug Greg KH
2012-04-11 23:11 ` [ 78/78] cred: copy_process() should clear child->replacement_session_keyring Greg KH
2012-04-11 23:59 ` [ 00/78] 3.3.2-stable review Sergio Correia
2012-04-12  0:29   ` Greg KH
2012-04-12  0:57     ` Sergio Correia
2012-04-12  1:03     ` Felipe Contreras
2012-04-12  1:13       ` Greg KH
2012-04-12 13:32         ` Felipe Contreras
2012-04-12 14:46           ` Greg KH
2012-04-12 16:49             ` Felipe Contreras
2012-04-12 17:24               ` Adrian Chadd
2012-04-12 18:43                 ` Felipe Contreras
2012-04-12 18:56                   ` Jonathan Nieder
2012-04-12 21:34                     ` Felipe Contreras
2012-04-12 21:43                       ` Willy Tarreau
2012-04-12 20:07                   ` Greg KH
2012-04-12 20:52                     ` Sven-Haegar Koch
2012-04-13  8:57                   ` Stefan Richter
2012-04-13 10:29                     ` Felipe Contreras
2012-04-13 13:42                       ` Stefan Richter
2012-04-13 14:01                         ` Stefan Richter
2012-04-13 22:38                         ` Felipe Contreras
2012-04-13 23:05                           ` Jonathan Nieder
2012-04-13 23:18                             ` Felipe Contreras
2012-04-14  5:44                               ` Willy Tarreau
2012-04-14 15:43                                 ` Felipe Contreras
2012-04-14 16:02                                   ` Willy Tarreau
2012-04-14  9:10                               ` Stefan Richter
2012-04-14 15:52                                 ` Felipe Contreras
2012-04-14 18:08                                   ` Stefan Richter
2012-04-14  7:41                           ` Stefan Richter
2012-04-14 15:29                             ` Felipe Contreras
2012-04-14 15:57                               ` Willy Tarreau
2012-04-14 19:33                                 ` Felipe Contreras
2012-04-14 19:58                                   ` Willy Tarreau
2012-04-14 17:55                               ` Stefan Richter
2012-04-14 19:21                                 ` Felipe Contreras
2012-04-14 21:21                                   ` Stefan Richter
2012-04-14 22:09                                     ` Felipe Contreras
2012-04-14 22:47                                       ` Stefan Richter
2012-04-14 22:56                                         ` Felipe Contreras
2012-04-14 23:06                                           ` Adrian Chadd
2012-04-13 19:08                       ` [ath9k-devel] " Peter Stuge
2012-04-13 22:53                         ` Felipe Contreras
2012-04-14  6:01                           ` Willy Tarreau
2012-04-16 16:27                           ` Greg KH
2012-04-16 20:11                             ` Felipe Contreras
2012-04-16 20:58                               ` Greg KH
2012-04-16 21:18                                 ` Felipe Contreras
2012-04-16 21:27                                   ` Greg KH
2012-04-16 21:44                                     ` Felipe Contreras
2012-04-16 22:34                                       ` Peter Stuge
2012-04-17  5:24                                       ` Willy Tarreau
2012-04-16 21:50                                     ` Felipe Contreras
2012-04-16 21:54                                       ` Don deJuan
2012-04-16 22:02                                       ` Don deJuan
2012-04-16 21:39                                   ` Don deJuan
2012-04-12 18:40               ` Willy Tarreau
2012-04-12 19:05               ` Linus Torvalds
2012-04-12 21:20                 ` Felipe Contreras
2012-04-12 21:34                   ` Linus Torvalds
2012-04-12 21:44                     ` Linus Torvalds
2012-04-12 22:02                       ` [ath9k-devel] " Luis R. Rodriguez
2012-04-12 22:04                     ` Felipe Contreras
2012-04-12 22:07                       ` Linus Torvalds
2012-04-12 22:29                         ` Felipe Contreras
2012-04-14 10:47                           ` Ingo Molnar
2012-04-14 15:59                             ` Felipe Contreras
2012-04-15  6:51                               ` Ingo Molnar
2012-04-15 17:15                                 ` Felipe Contreras
2012-04-15 17:29                                   ` Willy Tarreau
2012-04-15 17:49                                   ` Linus Torvalds
2012-04-15 22:12                                     ` Felipe Contreras
2012-04-16  5:32                                       ` Ingo Molnar
2012-04-16 20:25                                         ` Felipe Contreras
2012-04-16 21:08                                           ` Arend van Spriel
2012-04-16  5:39                                       ` Willy Tarreau
2012-04-16  6:38                                         ` Ingo Molnar
2012-04-12 22:12                       ` David Miller
2012-04-12 22:58                         ` Felipe Contreras
2012-04-13  5:34                           ` Willy Tarreau
2012-04-13 10:04                             ` Felipe Contreras
2012-04-12 21:39                   ` Willy Tarreau
2012-04-12 22:02                   ` Jesper Juhl
2012-04-12 19:57     ` Alexander Holler
2012-04-12 20:06       ` Greg KH
2012-04-12 20:30         ` Alexander Holler
2012-04-12 22:31           ` Greg KH
2012-04-12  4:16   ` Heinz Diehl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120411231026.059050794@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jason.wessel@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox