Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1203512

[PATCH 3.14 04/29] ARC: make sure instruction_pointer() returns unsigned value

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 3.14 04/29] ARC: make sure instruction_pointer() returns unsigned value
Date 2015-08-09 00:50 +0200
Message-ID <pVl6a-45c-7@gated-at.bofh.it> (permalink)
References <pVktr-3jX-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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

From: Alexey Brodkin <abrodkin@synopsys.com>

commit f51e2f1911122879eefefa4c592dea8bf794b39c upstream.

Currently instruction_pointer() returns pt_regs->ret and so return value
is of type "long", which implicitly stands for "signed long".

While that's perfectly fine when dealing with 32-bit values if return
value of instruction_pointer() gets assigned to 64-bit variable sign
extension may happen.

And at least in one real use-case it happens already.
In perf_prepare_sample() return value of perf_instruction_pointer()
(which is an alias to instruction_pointer() in case of ARC) is assigned
to (struct perf_sample_data)->ip (which type is "u64").

And what we see if instuction pointer points to user-space application
that in case of ARC lays below 0x8000_0000 "ip" gets set properly with
leading 32 zeros. But if instruction pointer points to kernel address
space that starts from 0x8000_0000 then "ip" is set with 32 leadig
"f"-s. I.e. id instruction_pointer() returns 0x8100_0000, "ip" will be
assigned with 0xffff_ffff__8100_0000. Which is obviously wrong.

In particular that issuse broke output of perf, because perf was unable
to associate addresses like 0xffff_ffff__8100_0000 with anything from
/proc/kallsyms.

That's what we used to see:
 ----------->8----------
  6.27%  ls       [unknown]                [k] 0xffffffff8046c5cc
  2.96%  ls       libuClibc-0.9.34-git.so  [.] memcpy
  2.25%  ls       libuClibc-0.9.34-git.so  [.] memset
  1.66%  ls       [unknown]                [k] 0xffffffff80666536
  1.54%  ls       libuClibc-0.9.34-git.so  [.] 0x000224d6
  1.18%  ls       libuClibc-0.9.34-git.so  [.] 0x00022472
 ----------->8----------

With that change perf output looks much better now:
 ----------->8----------
  8.21%  ls       [kernel.kallsyms]        [k] memset
  3.52%  ls       libuClibc-0.9.34-git.so  [.] memcpy
  2.11%  ls       libuClibc-0.9.34-git.so  [.] malloc
  1.88%  ls       libuClibc-0.9.34-git.so  [.] memset
  1.64%  ls       [kernel.kallsyms]        [k] _raw_spin_unlock_irqrestore
  1.41%  ls       [kernel.kallsyms]        [k] __d_lookup_rcu
 ----------->8----------

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: arc-linux-dev@synopsys.com
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arc/include/asm/ptrace.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arc/include/asm/ptrace.h
+++ b/arch/arc/include/asm/ptrace.h
@@ -63,7 +63,7 @@ struct callee_regs {
 	long r25, r24, r23, r22, r21, r20, r19, r18, r17, r16, r15, r14, r13;
 };
 
-#define instruction_pointer(regs)	((regs)->ret)
+#define instruction_pointer(regs)	(unsigned long)((regs)->ret)
 #define profile_pc(regs)		instruction_pointer(regs)
 
 /* return 1 if user mode or 0 if kernel mode */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.14 00/29] 3.14.50-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 11/29] mmc: sdhci-esdhc: Make 8BIT bus work Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 04/29] ARC: make sure instruction_pointer() returns unsigned value Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 26/29] avr32: handle NULL as a valid clock object Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 07/29] ALSA: usb-audio: add dB range mapping for some devices Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 15/29] Input: usbtouchscreen - avoid unresponsive TSC-30 touch screen Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 16/29] blkcg: fix gendisk reference leak in blkg_conf_prep() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 17/29] ata: pmp: add quirk for Marvell 4140 SATA PMP Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 24/29] rds: rds_ib_device.refcount overflow Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 23/29] x86/efi: Use all 64 bit of efi_memmap in setup_e820() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 20/29] xhci: report U3 when link is in resume state Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 10/29] mac80211: clear subdir_stations when removing debugfs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 19/29] xhci: Calculate old endpoints correctly on device reset Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 03/29] s390/sclp: clear upper register halves in _sclp_print_early Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 27/29] iscsi-target: Fix use-after-free during TPG session shutdown Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 02/29] freeing unlinked file indefinitely delayed Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  [PATCH 3.14 01/29] mm: avoid setting up anonymous pages into file mapping Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-09 00:50 +0200
  Re: [PATCH 3.14 00/29] 3.14.50-stable review Guenter Roeck <linux@roeck-us.net> - 2015-08-09 05:20 +0200
    Re: [PATCH 3.14 00/29] 3.14.50-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-08-10 21:20 +0200
  Re: [PATCH 3.14 00/29] 3.14.50-stable review Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-08-10 07:10 +0200

csiph-web