From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796472459; b=mqZ9MN9RgTz+VHpX9afj6WRCjl82tgJ/WUjqgJiVN1d3ROsiqNrjBWPxl6OOmRHDhHJd qQ0h6NdZfBRQOEnzJbCmgYTHWEV3i4goOvYbjW5DUGgMcHlJtWItgbqTZY+A/jWn5ctby qSJEhhkUU8q86/LpwecbCUVmKc9y880dCX3E8ao7/v+eEWD1oUS/V7316tvN9XQRrWK1J EB6sGkxiZQCUigvf19Fvz6VYmwZbYQV76As4pOf/gU6co8bbQ1IVrkFTQfl8ohoYFFrRM RAnaYPzAJjjgOax7QiFMe8uYTo6sJBrBcOlAc8QJ2LStYfYXagHnuN0xEfXX9RMK3bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796472459; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; bh=iOlISKLjT/BbBToEsh3UegXC3nsYHxyTAc7BpPT8FYs=; b=ShqpnDsE4f7auPw9Tq9cOZRMp6At/o7hriTxDt44Yo0OFApLdPBBrABzaoRcJ1sOXbfR b7E+HaFlJTww2ILipOEziaUc91ESNpYPadcAqHnTpIj6+jmH0iyRmCZCmFHcE7w3HWGvt vX3/r9TrURi/M2ZoXcxuo2tTLHoH0WZbM9XUnIxeT+Y0tXho9K8Qs3LWnjoZHttNEgEQs hvk8saI2P0S3pqJzkjRWAXTeI6BEAv/zd2iecf6OUPxDEDJbGWDfbWbs8EYkFPnCuZ0ql JSAZkvxKBYt0mDTJjHnAt+2/tA87DWHs+BUjSb33pPyqPmMaTTvkGOA57ieQ/1URbWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WRAUHQAQ; arc=none smtp.remote-ip=74.125.82.181 Received: from mail-dy1-f181.google.com (mail-dy1-f181.google.com [74.125.82.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95AB7606A330 for ; Sat, 5 Dec 2026 12:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95AB7606A330 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=WRAUHQAQ Received: by mail-dy1-f181.google.com with SMTP id 5a478bee46e88-385c497bf94so4353613eec.1 for ; Sat, 05 Dec 2026 04:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796472458; x=1797077258; darn=vger.kernel.org; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=iOlISKLjT/BbBToEsh3UegXC3nsYHxyTAc7BpPT8FYs=; b=WRAUHQAQ2vVbqR9R2M4mA6JBmvN2ZF+TR5iFy6L7leMFBd01rZ1KCbIrRmdU9mS0G/ KWJZYq7BbOXmB2G/TxDp/A0q6NIhzDE9J5rugnRQfqs6sEPokRkDrSBCcezelKB7Wn6v 8hknIEk+FezpTau9b6ZPeE25EoL+/95F80iEjMkyhe5f4WqOItAF5lie3G6oIVV51lKh nDos2fGGGsSvIbgsXZdNubjzInhyxdQJsvBSAG4x+oT7/vqv4ocdl0QQvYCR6RjnXE20 fwlun51GfJUzCXD62H+StOO3cRr7f3QT3UubaEC4Q6w+A45SyhWx8lHSPP1MF4t3Hhl0 vIgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796472458; x=1797077258; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iOlISKLjT/BbBToEsh3UegXC3nsYHxyTAc7BpPT8FYs=; b=PWKcPD6b4wiJb8t6z2R5N2pilvKEUTF3QgOAchUyu6cBpFvnXN4IHW2jo+o6XVdgkD IrthZZV68DpD77H3l/2N4lFZWK247VKSrpLCZhyhKVEvQ4WiA7nFCMhLosT1NK6IYhVz u1rGrqQzxEDQX1xOPnDBVafgHA2YjSeJpQtST3dFr/dR9Y52R5eBub/wmtmDV+Qapc3V OcYKdzaTgFmKAaQKTLa4Zj6f2giJS9f6dT9ovfbQbWKwwElL/oEEdHW5ojklsiF9poqL X+SqeY0lpnYDwTE6Na9TT1zLLMoy0ZnOsG/Y/iX5KQ94rcUpm6e2F6NYF4Uj68kJD8di CZcw== X-Forwarded-Encrypted: i=1; AL+hErFGSdnEKXWr0gPm8p5yHx+6rf3iqUBzCaYsiCMB8ikwtv10jt2UgTZvFCrpcMpaRZ6xxdNW24K4CvocW/0=@vger.kernel.org X-Gm-Message-State: AB4q+uG8TUDiXiVq/rhLKP1SFULyO0jt41FfZGzr5BVyPkXbRyqwpQ6G kJZTCgnqpBWVH1UnKxNeem9qG5S68GijTo6AePgRrgxcbfrYMns8WgoE X-Gm-Gg: AZFdTZfVWQC+9BRzRsXdtIE1Mx4nMse6NPzl4CqBk3pxyzclZhz6tluv9o26wQCZP5v KiKlg+cN0AtEIYrcXSOBb/Qx7elpiQgfDFefJrY6R9jprC3eJo022DSLYV3NStOtbbtt0f8zR+e 1S7hWEoGbsI/GnSDBdc6Q7AVN0meBppt5MpRPFs8gXGbMhtDxYVQyIKIjPI5Qs7avBeyjihkByK 3udA3S0mzhPjM0ZX8aBDxSZc9pI80yz2WOWCjkNZt5w40D+uYemqfmTljjftwtbJRbiaE3vtdOy x+rbz2JhQ8t75abVyYKwyi5skgysbXY6WXf0wFSQJpRL/IW7NG5uoaLGwiUPofw3hmsmIEXNH5K 9d+kdjI3LFctrnzl0E2/9/mUmceF5i915l9LRhXXb9T6meovoqMxasY0DLFnIdhHpwALW7ZZIaH I0szcR/iBXQMaa6qDozsvlwUjSkKqB3vWBJ0NZUaM7rG2XkRglVN+nCNWaNurOMYoNtLacou4P2 TiWZ0UXY2SdScXa91AqC9owKOqYu5+tuyB5ikFRfJGcsG8Z5lKZWisFgLn1BGFAmSl/bpp4K7WE 0wES/QdW/7BZeErSw9m7RyjJTnOoaYQtC91PB45cFLZ9kcdL7sfw4ArgVWNUYSKWb0dnYcNYtAZ QPtPmJvF0lLY= X-Received: by 2002:a05:693c:8108:b0:386:a1ae:6762 with SMTP id 5a478bee46e88-38752204559mr4629749eec.36.1796472457506; Sat, 05 Dec 2026 04:07:37 -0800 (PST) Received: from DESKTOP-7QP7L26 ([45.190.211.215]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218bd32sm17689113eec.9.2026.12.05.04.07.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Dec 2026 04:07:36 -0800 (PST) Date: Sat, 5 Dec 2026 09:07:29 -0300 (Hora oficial do Brasil) From: dev12124 To: Alvaro Parker cc: ardb@kernel.org, linux-efi@vger.kernel.org, ilias.apalodimas@linaro.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, x86@kernel.org, hpa@zytor.com, linux-pm@vger.kernel.org, rafael@kernel.org, jlee@suse.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/efi: Map firmware runtime regions before boot services regions In-Reply-To: <20261203153018.26852-1-alparkerdf@gmail.com> Message-ID: References: <20261203153018.26852-1-alparkerdf@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="2434444-23096-1796472455=:8328" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2434444-23096-1796472455=:8328 Content-Type: text/plain; format=flowed; charset=UTF-8 Content-Transfer-Encoding: 8BIT Hi, Analyzing the code, have a few points: I. The good side [ x ] - Why it would break during S4 (Hibernation) During the resumption from hibernation, the new kernel must map the EFI Runtime Services regions (RTCode and RTData) to the exact same virtual addresses used in the previous session, ensuring that `SetVirtualAddressMap()` and the firmware pointers remain valid. [ x ] - The failure of the old algorithm Since efi_map_regions() traversed the memory table from top to bottom, mapping everything in a single pass, any change in the size of Boot Services regions (BSCode/BSData)—which the firmware might allocate differently between a normal boot and an S4 wake—would shift all subsequent virtual addresses of the Runtime regions, causing an immediate page fault in efi_call_rts(). [ x ] - The two-pass correction (pass 0 and pass 1) Separating the loop to first map all pure runtime regions (pass == 0) and only subsequently mapping the reserved boot services regions (pass == 1) isolates the virtual layout of the runtime services. II. The bad side [ ] - Confusing and hard-to-read Boolean condition in the loop (pass == 0) In line: if (efi_is_firmware_runtime_region(md) != (pass == 0)) continue; Comparing the return value of a `bool` function—or an equality expression like `(pass == 0)`—using `!=` works in C (since both evaluate to 0 or 1), but it makes the code unnecessarily dense and prone to errors during future maintenance. Using a clear `enum` (e.g., `PASS_RUNTIME`, `PASS_BOOT_SERVICES`) or a direct check makes the intent immediately obvious. [ ] - Incompatibility of hibernation layout without a bump in RESTORE_MAGIC (Risk of silent regression) Regarding your notes: why shouldn't the x86 `RESTORE_MAGIC` be incremented, or, alternatively, shouldn't a consistency check be performed before calling `efi.runtime`? [ ] - Check the impact of ordering when EFI_PROPERTIES_TABLE is present Is this validated on firmwares that expose the EFI_PROPERTIES_TABLE? Given that the original interleaving between BS (Boot Services) and RT (Runtime Services) can alter the 2M page alignment(EFI_VAR_START). This is a good solution (but, with a `small bugs`). Cheers, João. --2434444-23096-1796472455=:8328--