From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E86DBC742A1 for ; Thu, 11 Jul 2019 22:22:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B70C420872 for ; Thu, 11 Jul 2019 22:22:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.de header.i=@amazon.de header.b="jFh0b+rr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728717AbfGKWVq (ORCPT ); Thu, 11 Jul 2019 18:21:46 -0400 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:49187 "EHLO smtp-fw-2101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbfGKWVq (ORCPT ); Thu, 11 Jul 2019 18:21:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1562883705; x=1594419705; h=from:to:cc:subject:date:message-id; bh=3gnH5RFwGHOCrCZhZO/bJsPHw0TAU3IEAqyti5ky+0M=; b=jFh0b+rrOlEV53NkaPH2Zz2Dxoo1rzVS0A1vSaP93NahysuwWnsMPkh9 G+ztqHCKmK9PXxjCn1KSKMBUHKyWd21Y/NgJFl9+Yy6m7hdzFYq2itCW2 qSp6FCAmmfqlu/oCtbGlNR8YTmfjjau6mtrRkYesWXEUqco6eH9Ucb1N2 4=; 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 Cc: KarimAllah Ahmed , Russell King , Catalin Marinas , Will Deacon , Mike Rapoport , Andrew Morton , Anders Roxell , Enrico Weigelt , Thomas Gleixner , Mark Rutland , James Morse , Anshuman Khandual , Jun Yao , Yu Zhao , Robin Murphy , Ard Biesheuvel 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4