From patchwork Thu Apr 6 13:16:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96964 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp726550qgd; Thu, 6 Apr 2017 06:16:35 -0700 (PDT) X-Received: by 10.84.129.195 with SMTP id b61mr43630402plb.83.1491484595673; Thu, 06 Apr 2017 06:16:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si1842368pgf.225.2017.04.06.06.16.35; Thu, 06 Apr 2017 06:16:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934716AbdDFNQe (ORCPT + 6 others); Thu, 6 Apr 2017 09:16:34 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:34020 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934703AbdDFNQ2 (ORCPT ); Thu, 6 Apr 2017 09:16:28 -0400 Received: by mail-pg0-f53.google.com with SMTP id 21so36268278pgg.1 for ; Thu, 06 Apr 2017 06:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QpTm2mstFzN49P7nRdltjahGOnEa2B/xZtj+f3QSx/o=; b=Ly/tn45M0o8Pik9a+w+9BjkjP9iOScMSkpBHBY40Sci3ZzNkGgOT7+oi/k/IO7d2GF gIeEDeV49ocRbojvPyXhrKHmfQLPhtmkAf4+6l7AeYPiywhlqJms7SiXYRkYcAM3GAzJ Kv/seSI/yw2jur2PHsnGgZxoCxXDJVrUTEVWI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QpTm2mstFzN49P7nRdltjahGOnEa2B/xZtj+f3QSx/o=; b=qmg+XE5YODqrl1StKCwZGzgjntrt26nXUwhKthBHT2eIaFJ378TXDlYKDxm6U8hLkt QqJMExNTW2EcgFqXwzAtXOL5ILZpl02y+zFv8lM+hxpwDgK/1ymV5cOfCdwXM4MgzrQG 18HMsHhT3ralmnCMSBFJZ2nqMG+MZci55zw/x2PN9W5cFy3I7br/3VRB5mGrhiTjIilQ C0680W200Cgkk/yc/DPPXZuc6KlwxDuLmkqMtOGDiBHastmP5wTZOVN4X02VgBeLCPAB G4aNyjM4K5kfvS8Z8QpTgFLdUdmvy7bWppbxP5BsWZxLrQy1lPHgn0kVSsXmQlYDeuDV tu9g== X-Gm-Message-State: AFeK/H1FkSToDipn+eeniMLlYGGawPbK5aGyR67u+VsEYRKsWMZZpY6yukw5FWoLD9O8oPYa X-Received: by 10.98.192.151 with SMTP id g23mr35345892pfk.254.1491484587051; Thu, 06 Apr 2017 06:16:27 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id y6sm4018940pgc.40.2017.04.06.06.16.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Apr 2017 06:16:26 -0700 (PDT) From: Amit Pundir To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, james.hogan@imgtec.com, Matt Redfearn , Thomas Gleixner , Adam Buchbinder , "Maciej W . Rozycki" , Marcin Nowakowski , Chris Metcalf , Paul Burton , Jiri Slaby , Andrew Morton , linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Ralf Baechle Subject: [PATCH for-4.9 2/7] MIPS: Stack unwinding while on IRQ stack Date: Thu, 6 Apr 2017 18:46:08 +0530 Message-Id: <1491484573-6228-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491484573-6228-1-git-send-email-amit.pundir@linaro.org> References: <1491484573-6228-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Matt Redfearn Within unwind stack, check if the stack pointer being unwound is within the CPU's irq_stack and if so use that page rather than the task's stack page. Signed-off-by: Matt Redfearn Acked-by: Jason A. Donenfeld Cc: Thomas Gleixner Cc: Adam Buchbinder Cc: Maciej W. Rozycki Cc: Marcin Nowakowski Cc: Chris Metcalf Cc: James Hogan Cc: Paul Burton Cc: Jiri Slaby Cc: Andrew Morton Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/14741/ Signed-off-by: Ralf Baechle (cherry picked from commit d42d8d106b0275b027c1e8992c42aecf933436ea) Signed-off-by: Amit Pundir --- arch/mips/kernel/process.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 1652f36..fbbf5fc 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -556,7 +557,19 @@ EXPORT_SYMBOL(unwind_stack_by_address); unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, unsigned long pc, unsigned long *ra) { - unsigned long stack_page = (unsigned long)task_stack_page(task); + unsigned long stack_page = 0; + int cpu; + + for_each_possible_cpu(cpu) { + if (on_irq_stack(cpu, *sp)) { + stack_page = (unsigned long)irq_stack[cpu]; + break; + } + } + + if (!stack_page) + stack_page = (unsigned long)task_stack_page(task); + return unwind_stack_by_address(stack_page, sp, pc, ra); } #endif