From patchwork Thu Apr 6 12:48:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96950 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp714176qgd; Thu, 6 Apr 2017 05:49:22 -0700 (PDT) X-Received: by 10.84.216.24 with SMTP id m24mr43037127pli.96.1491482962040; Thu, 06 Apr 2017 05:49:22 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 124si1800045pgg.14.2017.04.06.05.49.21; Thu, 06 Apr 2017 05:49:22 -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 S1756991AbdDFMtU (ORCPT + 6 others); Thu, 6 Apr 2017 08:49:20 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:36688 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756857AbdDFMtQ (ORCPT ); Thu, 6 Apr 2017 08:49:16 -0400 Received: by mail-pg0-f49.google.com with SMTP id g2so34895030pge.3 for ; Thu, 06 Apr 2017 05:49:16 -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=oIM6W3JWgwhacxm915ljVSVBeQBEhShLWURkpWncr7Q=; b=eK5F7a48xMm7ycNVEwk8obW88k3UY0jLg6SyeGNaca5f5/zJ0mQyXGf1CLUrLM3Kd7 di+XFSo2pCtplShTpoPlun9eBfUVe/rTe8qRroDDAomAYdeWDpiZazJqUA3TB55z+Qu6 ryrXxsaj4eDOakDAyWnBmvNY6XVIX3gdqXdE4= 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=oIM6W3JWgwhacxm915ljVSVBeQBEhShLWURkpWncr7Q=; b=n1ng5SKwTBwnS4FQJ5eicrEbqPqkNynILJCcjtXNKwLizF0x0NWjbgEbkYhLJQl0FS 4tGZWvFpAW1LaCiOsxtWdiCw0ytrDH19l6chR5/TF1VCe/aaXfln3bqEVfhMIxt3Ld65 Sp5Y81RYHSaB5+nHQmHNVy7o7X8p2JuaGS4veQueYsNZQYO8iaGyYu0WjbnYIXLfiX3r GwfYgu1r1PbBkKzRspLgQ5qhfa5nV5TJU/lKVye1t+vl5LJ1/I3VmnJs3M5HbkJ4KMDq PlHyDgqCTnrsyPOPihAU199HSMmUkqp54n+6m9P3MuRsOUScXU+eH5n61XIFVDzk6qO0 phlA== X-Gm-Message-State: AFeK/H2Lo+ysFiVazm4/MD12LKt8+Iai4/Qc1nuEwWxy1Kk1W/Ajj6mh68XDwUjiMjLFszmd X-Received: by 10.99.176.5 with SMTP id h5mr36291190pgf.179.1491482954679; Thu, 06 Apr 2017 05:49:14 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id n7sm3892564pfn.0.2017.04.06.05.49.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Apr 2017 05:49:14 -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.4 2/7] MIPS: Stack unwinding while on IRQ stack Date: Thu, 6 Apr 2017 18:18:55 +0530 Message-Id: <1491482940-1163-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491482940-1163-1-git-send-email-amit.pundir@linaro.org> References: <1491482940-1163-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 fc537d1..8c26eca 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -552,7 +553,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