From patchwork Thu Sep 15 13:49:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 76316 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2454319qgf; Thu, 15 Sep 2016 06:51:00 -0700 (PDT) X-Received: by 10.98.159.26 with SMTP id g26mr14678049pfe.137.1473947460774; Thu, 15 Sep 2016 06:51:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z89si7942290pff.2.2016.09.15.06.51.00; Thu, 15 Sep 2016 06:51:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934524AbcIONux (ORCPT + 27 others); Thu, 15 Sep 2016 09:50:53 -0400 Received: from foss.arm.com ([217.140.101.70]:37038 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934099AbcIONuN (ORCPT ); Thu, 15 Sep 2016 09:50:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C9319A78; Thu, 15 Sep 2016 06:50:07 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AF85C3F21A; Thu, 15 Sep 2016 06:50:05 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, james.morse@arm.com, keescook@chromium.org, linux-kernel@vger.kernel.org, lorenzo.pieralisi@arm.com, luto@kernel.org, mark.rutland@arm.com, suzuki.poulose@arm.com, takahiro.akashi@linaro.org, will.deacon@arm.com, kernel-hardening@lists.openwall.com Subject: [RFC PATCH 6/8] arm64: traps: use task_struct instead of thread_info Date: Thu, 15 Sep 2016 14:49:07 +0100 Message-Id: <1473947349-14521-7-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473947349-14521-1-git-send-email-mark.rutland@arm.com> References: <1473947349-14521-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In arm64's die and __die routines we pass around a thread_info, and subsequently use this to determine either the relevant task_struct, or the end of the thread's stack. This will shortly become problematic when we move the thread_info out of the thread's stack. Instead, pass around the task_struct, and use the new end_of_stack helper, which will work regardless of where thread_info is located. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/traps.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index e04f838..e9409a9 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -227,10 +227,9 @@ void show_stack(struct task_struct *tsk, unsigned long *sp) #endif #define S_SMP " SMP" -static int __die(const char *str, int err, struct thread_info *thread, +static int __die(const char *str, int err, struct task_struct *tsk, struct pt_regs *regs) { - struct task_struct *tsk = thread->task; static int die_counter; int ret; @@ -245,7 +244,8 @@ static int __die(const char *str, int err, struct thread_info *thread, print_modules(); __show_regs(regs); pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n", - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1); + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), + end_of_stack(tsk)); if (!user_mode(regs)) { dump_mem(KERN_EMERG, "Stack: ", regs->sp, @@ -264,7 +264,7 @@ static DEFINE_RAW_SPINLOCK(die_lock); */ void die(const char *str, struct pt_regs *regs, int err) { - struct thread_info *thread = current_thread_info(); + struct task_struct *tsk = current; int ret; oops_enter(); @@ -272,9 +272,9 @@ void die(const char *str, struct pt_regs *regs, int err) raw_spin_lock_irq(&die_lock); console_verbose(); bust_spinlocks(1); - ret = __die(str, err, thread, regs); + ret = __die(str, err, tsk, regs); - if (regs && kexec_should_crash(thread->task)) + if (regs && kexec_should_crash(tsk)) crash_kexec(regs); bust_spinlocks(0);