From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796472459; b=vdtuNk0d9zJaMJEhs7VzpbF9LO7hNarGF0E+mEv+3lFdCSbPEzPt9W3fKheIj/HGrgUM N0B7iSg5fX5359ZnK4k5rhVT8UVylYGFFu5++wbeC0CDfWd0N7qE7leJl5UWvOk+X2UCg aCLI1Ont4v0Cl5a6g4fUyShmJ6djsMKNpMO+HVy4PZzSRHzrYPF9fDqBWqzvdLyb55yqi aPONrxIvLNqHBxdl6Qk+bshCj5s70fAEk5z6xQIlLor16Y6DJ4HK6BOJMnUejw4fHCJPe UvW5lU1fnbBPMlqgIMnZd9J7o3d69JKz7KDx2rO21qhpwh/IOoEyRfUw/ylz85X4rIw== 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=MzjA78L08eK6wIVYW+1HexNMOua1wLNwMP7+z+mWqV/4Hix/dR3OV2vuiV2bdnuvQgnS p9kn8Ryuf3ihxmD7wNjvqYsUF9uAy2bRzrXzN4u1C+HQCQXDIOg/BK54bRs8KFS95FNJW NkdHjJTP5HWiRQb+qwJMmZ/4RICpmD3gfF3533FXZn2PHMpW6rggLvuVsGYRNNV+m5D2N Q28glB6/mp4KQZz/YfBOVRE3SZ9ywSXEVIBSMTX7Uz2t3TRG+DQJr4QzHMXGWXTkS0wM7 FrppZGDIQ0KjakNI6PQo+gSGIz1pj5vCSGYGWKiCJgJS5IWd2oleuMBQ2qbq2dxFI6g== 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.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (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 94B57606A322 for ; Sat, 5 Dec 2026 12:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94B57606A322 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-f170.google.com with SMTP id 5a478bee46e88-38692f62b22so3756456eec.0 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=PVZ6iAowelAo5LTlkm2Ss+JzkPATUggutGnQHrA95B9y3eu4pziNFVSvjQwJAeRISm E/f44pT/RD3XRk6K008AnGwyl5muG1SXHtvled/+LiGBSwigmx/ppa7BjPACP9aLw6s1 6NDwmI1Q8JcfFZymsyuhmo35CqHtGmWF9JFlQ0gsSn9ANXqs9o9qAo4wRnFkJcB+52Yb d1DvYuPSbEH/OIYgJM6xXVe6cqZLmZzleM0955BjJxKIGUy63VrE0kB1faBnY7RQEpSC zpHCoIbOMkVOmC9/Hwkkny5Rm6yrB7BD3+YyfCuIIYdcok7S4eBrDfZqpDpgCB4c9I4S JzNQ== X-Forwarded-Encrypted: i=1; AL+hErEhGVUjGqJ/m23v2oI32F/PQstUpo2SGOBktWjJwM9SU5mh/YunlD9u0nmBAkKf2pSvV2lPztXL81E=@vger.kernel.org X-Gm-Message-State: AB4q+uERLyZ++JthEM+zbavxCtJz/7zUugkHAKtfJWlLoEyvI1BXG4Rb lTm0h5oOfcmonNTbUFbBH7mqZdhhirIyNiCor8GV/MMRLerjVeQqEa/TFAbUkc5VawA= X-Gm-Gg: AZFdTZdNmhn4ouxIEHi5hZW/0xVeYr08h57F05CFUbaf5NuuI8fQfRwpR+2QQV0vxNE MjegSY9I0dhrAgBKzeXWv6P60Nx74S1zJaa9W31TpA2qQ1AeClMNeaYmScMfruAgX8m76FwU5hF cpokCWWTbmzuCu0xzQR8jS8+MmM9jR7SqDqePN8ywbWrT1M0tyDMnVV+7zibsfhWZx7oCJKexVw mR6aIkcI7NE6Ggh+1IQm2AO//6yn3m/xXBoWE14Kc6weVJeFfbaluQITsvba7tGx79UXqLTig/c WC3SzaljUFhdx7lavpSk97+Us1xUrAtXqk6nmdacKtgjyKQkWAPncVIk/ZzgCD7zjXhLqVtHqSj 4C8p/ai1Xwy51n2xUvZUkHS+puJtRrJRUMjH0BVi6ulgTk2QRPGoIxO1oRtLkVatU1/AvDCXBkk 9tCv2WJHwSXwoYm8yTuSzyVdT6QUAYT4n1WbeV/L/z656CSiw7JzvGmwg5InPaX5Dzuof3dYYhM GyPpFHclpeDkcdEW6fWd7szlLECNiINlk2dEgzOCRyDscQHdoOZoDD8KloGM2A8aIT3mzjzyY6a grPn5/FLK1Nl2cSjtBfvrT6M0JApQnEL5qNNWqRKBlWeXPgos2AhhW818uuQnPeZLqfRbYksLKa qLV2xDchKeyk= 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-efi@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--