From patchwork Thu Jul 11 22:21:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KarimAllah Ahmed X-Patchwork-Id: 11040809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 622CF1395 for ; Thu, 11 Jul 2019 22:21:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F13528B79 for ; Thu, 11 Jul 2019 22:21:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 406C528B7C; Thu, 11 Jul 2019 22:21:57 +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=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A0F8C28B79 for ; Thu, 11 Jul 2019 22:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=JWRaeQAsCPPWwaME1i+BK8mXBsHA2KhhgmI3BAxLcOk=; b=IG3 8dAKJ6Lzn54f+B35h7lNFkQ0v9YdZfx/wEgupiHyyYy3V4KK140Jc5eY58wIqfwME4KCBc6syeXwt LXEsc6TbAlGR/cfk7w/aTezWi/jfFGhs0Nu76UEasocrl2Vfewhotw+noGJSnx55bXBtK8jeXxJr6 amyFGaBVHw5P9OW8n2219v7TuxjHUXHg0yW3a0IBWALuMixu+aYPvetzL4WKvnHuOVa1U+sJCa/79 YiZQ0OYpXOMFy6jwt7gVDE7E1vKeWhq1cCnb85S3vjZuuSEHVxYRcyEQHCilEFRjYYbUG3/OqeH10 9TG2Mez4+U30e1XX7FCBLmEUAg/cHlw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hlhRl-0006Gl-Oh; Thu, 11 Jul 2019 22:21:49 +0000 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hlhRj-0006GH-5Y for linux-arm-kernel@lists.infradead.org; Thu, 11 Jul 2019 22:21:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1562883707; x=1594419707; h=from:to:cc:subject:date:message-id; bh=3gnH5RFwGHOCrCZhZO/bJsPHw0TAU3IEAqyti5ky+0M=; b=OzfdZJgQvLo4JvbYfcPyASjkf4Uy6b6W7hnDnr66UmHPiF3Pa0ofAA/O 9YVTLNSi3u3t+W8Y2s8ndpGwnndCvYQqhOY9ZJ3HA4apkGixUXYHkaR0n Xkpgs9JSylyttP1Vw88spYtVMe420eMAqNqxZBuAKjWLR2rkKMV4HWuxB c=; X-IronPort-AV: E=Sophos;i="5.62,480,1554768000"; d="scan'208";a="741422169" Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1a-715bee71.us-east-1.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 11 Jul 2019 22:21:43 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad7-ws-svc-lb50-vlan2.amazon.com [10.0.93.210]) by email-inbound-relay-1a-715bee71.us-east-1.amazon.com (Postfix) with ESMTPS id 976E5A17B3; Thu, 11 Jul 2019 22:21:38 +0000 (UTC) Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id x6BMLYLt019252; Fri, 12 Jul 2019 00:21:34 +0200 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id x6BMLWVb019247; Fri, 12 Jul 2019 00:21:32 +0200 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm: Extend the check for RAM in /dev/mem Date: Fri, 12 Jul 2019 00:21:21 +0200 Message-Id: <1562883681-18659-1-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 Precedence: Bulk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190711_152147_343965_45E3BFEF X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Enrico Weigelt , Anders Roxell , Yu Zhao , Anshuman Khandual , KarimAllah Ahmed , Catalin Marinas , Ard Biesheuvel , Russell King , Mike Rapoport , Jun Yao , James Morse , Andrew Morton , Will Deacon , Thomas Gleixner , Robin Murphy MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some valid RAM can live outside kernel control (e.g. using mem= kernel command-line). For these regions, pfn_valid would return "false" causing system RAM to be mapped as uncached. Use memblock instead to identify RAM. Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Mike Rapoport Cc: Andrew Morton Cc: Anders Roxell Cc: Enrico Weigelt Cc: Thomas Gleixner Cc: KarimAllah Ahmed Cc: Mark Rutland Cc: James Morse Cc: Anshuman Khandual Cc: Jun Yao Cc: Yu Zhao Cc: Robin Murphy Cc: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: KarimAllah Ahmed --- arch/arm/mm/mmu.c | 2 +- arch/arm64/mm/mmu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 1aa2586..492774b 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -705,7 +705,7 @@ static void __init build_mem_type_table(void) pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { - if (!pfn_valid(pfn)) + if (!memblock_is_memory(__pfn_to_phys(pfn))) return pgprot_noncached(vma_prot); else if (file->f_flags & O_SYNC) return pgprot_writecombine(vma_prot); diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 3645f29..cdc3e8e 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -78,7 +78,7 @@ void set_swapper_pgd(pgd_t *pgdp, pgd_t pgd) pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { - if (!pfn_valid(pfn)) + if (!memblock_is_memory(__pfn_to_phys(pfn))) return pgprot_noncached(vma_prot); else if (file->f_flags & O_SYNC) return pgprot_writecombine(vma_prot);