Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp755966ybh; Thu, 12 Mar 2020 10:31:38 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt3g2cq512WDnyg9m9lk2FzBViytEQEF2EVsLivSdkt0LADBF476McO3S+DJIU/uCI1WzpZ X-Received: by 2002:a9d:6ad9:: with SMTP id m25mr7411538otq.119.1584034298740; Thu, 12 Mar 2020 10:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584034298; cv=none; d=google.com; s=arc-20160816; b=EetQdfn+uh9+G+OIXgyiTIxFKm9wkEp8MotUO69QPmRON4ftHvnQQK79mvrMJYypOp /sSNUNBHCtNMeNLqNvBL4bvQ6KTpNIkYf+3+UxJ2ipxb6OV5imUhMH9uRZwOs01KSUk9 jGfcOuEVdY+pTldD2Nh3vX0baLR2Jx1bcymiwhUtNLf5bYL8Hv+iyaV1WTRqvRrYRwPv 8hzBUQF4pca75m0ZAtP4XOptn9KjdkSOmu/hX00zgqKfuJZ3JB8ofColsyyBb+sSetP1 2r8XTa3sgSrQFDf7979SQqZb8VGRB32fXKvdQDnysZYhXCzt67B0+cZ0ZlycTnREVioS V7vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zNgKjY4uG3pY18Bga7cSRfqY/wy2g8l/muxrIlSofrA=; b=m+cJGREjifEBmhOy0kU4gPO4Jxx8a0ncumkipOphVK7bgE9COsxNNTkb8UWg6bTa6M qY+pqgKNJceq69+PHlChD0YOHwZAbrn1D2p3dsv3EqXxZ+BjG20yEK9a99Kqzbqwsk9R 0DZo+4jCj7QCSuAcMj84pHWsoyZOfqGjsQmG+QreBt48uqckfd/FfEAYf+gAfJXVIvdc PIq6m3P8MuA0Kzaa2PttL6zYsSIwSvZp+BZ4s8e4GieMCaBVjrJVf6k2SSEO8q3JzouO B0ARndaIgv0oDgeetzIO9yTjsuTAHiFL2AYZlkPHlGQyJ0TpZJf9X/F2GazwXMQdCXg+ yEqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i2axZD6C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si3011985otx.151.2020.03.12.10.31.25; Thu, 12 Mar 2020 10:31:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i2axZD6C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726610AbgCLRbA (ORCPT + 99 others); Thu, 12 Mar 2020 13:31:00 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:51363 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726520AbgCLRa6 (ORCPT ); Thu, 12 Mar 2020 13:30:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584034257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zNgKjY4uG3pY18Bga7cSRfqY/wy2g8l/muxrIlSofrA=; b=i2axZD6CKWbql+cEIjpceOifGip7iG81qFImwhmQycOHVPPWbVuzy+oGLw1XnZ/sa6pz5f cW09FgapNhweQDscjuRPUpr1AOBSd9r2atPjZOHySC5TV+OQ2AYc/ugljt3O2AIxihZfRd v9C9/XjzyQYtaN8oz11y8i/jZighGps= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-owoaIwB5OGa2RdxUndfHQQ-1; Thu, 12 Mar 2020 13:30:53 -0400 X-MC-Unique: owoaIwB5OGa2RdxUndfHQQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A30709300C; Thu, 12 Mar 2020 17:30:51 +0000 (UTC) Received: from treble.redhat.com (ovpn-122-137.rdu2.redhat.com [10.10.122.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3983360C80; Thu, 12 Mar 2020 17:30:50 +0000 (UTC) From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Vince Weaver , Dave Jones , Jann Horn , Miroslav Benes , Andy Lutomirski , Steven Rostedt , Thomas Gleixner Subject: [PATCH 01/14] x86/dumpstack: Add SHOW_REGS_IRET mode Date: Thu, 12 Mar 2020 12:30:20 -0500 Message-Id: <2b2c601047136a4dbe42ed58715071e5323b5dae.1584033751.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that __show_regs() has the concept of "modes" to indicate which registers should be displayed, replace show_iret_regs() with a new SHOW_REGS_IRET mode. This is only a cleanup and doesn't change any behavior. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/kdebug.h | 1 + arch/x86/kernel/dumpstack.c | 27 ++++++++++----------------- arch/x86/kernel/process_64.c | 7 ++++++- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/kdebug.h b/arch/x86/include/asm/kdebug.= h index 247ab14c6309..6112227368e7 100644 --- a/arch/x86/include/asm/kdebug.h +++ b/arch/x86/include/asm/kdebug.h @@ -23,6 +23,7 @@ enum die_val { }; =20 enum show_regs_mode { + SHOW_REGS_IRET, SHOW_REGS_SHORT, /* * For when userspace crashed, but we don't think it's our fault, and diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index ae64ec7f752f..8a9ff25779ec 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -126,15 +126,8 @@ void show_ip(struct pt_regs *regs, const char *loglv= l) show_opcodes(regs, loglvl); } =20 -void show_iret_regs(struct pt_regs *regs) -{ - show_ip(regs, KERN_DEFAULT); - printk(KERN_DEFAULT "RSP: %04x:%016lx EFLAGS: %08lx", (int)regs->ss, - regs->sp, regs->flags); -} - static void show_regs_if_on_stack(struct stack_info *info, struct pt_reg= s *regs, - bool partial) + bool iret_only) { /* * These on_stack() checks aren't strictly necessary: the unwind code @@ -145,17 +138,17 @@ static void show_regs_if_on_stack(struct stack_info= *info, struct pt_regs *regs, * next stack, this function will be called again with the same regs so * they can be printed in the right context. */ - if (!partial && on_stack(info, regs, sizeof(*regs))) { + if (!iret_only && on_stack(info, regs, sizeof(*regs))) { __show_regs(regs, SHOW_REGS_SHORT); =20 - } else if (partial && on_stack(info, (void *)regs + IRET_FRAME_OFFSET, - IRET_FRAME_SIZE)) { + } else if (iret_only && on_stack(info, (void *)regs + IRET_FRAME_OFFSET= , + IRET_FRAME_SIZE)) { /* * When an interrupt or exception occurs in entry code, the * full pt_regs might not have been saved yet. In that case * just print the iret frame. */ - show_iret_regs(regs); + __show_regs(regs, SHOW_REGS_IRET); } } =20 @@ -166,13 +159,13 @@ void show_trace_log_lvl(struct task_struct *task, s= truct pt_regs *regs, struct stack_info stack_info =3D {0}; unsigned long visit_mask =3D 0; int graph_idx =3D 0; - bool partial =3D false; + bool iret_only =3D false; =20 printk("%sCall Trace:\n", log_lvl); =20 unwind_start(&state, task, regs, stack); stack =3D stack ? : get_stack_pointer(task, regs); - regs =3D unwind_get_entry_regs(&state, &partial); + regs =3D unwind_get_entry_regs(&state, &iret_only); =20 /* * Iterate through the stacks, starting with the current stack pointer. @@ -210,7 +203,7 @@ void show_trace_log_lvl(struct task_struct *task, str= uct pt_regs *regs, printk("%s <%s>\n", log_lvl, stack_name); =20 if (regs) - show_regs_if_on_stack(&stack_info, regs, partial); + show_regs_if_on_stack(&stack_info, regs, iret_only); =20 /* * Scan the stack, printing any text addresses we find. At the @@ -269,9 +262,9 @@ void show_trace_log_lvl(struct task_struct *task, str= uct pt_regs *regs, unwind_next_frame(&state); =20 /* if the frame has entry regs, print them */ - regs =3D unwind_get_entry_regs(&state, &partial); + regs =3D unwind_get_entry_regs(&state, &iret_only); if (regs) - show_regs_if_on_stack(&stack_info, regs, partial); + show_regs_if_on_stack(&stack_info, regs, iret_only); } =20 if (stack_name) diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index ffd497804dbc..d1986a63d403 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -71,7 +71,12 @@ void __show_regs(struct pt_regs *regs, enum show_regs_= mode mode) unsigned int fsindex, gsindex; unsigned int ds, es; =20 - show_iret_regs(regs); + show_ip(regs, KERN_DEFAULT); + printk(KERN_DEFAULT "RSP: %04x:%016lx EFLAGS: %08lx", (int)regs->ss, + regs->sp, regs->flags); + + if (mode =3D=3D SHOW_REGS_IRET) + return; =20 if (regs->orig_ax !=3D -1) pr_cont(" ORIG_RAX: %016lx\n", regs->orig_ax); --=20 2.21.1