Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751938AbbDLR0f (ORCPT ); Sun, 12 Apr 2015 13:26:35 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39154 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751704AbbDLR03 (ORCPT ); Sun, 12 Apr 2015 13:26:29 -0400 Date: Sun, 12 Apr 2015 10:26:01 -0700 From: tip-bot for Denys Vlasenko Message-ID: Cc: dvlasenk@redhat.com, acme@kernel.org, a.p.zijlstra@chello.nl, hpa@zytor.com, paulus@samba.org, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, tglx@linutronix.de Reply-To: a.p.zijlstra@chello.nl, acme@kernel.org, hpa@zytor.com, dvlasenk@redhat.com, mingo@kernel.org, paulus@samba.org, linux-kernel@vger.kernel.org, jolsa@redhat.com, tglx@linutronix.de In-Reply-To: <1428671219-29341-1-git-send-email-dvlasenk@redhat.com> References: <1428671219-29341-1-git-send-email-dvlasenk@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] perf/x86/64: Do not guess user_regs->cs, ss, sp in get_regs_user() Git-Commit-ID: aa21df0424468dbd991440d41ba0f700c5997103 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3949 Lines: 99 Commit-ID: aa21df0424468dbd991440d41ba0f700c5997103 Gitweb: http://git.kernel.org/tip/aa21df0424468dbd991440d41ba0f700c5997103 Author: Denys Vlasenko AuthorDate: Fri, 10 Apr 2015 15:06:56 +0200 Committer: Ingo Molnar CommitDate: Sat, 11 Apr 2015 13:08:52 +0200 perf/x86/64: Do not guess user_regs->cs, ss, sp in get_regs_user() After recent changes to syscall entry points, user_regs->{cs,ss,sp} are always correct. (They used to be undefined while in syscalls). We can report them reliably, without guessing. Signed-off-by: Denys Vlasenko Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1428671219-29341-1-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/perf_regs.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c index 02a8720..7ab198a 100644 --- a/arch/x86/kernel/perf_regs.c +++ b/arch/x86/kernel/perf_regs.c @@ -131,8 +131,8 @@ void perf_get_regs_user(struct perf_regs *regs_user, } /* - * RIP, flags, and the argument registers are usually saved. - * orig_ax is probably okay, too. + * These registers are always saved on 64-bit syscall entry. + * On 32-bit entry points, they are saved too except r8..r11. */ regs_user_copy->ip = user_regs->ip; regs_user_copy->cx = user_regs->cx; @@ -145,9 +145,12 @@ void perf_get_regs_user(struct perf_regs *regs_user, regs_user_copy->r11 = user_regs->r11; regs_user_copy->orig_ax = user_regs->orig_ax; regs_user_copy->flags = user_regs->flags; + regs_user_copy->sp = user_regs->sp; + regs_user_copy->cs = user_regs->cs; + regs_user_copy->ss = user_regs->ss; /* - * Don't even try to report the "rest" regs. + * Most system calls don't save these registers, don't report them. */ regs_user_copy->bx = -1; regs_user_copy->bp = -1; @@ -158,7 +161,7 @@ void perf_get_regs_user(struct perf_regs *regs_user, /* * For this to be at all useful, we need a reasonable guess for - * sp and the ABI. Be careful: we're in NMI context, and we're + * the ABI. Be careful: we're in NMI context, and we're * considering current to be the current task, so we should * be careful not to look at any other percpu variables that might * change during context switches. @@ -167,9 +170,6 @@ void perf_get_regs_user(struct perf_regs *regs_user, task_thread_info(current)->status & TS_COMPAT) { /* Easy case: we're in a compat syscall. */ regs_user->abi = PERF_SAMPLE_REGS_ABI_32; - regs_user_copy->sp = user_regs->sp; - regs_user_copy->cs = user_regs->cs; - regs_user_copy->ss = user_regs->ss; } else if (user_regs->orig_ax != -1) { /* * We're probably in a 64-bit syscall. @@ -177,17 +177,12 @@ void perf_get_regs_user(struct perf_regs *regs_user, * than just blindly copying user_regs. */ regs_user->abi = PERF_SAMPLE_REGS_ABI_64; - regs_user_copy->sp = user_regs->sp; - regs_user_copy->cs = __USER_CS; - regs_user_copy->ss = __USER_DS; - regs_user_copy->cx = -1; /* usually contains garbage */ + /* usually contains return address (same as ->ip) */ + regs_user_copy->cx = -1; } else { /* We're probably in an interrupt or exception. */ regs_user->abi = user_64bit_mode(user_regs) ? PERF_SAMPLE_REGS_ABI_64 : PERF_SAMPLE_REGS_ABI_32; - regs_user_copy->sp = user_regs->sp; - regs_user_copy->cs = user_regs->cs; - regs_user_copy->ss = user_regs->ss; } regs_user->regs = regs_user_copy; -- 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/