From patchwork Mon Jan 23 17:41:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 92264 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1335453qgi; Mon, 23 Jan 2017 09:42:07 -0800 (PST) X-Received: by 10.84.206.37 with SMTP id f34mr44883506ple.35.1485193327015; Mon, 23 Jan 2017 09:42:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si16316082pld.144.2017.01.23.09.42.06; Mon, 23 Jan 2017 09:42:07 -0800 (PST) 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=@linaro.org; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751461AbdAWRmB (ORCPT + 25 others); Mon, 23 Jan 2017 12:42:01 -0500 Received: from mail-io0-f174.google.com ([209.85.223.174]:34931 "EHLO mail-io0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751272AbdAWRl1 (ORCPT ); Mon, 23 Jan 2017 12:41:27 -0500 Received: by mail-io0-f174.google.com with SMTP id j18so115530109ioe.2 for ; Mon, 23 Jan 2017 09:41:27 -0800 (PST) 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=QmELpI1yQx8KG9aeiY/e8yP8uc5iky5fbqOe5tD9Uyg=; b=OErhm+X9PxhXNswGxPncxdbnyGLghHymeYOfnlsmiDxR3lf4ZXdiHqE6vqyWMfmID7 o7vy/kqupfGhjL4ek4O6Fr437lwSbbhQOBU6CGZ3Q74imaBHhwwQSQ0wRPbFnUmJqYoJ ezbEeYAxeofoxJivpaTvlNAZN0aFAKw1kKHWY= 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=QmELpI1yQx8KG9aeiY/e8yP8uc5iky5fbqOe5tD9Uyg=; b=WCz8YYv2f4/CLs/Vmb9wXxmSQ4YQqfxTVhcS9VI+8P9zmBNCKahrZ+R11j8Evy0jwK TmmsdBIxMZMuMewtsxSuwN+I/nDXqr4YsGOxWrvJ/kGxePjt8v78bW30f7itGC7JF0a2 duhdZ8Ttb8ls0oegLlSS3qboEV3IHRjY/m1R0a68Xq1EZWZnYsVeOha68UkPgtchHVah WlybY+5O6pGw7FIfDj8eZibVppBlaBwzrpc2LYgIBjOzMEm/wDj1fIH9nB0LpJak6Ddo cTgRMgHCCJo07t6fE0iEd3OoJ9s32/AUYRrhEnDzQhTNBRgeHh/kqzhovSN8U30jYFUA 7FIA== X-Gm-Message-State: AIkVDXLinO4B9ZodTzFY83nuCCMhPFdnuOen3x0NREGJfhIkv7KNJA51141iifPGL/kEMgc0 X-Received: by 10.107.190.196 with SMTP id o187mr25578286iof.95.1485193286878; Mon, 23 Jan 2017 09:41:26 -0800 (PST) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id t65sm2886736itt.12.2017.01.23.09.41.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Jan 2017 09:41:26 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] coresight: fix kernel panic caused by invalid CPU Date: Mon, 23 Jan 2017 10:41:22 -0700 Message-Id: <1485193284-31636-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485193284-31636-1-git-send-email-mathieu.poirier@linaro.org> References: <1485193284-31636-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Nan Commit d52c9750f150 ("coresight: reset "enable_sink" flag when need be") caused a kernel panic because of the using of an invalid value: after 'for_each_cpu(cpu, mask)', value of local variable 'cpu' become invalid, causes following 'cpu_to_node' access invalid memory area. This patch brings the deleted 'cpu = cpumask_first(mask)' back. Panic log: $ perf record -e cs_etm// ls Unable to handle kernel paging request at virtual address fffe801804af4f10 pgd = ffff8017ce031600 [fffe801804af4f10] *pgd=0000000000000000, *pud=0000000000000000 Internal error: Oops: 96000004 [#1] SMP Modules linked in: CPU: 33 PID: 1619 Comm: perf Not tainted 4.7.1+ #16 Hardware name: Huawei Taishan 2280 /CH05TEVBA, BIOS 1.10 11/24/2016 task: ffff8017cb0c8400 ti: ffff8017cb154000 task.ti: ffff8017cb154000 PC is at tmc_alloc_etf_buffer+0x60/0xd4 LR is at tmc_alloc_etf_buffer+0x44/0xd4 pc : [] lr : [] pstate: 60000145 sp : ffff8017cb157b40 x29: ffff8017cb157b40 x28: 0000000000000000 ...skip... 7a60: ffff000008c64dc8 0000000000000006 0000000000000253 ffffffffffffffff 7a80: 0000000000000000 0000000000000000 ffff0000080872cc 0000000000000001 [] tmc_alloc_etf_buffer+0x60/0xd4 [] etm_setup_aux+0x1dc/0x1e8 [] rb_alloc_aux+0x2b0/0x338 [] perf_mmap+0x414/0x568 [] mmap_region+0x324/0x544 [] do_mmap+0x334/0x3e0 [] vm_mmap_pgoff+0xa4/0xc8 [] SyS_mmap_pgoff+0xb0/0x22c [] sys_mmap+0x18/0x28 [] el0_svc_naked+0x24/0x28 Code: 912040a5 d0001c00 f873d821 911c6000 (b8656822) ---[ end trace 98933da8f92b0c9a ]--- Signed-off-by: Wang Nan Cc: Xia Kaixu Cc: Li Zefan Cc: Mathieu Poirier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm-perf.c | 1 + 1 file changed, 1 insertion(+) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 17741969026e..26cfac3e6de7 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -242,6 +242,7 @@ static void *etm_setup_aux(int event_cpu, void **pages, if (!sink_ops(sink)->alloc_buffer) goto err; + cpu = cpumask_first(mask); /* Get the AUX specific data from the sink buffer */ event_data->snk_config = sink_ops(sink)->alloc_buffer(sink, cpu, pages,