Message ID | 152856436164.18127.2847888121707136898.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4E58F601F7 for <patchwork-linux-mm@patchwork.kernel.org>; Sat, 9 Jun 2018 17:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39A0F2267B for <patchwork-linux-mm@patchwork.kernel.org>; Sat, 9 Jun 2018 17:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CDC922B39; Sat, 9 Jun 2018 17:22:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF5FC2267B for <patchwork-linux-mm@patchwork.kernel.org>; Sat, 9 Jun 2018 17:22:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 514A56B0003; Sat, 9 Jun 2018 13:22:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4C2F76B0005; Sat, 9 Jun 2018 13:22:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B2906B026E; Sat, 9 Jun 2018 13:22:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id EE2F66B0003 for <linux-mm@kvack.org>; Sat, 9 Jun 2018 13:22:40 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id y26-v6so7909442pfn.14 for <linux-mm@kvack.org>; Sat, 09 Jun 2018 10:22:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=u5NRsC/INttXmxQxQ94BtXZp/841I8zsiQQ8w9kUgKc=; b=aRd/wgr11xmy1b6kwbGd6MZCVR+DEkmcAcD0dfa5goEcSHCwF7w8qYEevA3Vyu+qDV IL5JLlXGQuYf+JoTJryPA+oAEgpi5aJ9kazpjozyJzRjHJ2+Gbz3390/gEfHM+FL00+5 jUd7iO9TN2oSiNRpW1LQzL1u7HY0L/cUgk+1JrYSInNqSbINaPZTOhymHxyHKpf7wqz0 YcWSlG7jaCWNHi61Egi8QOjyMOZth0EgTT9b/K6h416wkkJEqcYuO9kAOXT7Bjd2wMcY dg/oCUGk6SmP67LU0AIW/V9ER+iUggnQevv02vSvTNO0qJ4ppqUchJKFYDi5xugiLSKY lK2A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APt69E0RLBFQvakpAo+d0p/8Qz1HJ8/YppmddE7TRiDWH3tQPkSLL6Mv 9X0+e4LOPhXNpVdepgkxu3hrgVpd4WVGoMDcsEzzTUpqn0mzwQWMc9Y0p/27dNZ0PUdVVCpqxqL eeNawVtHYnjWVcmzQB1YAhG6QYzfv3dnhxXJqcHCF8nZreCoMLgQ23eOcCGvVkvTT4A== X-Received: by 2002:a17:902:74c8:: with SMTP id f8-v6mr11701634plt.317.1528564960601; Sat, 09 Jun 2018 10:22:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5fiXmSLITmx+XeYaFwtVRapPvyvCnN0jHbd16DfTv5CjG4OJh1NXbWU+Mb9I6PxZ4uYDq X-Received: by 2002:a17:902:74c8:: with SMTP id f8-v6mr11701591plt.317.1528564959683; Sat, 09 Jun 2018 10:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528564959; cv=none; d=google.com; s=arc-20160816; b=dZmT6hY+I4d+XVXPx2TuaDAj0yyFjpCaVWxKr43FH+geObLfT9wbMd81tgtHzHJM9d SkuccUPcRB4xQlO+fBpRd0IHzOdHrZK08Soja3VZyLGC5pvgfdlB/eP5rJmnsGjs5eoP OpBbAnbnFs6rxZuS4OaAK5gow+a1qxK8eCF1k4eVju3uJkhW/q8w1UBFxjFEUPtG4uDK kV605RtFThqv/1ks1fOVj4PEBmQbVAAE/n8bSpqeTPqHWIgVxybSjvq9dTvYwbA0pM+a CSF/cKS8jHTMxMTMIQv2FCtMiqlFiTPbSRKGj2ffkbcuWcTO0M8h9vRbuc50Uvm3FEqj oHYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=u5NRsC/INttXmxQxQ94BtXZp/841I8zsiQQ8w9kUgKc=; b=zuVHhZrhfyNRgRTgVvtDHf0aVSXbqzkwP0KlWhljSsgeiYpR1lnF4SMwVfQtwPb1Nx 5mgEiSW03JFW8/PN+UG8JsYjSCwIzR8P1CZs/IQpTU/OYrwvfRKRU8m9J2GHpUVckh7w iM5wQNq+VwLtqjO6waaSLVMPZsfDqGSeLEtr5/WZShTKjzAy8/kXtv9w9bzq9v18Eh4U P5lbD0+UxMracczZ62t17z3WGHpWKNdVbp1jA7pOsllX4bXwxDqVLzl//uL+QusAVzUg pMN8K6zvnw6YvG7sMdr5b5kbmh7/hr3WLEizxEoYRKAGhf9IGyl2RbfAB+0kVwNhh1Po 2uGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id q137-v6si22344473pfc.164.2018.06.09.10.22.39 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 10:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2018 10:22:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,495,1520924400"; d="scan'208";a="231245510" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga005.jf.intel.com with ESMTP; 09 Jun 2018 10:22:38 -0700 Subject: [PATCH] mm: Fix devmem_is_allowed() for sub-page System RAM intersections From: Dan Williams <dan.j.williams@intel.com> To: akpm@linux-foundation.org Cc: stable@vger.kernel.org, Christoph Hellwig <hch@lst.de>, Hussam Al-Tayeb <me@hussam.eu.org>, linux-mm@kvack.org, bugzilla-daemon@bugzilla.kernel.org Date: Sat, 09 Jun 2018 10:12:41 -0700 Message-ID: <152856436164.18127.2847888121707136898.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <bug-199999-27@https.bugzilla.kernel.org/> References: <bug-199999-27@https.bugzilla.kernel.org/> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index fec82b577c18..cee58a972cb2 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -706,7 +706,9 @@ void __init init_mem_mapping(void) */ int devmem_is_allowed(unsigned long pagenr) { - if (page_is_ram(pagenr)) { + if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE, + IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) + != REGION_DISJOINT) { /* * For disallowed memory regions in the low 1MB range, * request that the page be shown as all zeros.
Hussam reports: I was poking around and for no real reason, I did cat /dev/mem and strings /dev/mem. Then I saw the following warning in dmesg. I saved it and rebooted immediately. memremap attempted on mixed range 0x000000000009c000 size: 0x1000 ------------[ cut here ]------------ WARNING: CPU: 0 PID: 11810 at kernel/memremap.c:98 memremap+0x104/0x170 [..] Call Trace: xlate_dev_mem_ptr+0x25/0x40 read_mem+0x89/0x1a0 __vfs_read+0x36/0x170 The memremap() implementation checks for attempts to remap System RAM with MEMREMAP_WB and instead redirects those mapping attempts to the linear map. However, that only works if the physical address range being remapped is page aligned. In low memory we have situations like the following: 00000000-00000fff : Reserved 00001000-0009fbff : System RAM 0009fc00-0009ffff : Reserved ...where System RAM intersects Reserved ranges on a sub-page page granularity. Given that devmem_is_allowed() special cases any attempt to map System RAM in the first 1MB of memory, replace page_is_ram() with the more precise region_intersects() to trap attempts to map disallowed ranges. Link: https://bugzilla.kernel.org/show_bug.cgi?id=199999 Fixes: 92281dee825f ("arch: introduce memremap()") Cc: <stable@vger.kernel.org> Cc: Christoph Hellwig <hch@lst.de> Reported-by: Hussam Al-Tayeb <me@hussam.eu.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)