Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2797068ybv; Sat, 15 Feb 2020 03:51:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz1MX/e/IMNuM8klwV2xayxtoyARL6SjdA9QEHxb8zzU1UrRHmtMEH74HYQbL1ErFmw45Mj X-Received: by 2002:a9d:3bc4:: with SMTP id k62mr5951666otc.186.1581767461721; Sat, 15 Feb 2020 03:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581767461; cv=none; d=google.com; s=arc-20160816; b=TGdgCxY7nDKM2e7gOSRvpO2wDVdQq37Nu86mrm7m1tOJs/0B9LwB4HdufqMHBx+cdP yWa2fsU2AbM9CBoow9qeEEqXx8yQxhVACvVrT6Z3tjRsp9zCgxyA2Z6G5A4CCk/yIaJ3 tMdRU5RwFagtOF1LQY2nYyXKilHf0DFiI3FU28MTVCpDUakxusEGZuJGW9a/YTlkdET3 G8MROAXVUahrY9Az12Qb8Wx1Jp6CnlHRZNyui3NoPhSXxLIa4nbOgi0oCXxmBxtGr9gm pZQXES+O7/SLXghXij7Ye0sgdWfu3fERNzRwUenDHj887FHo4AT52RR1n0H7HGtrVzZp 7PSw== 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:references :in-reply-to:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aDjOBugZQ0SawLe+YxF3NbyjsZWKVVzA64MmA1w5uAk=; b=t7xqE7Qus5LJjyNdkSKs4DKsxYPEDuoPD5cdLLlpBBYzKQNM/ugq4HObS5yVc3F34g YbpuWl8TgOMe/PwQMcp/UfqkHRFWUIZQlsBCBk4+BrwT1+MkY7Z0Ef+dJeWuLLYqMO+1 BANgVEIV+QRoRb41EJGgkEKC0wOosKf3Ys320thAn+3b4uuW07fq7IxhiSUSTsVFV/AM JN5A1fF7rFuXte4QEFBcJ6OKKTPtlG6Wkp8r4TFCGU7+T1AEgPY9Xun6bB950t+7nrfq Tc/N88aT7xwQpTn3Ivq9NB3rcxSBkwMogH1P/UoiUsW9BUg8QgnYrFzvfu83euUyhiii W6rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@web.de header.s=dbaedf251592 header.b=mJKgCbiZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si4291649otn.12.2020.02.15.03.50.37; Sat, 15 Feb 2020 03:51:01 -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=@web.de header.s=dbaedf251592 header.b=mJKgCbiZ; 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 S1726402AbgBOLub (ORCPT + 99 others); Sat, 15 Feb 2020 06:50:31 -0500 Received: from mout.web.de ([217.72.192.78]:56481 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725965AbgBOLub (ORCPT ); Sat, 15 Feb 2020 06:50:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1581767418; bh=AKoI1ErJ1F/3SpqbaXivBShhVSF+4DVb1UPwPn9K9xA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References: In-Reply-To:References; b=mJKgCbiZ6DsG9pBjmp7Q/rVR1rt+ZjyUt4bwBodh29xfJDK95Hf8fOWZ8V8r1/D/D 946137HXeT5QJiUdRyX0Y6wU6z4SJ7eloxGf9Z4hlu2mnrBH29k/ZCsurRKceJ3R3d LASFjszsZAHIzYwQdfkUVh82xOKaMRoU4Nrs4jLE= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from md1f2u6c.ww002.siemens.net ([95.157.55.156]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MgO8g-1io06e15Py-00NgBR; Sat, 15 Feb 2020 12:50:18 +0100 From: Jan Kiszka To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] riscv: Fix crash when flushing executable ioremap regions Date: Sat, 15 Feb 2020 12:49:44 +0100 Message-Id: <8a555b0b0934f0ba134de92f6cf9db8b1744316c.1581767384.git.jan.kiszka@web.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V03:K1:3afGuyjXHZCaYg9y6mqcxZGBFQUaKdU7SqI4fBIhgjLUotUcjdu VuaSdTlCtsF3UnKqxPCCuX3NSTqYet+hsYgyVjRvAtcglfc77wGgfKg+q7l0b+vgEzSXcNM CiUzO8c4RrB3QFdyLZ+qc7PDN/+V1/qFsrrpPM56toO4IU9MQKuZcZYGhSJu63JCbKnsU7S ZlR79w+tspHae7bOSXjzA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:+JySpZD7Yok=:62+NnABRoebGkDXmyK+Xd0 eIJzRv8R5y2HGLiph7dktdAh0js3t0mQv4c2wcwhvcmveAgBoNukvjArwWPZ1xJizFVJSnpMA T3RUtWXubYB/CYg5SHFgKRGYO8kTC75cQJaYw+oBcwlpmV2yQiDH6PdhAQTv2bPn6AkLWfYjK GU26KrfV5KMVSaVaufxWdY3bi99mEUq8hXTHCXUh8OfKs/NBUOUW3KFjUzncjXh7Ma6mNvSiy lv6sWnRtg4Qi8LnQcsI3NpGtbZGsOC60A11lgT5qj71vAlzawDn+u69zhg0WLvEfCdT/2yGHU aHnGP9/660kNYKEk9c4Pkwph32RGBzxYJjJOP3Bx238unJ2wV4f0K+WZwz8lCjdO7PTA28Qol vgFFah1+fg+aCriLfS7xuW7C6PgBAD/I7APg7Gb4N4ZOAysN/JI/Yfz8j3QlR6ljh1jBkkwjC QY1hyt0n/Qs+VluYFX08NJ3PNxcXiT6xLZ+dK/NRyRBGio0DrsWe41Uqghs7sVF+w2l5lck2F 8DsI1A7BRs2MsRgSWgVHIB/UjhePROJOHNx2Wb08qblh9aODzTVOGiuj0E/NXWHZm6vlrOsOm e/ylsWEdqfuFKzLEuweXpenDl2TS1ZePSQY8dMvxg/kbD4FEZo0pAcNnJ44re6chXxgmUMw7j pyg3ubd9Lc1lMdFVzsp/bJe8LdMvAFDecJbuti4Q7zUOaOd+IYXBjYSLAzpMbaY3TZuU6pmrB n+52WvX0fvou7EHsREhNu3GyLkDjCTfXzEm/Mlw69mD0SXd14nyhKG/uzHTrcPqMBZDP7J0Q+ 4iVMRbrN3FV6h+nfYMSz3uRXd0zETqklRNxTKx17xU4nXt5NWCijmijRpf4f/AyaWfFNBp3bL LtncCTLT/I7qQiZnMPX2L+GRblBVV76VcrRmalGL4LI1tOm3gEJZNCxsDwKLSwt/oaxDMfcMS GUoeUQfkBWDgzNNocWAgBXSuoD73Z/Iev5BHmUT1vmhlnDjrOSdAwfJcMo6sj5U0ppwO5lPjf MALXxYkWxyEbSflZGkm4CyRibJAi04OzvUx3hWG3Y20yo/FYzktlMa6rItC0XGD2VdDwnewcw I0GqOgNfqJ9eM04gNnTxnw52AkI+NWe/HTdAjDHheGoKPX+oIlVB5OY7eYiI324KrPPOQ8byj PE4SKupY9fqqQYl4CwUV7f02ljqg01s5bW86QGrwBrd09KzWfqJ6BJ2gz/CIEAKGLY+oNlxPq gqLhcti884KhbRp+y Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka Those are not backed by page structs, and pte_page is returning an invalid pointer. Signed-off-by: Jan Kiszka =2D-- arch/riscv/mm/cacheflush.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c index 8930ab7278e6..9ee2c1a387cc 100644 =2D-- a/arch/riscv/mm/cacheflush.c +++ b/arch/riscv/mm/cacheflush.c @@ -84,7 +84,8 @@ void flush_icache_pte(pte_t pte) { struct page *page =3D pte_page(pte); - if (!test_and_set_bit(PG_dcache_clean, &page->flags)) + if (!pfn_valid(pte_pfn(pte)) || + !test_and_set_bit(PG_dcache_clean, &page->flags)) flush_icache_all(); } #endif /* CONFIG_MMU */ =2D- 2.16.4