From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796472459; b=LnSW/mvPVVUso31zE2bZgPebK6BGMnDrrO/2mpKMsaE7U/NdvNqqXnAjgyLKKApKW5Ki 6AnboMkLcbVnb6yop9P2U9tGvECB+i6zoUDx09R6b72bH/gCbEtcNzWpxUy8shn9Zm5KW nV4Sok2v6FDCTpMspjQwAahv5Jf/j5ufh1PNPn99Nl89vMbylrQGdijhDLmlcCl8LRVK1 L3lyi1creaZdJfctLeFavTV9y4fP8xYZ+E0AD67X560vji8M4qBEDxJDVKETL7XXif/Xp tOrLxiLqVZfmStQFwiPYy2vJV667B1ojGhn6uGJQgS2C1i7tucCdfZBBv6mYtHhAwpw== 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=UsZlpOSmwyYRTYWII8QXio/GTC8mMVXyNfqR5cPHGf+pEjXaaQhc9KHEnvt+IQSF6eLO KgJ5j3Hl16jdrXIGs6E0/RRWY2lbPLyaPwmVEBJkY2JK0OmLAoB+qpfjEZFwElFBjqTS4 HALOy9E+Ufn6nZ6g10Eil/N+vMsxeSZ6Pdk5lXfsxjzRLrsDGlcyrZCh9naZtfp+KscXM eFE+Ckwb/jBM0qT7I9ityh97Ic4YVbxeZaV8kDRhkyXPDibU9z1Ki6JVpcNMryl96g5vp wulOIFdhWToppSzhiSY3/PISAfAcv6Cb01gMAr5S4hE2/a7iRoa6zqGXTaDTkP7vXKQ== 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.169 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (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 95990606A32F for ; Sat, 5 Dec 2026 12:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 95990606A32F 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-f169.google.com with SMTP id 5a478bee46e88-38692f62b22so3756455eec.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=o0MWQaJPMwi1eYNNPBPawj+UYG5YinhI/IJRfZF0w++NWTVd4p8Mmq1m19TPB7zRZd +TO7kQSJ3dDPr8l3BNrlhcmi//Jtjat7VQf3MgLidzTV9jQs5GB3KADn7z6ERl9dflJJ QztkXcHI7BJlC0SlbY6uOGqyLduZytxEUk51SEnwk+DZN+CuRye1m1gABXtnkVnSZ8D9 xUEOArop/2YteNKeEc2SvrZtmd0xLBnYdylQKSqrZs116C8pIa6Ypx5t9mrQUUtRRaU+ fkAW6rhZb2X0PvffxG5hF6Sp5n9/G8qG8DMtdTel+g0v3qlveMEfkkYidnQF7594Gg7T wyRA== X-Forwarded-Encrypted: i=1; AL+hErGjYp2WXI6LUwv0rYlratk3J0xq8nhoNIALYpNMsXKdrrd71xhxrHWCwQcxcQotmA/PqZV3FzBO5A==@vger.kernel.org X-Gm-Message-State: AB4q+uGEVfB2qhhOAhD2Tp+EWo89oXf6MvMrfbdj29Ut+GOQlTnDdAk+ /6XggSB4TYDaFW1Xi7hy/kmAMG1MXKGvlDECneAlU9/IVUNMn/eRcklU X-Gm-Gg: AZFdTZcFdHdd9X9FCyc9lYPQnGJnwj2EIfy6EHuvuI53gcXr5Q5+eeav3pdlwY5VLvj BIHmeOlTubUbfk6ONknlk4hf8TrqMhfdxli4KVS5ySNtZMREp0Ad1RLVpcKBlMDvdxi3ocCCAYI hd3t1qEltjhoHXNmVOOQosYRMMO8BreggsRXjSNKnB2rJacowPAl5MGPG6cPgappYboZDYxbWcO hrUT3E1oghcccKc42l9o+wZ/Q/QLbEHUUZwULHeqaOOv2SIontR6Zh7MgQqSyngvGDcShmbvDuu Q6Mi+l6RfKJUoOGgQuakoblSpBg4iMUhoxPBGPYV5ZD8BFM1Y+LYXflDPSGSdOhg89mTkAJFqHo kkmEKmvDJuja34GSLcm56EO+oqbIN9mFu+VJjOInyDbUh9SrRJwbKemfVjZ+RkHT1OLd0MX9Gyd MV+ZPNuZb4KEeKb60zTqu1TWbW1W2SfGnTQ+O8uHef6Elrgkd72YB9B+s0ZNk6EETdfsXHMcaqQ IQ82ZefMf0GobdOvFh6rPVPJ6N9hhYL/gtJ9miBauqwV7Ore764CrhkNt3jrwPDn9Q1IFAUhQdp mfYae/xTYtfx/FK07hAp3piwqF+3wq9O6EqXwnWfUcow/TmHePSrANyE1GgVbiQlO4RNA96CUhc pSqEBXAoxORg= 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-pm@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--