Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp779472rdb; Thu, 15 Feb 2024 15:40:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX6sWr+kfT1xBZifqnd0ZTKIjI1pEPJGv4WnNqi6AoRNjC0pscj5MuJ2Qp7pI5+dQk2NU/DAGLUUPMFb6BaYXHL4+YLEBgu74jcfZAtSA== X-Google-Smtp-Source: AGHT+IEDR/Qyy/k+fGDnOUI8Fcl4WV1hd5eQCeZ2HheQtaHvuRzCAdLECRCpP98zzNdxlLTKmW2V X-Received: by 2002:a62:8182:0:b0:6e0:51a9:7c65 with SMTP id t124-20020a628182000000b006e051a97c65mr2956008pfd.21.1708040431137; Thu, 15 Feb 2024 15:40:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708040431; cv=pass; d=google.com; s=arc-20160816; b=jkgDbpFODKNd1qAWErABBmrdX5u6cIzG8YK9kH6y7gVa8osJojccbzBpyI7rn8XQUx AF8BfGmYpNqjbbxxOgYi62z5VgDhzIoLlg5xDAu9N5IGBaq10NZYiS8K+yFXOM/D2VR9 9BPM/mAXzdTGBjC8Big2d+kpztlWUS/BHRCtdQXefMtBFATpnFnEOxRc6Bqxox52HrYs kB6LLuetGWG9u7ZnKxGlexLUnkUk0pKdpHgg8Et0N7ahcfvyX/Yhk0NJ3G6kmkJIS3sU IYpCaVIR3iR7cABsMD6YablfOPrZ5NI5BeBYzahi9HcFrUeh/qFWDVB84r2B5WoRY370 c5Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=ko2kYNdjObDwDthi5sYAtyqInxCCdDKDVumkgEwSLsg=; fh=352mr9mIndSjSjZOfW+UHPotFAlPbv9uVkVIfN/VTxI=; b=H8QIGhnoisBeAejF0GBzPX14No6HWFtM1iIC9gD3I2SYL0cAU6fLn9m1jTzNF4e/jy hnmfr53rjc03864qXHcDOaPW6YReMjEAjcL4tZW7Z9GYKII9ozRUAf4wk3DzIcqedLi5 jLlcYYW9pRLsD14Y2zoKer7AAET9+ntDujOqaCJ6JDS+93AN2sXf+lxBd8sVwgllbVte /1UyLHwk0keGy2N7XOfxrXvliHbiAeaQ9+XL9BI3+OJbBAcZ2pDcsd7/CPJCSwHqiVG+ wvyH8r3RAhN6+CwhbPbauyUyIrBvIoQTDkNp2SKgqERrwVe9Y1THS1j6hDEEpq88/SPB 26hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZQnA+Vj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67843-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67843-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x62-20020a638641000000b005dc8372021bsi1936008pgd.464.2024.02.15.15.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 15:40:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67843-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZQnA+Vj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-67843-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67843-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D2743281F0D for ; Thu, 15 Feb 2024 23:40:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7BA1145B07; Thu, 15 Feb 2024 23:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gZQnA+Vj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 082DB8833; Thu, 15 Feb 2024 23:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708040421; cv=none; b=Ztx8fyZK54CPBy6zCo2vnsjSyLqZ3ivEmAZaBxUceIReqZ58LtTn/6unRJbALmLhi0GQkOICnDSc8nkcaHPZeFUqvkvTiHv1VCGA3LkjQ9qUfi4uajYfL3/H3fUQQnpXeCQOPqhNZT3mmEJEhWpumlWaPfz9haVPTW6kVBMLrm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708040421; c=relaxed/simple; bh=MdGOLNF5O+3/k/MN90ft/gq4gaJkB7U3p52hntLN17I=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=iXPfNeI+bHMIOVQ6X6rgC1TAFwlZMLhri3AnsYjBJsCdOVDDfbu5CprU0UlwOw1Usthw16D5c343oBhTv/2kK03dA/rReS3TKMQH6ZVxwmsa1Eeqx1rUiiN206U4/0lqbj2qvkUpZ2UuHeVcT70izc5QtnVmL8fd7ofkkuxZ7YY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gZQnA+Vj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D593C433C7; Thu, 15 Feb 2024 23:40:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708040420; bh=MdGOLNF5O+3/k/MN90ft/gq4gaJkB7U3p52hntLN17I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gZQnA+VjpmOCIRf9BW8kNoSxWl0GNonzrGp8LNK/SUjyPZVrrJ/rJJ40MCuRsXI/v ETfI2MnlVBYn/ByAwOfhMv+JCOydgbzT/QDKj8u8GV7iYeA0WN4s2w5wC+DlaG0mU2 dJPws4t1UCpi88hW8KXWrT1VJvjSEvMwah3AwwuPGhkCLhB4mNLhDI7GOleSNn6I+F MtDvAuoLpvlM9vO1P3NU+W5PgYLTPQ8XjJbY3vbWi8koboKupO22okOpKJZanKx9eG yPMl31hJ7LVqrlO6DYcqhHq7zvcgk+8cgAW9SOPVIokrpgPG/U9l3f0joYKyuE2evm VxdrqDzROXsyA== Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d0b4ea773eso18587331fa.0; Thu, 15 Feb 2024 15:40:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUWhRzD0P1zKDk9vdZ+E9F5V5VO9zXumfoZunB5H1a0zOgaTIDBsrmMPp4uypmAEgIA2zcITFf9V6K+2TZ1hehvcG81K9EJYFx+SAjgD9h7MOzmGoq5sxqq3m1Bx14pcTrvBReM1fk8 X-Gm-Message-State: AOJu0YyQ3mBHUB+ZAIAySBjH8IZ+LxjLPnn2iyiq9evBxP1TEIcxulY6 RyiMQS6C/ggSiRpyixSAfqamSLCt0yIhP6z5FFVuL1UKrxRhbY+TZ+5+8UQna6cMBI8ZvHe587A kxWCjFGkLk8VK18Oyimdo2u51kjQ= X-Received: by 2002:a05:651c:1a29:b0:2d2:912:916b with SMTP id by41-20020a05651c1a2900b002d20912916bmr2609906ljb.24.1708040418698; Thu, 15 Feb 2024 15:40:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240215225116.3435953-1-boqun.feng@gmail.com> In-Reply-To: From: Ard Biesheuvel Date: Fri, 16 Feb 2024 00:40:07 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC] efi: Add ACPI_MEMORY_NVS into the linear map To: Boqun Feng , Oliver Smith-Denny Cc: stable@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Linux ARM Content-Type: text/plain; charset="UTF-8" On Fri, 16 Feb 2024 at 00:21, Ard Biesheuvel wrote: > > (cc Oliver) > > On Thu, 15 Feb 2024 at 23:51, Boqun Feng wrote: > > > > Currently ACPI_MEMORY_NVS is omitted from the linear map, which causes > > a trouble with the following firmware memory region setup: > > > > [..] efi: 0x0000dfd62000-0x0000dfd83fff [ACPI Reclaim|...] > > [..] efi: 0x0000dfd84000-0x0000dfd87fff [ACPI Mem NVS|...] > > > > Which memory types were listed here? > > > , on ARM64 with 64k page size, the whole 0x0000dfd80000-0x0000dfd8ffff > > range will be omitted from the the linear map due to 64k round-up. And > > a page fault happens when trying to access the ACPI_RECLAIM_MEMORY: > > > > [...] Unable to handle kernel paging request at virtual address ffff0000dfd80000 > > > > You trimmed all the useful information here. ACPI reclaim memory is > reclaimable, but we don't actually do so in Linux. So this is not > general purpose memory, it is used for a specific purpose, and the > code that accesses it is assuming that it is accessible via the linear > map. There are reason why this may not be the case, so the fix might > be to use memremap() in the access instead. > Please try the below if the caller is already using memremap(). It might misidentify the region because the start is in the linear map but the end is not. diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c index 269f2f63ab7d..fef0281e223c 100644 --- a/arch/arm64/mm/ioremap.c +++ b/arch/arm64/mm/ioremap.c @@ -31,7 +31,6 @@ void __init early_ioremap_init(void) bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size, unsigned long flags) { - unsigned long pfn = PHYS_PFN(offset); - - return pfn_is_map_memory(pfn); + return pfn_is_map_memory(PHYS_PFN(offset)) && + pfn_is_map_memory(PHYS_PFN(offset + size - 1)); }