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=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 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 9E924C4727C for ; Wed, 30 Sep 2020 17:34:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 0D69820706 for ; Wed, 30 Sep 2020 17:34:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FBLhJ5zd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D69820706 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NZxPS9RRCXqQGFw9EcOg9qxqD0n0iQ53ReojEra3TXM=; b=FBLhJ5zdTT2EVx1RASROGHSuV 8mTdj+BZbEy8I1f9gOzVozmMlkW9mtni6pKQn3SiSimPqV+pcs6demXTabScBCepkmemQT7QvXJLJ zWowHCQMxlidfP2Sts7UoUusQmPRmr7Oyg1utjAUV0agvN42iR1VQeeWDQOMOBzTYNJQ1AjqKZQXE vmJfNyJV4Y7UCTuPZmeXbfkItAaJp6SYXZphLCLDzO84frC6qFCMQEnXtWQqE4MYHruujXYnRwI5w 5Cg8vLL8qn/JHqxpmEtX+pXhRn7SYrDesNz2qaeW80eS2Wk8Sn2pr2nHcNVB43btOfTNX7kLxhJ6Y yjvFez4FA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNfyT-0006ap-2P; Wed, 30 Sep 2020 17:33:05 +0000 Received: from lhrrgout.huawei.com ([185.176.76.210] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNfyQ-0006aW-Py for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2020 17:33:03 +0000 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id 39BD6143B61A661FC7AA; Wed, 30 Sep 2020 18:33:00 +0100 (IST) Received: from localhost (10.227.96.57) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Wed, 30 Sep 2020 18:33:00 +0100 Date: Wed, 30 Sep 2020 18:32:59 +0100 From: Jonathan Cameron To: Ard Biesheuvel Subject: Re: [PATCH] arm64: permit ACPI core to map kernel memory used for table overrides Message-ID: <20200930183259.00004582@huawei.com> In-Reply-To: <20200929132522.18067-1-ardb@kernel.org> References: <20200929132522.18067-1-ardb@kernel.org> Organization: Huawei tech. R&D (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.227.96.57] X-ClientProxiedBy: lhreml710-chm.china.huawei.com (10.201.108.61) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200930_133302_955163_9DAB2FD9 X-CRM114-Status: GOOD ( 25.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , catalin.marinas@arm.com, linux-acpi@vger.kernel.org, Sudeep Holla , will@kernel.org, linux-arm-kernel@lists.infradead.org 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 On Tue, 29 Sep 2020 15:25:22 +0200 Ard Biesheuvel wrote: > Jonathan reports that the strict policy for memory mapped by the > ACPI core breaks the use case of passing ACPI table overrides via > initramfs. This is due to the fact that the memory type used for > loading the initramfs in memory is not recognized as a memory type > that is typically used by firmware to pass firmware tables. > > Since the purpose of the strict policy is to ensure that no AML or > other ACPI code can manipulate any memory that is used by the kernel > to keep its internal state or the state of user tasks, we can relax > the permission check, and allow mappings of memory that is reserved > and marked as NOMAP via memblock, and therefore not covered by the > linear mapping to begin with. > My over enthusiastic filters went and swept this one away so I missed it. Catalin, thanks for pointing it out! Anyhow, retested and still looks good. Slightly tighter check makes sense. > Cc: Sudeep Holla > Cc: Lorenzo Pieralisi > Fixes: 1583052d111f ("arm64/acpi: disallow AML memory opregions to access kernel memory") > Fixes: 325f5585ec36 ("arm64/acpi: disallow writeable AML opregion mapping for EFI code regions") > Reported-by: Jonathan Cameron > Signed-off-by: Ard Biesheuvel Tested-by: Jonathan Cameron > --- > arch/arm64/kernel/acpi.c | 22 ++++++++++++++++++-- > include/linux/acpi.h | 2 +- > 2 files changed, 21 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index a85174d05473..cada0b816c8a 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -298,8 +298,21 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) > case EFI_BOOT_SERVICES_DATA: > case EFI_CONVENTIONAL_MEMORY: > case EFI_PERSISTENT_MEMORY: > - pr_warn(FW_BUG "requested region covers kernel memory @ %pa\n", &phys); > - return NULL; > + if (memblock_is_map_memory(phys) || > + !memblock_is_region_memory(phys, size)) { > + pr_warn(FW_BUG "requested region covers kernel memory @ %pa\n", &phys); > + return NULL; > + } > + /* > + * Mapping kernel memory is permitted if the region in > + * question is covered by a single memblock with the > + * NOMAP attribute set: this enables the use of ACPI > + * table overrides passed via initramfs, which are > + * reserved in memory using arch_reserve_mem_area() > + * below. As this particular use case only requires > + * read access, fall through to the R/O mapping case. > + */ > + fallthrough; > > case EFI_RUNTIME_SERVICES_CODE: > /* > @@ -388,3 +401,8 @@ int apei_claim_sea(struct pt_regs *regs) > > return err; > } > + > +void arch_reserve_mem_area(acpi_physical_address addr, size_t size) > +{ > + memblock_mark_nomap(addr, size); > +} > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 1e4cdc6c7ae2..64ae25c59d55 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -958,7 +958,7 @@ void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state, > acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, > u32 val_a, u32 val_b); > > -#ifdef CONFIG_X86 > +#ifndef CONFIG_IA64 > void arch_reserve_mem_area(acpi_physical_address addr, size_t size); > #else > static inline void arch_reserve_mem_area(acpi_physical_address addr, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel