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=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 8FA80C47089 for ; Thu, 27 May 2021 11:06:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 528C661028 for ; Thu, 27 May 2021 11:06:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 528C661028 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gXY7dvtfEfYmp3kE/pKkF9b9F7IdN3IhHy3dxaiJBAg=; b=dOZPVmGaYbDAXD t8BbbNSrjNWOqo1GcT6TAO4LeM8+lmzKE3bEWquoNmk8Ss3fuWBd7n/rAX0NEW4s6zE/u2533RQ61 d3hcYtgU/uWMS/Slo80FnLAHoWbGKrQ23DAn01MAs+UQZQtgA1t0pQx9YcvDPXdaFc3bwRayykgGu CxTasnEPm1L6WXmbGaJAvOVUypzCkiW9zVGfa7NbpUb98ZHxuuyJcYRIB0Tc2+8RqxhUHtPeAzO52 oci4lLrdq3n8sPjhEPnTl1M0IToHwpO1U47N9tfx8IjQBy1MwtGERmKe8W0nO18Vf3nK4KvLLHVt6 PX2n4tAb68FB5BHX2n/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmDoT-0054AU-US; Thu, 27 May 2021 11:04:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lmDnU-0053mQ-Pa for linux-arm-kernel@lists.infradead.org; Thu, 27 May 2021 11:03:30 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7DB1613DC; Thu, 27 May 2021 11:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622113408; bh=iqxgdjKfzBMflrU2lOM2jlyWGzSvLcEyA51d9fab2PI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsRd8d1WccoOBZmyAvZD4Y/mEjhAPTOol6Vb7YKq/0uX0azj11FEYlJckUmMuwm9z NxjwBrnm1qaBY8mwdfd3K2IDJWJzZHCJC9hZyDvLFwYCXkm7DXuLgtplqxwyxIGuWw Hrc/iXemn37S4eYNvMqr7KKB8hy9C3AP9ED/5lIKgdL6HbxQu62PCdWCk0lp1mxQ7I H/KlFO/CaKCRSX2HvHlTpHl97oY/XpJePydFFr9Hf8O8joexvY4ACcWjnNVG+KFk+S gFsSc4JvkmN5rANGs4sxht/SbHwFOUtA37o4MICtmHYCjVdf5vR5a/8mSLJXpLRWUn Mss2Ee8mbbfdA== From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: kernel-team@android.com, Will Deacon , Christoph Hellwig , Catalin Marinas , Ard Biesheuvel , Lorenzo Pieralisi , Mark Rutland Subject: [PATCH v2 2/3] arm64: acpi: Map EFI_MEMORY_WT memory as Normal-NC Date: Thu, 27 May 2021 12:03:18 +0100 Message-Id: <20210527110319.22157-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210527110319.22157-1-will@kernel.org> References: <20210527110319.22157-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210527_040328_960300_5DF7999E X-CRM114-Status: GOOD ( 16.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The only user we have of Normal Write-Through memory is in the ACPI code when mapping memory regions advertised as EFI_MEMORY_WT. Since most (all?) CPUs treat write-through as non-cacheable under the hood, don't bother with the extra memory type here and just treat EFI_MEMORY_WT the same way as EFI_MEMORY_WC by mapping it to the Normal-NC memory type instead and emitting a warning if we have failed to find an alternative EFI memory type. Cc: Ard Biesheuvel Cc: Lorenzo Pieralisi Cc: Christoph Hellwig Acked-by: Catalin Marinas Acked-by: Ard Biesheuvel Signed-off-by: Will Deacon --- arch/arm64/kernel/acpi.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index cada0b816c8a..f3851724fe35 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -239,6 +239,18 @@ void __init acpi_boot_table_init(void) } } +static pgprot_t __acpi_get_writethrough_mem_attribute(void) +{ + /* + * Although UEFI specifies the use of Normal Write-through for + * EFI_MEMORY_WT, it is seldom used in practice and not implemented + * by most (all?) CPUs. Rather than allocate a MAIR just for this + * purpose, emit a warning and use Normal Non-cacheable instead. + */ + pr_warn_once("No MAIR allocation for EFI_MEMORY_WT; treating as Normal Non-cacheable\n"); + return __pgprot(PROT_NORMAL_NC); +} + pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) { /* @@ -246,7 +258,7 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) * types" of UEFI 2.5 section 2.3.6.1, each EFI memory type is * mapped to a corresponding MAIR attribute encoding. * The EFI memory attribute advises all possible capabilities - * of a memory region. We use the most efficient capability. + * of a memory region. */ u64 attr; @@ -254,10 +266,10 @@ pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) attr = efi_mem_attributes(addr); if (attr & EFI_MEMORY_WB) return PAGE_KERNEL; - if (attr & EFI_MEMORY_WT) - return __pgprot(PROT_NORMAL_WT); if (attr & EFI_MEMORY_WC) return __pgprot(PROT_NORMAL_NC); + if (attr & EFI_MEMORY_WT) + return __acpi_get_writethrough_mem_attribute(); return __pgprot(PROT_DEVICE_nGnRnE); } @@ -340,10 +352,10 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) default: if (region->attribute & EFI_MEMORY_WB) prot = PAGE_KERNEL; - else if (region->attribute & EFI_MEMORY_WT) - prot = __pgprot(PROT_NORMAL_WT); else if (region->attribute & EFI_MEMORY_WC) prot = __pgprot(PROT_NORMAL_NC); + else if (region->attribute & EFI_MEMORY_WT) + prot = __acpi_get_writethrough_mem_attribute(); } } return __ioremap(phys, size, prot); -- 2.31.1.818.g46aad6cb9e-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel