Message ID | 20240215225116.3435953-1-boqun.feng@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp167907dyb; Thu, 15 Feb 2024 14:51:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWqGrg5+mZhqWj8QE97NOdyY7Aw8ElR3qC8Os7defQmz6hlyIi2eIPENmhr9tTvX41ZBb0Nx3kJ1p+3SWZseHiVuLfx/g== X-Google-Smtp-Source: AGHT+IG8YnUeKBcNVey6FKBedkyCgni8/Uas/mm0eUyVxOxhv4C1T4YXgsHWABPIjJsAOv5Nyhcw X-Received: by 2002:a05:690c:82e:b0:607:75e9:c786 with SMTP id by14-20020a05690c082e00b0060775e9c786mr3384836ywb.8.1708037510953; Thu, 15 Feb 2024 14:51:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708037510; cv=pass; d=google.com; s=arc-20160816; b=XZyp6CO0CS4uS5mVjTtaNhmYXNcIQPjySZps2L5F0qJFw6vdQbUOwp66lzXo2Cgm1e Xtzw4mHUTiyW1McvSw5PpVYB3MbNqPlaQ0Gw08OOkzQTt5VJt1nU88gu2C6LLwYsF6+Q w/x04+e2s0JVqByQ+F8ZpHm86YazXa8kRvY7EUWrFwgZSGUOuzEKWM1ASJIHnZcFUAzE w1XB3TtBax9aIFA4iG6g8Q7vJ8PwY/LzYjcZQmI6ia/8WlEiXMR9JtDXAJr7t0VwuMeg zEj0Cz6MsViyDS3xaIohiZJz3zzYx7CkibRcSJGSJxfbrGgS6qPZiKLkKavQtozn6j5v +0Vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:feedback-id:dkim-signature; bh=MnyzlgyQvhJraZkrPcyEIJ8UMchFvRt/RNLWEzws5Fw=; fh=bGqi63n0YgNwmisFyCRtKduPf3AZd2vfaPLJGrhnZb8=; b=XDB18nwtOPltHat0KzclX3PtchYALjsnxw2FoLatgUbDpIf2yfWasYH1hDC3GKcdT2 kKfo3bCAuWWXejIAK2iKDAnsNlR+Qm4JPpzW21HLjKMAFHAZCoHsAQwRWFLPrQwwXysi 0YrjYPh8klw0ekdNdfUhTiPH3TVMySnvxkAL5wX+pK/NGJycSCmWEuMWNZUFg9frdAIA gHVXOK5gKuX7vTYsbud1M6Rypm8yOe6oiJEs51NKKCV35jdiQfN2/Ppd678H9XVU5oSw ot7C7G/P9XkrF0Mr/yenWH3x4wPVPuX9znepxr1hqeL42E+l9gn75FbrzqdRSf20TnTj KIGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kq5fy2yO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q7-20020a05622a04c700b0042c69db0261si2603244qtx.275.2024.02.15.14.51.50 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 14:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kq5fy2yO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67786-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A33811C21B81 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 22:51:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C9BC145343; Thu, 15 Feb 2024 22:51:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kq5fy2yO" Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2154913A86F; Thu, 15 Feb 2024 22:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708037494; cv=none; b=u028JKfnU2t4xTR8rA10ryIOGBb4pwnUnKL+RV919B+qhR88CD1CxxxbrqZ5zk13IDjpPloSAHXStpOgrEvYiEMMeIq0PHcGuGJ8QVhSHWH/EaRAxUfD2HnEu4Er8mu69tI551F5M9sDX0+u91xC6JXzl1g8eTpnzfOf33XIFyA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708037494; c=relaxed/simple; bh=6XhwMTtsLs0JIWiOr9upPSdCY8YQXot2QALVLFFVtTA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oh5mNOi42vKMfsR1dQRxsPwE8JLlvJsEPVs1cUuZWnI/1/LjloxGYLVFiqN10YP70i2fEPoBi7vuAFntM/btYSa85XcqUx8ufhCeXKBRCGO4vQ1DgJguVoqdcw5wKI7uliEmeEJo1ux2ak0V4Az0thp03P3KOvTh1CwfTt1rj2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kq5fy2yO; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e42845298eso786875a34.2; Thu, 15 Feb 2024 14:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708037492; x=1708642292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=MnyzlgyQvhJraZkrPcyEIJ8UMchFvRt/RNLWEzws5Fw=; b=kq5fy2yOa3ia9NZAOnabiWem340bFMUD9byZyRscSJq1edzIxOelnGLD44EUYnDZTS znrGgvGYL0DUBcWCeSbZmTzuRw//NpjM74xqAFTEJZTJktkiM5fPN0hTK3RvVQsYJc5+ jfLiHwhzVDd+XIl3wNp1C82hJbYd3DlCZE77ngqyEhjwnd3GI8SmMD7O9QMMakqA7xh6 WgFmaghh50pZU1s1mTbl9LFLmUntLlEePWFQnbzokfLwnvq9JZmPtdMtjUtku1FQ7qCJ g22VsLt/KA75ccZD6khQMeafWQ9i07+eOBYO83ODnEstAIQQVvhk45DKU1ewdXk6I/+h +XqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708037492; x=1708642292; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:feedback-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MnyzlgyQvhJraZkrPcyEIJ8UMchFvRt/RNLWEzws5Fw=; b=xLAViVhoEYCZz6weBCmSdh50T8dR1V7OOSCPhw9RH1DpV19kai/NWmI7aG4AzKGEsX nYbzfKbIq+RF4WOteGePn75XEiYKn2YW6nNsQB20yz8VEdkXM77BwE/0cdN+lG48zpwY V2+iGAA1YXkFs9t5a2StgukmJLWSEKk6wht2yHTabDDaCwMIdLlm13uqCpSmMqVLFykc LlF86VEeZahbqG2pKHR690y8VQWpHWt4MGCKmKj9JO/t1cOrWLbCZC7CcOCm1Jwi7bJO lO4V+CXYv3Lo2H7PkNiwhEDNdi55herSFNrT1suWHozfxEx8JSUsoTxsaNBqnWSuQ7M8 V1ig== X-Forwarded-Encrypted: i=1; AJvYcCUn4AyIh0ZOopMS3i1MVp20OqfRdd2Z3RR4wcQFNI1cdar5Vx+H1wEK5IkxGYrpLcAebbRki/zDQ+km5mp7HTvBV9vzoruSNeWR39KOMe0vjFyJxdseHs4Y11k+/3WxpoekaB5i5jqNjVYio80vh+4ylaYq8fRwy++KSfEw2yvt X-Gm-Message-State: AOJu0Yxuaar00NG0bzvQXMtDsX2roolz7b6PImZvJmHIehfKDYyVPWmq 4caeBNUjVsNWQrav7b9zpWzZTTsECSIst958z4jAQf6hmddKiDyT X-Received: by 2002:a05:6830:12cf:b0:6e4:2202:ff9f with SMTP id a15-20020a05683012cf00b006e42202ff9fmr3142170otq.17.1708037491957; Thu, 15 Feb 2024 14:51:31 -0800 (PST) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id 11-20020ac8590b000000b0042c80eb0d79sm992012qty.52.2024.02.15.14.51.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 14:51:31 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfauth.nyi.internal (Postfix) with ESMTP id E339B1200043; Thu, 15 Feb 2024 17:51:30 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 15 Feb 2024 17:51:30 -0500 X-ME-Sender: <xms:cpXOZb1aE9duRy89ifK7dQhnCHAOL_538imeKi_uUIkub1Mt0oOo-Q> <xme:cpXOZaGM9crAP1vvGjcVhBB69HQM1yb7iC34IKif0QQHmSnAcUnqbPSd9QupWXwYH RmwyCRIiZ2x_UHZIw> X-ME-Received: <xmr:cpXOZb7esUBBD1pK1mso6yXvxRQbUPoEt_i_P9eBp0JsNsRtxgt1fjL44pY> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddugddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhnucfh vghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrthhtvg hrnhepgfetfffhheejgedtudeiffduteefhefggedujeduhfeifefgiefgveeuudeludff necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsghoqh hunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieegqddu jeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigihmvg drnhgrmhgv X-ME-Proxy: <xmx:cpXOZQ335bmTmgtqdxktyV4BJoOk3hPxiUqUGvJqVVQ0fvuIEaxJQw> <xmx:cpXOZeGiHwUhalTilpoToW9rhLUWgSqxJ2w0Qlcuq78tJwlOIRPODA> <xmx:cpXOZR8cIWEpJx8arOoJDCnivts6T5ALKn_tDY3CfehR74QHgPBMWA> <xmx:cpXOZbNKLkrIlURDOWlkFcOEC2xvOMr9Ro6IZuiZPKV_nb9NdoOhi2XoLVQ> Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 15 Feb 2024 17:51:30 -0500 (EST) From: Boqun Feng <boqun.feng@gmail.com> To: linux-arm-kernel@vger.kernel.org Cc: Boqun Feng <boqun.feng@gmail.com>, stable@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC] efi: Add ACPI_MEMORY_NVS into the linear map Date: Thu, 15 Feb 2024 14:51:06 -0800 Message-ID: <20240215225116.3435953-1-boqun.feng@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791007141127302602 X-GMAIL-MSGID: 1791007141127302602 |
Series |
[RFC] efi: Add ACPI_MEMORY_NVS into the linear map
|
|
Commit Message
Boqun Feng
Feb. 15, 2024, 10:51 p.m. UTC
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|...]
, 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
To fix this, add ACPI_MEMORY_NVS into the linear map.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Cc: stable@vger.kernel.org # 5.15+
---
We hit this in an ARM64 Hyper-V VM when using 64k page size, although
this issue may also be fixed if the efi memory regions are all 64k
aligned, but I don't find this memory region setup is invalid per UEFI
spec, also I don't find that spec disallows ACPI_MEMORY_NVS to be mapped
in the OS linear map, but if there is any better way or I'm reading the
spec incorrectly, please let me know.
It's Cced stable since 5.15 because that's when Hyper-V ARM64 support is
added, and Hyper-V is the only one that hits the problem so far.
drivers/firmware/efi/efi-init.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Comments
(Cc the correct arm mailing list) On Thu, Feb 15, 2024 at 02:51:06PM -0800, 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|...] > > , 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 > > To fix this, add ACPI_MEMORY_NVS into the linear map. > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > Cc: stable@vger.kernel.org # 5.15+ > --- > We hit this in an ARM64 Hyper-V VM when using 64k page size, although > this issue may also be fixed if the efi memory regions are all 64k > aligned, but I don't find this memory region setup is invalid per UEFI > spec, also I don't find that spec disallows ACPI_MEMORY_NVS to be mapped > in the OS linear map, but if there is any better way or I'm reading the > spec incorrectly, please let me know. > > It's Cced stable since 5.15 because that's when Hyper-V ARM64 support is > added, and Hyper-V is the only one that hits the problem so far. > > drivers/firmware/efi/efi-init.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c > index a00e07b853f2..9a1b9bc66d50 100644 > --- a/drivers/firmware/efi/efi-init.c > +++ b/drivers/firmware/efi/efi-init.c > @@ -139,6 +139,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md) > case EFI_LOADER_CODE: > case EFI_LOADER_DATA: > case EFI_ACPI_RECLAIM_MEMORY: > + case EFI_ACPI_MEMORY_NVS: > case EFI_BOOT_SERVICES_CODE: > case EFI_BOOT_SERVICES_DATA: > case EFI_CONVENTIONAL_MEMORY: > @@ -202,8 +203,12 @@ static __init void reserve_regions(void) > if (!is_usable_memory(md)) > memblock_mark_nomap(paddr, size); > > - /* keep ACPI reclaim memory intact for kexec etc. */ > - if (md->type == EFI_ACPI_RECLAIM_MEMORY) > + /* > + * keep ACPI reclaim and NVS memory and intact for kexec > + * etc. > + */ > + if (md->type == EFI_ACPI_RECLAIM_MEMORY || > + md->type == EFI_ACPI_MEMORY_NVS) > memblock_reserve(paddr, size); > } > } > -- > 2.43.0 >
(cc Oliver) On Thu, 15 Feb 2024 at 23:51, Boqun Feng <boqun.feng@gmail.com> 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. > To fix this, add ACPI_MEMORY_NVS into the linear map. > There is a requirement in the arm64 bindings in the UEFI spec that says that mixed attribute mappings within a 64k page are not allowed. This is not a very clear description of the requirement or the issue it is intended to work around. In short, the following memory types are special – EfiRuntimeServicesCode – EfiRuntimeServicesData – EfiReserved – EfiACPIMemoryNVS and care must be taken to ensure that allocations of these types are never mapped with mismatched attributes, which might happen on a 64k page size OS if a mapping is rounded outwards and ends up covering the adjacent region. The Tianocore reference implementation of UEFI achieves this by simply aligning all allocations of these types to 64k, so that the OS never has to reason about whether or not region A and region B sharing a 64k page frame could have mappings or aliases that are incompatible. (I.e., all mappings of A are compatible with all mappings of B) ACPI reclaim is just memory, EfiACPIMemoryNVS could have special semantics that the OS knows nothing about. That makes it unsafe to assume that we can simply create a cacheable and writable mapping for this memory. > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > Cc: stable@vger.kernel.org # 5.15+ > --- > We hit this in an ARM64 Hyper-V VM when using 64k page size, although > this issue may also be fixed if the efi memory regions are all 64k > aligned, but I don't find this memory region setup is invalid per UEFI > spec, also I don't find that spec disallows ACPI_MEMORY_NVS to be mapped > in the OS linear map, but if there is any better way or I'm reading the > spec incorrectly, please let me know. > I'd prefer fixing this in the firmware. > It's Cced stable since 5.15 because that's when Hyper-V ARM64 support is > added, and Hyper-V is the only one that hits the problem so far. > > drivers/firmware/efi/efi-init.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c > index a00e07b853f2..9a1b9bc66d50 100644 > --- a/drivers/firmware/efi/efi-init.c > +++ b/drivers/firmware/efi/efi-init.c > @@ -139,6 +139,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md) > case EFI_LOADER_CODE: > case EFI_LOADER_DATA: > case EFI_ACPI_RECLAIM_MEMORY: > + case EFI_ACPI_MEMORY_NVS: > case EFI_BOOT_SERVICES_CODE: > case EFI_BOOT_SERVICES_DATA: > case EFI_CONVENTIONAL_MEMORY: > @@ -202,8 +203,12 @@ static __init void reserve_regions(void) > if (!is_usable_memory(md)) > memblock_mark_nomap(paddr, size); > > - /* keep ACPI reclaim memory intact for kexec etc. */ > - if (md->type == EFI_ACPI_RECLAIM_MEMORY) > + /* > + * keep ACPI reclaim and NVS memory and intact for kexec > + * etc. > + */ > + if (md->type == EFI_ACPI_RECLAIM_MEMORY || > + md->type == EFI_ACPI_MEMORY_NVS) > memblock_reserve(paddr, size); > } > } > -- > 2.43.0 > >
On Fri, 16 Feb 2024 at 00:21, Ard Biesheuvel <ardb@kernel.org> wrote: > > (cc Oliver) > > On Thu, 15 Feb 2024 at 23:51, Boqun Feng <boqun.feng@gmail.com> 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)); }
On Thu, Feb 15, 2024 at 02:51:06PM -0800, 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|...] > > , 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 > > To fix this, add ACPI_MEMORY_NVS into the linear map. > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > Cc: stable@vger.kernel.org # 5.15+ What commit id does this fix? Can you include that as well? thanks, greg k-h
On Sat, Feb 17, 2024 at 08:49:32AM +0100, Greg KH wrote: > On Thu, Feb 15, 2024 at 02:51:06PM -0800, 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|...] > > > > , 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 > > > > To fix this, add ACPI_MEMORY_NVS into the linear map. > > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > > Cc: stable@vger.kernel.org # 5.15+ > > What commit id does this fix? Can you include that as well? > It should be 7aff79e297ee ("Drivers: hv: Enable Hyper-V code to be built on ARM64"), but as Ard mentioned earlier, this could be fixed at the VM firmware, and Oliver is working on that. Should the situation change, I will send a V2 with more information and include the commit id. Regards, Boqun > thanks, > > greg k-h
On Tue, 20 Feb 2024 at 05:10, Boqun Feng <boqun.feng@gmail.com> wrote: > > On Sat, Feb 17, 2024 at 08:49:32AM +0100, Greg KH wrote: > > On Thu, Feb 15, 2024 at 02:51:06PM -0800, 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|...] > > > > > > , 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 > > > > > > To fix this, add ACPI_MEMORY_NVS into the linear map. > > > > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > > > Cc: stable@vger.kernel.org # 5.15+ > > > > What commit id does this fix? Can you include that as well? > > > > It should be 7aff79e297ee ("Drivers: hv: Enable Hyper-V code to be built > on ARM64"), but as Ard mentioned earlier, this could be fixed at the VM > firmware, and Oliver is working on that. Should the situation change, I > will send a V2 with more information and include the commit id. > The patch as-is is not acceptable to me, so no need to send a v2 just to add more information. Please consider the fix I proposed for arch_memremap_can_ram_remap() if fixing this in the firmware is not feasible.
On Tue, Feb 20, 2024 at 09:27:54AM +0100, Ard Biesheuvel wrote: > On Tue, 20 Feb 2024 at 05:10, Boqun Feng <boqun.feng@gmail.com> wrote: > > > > On Sat, Feb 17, 2024 at 08:49:32AM +0100, Greg KH wrote: > > > On Thu, Feb 15, 2024 at 02:51:06PM -0800, 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|...] > > > > > > > > , 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 > > > > > > > > To fix this, add ACPI_MEMORY_NVS into the linear map. > > > > > > > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > > > > Cc: stable@vger.kernel.org # 5.15+ > > > > > > What commit id does this fix? Can you include that as well? > > > > > > > It should be 7aff79e297ee ("Drivers: hv: Enable Hyper-V code to be built > > on ARM64"), but as Ard mentioned earlier, this could be fixed at the VM > > firmware, and Oliver is working on that. Should the situation change, I > > will send a V2 with more information and include the commit id. > > > > The patch as-is is not acceptable to me, so no need to send a v2 just > to add more information. > > Please consider the fix I proposed for arch_memremap_can_ram_remap() > if fixing this in the firmware is not feasible. Got it. Would do if necessary, thanks! Regards, Boqun
diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index a00e07b853f2..9a1b9bc66d50 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -139,6 +139,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md) case EFI_LOADER_CODE: case EFI_LOADER_DATA: case EFI_ACPI_RECLAIM_MEMORY: + case EFI_ACPI_MEMORY_NVS: case EFI_BOOT_SERVICES_CODE: case EFI_BOOT_SERVICES_DATA: case EFI_CONVENTIONAL_MEMORY: @@ -202,8 +203,12 @@ static __init void reserve_regions(void) if (!is_usable_memory(md)) memblock_mark_nomap(paddr, size); - /* keep ACPI reclaim memory intact for kexec etc. */ - if (md->type == EFI_ACPI_RECLAIM_MEMORY) + /* + * keep ACPI reclaim and NVS memory and intact for kexec + * etc. + */ + if (md->type == EFI_ACPI_RECLAIM_MEMORY || + md->type == EFI_ACPI_MEMORY_NVS) memblock_reserve(paddr, size); } }