From patchwork Sat Nov 5 22:52:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13033286 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9D4FBC4332F for ; Sat, 5 Nov 2022 22:53:57 +0000 (UTC) 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: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:In-Reply-To:References: List-Owner; bh=6daANZ4k5avCgHC/CBi3jhVhEZnNYZX6WRMbEapcL8o=; b=4BD3z0imz+BJZY XVb4Q9pV/amGCOKlerV1iQrISLsQ0e4LX1+x5RapLy02JdFKab938Jy0ZkPXgMDeyMKnqrzLHVsW3 AeCwOk95yvti7/ImLFPIzZ/30bnF7ZOLKpEL75IxEiNOakosHToH/6HB0nO0fAfudXoNtPG+4XCU1 0rrkaXXgm6Uy0ybVce8YwaGSz1GFHjGd4FA92YngxTkDeJrGWJiWaufSc4Lxj4VMHWBkH2PRlZFKp ZfNCVmLTKBL/ZTeme8+9xz6fuTY7E516Qmb4ECDZ1yFIahNP2cZMXS8F2j97AZSYV3PsN6M4OiW5w mtN2Dr2tbOKuGRMxVQ9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orS1u-007LUJ-AL; Sat, 05 Nov 2022 22:52:46 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1orS1q-007LTv-M3 for linux-arm-kernel@lists.infradead.org; Sat, 05 Nov 2022 22:52:44 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D50D360BB5; Sat, 5 Nov 2022 22:52:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89B78C433D6; Sat, 5 Nov 2022 22:52:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667688761; bh=OdC/x6CRP1Q6DzJ2wktgiugPDGhj7AalzRHBSkGJxD0=; h=From:To:Cc:Subject:Date:From; b=LWsGaNyP/mFuyBSDsRu/CQgdNo5jg5uPDtR5AZzVl8HRSKgWJSwdYSE7jzoV8iqfP 5dKwfDdjpWB/r4unJzVuU4Y1SbR7rm9Wyu4ao6f2dnVGJk3bwr5V8Sc/TNMtaYIN51 hWghRW22JPMOSdOGfWSKf61xvQunzzAOVeQOJgndUzplqrUi8J0INlLIYY7LFwD589 rwBwRg6kWJUnhw0Tc4wLm53GUhlVu4FtMxVc/HNm+PTvcGxfOVhrSzfpamWmsi2YlH qdfOcMKy9taU2YWaJYqmxdwRwRgZDNolytVBKGPGf2g9PWoKC28WrkFDewEg3M6CCX XHwWg4GCy/AMQ== From: Ard Biesheuvel To: torvalds@linux-foundation.org Cc: linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, Ard Biesheuvel , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH] arm64: efi: Make runtime region misalignment warning less noisy Date: Sat, 5 Nov 2022 23:52:33 +0100 Message-Id: <20221105225234.3089177-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2001; i=ardb@kernel.org; h=from:subject; bh=OdC/x6CRP1Q6DzJ2wktgiugPDGhj7AalzRHBSkGJxD0=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjZukx6SKgMKw3LlKkQp2pxi87rwuExZ4iSWvVGqHl 0Z0T+3OJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY2bpMQAKCRDDTyI5ktmPJJ8LC/ 9jCy4inYywhm11pl9pnWZlsM6YNwFUKEweZhfKY5B7pLqxCWiuzyx1PNyIk3i8JcAaQsWzGQ/0WAmS WxoGi7V4VBVihq8b+5vipPh12GaM/cDAYFnMm6l0wU4EiHmkRlKnrlFtrTH9BeVmXYRKQUEnroDLRL bmx7x5rmW5Pv4ETJjrlmP7DZjbrCbzeqavKtH1C6Ge0rP0fyWaRnZpCKww2gZfOlTx8L9Xyw4y/mZK pY2IKPSua5RX4LOMPe318hoebBe/WcF1CS3WcwB/4qk7xA+hsuNGDMzum3O9B+mgXSxijBlKzy8/gc irF0aUMxJlOmodRVMP7tXLby9vt3P9WLRYIf9Juqc228LT8jOnHOSe++brsVBPRJq3jSLbz71eHd3u hhzhskPxpTSvXMn7QtPU/spCQK2lhFRnzdqtRKTi9c8pWvDTanE6SFJ++7Qj+JOVKnzL4MCVIKQtiL jpo9KZWMyNs0GbxXIbQaslUFlP/UZPyQpJB+6aNVS2ALk= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221105_155242_813770_E81CF911 X-CRM114-Status: GOOD ( 19.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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The EFI spec requires that on arm64 systems, all runtime code and data regions that share a 64k page can be mapped with the same memory type attributes. Unfortunately, this does not take permission attributes into account, and so the firmware is permitted to expose runtime code and data regions that share 64k pages, and this may prevent the OS from using restricted permissions in such cases, e.g., map data regions with non-exec attributes. We currently emit a warning when hitting this at boot, but the warning is problematic for a number of reasons: - it uses WARN() which spews a lot of irrelevant information into the log about the execution context where the issue was detected; - it only takes the start of the region into account and not the size Let's just drop the warning, as the condition does not strictly violate the spec (although it only occurs with U-Boot), and fix the check to take both the start and the end addresses into account. Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Reported-by: Linus Torvalds Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index e1be6c429810d0d5..3dd6f0c66f8aeb78 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -25,8 +25,8 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) if (type == EFI_MEMORY_MAPPED_IO) return PROT_DEVICE_nGnRE; - if (WARN_ONCE(!PAGE_ALIGNED(md->phys_addr), - "UEFI Runtime regions are not aligned to 64 KB -- buggy firmware?")) + if (!PAGE_ALIGNED(md->phys_addr) || + !PAGE_ALIGNED(md->num_pages * EFI_PAGE_SIZE)) /* * If the region is not aligned to the page size of the OS, we * can not use strict permissions, since that would also affect