From nobody Mon Nov 23 22:31:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885563; cv=none; d=zohomail.com; s=zohoarc; b=n2y125TzqYbRwPpumv/0cLNkPzXoL+4vbCh+LaiyBbgZR+bpy8E5YlHlXUYzEFbzIpEZDbGmtVP2Lgr5DF3ZLrG0HLEtO+E2XjmHPUeDiK2H2jKLJMVXHpVQLMraPHV4H8gLQ90nt0dAJGgv4NyHwdSrrBS7aIVUj8KVZChNLNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885563; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pu1UgUgWUzi4OHOR1sIfgHhhY81bof5NV4x1QUXUyUA=; b=TRpRVsywoDKukVRitMEcbIft+lSGJj9S2juDIKqBeE7IxvNEHFYEgwp12AiLxGauh8wmoR0FRZ6hZaJ0F6+U6U7dj9XUjzJHubrR8SL83keU9lzAeC2WlDrleW1VtuMzzseH52aLJc3ahm8lhtM0x3vcuLT3kXtXfGXTSnO7MXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885563360622.9477804354701; Thu, 5 Nov 2026 05:32:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474623.1681633 (Exim 4.92) (envelope-from ) id 1xOxZs-0004Cw-Th; Thu, 05 Nov 2026 13:32:28 +0000 Received: by outflank-mailman (output) from mailman id 1474623.1681633; Thu, 05 Nov 2026 13:32:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxZs-0004Cp-Q0; Thu, 05 Nov 2026 13:32:28 +0000 Received: by outflank-mailman (input) for mailman id 1474623; Thu, 05 Nov 2026 13:32:27 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxZr-0004Cj-SZ for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:32:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxZq-000NaQ-FI for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:32:26 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8559-2eae-0a2a0a5409dd-0a2a4501e258-46 for ; Thu, 05 Nov 2026 14:32:26 +0100 Received: from [209.85.218.49] (helo=mail-ej1-f49.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec8569-5984-0a2a45010019-d155da31b1c8-3 for ; Thu, 05 Nov 2026 14:32:26 +0100 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-c450ab1483cso311782466b.3 for ; Thu, 05 Nov 2026 05:32:26 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e48d0dcsm171112266b.70.2026.11.05.05.32.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:32:24 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885545; x=1794490345; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=pu1UgUgWUzi4OHOR1sIfgHhhY81bof5NV4x1QUXUyUA=; b=RzQZZPQGxT0HYPgcSgrpqCnsHfWtH9+v9YhgBV1gzNf3BmOKt9sqFqMXRMAe49FDMx Ruk+meQo3reTz5EE4QnL9d9HpBJpZpLyq/mWFr78kO3HENyWm5r7iahBJT31XLfDtmBT 5jsurJ53Vjo1FDpaxKiJXLJ/2p3twK4+CNr2z6O75aJH96DWT8yB4yaw4t622vGK8GF8 GqA1Fu+w+wkXDnuIS9ZV7SyMvY/vrqQ8dnDCaSOdzShygvBtn0TJUitW526qcllUwxpI zTTVVzxExrRB5LsFNc9XEuq6c9bcKmogaKgTiqkYNjzYp3E5e3e9kCBcoNsu4r5hw5VF SgEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885545; x=1794490345; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=pu1UgUgWUzi4OHOR1sIfgHhhY81bof5NV4x1QUXUyUA=; b=wykG6C4XnavwYl11Is3cZlIuu9KNnC2QhjwgnJ3DD5bsVRtoztGHnuOo5JqJjhrbI+ M46oEnPjONZ//47KkzFpE7WXUUIv19pSAu7n7Y7MeZpX8IwxBxZjT1BBwWdaxoEXBTZ/ SYliTs0MWc1wETyZ1+x05iBVoPL99HyWsoMzHYiEUapVx7INmXuu/kmY/HYtF4BXomoG lKZTYu+OCLTX0dUGVF6FCgVvsOgL08xR6HnsJtCp61Fye3IBTcdrtcLWoZi4FKtLtzDg dWByrsU0+Dg6qnMvqCDg3rTl4KuODGwotJHySUpjz9H3SbKd4jxT/Y1i1zRPB0NAvPWk 6cnw== X-Gm-Message-State: APuU4Z/u8CXT2WlXAaQY9ABLqN3HOFWhg8oB1a12mhXy8seQQEQ4U+Wi NOuoHKMIcMpBABNHl2P+1cUDbKANf1SFiKzsW5DFPmEnDProGwmUhNh6tcBeplYqUCUtsL/HedB 8b/v8Cw== X-Gm-Gg: AYBFou12Dt894bFHNtgsCx8ed3ytTda9mOlPaRp3mN7kL7LbWzpgFosgCS748xsfgGd 5yakJzLXCKVqfxXhHYTxren/p5HJxG9ONZlZl2aQVP+MNq3CfZSRjG7BDXFWj5s5fcTd/VcRJBz BzOLEMquGKCq+NdQRlxylDgrvmZP9rlf2yJUXgODyLELg8Q4iKBn0t1UwwIwmxxc+MbpbnM1SO2 DAFPuPCPFHfzYSmJr1Dp8PW28dtqzWzhsQ0AosxAsc98m39vrhPbzscWTLuG6IBbx1qPQXhTokB 8/JKbGGXn27Mfhns3O0PwqSdl3S0Pv0AGvmtrCY5EYpN90+iTGPlE7oTsaal5AbUfaR11XloHX4 afJIuPTFl9AmcA6uVvcB0h8yBO2w27PGEGVP6OHESwWxZ4fzV5/YZ5gIrPLgFBfjxUoSEzLZ5mp Y+g5Bq7lhvSTgxLHkiFvbuEg7lp6HH1JCQj+2DkduP7KbGovk2ZOD070qlQhLwrCzi0FIbTBeF1 aC8Cv/BpgkHhndi4rAIwPwTDUMOadhzvYcza87hSh6fuf/MSk2XZILpX1s6Jcd91gLgqcS7Jbwv J4juGJhKyFSc9M9tGfpZmnTudY+rR6RN+vBooFd86tz7Boc/s7gGQiuHo67Oxs7fbkcjBCEqkZm Jn5hAE3jheBYH7eY= X-Received: by 2002:a17:907:868a:b0:c40:231:6eab with SMTP id a640c23a62f3a-c4ca7a4e651mr1693952066b.16.1793885545530; Thu, 05 Nov 2026 05:32:25 -0800 (PST) Message-ID: <64ac61c0-f265-4860-bdb0-f142ea9e4a04@suse.com> Date: Thu, 5 Nov 2026 14:32:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 01/14] x86/EFI: guard against oversized modules From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Marek Marczykowski , Daniel Smith References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1793885546-BC359757-EF92E473/10/78276251493 X-purgate-type: spam X-purgate-size: 1040 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885565563158500 module_t's mod_end field (which we repurpose to hold a module's size) cannot hold values 4Gb and up. Don't let truncation go silently. Signed-off-by: Jan Beulich Reviewed-by: George Dunlap Acked-by: Marek Marczykowski-G=C3=B3recki --- MB and MB2 also constrain module to below 4Gb. The constraint here may be possible to drop once hyperlaunch work has progressed enough to no longer require the intermediate mb_modules[]. --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -736,6 +736,13 @@ static void __init efi_arch_handle_modul place_string(&mb_modules[mbi.mods_count].string, local_name.s); mb_modules[mbi.mods_count].mod_start =3D file->addr >> PAGE_SHIFT; mb_modules[mbi.mods_count].mod_end =3D file->size; + + if ( mb_modules[mbi.mods_count].mod_end !=3D file->size ) + { + PrintStr(name); + blexit(L" is too large"); + } + ++mbi.mods_count; efi_bs->FreePool(ptr); } From nobody Mon Nov 23 22:31:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885601; cv=none; d=zohomail.com; s=zohoarc; b=XZFUFosotvMlPaLAvTKjlfgylaBoCrN71XfmnJsJ2CRN5iBwm+R5WdnuQJQXT57D35e3sta69xfbUdAWQQJrzl3n2JLQT9Gk36l6kK64EguBhQjJcTPkm8nSez6mm8AOTk/SfKFVEs26w0JfwppD87o1oA6hmcVrGrCD+xNWUS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885601; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YuPU3a8IBBvMhUzOW5Q9jnXRThErt0mAuRAL2YchLs4=; b=aRC4TetEJesBrKk1hLq/+Drw56BPi84w+Fxf/OjRgQ+oDnMfglqk/wNUf41MB54BvgNpC1Fz4addFG0MhLV5ddx0qqUPjLt73q2SIcZn/vSx3FWfu5eJ4EF3SqNZMsSfSgYj/zzcD6G9UuAAPDWX1QCw/tzYsi5//kan3ZR1l+s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885601271744.6300530001944; Thu, 5 Nov 2026 05:33:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474634.1681641 (Exim 4.92) (envelope-from ) id 1xOxaS-0004iP-4M; Thu, 05 Nov 2026 13:33:04 +0000 Received: by outflank-mailman (output) from mailman id 1474634.1681641; Thu, 05 Nov 2026 13:33:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxaS-0004iI-0v; Thu, 05 Nov 2026 13:33:04 +0000 Received: by outflank-mailman (input) for mailman id 1474634; Thu, 05 Nov 2026 13:33:03 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxaQ-0004ht-VR for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:33:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxaQ-00Aj8S-BO for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:33:02 +0100 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8580-8faa-0a2a0a5109dd-0a2a4506831e-44 for ; Thu, 05 Nov 2026 14:33:02 +0100 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec858d-195a-0a2a45060019-d155802bd4ff-3 for ; Thu, 05 Nov 2026 14:33:01 +0100 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4b467581b98so13351095e9.0 for ; Thu, 05 Nov 2026 05:33:01 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b57317cae5sm103423815e9.12.2026.11.05.05.32.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:33:00 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885581; x=1794490381; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=YuPU3a8IBBvMhUzOW5Q9jnXRThErt0mAuRAL2YchLs4=; b=gSywKm74J5m1Cs5SvUIN3mDAJ5WVZRGGBA7Z0aAWtEEDF34MZRWDlFlSLIklSXFbxz k99iw4y8SV1U6UEBVcO8SKM2UJ7Q3dkYyKXAoTcYUVLtV0naaqRonbA1Mm9k6YbI7hBz DcjtLmGSCgj+ORKoEuC1jfTWjxmdscT9KshOjnesyk8Wdj1yfVgeLXfRulxuI3Ibx890 joBhI5gUGkSqqY7GM8hpSNb/JCLgPBIhPjYUa/3xay2qQ7t8z+aCCx5GpdOSL13wazZ0 zAir1IjhMQCjISbGEriwOsrFUC3wGE61j5Fgj/cag8NOCYHbRWHthf7xcDA/QHQmTFs4 PlNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885581; x=1794490381; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=YuPU3a8IBBvMhUzOW5Q9jnXRThErt0mAuRAL2YchLs4=; b=euXUYxoeZwzC24nX64f6XTeQoTtWI7fFwM3TG9fPMiSR3yDOt70YgWZ+t3TU7Xp0NB 3AtxtGmbSIMIy8a0p1Vy8Ly0nlshrNeCWlA9/eOncdLALdg8GEyJYsRgMtnLsbIaOzYX N0KXR9FKMA2F04iMxkpLJD66OP+lSfyWSm+HFKDEwNKohzhLbGOYCuhYKzk652o/ccNJ TIBwTkvQvFkq69vnOVYW3SS+B77KT4hdS714xZG2X78VmDcJqy74tavwjzfM57xX1XTY h1qD/laO36vEr99vT5C8OoOj/jxM4YodT3FQeTOismfj5uBJ5Si/f4q73pPCdIUVZOaX W7Ag== X-Gm-Message-State: APuU4Z/rY+x09UdqzzSFYWlvB0bgpBK5c/5oyNf1FL06MMp9NIMqDipA ZmZOXTb32heUvJYWTbiEZNN9fpF7aM/03q98ily1xhLUrTrt/kD+mdV3lDQYuHcgFiZofm7H45e NQuMM3Q== X-Gm-Gg: AYBFou28EwZ16ao4AM7KEmwqh5IUWRwi5PjnZAA3fc68Hf7JEju4TwjUCj1FyMzF8D3 FrfluecKdV2KcPERUqj5pnnEgcez8YgbUs6HSgS6NqUkaI5xshHNkIYETK/GWtCQgYBwSQ6f/vb c2LhdMtZKA6lAZIQWVtxodlDCdrW5TrkSpqJ1/vzdSDScv+skQkGvX0CLS/VDcu/Nn9ZyAntcQJ VOyz6+KuSIUQq0zglh77Fjbh8zjpZi5SG8QJFPMBBqtTsdqTFbuSklb1i744e8GFeUhbFe2Rlxm 2SKFCNIQp1fjKCUZ8/uCkndDR/u2Flq388IUeKxc/C1wYK6BYqOrD9OX+PW02IYtG8uI9wiksnO RP0c5cKTkYMeTbSLJrnIRaXPhmbMhZS4e/CpRag0GKmDi9CyF3QpKYljD5ydk+qS/DxgwA1Zdnd yecdWBLxl96LOwWZyc6YtdM1HXzxmtmGSbfYfboWT1KCUG60JXWXgaMKp6dVdTJALCDRQzAGi7W eZqCUiGyGeNlqGaHJdlD+SnI2sWfloi/Ygz/l22NSqBTFcais6p96qZr3FIWfJ3FFJqN4hXqhsb v3fCMlaOBxOJzWRFuYnoAn3UxKFkM5BDG1/K5iax+h5cIJK2tpG+l0nozUBrp4ddrhceTfP1iJJ 5YIK0413ppEcYbPM= X-Received: by 2002:a05:600c:8b06:b0:4a2:d:5ccc with SMTP id 5b1f17b1804b1-4ac17b2bc63mr431783145e9.10.1793885581330; Thu, 05 Nov 2026 05:33:01 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:32:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 02/14] x86/setup: widen consider_modules()'es size parameter From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1793885581-FD40B77B-5516A196/10/78276251493 X-purgate-type: spam X-purgate-size: 712 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885601848158500 Content-Type: text/plain; charset="utf-8" Eventually we will want to lift the restriction on module size anyway. Right now what we (subsequently) need is a way to express at least "exactly 4G", when rounding up valid sizes below 4G to the next 1G boundary. Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -690,7 +690,7 @@ static void __init noinline move_xen(voi #undef BOOTSTRAP_MAP_LIMIT =20 static uint64_t __init consider_modules( - uint64_t s, uint64_t e, uint32_t size, const struct boot_module *mods, + uint64_t s, uint64_t e, uint64_t size, const struct boot_module *mods, unsigned int nr_mods, unsigned int this_mod) { unsigned int i; From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885621; cv=none; d=zohomail.com; s=zohoarc; b=V4zwweS/zq6Y9Pxl0GGyanvuOWFuWqElWosCn8D+grWDc+y8gaGOD1BziUMxQvDRphaB156wWNTJDufUta4EWauHi38qXDfJgeWt8Jze6BFGqnHexGrTlxNvNlhJR0ehD+9o1Wm0qCB/8O805+4uzPmyArZfIh1y07iUj3rGRwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885621; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sX6VGdCa/sWhS6op5NPZP97VCREu6kSDPuran2qHXj0=; b=NrLiYYra1Dn5LVoC3aeTLSEWfgyi15ysycSY7onATp6zUcOORu4NArZvQbJfHCrksvFB+kCxFNLxp9PucytuwowujHACRCk3dYli8eGokKJ//BcVpcxr5LDdY/1qqHX8aEDMCwQtB2rOUliAcVXQevu6TQGDYL/k0fwAfNMuMHM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885620996881.9081293167369; Thu, 5 Nov 2026 05:33:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474649.1681650 (Exim 4.92) (envelope-from ) id 1xOxaq-0005CL-FI; Thu, 05 Nov 2026 13:33:28 +0000 Received: by outflank-mailman (output) from mailman id 1474649.1681650; Thu, 05 Nov 2026 13:33:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxaq-0005CD-Bw; Thu, 05 Nov 2026 13:33:28 +0000 Received: by outflank-mailman (input) for mailman id 1474649; Thu, 05 Nov 2026 13:33:26 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxao-0005Am-64 for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:33:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxan-00ESLJ-JE for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:33:25 +0100 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec85a3-e002-0a2a0a5209dd-0a2a450b9b9c-12 for ; Thu, 05 Nov 2026 14:33:25 +0100 Received: from [209.85.221.44] (helo=mail-wr1-f44.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec85a5-b7e8-0a2a450b0019-d155dd2cb555-3 for ; Thu, 05 Nov 2026 14:33:25 +0100 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-49231763f81so97060f8f.1 for ; Thu, 05 Nov 2026 05:33:25 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b433ebd278sm117146845e9.3.2026.11.05.05.33.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:33:24 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885605; x=1794490405; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=sX6VGdCa/sWhS6op5NPZP97VCREu6kSDPuran2qHXj0=; b=AVvMdPBbQpZ9lyX7ZTfF8M7U4KwVGURlYyE8XWkdmlwkIFFdBIs/GHxtrQqk+caJSD yZfskhJHEwPuVTQmwOf4kXFtu3+3vtGWh5IlN98OvTsBq0nnFolU73L81GyutGEdliwt qUyqdIdKkT/Bj5MLoT0twU85eXoGkwSZhEANLJjzFbkyHJPzATCVvigovbVOjW77/cjS TK6gZuFOK/IzoKrZ3v4ZxHY1h1wIBFWHkds92oBBwp+Kg/d1eIjV8zmS+vSR7Ki/4mTJ jZw824zLeI0l5lKsoKKzn2pjMD0OfCvK5FNWdWjvoLqUAu6T1WCiy+jZdrs3QFBcKGLP Oi5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885605; x=1794490405; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=sX6VGdCa/sWhS6op5NPZP97VCREu6kSDPuran2qHXj0=; b=1vQMPKSOefk+6mH+Y9rB7lyJCt3z9E8CQMelwRotLMmrK46YoO/RpxK5LHfFntczeh +VJdrK2HQmQPb5YG/4/VmShoU/bZ8C55mWHBXqT3UpT2j2WEynewAFgOc5AowOqrYVqs Rl50bDD4Gwq73NEhwDeRBgaWVhr1wuzusJs1HYxm5nEdSK9GCNQnHaw3QmWRTFY5ptvZ lt5/4j5iCJxH78RV/46nvoRcMtF/pN+FaEcjfm0LYSqoeKS6fpu9cnYKAj/SvI9dbO+1 UMRIyRH6XPkaY4GPLN5hc9jB5QwZ9lH5GT9qIwaPEZ83ndFAhvoPlpvhM88tzC10PcNN uLqA== X-Gm-Message-State: APuU4Z83DBGQl2AXRSYbqAbpYeyjtROXlbURMSPROUdPF9FC1Zh928TQ 42sHOwvezbtgf3/ZzkN/7oGzXa5nM8eKbWm8YQ5mNq3+E4cLKfYD98pyCZ9xIJvkEaHyCwM8Uhb qMroFxg== X-Gm-Gg: AYBFou1NPWLmaqoJpj7Z5EIK5ZVu76joZrTu4F1L36sWCoe1+p8wMaTjfREObURwRRi PgHM7QHkZvrUkF1vXxj2nFwXF703qH83i/yiVCFjeMz4BQE2wF6pCnxmR+EP75E5W87cLrpNQGH IQdRaGK85Fv4ev4PwRiThdGx4ikHxeUbpbNDmiOKygOxexBMZnw1c6bnTPsjnjPVtHnFF7BDmco G5Xcj4FAOpfK6849a1oc5g/HQdhM+ipOocd6E+939FtMmBoz7zR+TrMsCLXp7Yf0GOPwdNjo0Nn dDyiPusykTOL8wJ4pOG7xdf2tbpFlBOomfI71dbnVq7vCxYtvXmEyT920yj1FdJaYW/QWzn6X2Y RAZxw8Q29zGGe/8YqMn7wr8d1N+Pg2vQTYct4PB1i9Jcy9CPu4sIMHGGDVE62PzKuKUKDw0KOjb AE4OrMcObJVt7/CpkjqgKhmc/eZ8RxGQoqr1djOGtUh7P92yztWsksN68FlIzH98C4KUyUCip/p kfsWt8XsxQbHQKyAEwz8DMOlGGblr4YpuA/9lZzwOwDVkYw7P2KY3xGYTOALiiIymrKp7sJnY/Y Wl6I9THIMA+rpXtPfvwPOKBMVrGo2cryda1iTVedmvU9l9dZTJESXYeH7Gea2xNRHlk7Y7y+ELq OItqLy3QpoLHBpIq5v9fw7+0EcvgXy3iQU2OP5w== X-Received: by 2002:a05:600c:4f86:b0:4a7:669c:c988 with SMTP id 5b1f17b1804b1-4ac18b7df2cmr444154455e9.23.1793885604650; Thu, 05 Nov 2026 05:33:24 -0800 (PST) Message-ID: <2ad8d4fb-5256-4371-a21f-6b9886f1b3ae@suse.com> Date: Thu, 5 Nov 2026 14:33:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 03/14] x86/setup: special treatment of initrd for PVH Dom0 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1793885605-18ECE9EA-58F97632/10/78276251493 X-purgate-type: spam X-purgate-size: 7762 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885622338158500 Content-Type: text/plain; charset="utf-8" Dealing with large initrd-s is problematic in two ways: We needlessly copy around a large chunk of data, and our calculation of how much memory to give Dom0 assumes the space taken by the initrd is actually available at the time of populating Dom0's P2M. As a first step, make effort during early boot to try to place the initrd in a chunk of memory that's a multiple of 1Gb (or, if not available / not possibly going to fit, in a chunk a multiple of 2Mb in size). This may (but generally won't) result in more copying, which we simply need to accept. Record (and use) the extra space allocated in (as) headroom, which then needs accouting for in pvh_load_kernel(). Signed-off-by: Jan Beulich --- Not being able to check bm->kind is of course not very nice. The field is only set quite a bit later, and that setting can - afaict - not be moved ahead of the call to xsm_multiboot_init(). The bumping of mask to L3's in __start_xen() may transiently breaks booting of Dom0 with overly much memory assigned to it (with the improved heuristic it doesn't on my test systems anymore, though). That'll be resolved when the headroom space is properly dealt with (consumed into Dom0, or freed). Therefore this patch and everything up to the one adding the consuming code want committing together, or addition of that conditional wants delaying until that later change. Simply using nr_ram_pages()' return value is of course a pretty raw estimate. We could e.g. also subtract Xen's image size and, perhaps more relevant, an estimate of frame_table[]. --- v2: Re-instate lost loop continuation condition. Improve and explain heuristic for whether to look for a multi-Gb block of memory. --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -445,6 +445,20 @@ unsigned long __init dom0_compute_nr_pag return nr_pages; } =20 +/* + * A simplistic sibling of dom0_compute_nr_pages(), for obtaining a very e= arly + * estimate. + */ +unsigned long __init get_dom0_size(unsigned long avail) +{ + if ( CONFIG_DOM0_MEM[0] && !dom0_mem_set ) + parse_dom0_mem(CONFIG_DOM0_MEM); + + return get_memsize(memsize_gt_zero(&dom0_size) ? &dom0_size + : &dom0_max_size, + avail); +} + static void __init process_dom0_ioports_disable(struct domain *dom0) { unsigned long io_from, io_to; --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -653,7 +653,8 @@ static int __init pvh_load_kernel( void *image_base =3D bootstrap_map_bm(image); void *image_start =3D image_base + image->arch.headroom; unsigned long image_len =3D image->size; - unsigned long initrd_len =3D initrd ? initrd->size : 0; + unsigned long initrd_len =3D + initrd ? initrd->size - initrd->arch.headroom : 0; size_t cmdline_len =3D bd->cmdline ? strlen(bd->cmdline) + 1 : 0; const char *initrd_cmdline =3D NULL; struct elf_binary elf; @@ -751,7 +752,8 @@ static int __init pvh_load_kernel( =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, __va(initrd->start), + rc =3D hvm_copy_to_guest_phys(last_addr, + __va(initrd->start + initrd->arch.head= room), initrd_len, v); if ( rc ) { --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -68,4 +68,6 @@ extern bool opt_dom0_verbose; extern bool opt_dom0_cpuid_faulting; extern bool opt_dom0_msr_relaxed; =20 +unsigned long get_dom0_size(unsigned long avail); + #endif --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1023,6 +1023,26 @@ static unsigned long __init nr_ram_pages return nr_pages; } =20 +static __init bool fits_in_low_ram(unsigned long size, unsigned long align) +{ + size =3D ROUNDUP(size, align); + + for ( unsigned int i =3D 0; i < e820.nr_map; ++i ) + { + unsigned long start =3D ROUNDUP(e820.map[i].addr, align); + unsigned long end =3D ROUNDDOWN(e820.map[i].addr + e820.map[i].siz= e, + align); + + if ( e820.map[i].type !=3D E820_RAM || start >=3D GB(4) ) + continue; + + if ( end > start && end - start >=3D size ) + return true; + } + + return false; +} + /* * Calculate the maximum possible size of the dom0 cmdline. Pieces of the * dom0 cmdline optionally come from the bootloader directly, from Xen's @@ -1613,6 +1633,60 @@ void asmlinkage __init noreturn __start_ struct boot_module *bm =3D &bi->mods[j]; unsigned long size =3D PAGE_ALIGN(bm->arch.headroom + bm->size= ); =20 + /* + * For PVH Dom0 try to place the initrd in a full multi-Gb (or + * multi-2Mb) chunk, such that assigning the pages directly can + * be done while still using superpage mappings. + */ + if ( opt_dom0_pvh && j =3D=3D 1 /* bm->kind =3D=3D BOOTMOD_RAM= DISK */ ) + { + /* + * As we may come here more than once, and as bm->size inc= ludes + * headroom after relocation, unlike above we need to subt= ract + * headroom here. (The only module with incoming non-zero + * headroom is the kernel.) + */ + size =3D PAGE_ALIGN(bm->size - bm->arch.headroom); + + /* + * Heuristic, in an attempt to predict what will be decided + * when actually loading (mapping) the initrd: There's no = point + * trying 1Gb mappings when Dom0 has less than 2Gb. There= 's + * also no point trying 1Gb mappings if the initrd fits in= low + * memory, but there's no contiguous 1G-aligned range avai= lable + * there. + */ + if ( get_dom0_size(nr_ram_pages()) >=3D PFN_DOWN(GB(2)) && + (fits_in_low_ram(size, 1UL << L3_PAGETABLE_SHIFT) || + !fits_in_low_ram(size, PAGE_SIZE)) ) + mask =3D (1UL << L3_PAGETABLE_SHIFT) - 1; + + for ( ; mask > PAGE_SIZE; mask >>=3D PAGETABLE_ORDER ) + { + if ( !(bm->start & mask) && bm->arch.relocated ) + break; + + end =3D e; + do { + end =3D consider_modules((s + mask) & ~mask, end &= ~mask, + (size + mask) & ~mask, bi->= mods, + bi->nr_modules + relocated,= j); + } while ( (end & mask) && end > s ); + + if ( end <=3D s ) + continue; + + if ( highmem_start && end > highmem_start ) + break; + + size =3D (size + mask) & ~mask; + bm->start +=3D bm->arch.headroom; + bm->size -=3D bm->arch.headroom; + bm->arch.headroom =3D size - PAGE_ALIGN(bm->size); + goto move_module; + } + } + if ( bm->arch.relocated ) continue; =20 @@ -1625,6 +1699,7 @@ void asmlinkage __init noreturn __start_ =20 if ( s < end && (bm->arch.headroom || (end - size) > bm->start= ) ) { + move_module: move_memory(end - size + bm->arch.headroom, bm->start, bm-= >size); bm->start =3D (end - size); bm->size +=3D bm->arch.headroom; From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885654; cv=none; d=zohomail.com; s=zohoarc; b=XdYaXnXgfRRt9Nt7L7dGK1TApI4kLYh7tbrXkNoif5hM8uThZyt9oNlSgyrZWRTsuSRfzbhkmRGfkCQtdxN+QZx4Bfxk5Cgeq/NrzbStk7UpEPV/RVuRB7z2r4MLFKj2wwlcX7sw1MXilPDh91SQIac6WT8hQbp+/jnkoUkg/QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885654; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T7Nq9uZ3jEvxZNv9g78qXVfRY8rIVXwVbnY0N5ssSvg=; b=JhJE53/JYYv+OLxEvyngqDDoUo2U3R9K3mqMxp648L08dmOFH22BfUpKCF2mtEp8QgnZZBAykqxwcUuvq0D9rjdCfo48GZxiA/8/cPyP8yhyhqcD4ZL7j9ztxmDlPferXfHVVAoiTSnRAEe+RRXFD7TimcCaNgoH37Q8BcRno8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885654796305.7724029666715; Thu, 5 Nov 2026 05:34:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474667.1681658 (Exim 4.92) (envelope-from ) id 1xOxbG-0005mc-MY; Thu, 05 Nov 2026 13:33:54 +0000 Received: by outflank-mailman (output) from mailman id 1474667.1681658; Thu, 05 Nov 2026 13:33:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxbG-0005mR-Jc; Thu, 05 Nov 2026 13:33:54 +0000 Received: by outflank-mailman (input) for mailman id 1474667; Thu, 05 Nov 2026 13:33:54 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxbG-0005l0-6q for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:33:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxbF-00E4OU-Ji for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:33:53 +0100 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec85ba-e002-0a2a0a5209dd-0a2a4506c6a8-14 for ; Thu, 05 Nov 2026 14:33:53 +0100 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec85c1-195a-0a2a45060019-d1558032cd70-3 for ; Thu, 05 Nov 2026 14:33:53 +0100 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4a20bdaf39cso19875185e9.1 for ; Thu, 05 Nov 2026 05:33:53 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b41297c0d3sm111256165e9.1.2026.11.05.05.33.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:33:50 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885633; x=1794490433; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=T7Nq9uZ3jEvxZNv9g78qXVfRY8rIVXwVbnY0N5ssSvg=; b=KjopbVO2dmmgoq+rMUUiLOS3+WYm/BeHzNZw2fzNNbI7W/eIWi0lPJtC2Cwt/Xi+NH A6lGtqXUPYIdDGSF3Wm0xeYxp/V5Dme91dFmHeB/J05MfFf5T5/U5X5DeKesvPIg0N4S hRIZPLN8cAh5OfxV+CwNZhnO6nXowjHtFrPLBamIHbcXLLjpHpXtVNxK6t6yyfboc5Iq cdrthcBLy9R0Ya2ZYbhn0dJoIOEVCk7FqjZ0khX6CovNV6ixT7cQJMGdYblPoqpsN7xg aE2sfLCsxbSvGJAfgTY2WYKK71T1gkSg21udMQMPOOyPkbFGfXHMECrx7uuJGz7Cjryo NhNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885633; x=1794490433; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=T7Nq9uZ3jEvxZNv9g78qXVfRY8rIVXwVbnY0N5ssSvg=; b=VuAIs+tUDFwgy54YJpC6+9ZQJjSqHvi4m+61acNCRkjtqPNNznoMKR+RCmZdxT/Zls EKLEezEsNtNkbQObGeIC52YEQahrniDTXWoaEZ/H7QXk5eqTpkWd4Y85wRHLW/4/zDSy qkH2RzsY4NKIhhEuooWmWunVbbrWS2IEJlfq2zbPV5XVbxf8FK3x6ht2FpvvyYNeuP5p p8LL2qnG/UPFe3Oj8q8IlbacaPwBK1pcUgoUWb5hBEyC9i74jZQSxmIMVwkDfGhLA9aZ 4wAOwvcQ6WpZ2Jli1V7ynwZdJ7BAiDunRxI/HtXNwOWCreitEH8xu3JQEvJeYPOS0GtD agqg== X-Gm-Message-State: APuU4Z+ifjTNyw0OOJWnc0s572nljVGSfQAlt2pG1ftSRJnniBhJXJ8l y+bOMZJ2DEJX0qog57HV/Iu/txM2q7l6tVtNK2oi4jj+3shBY8QIUbyqptfne7l61q7t4GgO1yK obRzZ5g== X-Gm-Gg: AYBFou3Io5Q4XSo3lkqLVo+61HeHrk2+5CWYvzmEfbpnBUe7ongh4CMz/DP43CWVNfZ +I+Zi2jpuuIQQiNLb7JjIy446vUEetz/TADlK0vJr6PB6m0l1e62Ob/5nk/329GmC46HLVf7OKN PgWzDo7WneRrmFF39YxXmbKuLo0bhcMplsK4a788v5504OdfAGT6sjaffPN1ETzHSPA2N0nLkzH 45rE1ky0jPB1ewDRWbUvulyhijVohMs25SM4XCNmNCVky/rdFmZe9/vpSDf/csGATR6A3/oanKr Db3QkdOswFL97UJcR/hlzBhDrwnewyyDR5NX+uZdMoD/LAAp93E5SNxXayW6GxV6A6KUZzCb9YH AkqaKdD6kc/kD2vIJIoJyiEP8rGV/Ik1As8v2qJRbkDChPuMpA5iX7lD3/+Jpo2sw7fgEU8B1fG sjsnWYme1IGSwiQvVxjaJBNw3AjR3DDMD+e7AV30EpIiVBdutLXPf2yx7ZgqWIxnC91KiqqSBrx RpDkkDVzfmHt2u1nZ7Rs0jhJUbjDoOs7BCCQZmbgogG9dvXfEHW2uT59gdOGg4WLsZXOPcnD23y EVZpGOi4xkmxG3vnIwSK8zBvKv/rhdv/Eaci+MaSCKhhCxIFqvyqrOIrDLtGN1JeX0ME6e1bYL+ qDkd9iEZQYV4lNM/u X-Received: by 2002:a05:600c:a00a:b0:4a2:190f:cf6a with SMTP id 5b1f17b1804b1-4ac19802310mr424240255e9.35.1793885632776; Thu, 05 Nov 2026 05:33:52 -0800 (PST) Message-ID: <839f9e5b-43ba-4cf2-9176-ce5ea51f9149@suse.com> Date: Thu, 5 Nov 2026 14:33:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 04/14] x86/PVH: split pvh_load_kernel() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1793885633-F74C977B-2C878843/10/78276251493 X-purgate-type: spam X-purgate-size: 6931 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885656873158500 Content-Type: text/plain; charset="utf-8" All E820 manipulations want to happen before the initrd is placed. As a first step, split placing the kernel from actually loading it. Then placement of other data (ACPI, VMX) can be inserted between kernel placement and P2M population (followed by the loading of the kernel). Signed-off-by: Jan Beulich Reviewed-by: Teddy Astie --- If need be, moving the "elf" local variable to dom0_construct_pvh() could of course further be split off. Just that this by itself doesn't make much sense. --- v2: Also log domain in new printk(). --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -644,26 +644,17 @@ static bool __init check_and_adjust_load return true; } =20 -static int __init pvh_load_kernel( - const struct boot_domain *bd, paddr_t *entry, paddr_t *start_info_addr) +static int __init pvh_place_kernel( + const struct boot_domain *bd, + struct elf_binary *elf, + paddr_t *entry) { struct domain *d =3D bd->d; struct boot_module *image =3D bd->kernel; - struct boot_module *initrd =3D bd->initrd; void *image_base =3D bootstrap_map_bm(image); void *image_start =3D image_base + image->arch.headroom; unsigned long image_len =3D image->size; - unsigned long initrd_len =3D - initrd ? initrd->size - initrd->arch.headroom : 0; - size_t cmdline_len =3D bd->cmdline ? strlen(bd->cmdline) + 1 : 0; - const char *initrd_cmdline =3D NULL; - struct elf_binary elf; struct elf_dom_parms parms; - size_t extra_space; - paddr_t last_addr; - struct hvm_start_info start_info =3D { 0 }; - struct hvm_modlist_entry mod =3D { 0 }; - struct vcpu *v =3D d->vcpu[0]; int rc; =20 if ( (rc =3D bzimage_parse(image_base, &image_start, &image_len)) !=3D= 0 ) @@ -672,19 +663,19 @@ static int __init pvh_load_kernel( return rc; } =20 - if ( (rc =3D elf_init(&elf, image_start, image_len)) !=3D 0 ) + if ( (rc =3D elf_init(elf, image_start, image_len)) !=3D 0 ) { printk("Unable to init ELF\n"); return rc; } if ( opt_dom0_verbose ) - elf_set_verbose(&elf); - elf_parse_binary(&elf); - if ( (rc =3D elf_xen_parse(&elf, &parms, true)) !=3D 0 ) + elf_set_verbose(elf); + elf_parse_binary(elf); + if ( (rc =3D elf_xen_parse(elf, &parms, true)) !=3D 0 ) { printk("Unable to parse kernel for ELFNOTES\n"); - if ( elf_check_broken(&elf) ) - printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&el= f)); + if ( elf_check_broken(elf) ) + printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(elf= )); return rc; } =20 @@ -697,20 +688,43 @@ static int __init pvh_load_kernel( if ( (rc =3D initdom_check_parms(d, &parms)) !=3D 0 ) return rc; =20 - /* Copy the OS image and free temporary buffer. */ - elf.dest_base =3D (void *)(parms.virt_kstart - parms.virt_base); - elf.dest_size =3D parms.virt_kend - parms.virt_kstart; + elf->dest_base =3D (void *)(parms.virt_kstart - parms.virt_base); + elf->dest_size =3D parms.virt_kend - parms.virt_kstart; =20 - if ( !check_and_adjust_load_address(d, &elf, &parms) ) + if ( !check_and_adjust_load_address(d, elf, &parms) ) return -ENOSPC; =20 - elf_set_vcpu(&elf, v); - rc =3D elf_load_binary(&elf); + *entry =3D parms.phys_entry; + + return 0; +} + +static int __init pvh_load_kernel( + const struct boot_domain *bd, + struct elf_binary *elf, + paddr_t *start_info_addr) +{ + struct domain *d =3D bd->d; + struct boot_module *initrd =3D bd->initrd; + unsigned long initrd_len =3D + initrd ? initrd->size - initrd->arch.headroom : 0; + size_t cmdline_len =3D bd->cmdline ? strlen(bd->cmdline) + 1 : 0; + const char *initrd_cmdline =3D NULL; + size_t extra_space; + paddr_t last_addr; + struct hvm_start_info start_info =3D { 0 }; + struct hvm_modlist_entry mod =3D { 0 }; + struct vcpu *v =3D d->vcpu[0]; + int rc; + + /* Copy the OS image and free temporary buffer. */ + elf_set_vcpu(elf, v); + rc =3D elf_load_binary(elf); if ( rc < 0 ) { printk("Failed to load kernel: %d\n", rc); - if ( elf_check_broken(&elf) ) - printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&el= f)); + if ( elf_check_broken(elf) ) + printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(elf= )); return rc; } =20 @@ -724,7 +738,7 @@ static int __init pvh_load_kernel( =20 if ( initrd ) { - size_t initrd_space =3D elf_round_up(&elf, initrd_len); + size_t initrd_space =3D elf_round_up(elf, initrd_len); =20 if ( initrd->arch.cmdline_pa ) { @@ -741,9 +755,9 @@ static int __init pvh_load_kernel( initrd =3D NULL; } =20 - extra_space +=3D elf_round_up(&elf, cmdline_len); + extra_space +=3D elf_round_up(elf, cmdline_len); =20 - last_addr =3D find_memory(d, &elf, extra_space); + last_addr =3D find_memory(d, elf, extra_space); if ( last_addr =3D=3D INVALID_PADDR ) { printk("Unable to find a memory region to load initrd and metadata= \n"); @@ -763,7 +777,7 @@ static int __init pvh_load_kernel( =20 mod.paddr =3D last_addr; mod.size =3D initrd_len; - last_addr +=3D elf_round_up(&elf, initrd_len); + last_addr +=3D elf_round_up(elf, initrd_len); if ( initrd_cmdline ) { size_t len =3D strlen(initrd_cmdline) + 1; @@ -796,7 +810,7 @@ static int __init pvh_load_kernel( * Round up to 32/64 bits (depending on the guest kernel bitness) so * the modlist/start_info is aligned. */ - last_addr +=3D elf_round_up(&elf, cmdline_len); + last_addr +=3D elf_round_up(elf, cmdline_len); =20 if ( initrd !=3D NULL ) { @@ -820,7 +834,6 @@ static int __init pvh_load_kernel( return rc; } =20 - *entry =3D parms.phys_entry; *start_info_addr =3D last_addr; =20 return 0; @@ -1338,6 +1351,7 @@ int __init dom0_construct_pvh(const stru { paddr_t entry, start_info; struct domain *d =3D bd->d; + struct elf_binary elf; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); @@ -1375,6 +1389,13 @@ int __init dom0_construct_pvh(const stru =20 iommu_hwdom_init(d); =20 + rc =3D pvh_place_kernel(bd, &elf, &entry); + if ( rc ) + { + printk("%pd: failed to place kernel\n", d); + return rc; + } + rc =3D pvh_populate_p2m(d); if ( rc ) { @@ -1382,7 +1403,7 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_load_kernel(bd, &entry, &start_info); + rc =3D pvh_load_kernel(bd, &elf, &start_info); if ( rc ) { printk("Failed to load Dom0 kernel\n"); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885663; cv=none; d=zohomail.com; s=zohoarc; b=BdvyVvKQGaXscIqyT+IshHXwesWBWXmMCI6isUwAHmsUd6knG3RcA2sy3JQr+0lsrqB8s4lbILLMIoIuZvlNRuuXRF0zmBcDo4l8FD42zveYa0VX/PDUE8/LMK3K2a3XFR54/Lue611PvA1GOmmeVq1JsBqTrxs7e6gsrYLqsjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885663; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XhVMm7OWGM53YPwY0RwS/WYkkxI/DMxC9jQTrfPSs7E=; b=d6S34No2Vqf9ovGfPobLJMHDGay/TFp04y+yJdP03XZV5sMeDmyB+5vQogLz6ZaQ87EEUSyFw3DTva5CBcDiFg+LF0/74Ssm6CxzqImiTseQ9AqpcERj1truRIjwDG+Ld7GgKC47q5tGGgu/C043xg9vOaEjBxNIREC8AVb0Zlc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885663912444.41934445772927; Thu, 5 Nov 2026 05:34:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474673.1681668 (Exim 4.92) (envelope-from ) id 1xOxbY-0006Cj-U8; Thu, 05 Nov 2026 13:34:12 +0000 Received: by outflank-mailman (output) from mailman id 1474673.1681668; Thu, 05 Nov 2026 13:34:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxbY-0006Cc-Qg; Thu, 05 Nov 2026 13:34:12 +0000 Received: by outflank-mailman (input) for mailman id 1474673; Thu, 05 Nov 2026 13:34:12 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxbY-0006B7-4x for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:34:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxbX-00E4XL-He for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:34:11 +0100 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec85c8-e002-0a2a0a5209dd-0a2a450ac31c-28 for ; Thu, 05 Nov 2026 14:34:11 +0100 Received: from [209.85.218.50] (helo=mail-ej1-f50.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec85d3-f2d2-0a2a450a0019-d155da32d411-3 for ; Thu, 05 Nov 2026 14:34:11 +0100 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c4322d310e7so31676366b.0 for ; Thu, 05 Nov 2026 05:34:11 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e444950sm179757666b.40.2026.11.05.05.34.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:34:10 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885651; x=1794490451; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=XhVMm7OWGM53YPwY0RwS/WYkkxI/DMxC9jQTrfPSs7E=; b=XLHxxp6lGywZ/iIxyVAZz1qpI7EGK4unqTcEWb2c0ROFupX5o45ZcMqKQrqAvYSP6r ANuwqJT9h3wL/9S/94qKJrRW4t9opXkOExujmiljMWyscjvJnWwwNLot2P8PJse0iloR XMGjYeoTlPq7bMxVNAWiCVoFJt3hQqsFQL0av/ENcFZAeE0dtulKHyrSGm28EocxZvW6 zsbsJT5yEQVDMwyEtZq9Q/eYt/0muLgUmFlsotmbEjRtg7MI3RKS7TpNPTJTioiyHTsI OrB/3vxMLoknpl2rmEIs9/SbaTBJ2n5pUFsRQZ0k+Gq5MVTZdyA86VmAHK/nTiHUvw8R rxtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885651; x=1794490451; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=XhVMm7OWGM53YPwY0RwS/WYkkxI/DMxC9jQTrfPSs7E=; b=DBzyWtkaauCGefvMVyl+tUYs9namnkKSWOknSdHSiFjpnI1Rh4kGslP81EDHEQ+J5s zSmYGRx+NSBf2VX75jjb/u5Bm06jeLiQePAqqIGXW2D0MBoT8Kt34sWSNYFSH7S4FnDt 3YanjVT9HyQgDhxhpmr0R0PFidlxq5EmaiHg7VbmVZwoiWeOXCehFaOvklorNZ/t6z7s sX6dE7ZEsDBQrj6tPzYWnBtBwnkadR6XuQA2e9rjC+HftQJ0Xv2dFBk65Sy/uybIgGep SGf+EsBCGY+RyhzicO6vkqififvNDnA+zMV61lA9x3C9aetw4nG+UF97VZDhCzXLtXFd IenA== X-Gm-Message-State: APuU4Z+fFKkcqYNekiXxK2l57RLzNQY/256JXJr0iRHYJvEzY6dzepS2 Lmox0i2xrxLgQqZKO6po+18RFaFY8Qk+V6mCg1n5PTBTp7uKeHDIOtsmclV7CczPSf1P75bNkv3 +hFAK6A== X-Gm-Gg: AYBFou0cAB+QIURXtT8aAh9nSr6O/vUjP6EXZ6sTyvZ56kX1RwxVWhg08WOd+dEkXWr Yu0sObMA7qJdMg0+q4owyDHm6FfhrhSAmY0+z5wjqA1rEhRT37F9cUCKyrItrRCX4ItqGHg7pzP jNtYbMEcF93EqQ9vC1i088YBMGveNMxQOIMi3YlCsdfbeqkgxS8Mx42xSwgStmqCuAGcGGC74WS kLWYedwYx/OiJrTTIKUVgHmxa/+vaoxazCPY584lQOBfg5oWSnfPqD/C4uOyTGTQA/GuYUOKmrG bDumNwLJwo9vPMYhsLcYL520RuLjdfOcUgOgNGbFxi3Upv/MsNnKWnBuoMESUutWHZuougpGBW6 eQfXNZoPmXJWeVX9i7epQ8rzKRt0ZIQWESRmgWaTCDjeN4AFDK5Qiqu/GKZIxplgxlfl/1iGTvQ 9l2z7nY6XKqgjsB65MGPZTxa83alFB4YLKsFjRRDDYbs4ZNcQkfqqHbiG7Kkhb42mjhVwjC5/dM khKO8slEn3aMWxw6zKXoiv0Ht7SRSMhJkQFZq9PI0ynSrxARTxuQgApZDoGHXVF3+KgqUC9Zt4r Ftln0ONVLNfniYazaPlDNNks2QGoGtS6ELjuVeMJam4k910yl2Ilq6c4DQGZAxjVF2QY5XnsVBU V05UIXWp5DIMSWgQz X-Received: by 2002:a17:907:9612:b0:c3f:8c92:3b51 with SMTP id a640c23a62f3a-c4ca793c5f9mr1753027866b.4.1793885650906; Thu, 05 Nov 2026 05:34:10 -0800 (PST) Message-ID: <15a24084-6fd8-4e87-96da-d7059fe43946@suse.com> Date: Thu, 5 Nov 2026 14:34:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 05/14] x86/PVH: keep a copy of Dom0's initial E820 map From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1793885651-52CDBCFC-88047AFE/10/78276251493 X-purgate-type: spam X-purgate-size: 3767 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885665033158500 Content-Type: text/plain; charset="utf-8" pvh_populate_p2m() needs to populate RAM according to the initial map established, prior to any stealing by pvh_steal_ram(). Subsequently the invocations of those functions will (need to) move ahead of pvh_populate_p2m() (while accessing those regions needs to stay after that), so what to act on is no longer Dom0's memory map at the time of invocation. Don't bother freeing the allocation on intermediate error paths: We're going to panic() anyway. Signed-off-by: Jan Beulich --- v2: Clarify plans in description. Also log domain in new printk(). --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -13,6 +13,7 @@ #include #include #include +#include =20 #include =20 @@ -413,7 +414,10 @@ static void __init pvh_init_p2m(struct d } while ( preempted ); } =20 -static int __init pvh_populate_p2m(struct domain *d) +static int __init pvh_populate_p2m( + struct domain *d, + const struct e820entry *e820, + unsigned int nr_e820) { struct vcpu *v =3D d->vcpu[0]; unsigned int i; @@ -421,15 +425,15 @@ static int __init pvh_populate_p2m(struc #define MB1_PAGES PFN_DOWN(MB(1)) =20 /* Populate memory map. */ - for ( i =3D 0; i < d->arch.nr_e820; i++ ) + for ( i =3D 0; i < nr_e820; i++ ) { unsigned long addr, size; =20 - if ( d->arch.e820[i].type !=3D E820_RAM ) + if ( e820[i].type !=3D E820_RAM ) continue; =20 - addr =3D PFN_DOWN(d->arch.e820[i].addr); - size =3D PFN_DOWN(d->arch.e820[i].size); + addr =3D PFN_DOWN(e820[i].addr); + size =3D PFN_DOWN(e820[i].size); =20 rc =3D pvh_populate_memory_range(d, addr, size); if ( rc ) @@ -438,11 +442,11 @@ static int __init pvh_populate_p2m(struc if ( addr < MB1_PAGES ) { uint64_t end =3D min_t(uint64_t, MB(1), - d->arch.e820[i].addr + d->arch.e820[i].si= ze); + e820[i].addr + e820[i].size); enum hvm_translation_result res =3D hvm_copy_to_guest_phys(mfn_to_maddr(_mfn(addr)), mfn_to_virt(addr), - end - d->arch.e820[i].addr, + end - e820[i].addr, v); =20 if ( res !=3D HVMTRANS_okay ) @@ -1352,6 +1356,8 @@ int __init dom0_construct_pvh(const stru paddr_t entry, start_info; struct domain *d =3D bd->d; struct elf_binary elf; + struct e820entry *orig_e820; + unsigned int nr_orig_e820; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); @@ -1389,6 +1395,16 @@ int __init dom0_construct_pvh(const stru =20 iommu_hwdom_init(d); =20 + nr_orig_e820 =3D d->arch.nr_e820; + orig_e820 =3D xvmalloc_array(struct e820entry, nr_orig_e820); + if ( !orig_e820 ) + { + printk("%pd: no memory for copy of E820 map (%u entries)\n", + d, nr_orig_e820); + return -ENOMEM; + } + memcpy(orig_e820, d->arch.e820, nr_orig_e820 * sizeof(*orig_e820)); + rc =3D pvh_place_kernel(bd, &elf, &entry); if ( rc ) { @@ -1396,13 +1412,15 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_populate_p2m(d); + rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820); if ( rc ) { printk("Failed to setup Dom0 physical memory map\n"); return rc; } =20 + xvfree(orig_e820); + rc =3D pvh_load_kernel(bd, &elf, &start_info); if ( rc ) { From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885698; cv=none; d=zohomail.com; s=zohoarc; b=d0rUY//EqEwDQQZ5BC75wvdLvmtzezngqIKN+jiSTmwwgQCwXjSscyKlPOnf4LBDpajd+jhVXU5yazkcycMh12Ld7gKi4h5Dhh7GgVBPgcjybDzQxHFQ6giarcOgnuERLWJa8m8nP2uj2jJC7+xyEjilcdo8RVX/UrZ3J4cQv8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885698; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nRoV9beagea783Ja6NbKXTJm/ZIqSGgGKZTTcQHFyvI=; b=l0vsLXfVw2eIklVUD90/14FSkOJW2qdW1bRj2ZDtUXOx0kom78PhPB4DZJP0gYbGYeOoKIFy5jQ+rlwFEbOxaj0ckO+axjgA+F77E/5R4x/KAbcEw/q1vPqaf/QzyIcbIj/NRcBs/leLjDEnigeCQK8NkUMblU8oWIbBqwbp0Yw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885698080802.9387759927835; Thu, 5 Nov 2026 05:34:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474686.1681677 (Exim 4.92) (envelope-from ) id 1xOxc5-0006vS-8w; Thu, 05 Nov 2026 13:34:45 +0000 Received: by outflank-mailman (output) from mailman id 1474686.1681677; Thu, 05 Nov 2026 13:34:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxc5-0006vL-6I; Thu, 05 Nov 2026 13:34:45 +0000 Received: by outflank-mailman (input) for mailman id 1474686; Thu, 05 Nov 2026 13:34:43 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxc3-0006pe-De for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:34:43 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxc2-009qG4-PS for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:34:42 +0100 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec85ef-2eae-0a2a0a5409dd-0a2a4503d530-8 for ; Thu, 05 Nov 2026 14:34:42 +0100 Received: from [209.85.218.46] (helo=mail-ej1-f46.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec85f2-fae8-0a2a45030019-d155da2ed5b4-3 for ; Thu, 05 Nov 2026 14:34:42 +0100 Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c49b431f022so31451466b.1 for ; Thu, 05 Nov 2026 05:34:42 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e140fcasm174955266b.1.2026.11.05.05.34.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:34:41 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885682; x=1794490482; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=nRoV9beagea783Ja6NbKXTJm/ZIqSGgGKZTTcQHFyvI=; b=SWYW/4wIIGIvef1pF01qWIK117vn/KZEuR+t531TsxVdCSgWjD+HrVkoZIOzu6J3mG Od9uBA2yF76zK17Q8UQ+U0qzSCb7W58XDxWEMFeR44QsYfrPPvsA5n97omOJZmeyD3qw oVqKDLI9rm3IgR7X7hbC2ZuJF0f+ArDkT06PtgzbcyXYITI7B7b9jsnOspwyVj0HePyB 50Qonj3+4ghNO80iFREnKCxXNOHHLYKCYMkSrfi1XihifxhUyHg70eVpwPWXQgk/W3Wc dbN4WRWTKUi0lPeeB8ZxdiNtuYgRxNq20qZ91c4wzEQ93pQT6GYXLWFymSPQ3Yf60u4r fNYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885682; x=1794490482; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=nRoV9beagea783Ja6NbKXTJm/ZIqSGgGKZTTcQHFyvI=; b=i2OkbiNsuuh5LmNQKX8Cn3rAdpqlt755zQmTmFkwzvnLFwVyVz2L0PQcZS2XTYg7XC brGJWmaa6wZOK2c9BxxhpIfR6ce4OsqFBl9f7/z3I9I4Q2yafWV4W2sbm1YtTR7jtbjE zEt1Jg/ul0IgSL6ale8cclZfDFvYzT96fCMTSdgrEUcv1Fx5/gu98E05QAdsFnQ5rdh1 UaJohcSHgaRvpwStKgaZY5ayG1LK5vN1sPtEljsw2cBkNcNRukabB2fM0FnfK7599Y5x +kIJE/cLkcERSHLsjctn/9jFL7fLYQUmH85HlCZR6PgpntnYgjklGkzh0esrFge0lPTT IYzA== X-Gm-Message-State: APuU4Z8mnK8r7I83zFdWK0ErELVNUEP6yXuEkBBFwzlpU3lo/5azR1lk gpK4IW7F8FhFqMTz9Kx9lwuRtpY9e6j3pmXQbNUrpZRHh3Y2yjiDmSgNAIGjSenwrteZ9rix4++ nTt90lQ== X-Gm-Gg: AYBFou3mLfDKvkhwAyK7pGScPxW6/DRexvAeMSvnoz/5nZ0prefSmrFWMuVq38DOmin AOdzkcD1xC0FiLWfD+u2qKm4qsLDLrmKYLE6/wNVajOW92/hJJ8N2CW40ce4pYviQ8FGY0AcaSD e4BtpjOShnLssw7J/xoxQyRKd5BCc7ToTafu3fdQ4tXJ1gyZ9IF28L549L4i7yA08V0ggUpZ+Fo HsjRr3CMNime1yjoxSM3A0VNhZl11hCjJjHBIR7mJpe6Z1bdy4+o3wFfgwpEPWmd5jKXzfVT5wb Glkh7v5NEOWut//lwNchRh32dvM6361Bl4wiaBI2S5iz+GPY6Ri2N5vkWzAXrEFKCBSSiqDMBJZ 9D50NvRJwHR/J6eejyOfdYfWHpNgYxSh+TUzie6ZIgvXdYmgkncEml9B3h0wTiMrsu134vEVhN/ q964+vnFjhjhMM9Hb5v82BXEX+GABERARzcPK9qeK8Z4eUdJgbQb9YgtuRTf0vdV2zXF7tQ3Y10 m9B6rSSxqIyKG0I+RLmvMNrRmEsmWtqmxQqhynzJzzshtzhiYMFUJV+W5+qNnoqYPJM7bhgwTZV ZzQZlQwUJKInpW/sMCY4Ksrhu5ZtPSEpa/jWdCHP0zHt1dM/7jBUjpGhYTObRbnCNLN+B0kgRau 9dw== X-Received: by 2002:a17:907:6d06:b0:c34:c5e8:1dc5 with SMTP id a640c23a62f3a-c4ca7a7255cmr1667128066b.20.1793885682239; Thu, 05 Nov 2026 05:34:42 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:34:41 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 06/14] x86/PVH: lift E820 alignment requirement From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1793885682-6D8D54E9-A424904B/10/78276251493 X-purgate-type: spam X-purgate-size: 2102 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885699730158501 Content-Type: text/plain; charset="utf-8" Before reordering things (to move in particular pvh_steal_ram() invocations ahead of the pvh_populate_p2m() one) drop an undue (and as it turns out unnecessary) assumption: find_memory() doesn't really depend on E820 regions to end on page boundaries. (Note that the check of "start" was pointless, as just before "start" was aligned to a page boundary.) Signed-off-by: Jan Beulich --- Really the assumption towards the start of regions doesn't look to be relevant either, yet I thought I'd limit the change to the minimum needed. --- v2: Drop leftover (pointless) assertion altogether. Further shrink comment. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -365,6 +365,9 @@ static __init void pvh_setup_e820(struct * that's the minimum granularity of the 2nd stage translation. Si= nce * the p2m code uses PAGE_ORDER_4K internally, also use it here in * order to prevent this code from getting out of sync. + * + * Note that this is only for pvh_populate_p2m(). Subsequent uses= of + * pvh_steal_ram() will break the length part. */ start =3D ROUNDUP(entry->addr, PAGE_SIZE << PAGE_ORDER_4K); end =3D (entry->addr + entry->size) & @@ -505,10 +508,7 @@ static paddr_t __init find_memory( PAGE_SIZE); unsigned int i; =20 - /* - * The memory map is sorted and all RAM regions starts and sizes are - * aligned to page boundaries. - */ + /* The memory map is sorted. */ for ( i =3D 0; i < d->arch.nr_e820; i++ ) { paddr_t start, end =3D d->arch.e820[i].addr + d->arch.e820[i].size; @@ -519,8 +519,6 @@ static paddr_t __init find_memory( =20 start =3D MAX(ROUNDUP(d->arch.e820[i].addr, PAGE_SIZE), MB(1)); =20 - ASSERT(IS_ALIGNED(start, PAGE_SIZE) && IS_ALIGNED(end, PAGE_SIZE)); - /* * NB: Even better would be to use rangesets to determine a suitab= le * range, in particular in case a kernel requests multiple heavily From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885721; cv=none; d=zohomail.com; s=zohoarc; b=RVXotrHfvFdeMPvoGjGQMaPK03JtST8fF5AsxOn2hlGE8+hpoVTgamSIpdBXDk1b6ipa3/fcvyXCDyPDzvNH+tDvDR4NXuWNslVXyr5TXyrV0e/YtT/lY2i3Nfmaf7VDK/lKa6cDjrpf3r3Y4cD7mmwVC8se2f6cnOteL1vpBuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885721; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XpCmbNgO/MZ7F5Rzx8w1sv0eb+AM+ypq+lRrGobD9wM=; b=X+e7pH5yjIcU7RsxN0lofsrb2OCqrN38Qt6kQuQ8SMECBIBuJODbMkDSpHUYKZhcttCIybypS92FR5DquUX453Cqwi4x3r4iutq7s7ppaauywChXVGuCJbTQizTPueVVzOU7jfDm3aZO2pTabymjGAH7NRAgJL7SkP7Skm7EEYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885721128333.7374257176589; Thu, 5 Nov 2026 05:35:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474693.1681687 (Exim 4.92) (envelope-from ) id 1xOxcR-0007NN-IL; Thu, 05 Nov 2026 13:35:07 +0000 Received: by outflank-mailman (output) from mailman id 1474693.1681687; Thu, 05 Nov 2026 13:35:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxcR-0007NG-DJ; Thu, 05 Nov 2026 13:35:07 +0000 Received: by outflank-mailman (input) for mailman id 1474693; Thu, 05 Nov 2026 13:35:05 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxcP-0007Mt-IV for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:35:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxcO-009qSu-RY for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:35:04 +0100 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec85ef-2eae-0a2a0a5409dd-0a2a4503d530-30 for ; Thu, 05 Nov 2026 14:35:04 +0100 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec8608-fae8-0a2a45030019-d155802ab8d2-3 for ; Thu, 05 Nov 2026 14:35:04 +0100 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a5177d78c7so17301245e9.2 for ; Thu, 05 Nov 2026 05:35:04 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b56ba6bc36sm73994885e9.0.2026.11.05.05.35.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:35:03 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885704; x=1794490504; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=XpCmbNgO/MZ7F5Rzx8w1sv0eb+AM+ypq+lRrGobD9wM=; b=f5h2bqE2GFGqvN18qz0RCZRFN2aE8A9icyUOEGCzKPba0ikEBu5vDJtsJRnelJkA1Y 001SnKFpUpFCnA87e2eQsIguOE77OTHLSCUYesaQFTQcTH+sudrqrDbXNYh7kPYPIvDe Jmyp+D4tuJ5AJi8QJHbu05ClnBnonb52wnfaZnHrrJ2oKiTpeCDLmW74Ory/5bysCBs1 BMhUhB9hGDTioI5IXCGonySmwR0qy7aUVQe/0RMus+xP5sZ4050WOH1C0KBD79U3n/Am pAA1GtCPtIjP77O39tyQXZwP0zb9975I24JABfse9lF3ostA8MgnzzJ7hfw7m3iSgNLi rVSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885704; x=1794490504; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=XpCmbNgO/MZ7F5Rzx8w1sv0eb+AM+ypq+lRrGobD9wM=; b=HUm49OXwgXximWl+fcuOi6IJZRmTwKvGlWOVyP8gEHUKo7o2Ec0BM5GEas9Wc8BHoo BcFglaJfpxgUfOmgPrrQRkH018ZhnqdVxYgGFJwTh6y/DcfRnL3qAZdpxxgVS98PGtPa dKeM02ncG3INPt2WbveSBTC+1YxgqP/XtYNMFhHaoM3HQxrLpkz3d0oSbzvjS6w05C6h y3+6CcwS1EalZxPfkP70ApMlAQjJh9kZycI5jjn2F5oIobaLY4taoOS4XnYwHfvyzIUT ejamEW0ZMoNmArdg3xLBnRk1xPgdv1IeM4vyHcK1h5/e16sZsl/QVORWyhFDNWPiiYNC TOXA== X-Gm-Message-State: APuU4Z9K5YNYsOsFgFmBY9NPuk3bQhkQBAd9MvU/VskS/zIIm+ZG3Pm+ k8CJ8P/UZeeTlNpZOumTya+J5ueci48hRfo+LlGbT4nNpYf42b5WWdLJDgH47wQ94k46+Fo3te/ 4WNSajQ== X-Gm-Gg: AYBFou0QHlRgA3xlSJ/KAVmNg53/cfeZ4Hq99/pwXuQv6R+dV6Q/JXw36Jze+/l3UVa ReGsbVnqPFZGz6CrWCwYaa2V/119DLskkCssSEkMcxSrrro/cBVO9QjsWmZY7Eld6HeIHD4xL6d PCQ5e2j+02ihPKH4onrn7QQXOIVEW/s83ehj8WC6CCakpmv5sDRBk23pbV32ZqJVlwRsmu5jFm1 7ZJlEjHrccrFkmWiCXrtR5v5AFUITTRRYNloYUQv2QraD8uVluwdYFxDz97hofnaw8fK7E8SqxR cIIz+4yLRNSQ2AxIXVVqsXhqSnb2EKkzCTjYfXYBZWWCh4JYGx8ZogtQRSzDLDmdWyqKS1t1p39 Lv+PcI+IXdAbF8up25TMAQJmZUVS/s2yB4V2OtHgNf9PByLMdXwrCbh5LYNkREYlGYQnohHP78l N77gA4XLXJ7DHOmkw7A8feCMqPkj2V/C9xtix1BVT9zpsGiF1tZgI5AdFfRfVCvXxN6qGIexNjh MIxxdI3EnhtkC7umXllO/ZPU7AgMX1qpsdwcfjxR5qyLA2e5LSE0tIdqWeAdGYDiVOQHOyS/GPq EImzKAYhgtmUhkVhARTwVQxPGmbj4v3y04khNwlyRCH5bN/au9EbOawBfxgbQQ0V/6LkOcIqPHk nmcQhoJQpWLQsWSzd X-Received: by 2002:a05:600c:468c:b0:4a3:59c9:a750 with SMTP id 5b1f17b1804b1-4ac17d168bcmr429458455e9.9.1793885704152; Thu, 05 Nov 2026 05:35:04 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:35:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 07/14] x86/PVH: split pvh_setup_acpi() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1793885704-768FA4E9-657B38E2/10/78276251493 X-purgate-type: spam X-purgate-size: 10309 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885724063158500 Content-Type: text/plain; charset="utf-8" All E820 manipulations want to happen before the initrd is placed, or else pvh_steal_ram() may steal from the tail part of it. As a second step, split placing ACPI data from actually populating it. To reuse size calculations and limit churn, convert pvh_setup_acpi_{madt,xsdt}() to two-pass functions: The 1st pass merely reserves space, while the 2nd pass actually populates information. Fixes: 1d74282c455f ("x86: setup PVHv2 Dom0 ACPI tables") Signed-off-by: Jan Beulich --- v2: Also log domain in new/moved/altered printk()s. Don't add BUILD_BUG_ON() which is being removed again by a later change. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -915,8 +915,9 @@ static int __init pvh_setup_acpi_madt(st int rc; =20 /* Count number of interrupt overrides in the MADT. */ - acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, - acpi_count_intr_ovr, UINT_MAX); + if ( !*addr ) + acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE, + acpi_count_intr_ovr, UINT_MAX); =20 /* Calculate the size of the crafted MADT. */ size =3D sizeof(*madt); @@ -924,6 +925,22 @@ static int __init pvh_setup_acpi_madt(st size +=3D sizeof(*intsrcovr) * acpi_intr_overrides; size +=3D sizeof(*x2apic) * d->max_vcpus; =20 + if ( !*addr ) + { + /* Reserve space to place the new MADT in guest memory space. */ + if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) + { + printk("%pd: unable to steal guest RAM for MADT\n", d); + return -ENOMEM; + } + + /* Mark this region as E820_ACPI. */ + if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) + printk("%pd: unable to add MADT region to memory map\n", d); + + return 0; + } + madt =3D xzalloc_bytes(size); if ( !madt ) { @@ -986,17 +1003,6 @@ static int __init pvh_setup_acpi_madt(st madt->header.checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, madt), s= ize); =20 /* Place the new MADT in guest memory space. */ - if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) - { - printk("Unable to steal guest RAM for MADT\n"); - rc =3D -ENOMEM; - goto out; - } - - /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) - printk("Unable to add MADT region to memory map\n"); - rc =3D hvm_copy_to_guest_phys(*addr, madt, size, d->vcpu[0]); if ( rc ) { @@ -1111,6 +1117,22 @@ static int __init pvh_setup_acpi_xsdt(st */ size +=3D num_tables * sizeof(xsdt->table_offset_entry[0]); =20 + if ( !*addr ) + { + /* Reserve space to place the new XSDT in guest memory space. */ + if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) + { + printk("%pd: unable to find guest RAM for XSDT\n", d); + return -ENOMEM; + } + + /* Mark this region as E820_ACPI. */ + if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) + printk("%pd: unable to add XSDT region to memory map\n", d); + + return 0; + } + xsdt =3D xzalloc_bytes(size); if ( !xsdt ) { @@ -1174,17 +1196,6 @@ static int __init pvh_setup_acpi_xsdt(st xsdt->header.checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, xsdt), s= ize); =20 /* Place the new XSDT in guest memory space. */ - if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) - { - printk("Unable to find guest RAM for XSDT\n"); - rc =3D -ENOMEM; - goto out; - } - - /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) - printk("Unable to add XSDT region to memory map\n"); - rc =3D hvm_copy_to_guest_phys(*addr, xsdt, size, d->vcpu[0]); if ( rc ) { @@ -1200,18 +1211,18 @@ static int __init pvh_setup_acpi_xsdt(st return rc; } =20 -static int __init pvh_setup_acpi(struct domain *d, paddr_t start_info) +struct acpi_info { + paddr_t madt; + paddr_t xsdt; + paddr_t rsdp; +}; + +static int __init pvh_place_acpi( + struct domain *d, + struct acpi_info *info) { - unsigned long pfn, nr_pages; - paddr_t madt_paddr, xsdt_paddr, rsdp_paddr; unsigned int i; int rc; - struct acpi_table_rsdp *native_rsdp, rsdp =3D { - .signature =3D ACPI_SIG_RSDP, - .revision =3D 2, - .length =3D sizeof(rsdp), - }; - =20 /* Scan top-level tables and add their regions to the guest memory map= . */ for( i =3D 0; i < acpi_gbl_root_table_list.count; i++ ) @@ -1234,6 +1245,8 @@ static int __init pvh_setup_acpi(struct /* Identity map ACPI e820 regions. */ for ( i =3D 0; i < d->arch.nr_e820; i++ ) { + unsigned long pfn, nr_pages; + if ( d->arch.e820[i].type !=3D E820_ACPI && d->arch.e820[i].type !=3D E820_NVS ) continue; @@ -1262,32 +1275,49 @@ static int __init pvh_setup_acpi(struct } } =20 - rc =3D pvh_setup_acpi_madt(d, &madt_paddr); + rc =3D pvh_setup_acpi_madt(d, &info->madt); if ( rc ) return rc; =20 - rc =3D pvh_setup_acpi_xsdt(d, madt_paddr, &xsdt_paddr); + rc =3D pvh_setup_acpi_xsdt(d, info->madt, &info->xsdt); if ( rc ) return rc; =20 - /* Craft a custom RSDP. */ - native_rsdp =3D acpi_os_map_memory(acpi_os_get_root_pointer(), sizeof(= rsdp)); - if ( !native_rsdp ) + if ( pvh_steal_ram(d, sizeof(struct acpi_table_rsdp), 0, GB(4), + &info->rsdp) ) { - printk("Failed to map native RSDP\n"); + printk("%pd: unable to allocate guest RAM for RSDP\n", d); return -ENOMEM; } - memcpy(rsdp.oem_id, native_rsdp->oem_id, sizeof(rsdp.oem_id)); - acpi_os_unmap_memory(native_rsdp, sizeof(rsdp)); - rsdp.xsdt_physical_address =3D xsdt_paddr; - /* - * Calling acpi_tb_checksum here is a layering violation, but - * introducing a wrapper for such simple usage seems overkill. - */ - rsdp.checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, &rsdp), - ACPI_RSDP_REV0_SIZE); - rsdp.extended_checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, &rsdp), - sizeof(rsdp)); + + /* Mark this region as E820_ACPI. */ + if ( pvh_add_mem_range(d, info->rsdp, + info->rsdp + sizeof(struct acpi_table_rsdp), + E820_ACPI) ) + printk("%pd: unable to add RSDP region to memory map\n", d); + + return 0; +} + +static int __init pvh_setup_acpi( + struct domain *d, + struct acpi_info *info, + paddr_t start_info) +{ + int rc; + struct acpi_table_rsdp *native_rsdp, rsdp =3D { + .signature =3D ACPI_SIG_RSDP, + .revision =3D 2, + .length =3D sizeof(rsdp), + }; + + rc =3D pvh_setup_acpi_madt(d, &info->madt); + if ( rc ) + return rc; + + rc =3D pvh_setup_acpi_xsdt(d, info->madt, &info->xsdt); + if ( rc ) + return rc; =20 /* * Place the new RSDP in guest memory space. @@ -1297,19 +1327,27 @@ static int __init pvh_setup_acpi(struct * the native RSDT, and should not be used for the Dom0 kernel's boot * purposes (we keep it visible for post boot access). */ - if ( pvh_steal_ram(d, sizeof(rsdp), 0, GB(4), &rsdp_paddr) ) + native_rsdp =3D acpi_os_map_memory(acpi_os_get_root_pointer(), sizeof(= rsdp)); + if ( !native_rsdp ) { - printk("Unable to allocate guest RAM for RSDP\n"); + printk("%pd: failed to map native RSDP\n", d); return -ENOMEM; } + memcpy(rsdp.oem_id, native_rsdp->oem_id, sizeof(rsdp.oem_id)); + acpi_os_unmap_memory(native_rsdp, sizeof(rsdp)); + rsdp.xsdt_physical_address =3D info->xsdt; =20 - /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, rsdp_paddr, rsdp_paddr + sizeof(rsdp), - E820_ACPI) ) - printk("Unable to add RSDP region to memory map\n"); + /* + * Calling acpi_tb_checksum here is a layering violation, but + * introducing a wrapper for such simple usage seems overkill. + */ + rsdp.checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, &rsdp), + ACPI_RSDP_REV0_SIZE); + rsdp.extended_checksum -=3D acpi_tb_checksum(ACPI_CAST_PTR(u8, &rsdp), + sizeof(rsdp)); =20 /* Copy RSDP into guest memory. */ - rc =3D hvm_copy_to_guest_phys(rsdp_paddr, &rsdp, sizeof(rsdp), d->vcpu= [0]); + rc =3D hvm_copy_to_guest_phys(info->rsdp, &rsdp, sizeof(rsdp), d->vcpu= [0]); if ( rc ) { printk("Unable to copy RSDP into guest memory\n"); @@ -1319,7 +1357,7 @@ static int __init pvh_setup_acpi(struct /* Copy RSDP address to start_info. */ rc =3D hvm_copy_to_guest_phys(start_info + offsetof(struct hvm_start_info, rsdp_paddr= ), - &rsdp_paddr, + &info->rsdp, sizeof_field(struct hvm_start_info, rsdp_p= addr), d->vcpu[0]); if ( rc ) @@ -1356,6 +1394,7 @@ int __init dom0_construct_pvh(const stru struct elf_binary elf; struct e820entry *orig_e820; unsigned int nr_orig_e820; + struct acpi_info acpi =3D {}; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); @@ -1410,6 +1449,13 @@ int __init dom0_construct_pvh(const stru return rc; } =20 + rc =3D pvh_place_acpi(d, &acpi); + if ( rc ) + { + printk("%pd: failed to place ACPI tables: %d\n", d, rc); + return rc; + } + rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820); if ( rc ) { @@ -1433,7 +1479,7 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_setup_acpi(d, start_info); + rc =3D pvh_setup_acpi(d, &acpi, start_info); if ( rc ) { printk("Failed to setup Dom0 ACPI tables: %d\n", rc); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885743; cv=none; d=zohomail.com; s=zohoarc; b=Crwo0WqOT3MlMZdQuRNEIC/uaJwVcwOSKB9brlov0ayX0XotqLo4qibhunqBG8wbdZu6gyF7yfDem0w0xy8q6qkJFxhauz2InvXdCFkeGuk/bLtLwbqyFm4o16LSPIK6wR0h8hB2KvX4Xp29XPaFOrI6NQ8GqHJS4mUhOiQHOwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885743; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=j1H0axRw7JFmol/inFP+mhs/4Cd3fWwbDSonZNiObFg=; b=ALLQK+tMmSebJpgOX3h3uXZlXTEhvqkW9pqgdkKpW1t7YY9kRRi95fr70sRUJoUgKYLOcjXMr8gQQV57eSWfjdnXNXQC2WZetjlQYVPoTwUvrYM7gyHE646ZSAmE6EThaq/FykePP3KxRcHRxldadqs2qKujvV/PmssV0mMnDLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885743368182.2027266557959; Thu, 5 Nov 2026 05:35:43 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474698.1681694 (Exim 4.92) (envelope-from ) id 1xOxcl-0007pQ-Nk; Thu, 05 Nov 2026 13:35:27 +0000 Received: by outflank-mailman (output) from mailman id 1474698.1681694; Thu, 05 Nov 2026 13:35:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxcl-0007pG-Kl; Thu, 05 Nov 2026 13:35:27 +0000 Received: by outflank-mailman (input) for mailman id 1474698; Thu, 05 Nov 2026 13:35:25 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxcj-0007n9-HE for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:35:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxci-00G3pg-Tx for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:35:24 +0100 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8616-8faa-0a2a0a5109dd-0a2a4504cdde-14 for ; Thu, 05 Nov 2026 14:35:24 +0100 Received: from [209.85.208.51] (helo=mail-ed1-f51.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec861c-b57f-0a2a45040019-d155d033c593-3 for ; Thu, 05 Nov 2026 14:35:24 +0100 Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-6b5669a5100so2204756a12.1 for ; Thu, 05 Nov 2026 05:35:24 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6b55abd3da7sm1898289a12.1.2026.11.05.05.35.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:35:23 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885724; x=1794490524; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=j1H0axRw7JFmol/inFP+mhs/4Cd3fWwbDSonZNiObFg=; b=ByoTe8/SJQKTKxYnPEaC500+t4yqrsLOYP+aeKkk+88AVsjTOS37Nh3IArfJ6vEXXd TlfNoMG3SZVT6qCjzymiMc36mTa9Kyuz+DzhXE5VfdFJGuIpifPWWouNVEQy1bhxMdHw QneAdAUrs1pHk7ObhwH9o62noP8j148SN0yy04mtOEPPGE6RolNMcVjWC+Ly4rmk4Rd0 0rVPHvd81LgjcUa8yWNvSVS3HrARxDn1SfT0xtMaNRzmkhcQYlsbPHg3afkzb60M3kzS O1I4kllpsO2staPKD/a7y9DRWtDUESVmrHkmQGQ2U3VItratefo7WpYJaHbIBwJGSqVj XlZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885724; x=1794490524; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=j1H0axRw7JFmol/inFP+mhs/4Cd3fWwbDSonZNiObFg=; b=wNmDD2d3guRSoKxcmVuiHgVDGJU44v6dgAufTZCxT8PnoCucbeKo2SYW9hxLdkTxWN wjx6NbQUTlvQXNUFVmvELquHvFpUsJp09y01CtiB4sXqA/zTpEcx5oRwqafupFlKklUi pshG9XziuUgDgSjMzgxstpUg6yWG5ZRomvZwPbdqli8r/7FeSK2kFlsuupumTBy74ktt QI1t4s3BSXYEqPyOnAkhmmWOMAPa4MXwJjHvA23iCRdp30jffPe70v3QxtjpOyolcfe8 WVBOXdb5fKOOlZdNpvDu88Z47D6v4VlgXS1+PIJCqa47vEoC702eUSLtMETj8PW85c6p ze+g== X-Gm-Message-State: APuU4Z+pW+q//4tL0jrRL53FWAuZj2gYnHO0XMo4ptYm26QjRYD/zRFR vVF4jKrZt6ddzuSIi3s3uMU/NcflQuBQyhenbmWmkzhvAJMdUc1mJ9sWYHB8TcbwsFoRnpSIobi yxFvUbA== X-Gm-Gg: AYBFou2NSPbvy0R9teSxI4NgGA+qMs2qJmW2XiO7rqXWVqNZPogrHc6ReqvTQ5ZyRKO VRiShexbUnUhMoBhfAFeAAspoZMGgXyLZ8bLkskaEOoAS8v2EQmbRZK+NltaakjZp0j/XEs3oqF 4ESFdpGNKOz7ZmU2xKoU206aLdidpyQKi1Oz7cZmXOIy2N5c+1bxvciKV4tDYEQ2t/2/kH/DHwI +MTQJbgv3XrDP6P3uLo274JRQRQVL9kV66ZfdNRG3TrVK0wV0Q+v9zF55FE/RCI6MnQcwGUFfFd JIkBWYwBy26t63eb4TgoMyLEm9Y2c1ng3KdueZ0F69NH2ONXPnCNtEAcKb+M1JOIlkdgS+fx9zC iDR6R+TK6/p4FdzmyHw/V2hkHyLfkrwjxyXtLr9ByQh5q014N+6Z0pettcRqxXRTlIKYrXQZdjU 219eTm00saogC1+Vl2pctSChZzUbyXhBWZ5wUQawfHF/HPt0IsDsXaXR9VlosAM93ZaeGkeCZhk wTE5ILpyXApcJG7JSQfIy5nhYL2E3UbPcZEnyidElhBRsN4h4CxG8yPxex/F3wDt6BJtDhj6uMT lhUK0xDBzD489bnfpt7vRm6lUxCaqMPbDKwjxCfBDBQJnp/DAuaOOOk0vCpb+qfHekm0fuWHVpG IycI73Jggexj9AFG6 X-Received: by 2002:a05:6402:4512:b0:6b5:7872:2d1a with SMTP id 4fb4d7f45d1cf-6b57872312emr1932887a12.41.1793885724030; Thu, 05 Nov 2026 05:35:24 -0800 (PST) Message-ID: <65f0d55b-9552-45e5-8b36-bc76a73011d1@suse.com> Date: Thu, 5 Nov 2026 14:35:22 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 08/14] x86/PVH: split pvh_setup_vmx_realmode_helpers() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1793885724-50EDEB50-C9A51486/10/78276251493 X-purgate-type: spam X-purgate-size: 5989 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885744521158500 Content-Type: text/plain; charset="utf-8" All E820 manipulations want to happen before the initrd is placed, or else pvh_steal_ram() may steal from the tail part of it. While this is currently suitably ordered, mapping the initrd directly into Dom0 will want to happen ahead of pvh_populate_p2m(). Hence as a third step, split placing VMX data (if needed at all) from actually populating it. Also move the invocation of pvh_setup_vmx_realmode_helpers() out of pvh_populate_p2m(). Make it unconditional as well, instead bailing from the function when pvh_place_vmx_realmode_helpers() wasn't called. Signed-off-by: Jan Beulich --- v2: Also log domain in moved printk(). --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -268,26 +268,30 @@ static int __init pvh_add_mem_range(stru return 0; } =20 -static int __init pvh_setup_vmx_realmode_helpers(struct domain *d) +struct vmx_info { + paddr_t tss; + gfn_t identpt; +}; + +static int __init pvh_place_vmx_realmode_helpers( + struct domain *d, + struct vmx_info *info) { - uint32_t rc, *ident_pt; - mfn_t mfn; paddr_t gaddr; - struct vcpu *v =3D d->vcpu[0]; =20 /* - * Steal some space from the last RAM region below 4GB and use it to - * store the real-mode TSS. It needs to be aligned to 128 so that the - * TSS structure (which accounts for the first 104b) doesn't cross - * a page boundary. + * Steal some space from the last RAM region below 4GB to store the + * real-mode TSS. It needs to be aligned to 128 so that the TSS + * structure (which accounts for the first 104b) doesn't cross a page + * boundary. */ if ( !pvh_steal_ram(d, HVM_VM86_TSS_SIZE, 128, GB(4), &gaddr) ) { - if ( hvm_copy_to_guest_phys(gaddr, NULL, HVM_VM86_TSS_SIZE, v) != =3D - HVMTRANS_okay ) - printk("Unable to zero VM86 TSS area\n"); d->arch.hvm.params[HVM_PARAM_VM86_TSS_SIZED] =3D VM86_TSS_UPDATED | ((uint64_t)HVM_VM86_TSS_SIZE << 32) | gaddr; + + info->tss =3D gaddr; + if ( pvh_add_mem_range(d, gaddr, gaddr + HVM_VM86_TSS_SIZE, E820_RESERVED) ) printk("Unable to set VM86 TSS as reserved in the memory map\n= "); @@ -302,12 +306,42 @@ static int __init pvh_setup_vmx_realmode return -ENOMEM; } =20 + if ( pvh_add_mem_range(d, gaddr, gaddr + PAGE_SIZE, E820_RESERVED) ) + printk("%pd: Unable to set identity page tables as reserved in the= memory map\n", + d); + + d->arch.hvm.params[HVM_PARAM_IDENT_PT] =3D gaddr; + info->identpt =3D _gfn(PFN_DOWN(gaddr)); + + return 0; +} + +static int __init pvh_setup_vmx_realmode_helpers( + const struct domain *d, + const struct vmx_info *info) +{ + uint32_t rc, *ident_pt; + mfn_t mfn; + struct vcpu *v =3D d->vcpu[0]; + + /* Bail if no space needed reserving in the first place. */ + if ( gfn_eq(info->identpt, _gfn(0)) ) + return 0; + + /* Store the real-mode TSS, if space for it was successfully stolen. */ + if ( info->tss ) + { + if ( hvm_copy_to_guest_phys(info->tss, NULL, HVM_VM86_TSS_SIZE, v)= !=3D + HVMTRANS_okay ) + printk("%pd: unable to zero VM86 TSS area\n", d); + } + /* * Identity-map page table is required for running with CR0.PG=3D0 * when using Intel EPT. Create a 32-bit non-PAE page directory of * superpages. */ - ident_pt =3D map_domain_gfn(p2m_get_hostp2m(d), _gfn(PFN_DOWN(gaddr)), + ident_pt =3D map_domain_gfn(p2m_get_hostp2m(d), info->identpt, &mfn, 0, &rc); if ( ident_pt =3D=3D NULL ) { @@ -317,9 +351,6 @@ static int __init pvh_setup_vmx_realmode write_32bit_pse_identmap(ident_pt); unmap_domain_page(ident_pt); put_page(mfn_to_page(mfn)); - d->arch.hvm.params[HVM_PARAM_IDENT_PT] =3D gaddr; - if ( pvh_add_mem_range(d, gaddr, gaddr + PAGE_SIZE, E820_RESERVED) ) - printk("Unable to set identity page tables as reserved in the = memory map\n"); =20 return 0; } @@ -481,18 +512,6 @@ static int __init pvh_populate_p2m( } } =20 - if ( using_vmx() && !paging_mode_shadow(d) && !vmx_unrestricted_guest(= v) ) - { - /* - * Since Dom0 cannot be migrated, we will only setup the - * unrestricted guest helpers if they are needed by the current - * hardware we are running on. - */ - rc =3D pvh_setup_vmx_realmode_helpers(d); - if ( rc ) - return rc; - } - if ( opt_dom0_verbose ) print_order_stats(d); =20 @@ -1395,6 +1414,7 @@ int __init dom0_construct_pvh(const stru struct e820entry *orig_e820; unsigned int nr_orig_e820; struct acpi_info acpi =3D {}; + struct vmx_info vmx =3D {}; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); @@ -1456,6 +1476,22 @@ int __init dom0_construct_pvh(const stru return rc; } =20 + /* + * Since Dom0 cannot be migrated, only set up the unrestricted guest + * helpers if they are needed by the hardware we are running on. + */ + if ( using_vmx() && !paging_mode_shadow(d) && + /* + * TODO: Unrestricted Guest should be a domain property, not a vC= PU + * one. + */ + !vmx_unrestricted_guest(d->vcpu[0]) ) + { + rc =3D pvh_place_vmx_realmode_helpers(d, &vmx); + if ( rc ) + return rc; + } + rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820); if ( rc ) { @@ -1486,6 +1522,10 @@ int __init dom0_construct_pvh(const stru return rc; } =20 + rc =3D pvh_setup_vmx_realmode_helpers(d, &vmx); + if ( rc ) + return rc; + if ( opt_dom0_verbose ) { printk("Dom%u memory map:\n", d->domain_id); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885765; cv=none; d=zohomail.com; s=zohoarc; b=lpHxRRQ0QR8tjkhSxEU9xX/xx2r+nm+S+cC6/ZbT+lAemL+SvI3sqVpmKkHp4VN3PIRrl2al4xVJf946hmd0OY4QWjuTUvsjS2LgKdx26GyF7LhvYBiZxwPoW/KD0QcJzASuNoJb9HmmhwPoI0YPoQQgqHQppk+WAWiLo4X2hgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885765; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Les9WkE9lOfW3mflu8VwX8atN7kQJgnKhFYC3t+evzA=; b=iTO0OCqnBJeVFqSRh/KM6MaGh7QgxXnSFfEE8kgfaC7r6pjRcJWAkkE+EvQWdk6kTmm6RHpx7Lzi0leU376SE1p/MwWPYszP3fuyR7Vd/cTokur94Hc7s2hzI5NnPaSlpxio5uJqJ6bdKjjtqoS2Lbv9NFfxp+tOme488FBXbRg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885765714999.0333308142535; Thu, 5 Nov 2026 05:36:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474707.1681704 (Exim 4.92) (envelope-from ) id 1xOxdA-0008O8-3o; Thu, 05 Nov 2026 13:35:52 +0000 Received: by outflank-mailman (output) from mailman id 1474707.1681704; Thu, 05 Nov 2026 13:35:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxdA-0008O1-0q; Thu, 05 Nov 2026 13:35:52 +0000 Received: by outflank-mailman (input) for mailman id 1474707; Thu, 05 Nov 2026 13:35:51 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxd9-0008Np-DH for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:35:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxd3-00Ak0m-Ph for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:35:45 +0100 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8627-2eae-0a2a0a5409dd-0a2a4509c210-22 for ; Thu, 05 Nov 2026 14:35:45 +0100 Received: from [209.85.208.41] (helo=mail-ed1-f41.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec8631-be1a-0a2a45090019-d155d029f134-3 for ; Thu, 05 Nov 2026 14:35:45 +0100 Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-6b570ff3dfdso1362468a12.3 for ; Thu, 05 Nov 2026 05:35:45 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6b55ac5aec7sm1818296a12.20.2026.11.05.05.35.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:35:44 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885745; x=1794490545; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Les9WkE9lOfW3mflu8VwX8atN7kQJgnKhFYC3t+evzA=; b=OM4t+89RFlU9gUCGDuVXykKkTknSM8lB2hAnI5RS+Hn+BF9OtVHAvooaS2c6CxeA0u mgwJP51EhCzXBLjgGCa8CQmejZJ2/q7boyL0LgNnCbJUWoQq869f8dd2sdwyADVkprEx PaqpSSKFiq/B+xB4jXGV7waJzM99TK57Z4ILU/enKVbO+rrJI6nA9SziKfaQSKGSNn3b 1UpLBzBAcRR7Gn6tnYGy9PDqmFTNS+WNzqiaj+7VYCBi8WJJFS9PW8ouoYNOKWTC7eGH djo3AmmL8ZKUS9FfI4XjXDpw3VAEyJaHPOLVtP+AmSYAXiaaSTNpkLRHJluJOwBLO/WQ w09Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885745; x=1794490545; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Les9WkE9lOfW3mflu8VwX8atN7kQJgnKhFYC3t+evzA=; b=Pk1pC0WuAdfoT0h+nhCqL7dzmbCS5jqbzgDCUP4XMjfEEHrGCa3RTnr3wVqcT+XIzn SKd05OIjQ5Es6sLPgBHWbXZWnIWOVoFO25k7D+KXZz8z7UMdz2ta2MXb0LaCysbsw4PM uVXD68El24z4nLXQOgyVBeLJoSZxcDLFZVSYMr85fRpnTQJmi3nmtbd55v0d6eEk93gE xof/PoQczLEEAl99MpmeAU34bpXmnKRzRguwOtV3gHiazOnHjJWt4dyD6fzTXi2Oz8jU y1Y5GUUlIJZnrSMditoDnHdskKeV17jrDXiaOc3TfUqwDLeg8vks3gP7b2/ilp+4eoMI GI5g== X-Gm-Message-State: APuU4Z/upeZ4R4F69nRsekIMIJKeWdvNjhABvQVx2XLFX5cm6x2gPcsl V51FKEvHdCrcvrca3CL6wh5WM9jPFIvPDNw0Eu5n8/OrJB765r0EgFCKy7+IpvI49zEI9DTfSSc Ahhn+2A== X-Gm-Gg: AYBFou2/85QMToh4V6kbTDzlYHSILmBNrm+c1muqpsVzNu4k97qWPaHfAOSUOIUG5qN IKRlRou96bAKZGmpHm6DRbRLG7PbXWjGGTPWddlbpBlxaBz46hWGpRWLaZ4nXNybxvWe64hLMv+ wQpZelPQufEOW9CtErjJL1Ypl5PKzRRDhvD4C+LjRsavUp60pFsPhdH4U1T39PaleCqpUZ/jaNC PIyCrFh6iruw0+5ORYz8+momjcegOnL21iE1rK1ePh8nTwCi67UO3jQvRTpfFrPHcvQpzekJZPh EzYGETApURBmGhJzMx1uRehnsXtmZL+Vjy1tRT4kbX/QTlkxXSt7QQkjPEfBBozxpI0EHrrO9bi nHwgDKThtchMnQx8EB35kK6lU4nt+ERqUtM1CPmH/L5R7lLJyZejSiu0Y85SH1G7kgSDC5+UjgI 43qnEcApCtYsdk5w1VlsRjG2xoWARa934MQEyyBIhaZkKComNvh0b/nYBNSO+rm+5A6igjBi/px AUNoM8iuxHMp8vcGXJ93y0IiDk2OGajfXqLNMc0kcY8ShWVptWSVpTXDUl41WQqvqsnbjegzlqO JmL5Pj6FfX1CViCdENTpF9tPHzyKSA8j3CYU3QM/EfPagq4tuCwooahjadwj8PorKcEaIC3/1bh 3WHBq9b1+yJRK4vo= X-Received: by 2002:a17:907:84b:b0:c49:8f1e:af0a with SMTP id a640c23a62f3a-c4ca795e453mr1630598666b.7.1793885744727; Thu, 05 Nov 2026 05:35:44 -0800 (PST) Message-ID: <4a678bd3-e70b-4194-b4ce-645328d61bd3@suse.com> Date: Thu, 5 Nov 2026 14:35:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 09/14] x86/PVH: track Dom0 available RAM in a rangeset From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1793885745-BCECE034-2AEE01BF/10/78276251493 X-purgate-type: spam X-purgate-size: 17504 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885766938158500 Content-Type: text/plain; charset="utf-8" Convert pvh_steal_ram() to work from a rangeset, and replace find_memory() entirely. By tracking the kernel range right from the creation of that rangeset we also avoid inadvertently stealing from the kernel range. Shrinking the E820 region stolen from moves into pvh_add_mem_range(). To retain coverage of tail padding, the real end address now needs communicating from pvh_steal_ram() to pvh_add_mem_range(). Sadly the find_memory() replacement cannot use an upper limit of 4Gb, as that would break current Linux: It accesses module table (and memory map, which for Dom0 we don't set) via a very early direct-map, which has only the first L3 entry populated. Fixes: 1d74282c455f ("x86: setup PVHv2 Dom0 ACPI tables") Suggested-by: Xenia Ragiadakou Signed-off-by: Jan Beulich --- The Suggested-by: is based on the respective commit's S-o-b. I didn't go hunt for whether this may have been suggested in review of that patch. Clearly find_kernel_memory() could also be converted, but is unrelated here and hence left for a separate change. --- v2: New. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -183,41 +183,62 @@ static int __init pvh_populate_memory_ra return 0; } =20 +struct steal_info { + unsigned long size, align; + paddr_t addr, end; +}; + +static int cf_check __init find_ram( + unsigned long s, unsigned long e, void *data) +{ + struct steal_info *info =3D data; + + if ( e + 1 - s >=3D info->size ) + { + paddr_t addr =3D (e + 1 - info->size) & ~(info->align - 1); + + if ( addr >=3D s ) + { + info->addr =3D addr; + info->end =3D e; + } + } + + return 0; +} + /* Steal RAM from the end of a memory region. */ -static int __init pvh_steal_ram(struct domain *d, unsigned long size, +static int __init pvh_steal_ram(struct rangeset *ram, unsigned long size, unsigned long align, paddr_t limit, - paddr_t *addr) + paddr_t *addr, paddr_t *end) { - unsigned int i =3D d->arch.nr_e820; - /* * Alignment 0 should be set to 1, so it doesn't wrap around in the - * calculations below. + * calculations in find_ram(). */ - align =3D align ? : 1; - while ( i-- ) - { - struct e820entry *entry =3D &d->arch.e820[i]; + struct steal_info info =3D { + .size =3D size, + .align =3D align ?: 1, + .addr =3D INVALID_PADDR, + }; =20 - if ( entry->type !=3D E820_RAM || entry->addr + entry->size > limi= t ) - continue; + rangeset_report_ranges(ram, MB(1), limit - 1, find_ram, &info); =20 - *addr =3D (entry->addr + entry->size - size) & ~(align - 1); - if ( *addr < entry->addr || - /* Don't steal from the low 1MB due to the copying done there= . */ - *addr < MB(1) ) - continue; + if ( info.addr =3D=3D INVALID_PADDR ) + return -ENOMEM; =20 - entry->size =3D *addr - entry->addr; - return 0; - } + *addr =3D info.addr; =20 - return -ENOMEM; + if ( end ) + /* Suitable for passing to pvh_add_mem_range(). */ + *end =3D info.end + 1; + + return rangeset_remove_range(ram, info.addr, info.end); } =20 /* NB: memory map must be sorted at all times for this to work correctly. = */ static int __init pvh_add_mem_range(struct domain *d, uint64_t s, uint64_t= e, - unsigned int type) + unsigned int type, bool replace) { struct e820entry *map; unsigned int i; @@ -245,12 +266,66 @@ static int __init pvh_add_mem_range(stru break; =20 if ( re > s ) - return -EEXIST; + { + if ( !replace || d->arch.e820[i].type !=3D E820_RAM ) + return -EEXIST; + + /* In the common case we get away without memory allocation. */ + if ( re =3D=3D e && rs <=3D s ) + { + d->arch.e820[i].size -=3D e - s; + + if ( !d->arch.e820[i].size ) + { + memmove(d->arch.e820 + i, d->arch.e820 + i + 1, + (d->arch.nr_e820 - i - 1) * sizeof(*d->arch.e8= 20)); + + d->arch.nr_e820--; + i--; + } + } + else + { + /* + * While pvh_steal_ram() steals from the end of regions, t= his + * case can still occur because of RAM ranges in use which + * aren't reflected in E820 (first and foremost the kernel= ). + */ + map =3D xzalloc_array(struct e820entry, d->arch.nr_e820 + = 1); + if ( !map ) + goto nomem; + + memcpy(map, d->arch.e820, (i + 1) * sizeof(*map)); + memcpy(map + i + 1, d->arch.e820 + i, + (d->arch.nr_e820 - i) * sizeof(*map)); + + map[i].size =3D max(rs, s) - rs; + + map[i + 1].addr =3D min(re, e); + map[i + 1].size =3D re - map[i + 1].addr; + + if ( !map[i].size ) + goto insert; + + if ( !map[i + 1].size ) + { + d->arch.e820[i] =3D map[i]; + xfree(map); + } + else + { + xfree(d->arch.e820); + d->arch.e820 =3D map; + d->arch.nr_e820++; + } + } + } } =20 map =3D xzalloc_array(struct e820entry, d->arch.nr_e820 + 1); if ( !map ) { + nomem: printk(XENLOG_WARNING "E820: out of memory to add region\n"); return -ENOMEM; } @@ -258,6 +333,8 @@ static int __init pvh_add_mem_range(stru memcpy(map, d->arch.e820, i * sizeof(*d->arch.e820)); memcpy(map + i + 1, d->arch.e820 + i, (d->arch.nr_e820 - i) * sizeof(*d->arch.e820)); + + insert: map[i].addr =3D s; map[i].size =3D e - s; map[i].type =3D type; @@ -275,9 +352,10 @@ struct vmx_info { =20 static int __init pvh_place_vmx_realmode_helpers( struct domain *d, + struct rangeset *ram, struct vmx_info *info) { - paddr_t gaddr; + paddr_t gaddr, gend; =20 /* * Steal some space from the last RAM region below 4GB to store the @@ -285,28 +363,27 @@ static int __init pvh_place_vmx_realmode * structure (which accounts for the first 104b) doesn't cross a page * boundary. */ - if ( !pvh_steal_ram(d, HVM_VM86_TSS_SIZE, 128, GB(4), &gaddr) ) + if ( !pvh_steal_ram(ram, HVM_VM86_TSS_SIZE, 128, GB(4), &gaddr, &gend)= ) { d->arch.hvm.params[HVM_PARAM_VM86_TSS_SIZED] =3D VM86_TSS_UPDATED | ((uint64_t)HVM_VM86_TSS_SIZE << 32) | gaddr; =20 info->tss =3D gaddr; =20 - if ( pvh_add_mem_range(d, gaddr, gaddr + HVM_VM86_TSS_SIZE, - E820_RESERVED) ) + if ( pvh_add_mem_range(d, gaddr, gend, E820_RESERVED, true) ) printk("Unable to set VM86 TSS as reserved in the memory map\n= "); } else printk("Unable to allocate VM86 TSS area\n"); =20 /* Steal some more RAM for the identity page tables. */ - if ( pvh_steal_ram(d, PAGE_SIZE, PAGE_SIZE, GB(4), &gaddr) ) + if ( pvh_steal_ram(ram, PAGE_SIZE, PAGE_SIZE, GB(4), &gaddr, &gend) ) { printk("Unable to find memory to stash the identity page tables\n"= ); return -ENOMEM; } =20 - if ( pvh_add_mem_range(d, gaddr, gaddr + PAGE_SIZE, E820_RESERVED) ) + if ( pvh_add_mem_range(d, gaddr, gend, E820_RESERVED, true) ) printk("%pd: Unable to set identity page tables as reserved in the= memory map\n", d); =20 @@ -519,14 +596,15 @@ static int __init pvh_populate_p2m( #undef MB1_PAGES } =20 -static paddr_t __init find_memory( - const struct domain *d, const struct elf_binary *elf, size_t size) +static struct rangeset *__init make_ram_rangeset( + const struct domain *d, const struct elf_binary *elf) { - paddr_t kernel_start =3D (paddr_t)elf->dest_base & PAGE_MASK; - paddr_t kernel_end =3D ROUNDUP((paddr_t)elf->dest_base + elf->dest_siz= e, - PAGE_SIZE); + struct rangeset *ram =3D rangeset_new(NULL, NULL, 0); unsigned int i; =20 + if ( !ram ) + return NULL; + /* The memory map is sorted. */ for ( i =3D 0; i < d->arch.nr_e820; i++ ) { @@ -538,26 +616,24 @@ static paddr_t __init find_memory( =20 start =3D MAX(ROUNDUP(d->arch.e820[i].addr, PAGE_SIZE), MB(1)); =20 - /* - * NB: Even better would be to use rangesets to determine a suitab= le - * range, in particular in case a kernel requests multiple heavily - * discontiguous regions (which right now we fold all into one big - * region). - */ - if ( end <=3D kernel_start || start >=3D kernel_end ) - { - /* No overlap, just check whether the region is large enough. = */ - if ( end - start >=3D size ) - return start; - } - /* Deal with the kernel already being loaded in the region. */ - else if ( kernel_start > start && kernel_start - start >=3D size ) - return start; - else if ( kernel_end < end && end - kernel_end >=3D size ) - return kernel_end; + if ( start < end && + rangeset_add_range(ram, start, end - 1) !=3D 0 ) + return NULL; } =20 - return INVALID_PADDR; + /* + * Remove the kernel range, rounded to page boundaries. + * + * NB: Even better would be to record space needed by the kernel at its + * allocation, in particular in case a kernel requests multiple heavily + * discontiguous regions (which right now we fold all into one big one= ). + */ + if ( rangeset_remove_range(ram, (paddr_t)elf->dest_base & PAGE_MASK, + ROUNDUP((paddr_t)elf->dest_base + elf->dest= _size, + PAGE_SIZE) - 1) !=3D 0 ) + return NULL; + + return ram; } =20 static bool __init check_load_address( @@ -723,7 +799,8 @@ static int __init pvh_place_kernel( static int __init pvh_load_kernel( const struct boot_domain *bd, struct elf_binary *elf, - paddr_t *start_info_addr) + paddr_t *start_info_addr, + struct rangeset *ram) { struct domain *d =3D bd->d; struct boot_module *initrd =3D bd->initrd; @@ -778,8 +855,13 @@ static int __init pvh_load_kernel( =20 extra_space +=3D elf_round_up(elf, cmdline_len); =20 - last_addr =3D find_memory(d, elf, extra_space); - if ( last_addr =3D=3D INVALID_PADDR ) + /* + * While not written down anywhere, 64-bit Linux requires at least mod= to + * live below 1Gb (mapped by the first L3 entry of the direct map). 3= 2-bit + * Linux may map more, but defaults to mapping only 1Gb. + */ + if ( pvh_steal_ram(ram, PAGE_ALIGN(extra_space), PAGE_SIZE, GB(1), + &last_addr, NULL) ) { printk("Unable to find a memory region to load initrd and metadata= \n"); return -ENOMEM; @@ -922,7 +1004,10 @@ static int __init cf_check acpi_set_intr return 0; } =20 -static int __init pvh_setup_acpi_madt(struct domain *d, paddr_t *addr) +static int __init pvh_setup_acpi_madt( + struct domain *d, + struct rangeset *ram, + paddr_t *addr) { struct acpi_table_madt *madt; struct acpi_table_header *table; @@ -946,15 +1031,17 @@ static int __init pvh_setup_acpi_madt(st =20 if ( !*addr ) { + paddr_t end; + /* Reserve space to place the new MADT in guest memory space. */ - if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) + if ( pvh_steal_ram(ram, size, 0, GB(4), addr, &end) ) { printk("%pd: unable to steal guest RAM for MADT\n", d); return -ENOMEM; } =20 /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) + if ( pvh_add_mem_range(d, *addr, end, E820_ACPI, true) ) printk("%pd: unable to add MADT region to memory map\n", d); =20 return 0; @@ -1102,8 +1189,11 @@ static bool __init pvh_acpi_xsdt_table_a strncmp(sig, ACPI_SIG_FACS, ACPI_NAME_SIZE)); } =20 -static int __init pvh_setup_acpi_xsdt(struct domain *d, paddr_t madt_addr, - paddr_t *addr) +static int __init pvh_setup_acpi_xsdt( + struct domain *d, + struct rangeset *ram, + paddr_t madt_addr, + paddr_t *addr) { struct acpi_table_xsdt *xsdt; struct acpi_table_header *table; @@ -1138,15 +1228,17 @@ static int __init pvh_setup_acpi_xsdt(st =20 if ( !*addr ) { + paddr_t end; + /* Reserve space to place the new XSDT in guest memory space. */ - if ( pvh_steal_ram(d, size, 0, GB(4), addr) ) + if ( pvh_steal_ram(ram, size, 0, GB(4), addr, &end) ) { printk("%pd: unable to find guest RAM for XSDT\n", d); return -ENOMEM; } =20 /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, *addr, *addr + size, E820_ACPI) ) + if ( pvh_add_mem_range(d, *addr, end, E820_ACPI, true) ) printk("%pd: unable to add XSDT region to memory map\n", d); =20 return 0; @@ -1238,9 +1330,11 @@ struct acpi_info { =20 static int __init pvh_place_acpi( struct domain *d, - struct acpi_info *info) + struct acpi_info *info, + struct rangeset *ram) { unsigned int i; + paddr_t end; int rc; =20 /* Scan top-level tables and add their regions to the guest memory map= . */ @@ -1258,7 +1352,7 @@ static int __init pvh_place_acpi( if ( strncmp(sig, ACPI_SIG_MADT, ACPI_NAME_SIZE) ? pvh_acpi_table_allowed(sig, addr, size) : !acpi_memory_banned(addr, size) ) - pvh_add_mem_range(d, addr, addr + size, E820_ACPI); + pvh_add_mem_range(d, addr, addr + size, E820_ACPI, false); } =20 /* Identity map ACPI e820 regions. */ @@ -1294,25 +1388,23 @@ static int __init pvh_place_acpi( } } =20 - rc =3D pvh_setup_acpi_madt(d, &info->madt); + rc =3D pvh_setup_acpi_madt(d, ram, &info->madt); if ( rc ) return rc; =20 - rc =3D pvh_setup_acpi_xsdt(d, info->madt, &info->xsdt); + rc =3D pvh_setup_acpi_xsdt(d, ram, info->madt, &info->xsdt); if ( rc ) return rc; =20 - if ( pvh_steal_ram(d, sizeof(struct acpi_table_rsdp), 0, GB(4), - &info->rsdp) ) + if ( pvh_steal_ram(ram, sizeof(struct acpi_table_rsdp), 0, GB(4), + &info->rsdp, &end) ) { printk("%pd: unable to allocate guest RAM for RSDP\n", d); return -ENOMEM; } =20 /* Mark this region as E820_ACPI. */ - if ( pvh_add_mem_range(d, info->rsdp, - info->rsdp + sizeof(struct acpi_table_rsdp), - E820_ACPI) ) + if ( pvh_add_mem_range(d, info->rsdp, end, E820_ACPI, true) ) printk("%pd: unable to add RSDP region to memory map\n", d); =20 return 0; @@ -1330,11 +1422,11 @@ static int __init pvh_setup_acpi( .length =3D sizeof(rsdp), }; =20 - rc =3D pvh_setup_acpi_madt(d, &info->madt); + rc =3D pvh_setup_acpi_madt(d, NULL, &info->madt); if ( rc ) return rc; =20 - rc =3D pvh_setup_acpi_xsdt(d, info->madt, &info->xsdt); + rc =3D pvh_setup_acpi_xsdt(d, NULL, info->madt, &info->xsdt); if ( rc ) return rc; =20 @@ -1413,6 +1505,7 @@ int __init dom0_construct_pvh(const stru struct elf_binary elf; struct e820entry *orig_e820; unsigned int nr_orig_e820; + struct rangeset *ram; struct acpi_info acpi =3D {}; struct vmx_info vmx =3D {}; int rc; @@ -1469,7 +1562,14 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_place_acpi(d, &acpi); + ram =3D make_ram_rangeset(d, &elf); + if ( !ram ) + { + printk("%pd: not enough memory to track RAM\n", d); + return -ENOMEM; + } + + rc =3D pvh_place_acpi(d, &acpi, ram); if ( rc ) { printk("%pd: failed to place ACPI tables: %d\n", d, rc); @@ -1487,7 +1587,7 @@ int __init dom0_construct_pvh(const stru */ !vmx_unrestricted_guest(d->vcpu[0]) ) { - rc =3D pvh_place_vmx_realmode_helpers(d, &vmx); + rc =3D pvh_place_vmx_realmode_helpers(d, ram, &vmx); if ( rc ) return rc; } @@ -1501,13 +1601,15 @@ int __init dom0_construct_pvh(const stru =20 xvfree(orig_e820); =20 - rc =3D pvh_load_kernel(bd, &elf, &start_info); + rc =3D pvh_load_kernel(bd, &elf, &start_info, ram); if ( rc ) { printk("Failed to load Dom0 kernel\n"); return rc; } =20 + rangeset_destroy(ram); + rc =3D pvh_setup_cpus(d, entry, start_info); if ( rc ) { From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885781; cv=none; d=zohomail.com; s=zohoarc; b=SuuCzYBRfoxFHEIt6tGU6Iz/2+e8Jvv5AQgTPXLfhu9Y2E4knrT2bKZQI/watfeZvmFhVa8s0FnLGunSfzF4UjOqmeo1vvR0uYwvOK3jkLMQ79edRY/Q2jnO7HFiFVWPLVrwEjFhghEi2tXLj6lXsZV6W5XUsMfQZADZsm18RIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885781; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Xqd7lQJf6HxSa5w7PCo/dVug3ab9DqyZkj44HJO+byE=; b=OVc9n6VM8KQy4Sxe0CR0yfhzd/zEiY7qSmUGRfebPX5+Bw0kmJO6qh5sUmbsqXIk3c9CVL7q4CIZzOWyk4kvTc5UjJuuU5WLkOs2ThzRKOIFbKsQmMqj4ZbznYUfku5J20kYcYH/J31F8Gq1AY29kct6Es+wBdFWSmAf45Zh09I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885781345815.1963776740594; Thu, 5 Nov 2026 05:36:21 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474713.1681713 (Exim 4.92) (envelope-from ) id 1xOxdO-0000Ph-AQ; Thu, 05 Nov 2026 13:36:06 +0000 Received: by outflank-mailman (output) from mailman id 1474713.1681713; Thu, 05 Nov 2026 13:36:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxdO-0000Pa-7R; Thu, 05 Nov 2026 13:36:06 +0000 Received: by outflank-mailman (input) for mailman id 1474713; Thu, 05 Nov 2026 13:36:05 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxdN-0000Ou-8x for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:36:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxdM-00Ak7z-Le for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:36:04 +0100 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8630-2eae-0a2a0a5409dd-0a2a45088e0a-42 for ; Thu, 05 Nov 2026 14:36:04 +0100 Received: from [209.85.218.45] (helo=mail-ej1-f45.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec8644-f659-0a2a45080019-d155da2dd4bc-3 for ; Thu, 05 Nov 2026 14:36:04 +0100 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c4322d310e7so32200166b.0 for ; Thu, 05 Nov 2026 05:36:04 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e4668afsm172795166b.51.2026.11.05.05.36.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:36:03 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885764; x=1794490564; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=Xqd7lQJf6HxSa5w7PCo/dVug3ab9DqyZkj44HJO+byE=; b=PZehcl6LqNrWcNaAcUWURluYaEBu/6sv3BEFWpjoedJzij+eH+9A73nJqGRu2KwJgi jW9wo7O3ZkB2X1OvTGLyTZUqd71HgRySzWOkDhkPrJCIFixHyThKcJpw9HcNDCVBeBQa M5B5iTiP+n+9TtwDTukBVbAxVQNbGAJEuQRXPDpe/+CoxtihOxm0SL+PLs9+g7hTY8cb wBTNDGOXnmEzm30E+b7BDtn9AKI96ZnOVwgcIJvEAxKrQXFDdmolYWaO/IExiiK5bQiq lhYykBuFBP/FfjHsWURglLk/ugCbtghiywgfN/lLWF0Nk8aIJ+5z51UH/x6WHbwhW5pE P7yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885764; x=1794490564; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Xqd7lQJf6HxSa5w7PCo/dVug3ab9DqyZkj44HJO+byE=; b=Umiutjnf5TWpu2iv80TFBHUuxOPXQGNK6CojWfKqkaz1mjUrYawyrKyCtCXS84A4ib ANZhpiqOhB3Wtittb/w9TWIsGPSCSfty2dYCD67FUVe9G81mrNhf7iHjFfa+iP7i4TTz QXCkDdFq7+CA7Xu4CKxCIo2TSyV+BV4eX+4fVwaEEo7dNYM+kgCVJEY8LYhSReuHzpt9 1r0kMCwklGQ5jXu57LfhcG3xSf3r0+lsjTa+Rx9XD5pAQgN6ycEnkBwIJqUdBgOcoQbX 8jUxiJ5rTv2o469ACsP4PJJ/jZkJ/fyD9qdGCfKa9I8HY7YFtJn+4djkZxfQ/E92prjG 0V5g== X-Gm-Message-State: APuU4Z/Obu6iVzFNeoTGA9Gp2ftFoK0AFXBBcxUqR+LrMdzL19Zp7B06 a+LUuZK7gJL6wstzodXyrGSMmnhMmbSjLpDYAFlISK3CV8FD48WNll44bFPV56V9A++mIavZEai 6FtvthQ== X-Gm-Gg: AYBFou0cnUkP22Axt1AXsh7U0o3biR/2kTWfCZVNQdOetZg8NMLEIwDX9kGiYJjaUdo F0aUWPer6mhjpyxVYEPiNkOJXQ9K8Yhi2d7lOt1D6HZBlOMUEN9VQW1O8ILJmCZOm4NM5RdLZzv +pCOV9tnSqHPZLiYDy5hGt9JkwYTH/jGYXdY47HneZsgoojOrOcv7TYYezHLelWxbi7z/wDCaGy udm1cMoitGeWnnxzwDbOMDzvGkUOaoENtet5O5zEYVnouSEg9tzCZHp3P55GhU3sWicxsz5d/7c pHjRP3cocSV4DfNWn6FySfG3/+tb22OutMvdq0zWBITS+BiIevj0R5ApAmse1N8TwdY9njs1iLI t7TXBahd9U4TrCQCQyoNuWaI9YQkmdTyl0lGcklUiduwPkmd0+UJsqNQIT/lqim5yLunhZzZ4Ns t8Ot7Vt4rCnhwvqvdnPaQYLyLfejMLm1iLcDs3SBcwwira1lx55z77G4iYjvnkaNdTOjDd6YaIa vVlQ4L6tlHw+udGc0ZyuCaFgVzEYQRiN1Eypkpef2g0sxihf6nOZNpXuhgaQz2VCCGw00zL7jW8 Lng0H5gEke8dwnTxX7M+wUf9m2LL4FcG0KukFvBMlIoe+zMsdlr2zSrjptewjSy1JXI1Gh7G9rg 8QHOdh+WHzWI49uUp X-Received: by 2002:a17:907:84b:b0:c46:6a50:40c2 with SMTP id a640c23a62f3a-c4ca7acc58fmr1606505166b.39.1793885764041; Thu, 05 Nov 2026 05:36:04 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:36:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 10/14] x86/PVH: try to map initrd directly into Dom0 From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1793885764-D554C87B-F29BFDCD/10/78276251493 X-purgate-type: spam X-purgate-size: 12187 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885783376158500 Our present handling of initrd is problematic in particular when the initrd is huge, and when at the same time "dom0_mem=3D" isn't in use to significantly shrink Dom0's memory (from the default). In that case, insufficient memory may exist for pvh_populate_p2m() to succeed (because initrd memory can be freed only after copying). Make an attempt to map the blob (including headroom) into Dom0's P2M instead, thus also saving the copying operation. With __start_xen() having arranged for a larger than necessary blob, that mapping can typically be done with superpage mappings. Reported-by: Marek Marczykowski-G=C3=B3recki Signed-off-by: Jan Beulich --- pvh_steal_ram() can (theoretically) fail just because of rangeset_remove_range() there failing, in which case we may be in limbo state. That's hopefully an acceptable risk. --- v2: Re-base over changes earlier in the series, in particular to use pvh_steal_ram() here. Avoid NULL deref when there's no initrd. Also log domain in new/moved printk(). --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -528,7 +528,9 @@ static void __init pvh_init_p2m(struct d static int __init pvh_populate_p2m( struct domain *d, const struct e820entry *e820, - unsigned int nr_e820) + unsigned int nr_e820, + unsigned long initrd_start, + unsigned long initrd_end) { struct vcpu *v =3D d->vcpu[0]; unsigned int i; @@ -546,7 +548,12 @@ static int __init pvh_populate_p2m( addr =3D PFN_DOWN(e820[i].addr); size =3D PFN_DOWN(e820[i].size); =20 - rc =3D pvh_populate_memory_range(d, addr, size); + if ( addr + size <=3D initrd_start || addr >=3D initrd_end ) + rc =3D pvh_populate_memory_range(d, addr, size); + else + rc =3D pvh_populate_memory_range(d, addr, initrd_start - addr) + ?: pvh_populate_memory_range(d, initrd_end, + addr + size - initrd_end); if ( rc ) return rc; =20 @@ -636,6 +643,43 @@ static struct rangeset *__init make_ram_ return ram; } =20 +static int __init pvh_map_initrd( + struct domain *d, const struct boot_module *initrd, + paddr_t initrd_start, unsigned int order) +{ + for ( paddr_t ga =3D initrd_start, ma =3D initrd->start; + ga < initrd_start + initrd->size; + ga +=3D PAGE_SIZE << order, ma +=3D PAGE_SIZE << order ) + { + int rc =3D p2m_add_page(d, gaddr_to_gfn(ga), maddr_to_mfn(ma), + order, p2m_ram_rw); + + if ( rc ) + { + printk("%pd: failed to map initrd: [%#lx,%#lx): %d\n", + d, PFN_DOWN(ga), PFN_DOWN(ga) + (1UL << order), rc); + + /* + * Best effort rollback: The range will be replaced anyway by = the + * subsequent pvh_populate_p2m(). + */ + while ( ga > initrd_start ) + { + ga -=3D PAGE_SIZE << order; + ma -=3D PAGE_SIZE << order; + p2m_remove_page(d, gaddr_to_gfn(ga), maddr_to_mfn(ma), ord= er); + order_stats[order]--; + } + + return rc; + } + + order_stats[order]++; + } + + return 0; +} + static bool __init check_load_address( const struct domain *d, const struct elf_binary *elf) { @@ -796,9 +840,98 @@ static int __init pvh_place_kernel( return 0; } =20 +static void __init pvh_place_initrd( + const struct boot_domain *bd, + const struct elf_binary *elf, + struct rangeset *ram, + struct hvm_modlist_entry *mod, + paddr_t *blob_start, + paddr_t *blob_end) +{ + struct domain *d =3D bd->d; + struct boot_module *initrd =3D bd->initrd; + struct boot_module try; + unsigned long initrd_len =3D + initrd ? initrd->size - initrd->arch.headroom : 0; + size_t align =3D 1UL << L3_PAGETABLE_SHIFT; + int rc; + + *blob_start =3D INVALID_PADDR; + *blob_end =3D 0; + + if ( !initrd_len ) + return; + + try =3D *initrd; + + mod->size =3D initrd_len; + + /* + * As we promise to place below 4G whatever fits there, make a first p= ass + * limiting permitted addresses. If we can't fit it there, fall back = to + * placing above 4G. + */ + for ( paddr_t limit =3D GB(4); ; ) + { + unsigned long size =3D ROUNDUP(try.size, PAGE_SIZE); + paddr_t start; + + if ( IS_ALIGNED(try.start | size, align) && + !pvh_steal_ram(ram, size - try.arch.headroom, align, limit, + blob_start, NULL) ) + break; + + if ( align =3D=3D PAGE_SIZE ) + { + if ( !(limit + 1) ) + return; + + limit =3D -1; + align =3D 1UL << L3_PAGETABLE_SHIFT; + try =3D *initrd; + continue; + } + + align >>=3D PAGETABLE_ORDER; + + start =3D ROUNDDOWN(try.start + try.arch.headroom, align); + if ( start > try.start ) + { + /* Free (part of) and reduce headroom. */ + try.arch.headroom -=3D start - try.start; + try.size -=3D start - try.start; + try.start =3D start; + } + } + + /* Free unused headroom, if any. */ + if ( try.start > initrd->start ) + { + init_domheap_pages(initrd->start, try.start); + *initrd =3D try; + } + + rc =3D pvh_map_initrd(d, initrd, *blob_start, get_order_from_bytes(ali= gn)); + if ( rc ) + { + printk("%pd: failed to map initrd @ %#lx: %d\n", d, *blob_start, r= c); + return; + } + + rc =3D assign_pages(maddr_to_page(initrd->start), + PFN_UP(initrd->size), d, dom0_memflags); + if ( rc ) + panic("%pd: cannot assign initrd RAM: %d\n", d, rc); + + mod->paddr =3D *blob_start + initrd->arch.headroom; + *blob_end =3D *blob_start + initrd->size; + initrd->arch.released =3D true; +} + static int __init pvh_load_kernel( const struct boot_domain *bd, struct elf_binary *elf, + struct hvm_modlist_entry *mod, paddr_t *start_info_addr, struct rangeset *ram) { @@ -809,9 +942,8 @@ static int __init pvh_load_kernel( size_t cmdline_len =3D bd->cmdline ? strlen(bd->cmdline) + 1 : 0; const char *initrd_cmdline =3D NULL; size_t extra_space; - paddr_t last_addr; + paddr_t last_addr, initrd_start =3D 0; struct hvm_start_info start_info =3D { 0 }; - struct hvm_modlist_entry mod =3D { 0 }; struct vcpu *v =3D d->vcpu[0]; int rc; =20 @@ -828,15 +960,18 @@ static int __init pvh_load_kernel( =20 /* * Find a RAM region big enough (and that doesn't overlap with the loa= ded - * kernel) in order to load the initrd and the metadata. Note it could= be - * split into smaller allocations, done as a single region in order to - * simplify it. + * kernel) in order to load the initrd (if it wasn't mapped directly a= bove) + * and the metadata. Note it could be split into smaller allocations,= done + * as a single region in order to simplify it. */ extra_space =3D sizeof(start_info); =20 if ( initrd ) { - size_t initrd_space =3D elf_round_up(elf, initrd_len); + size_t initrd_space =3D 0; + + if ( !mod->paddr ) + initrd_space =3D elf_round_up(elf, initrd_len); =20 if ( initrd->arch.cmdline_pa ) { @@ -848,7 +983,9 @@ static int __init pvh_load_kernel( initrd_space +=3D strlen(initrd_cmdline) + 1; =20 if ( initrd_space ) - extra_space +=3D ROUNDUP(initrd_space, PAGE_SIZE) + sizeof(mod= ); + extra_space +=3D ROUNDUP(initrd_space, PAGE_SIZE) + sizeof(*mo= d); + else if ( mod->paddr ) + extra_space +=3D sizeof(*mod); else initrd =3D NULL; } @@ -860,14 +997,16 @@ static int __init pvh_load_kernel( * live below 1Gb (mapped by the first L3 entry of the direct map). 3= 2-bit * Linux may map more, but defaults to mapping only 1Gb. */ - if ( pvh_steal_ram(ram, PAGE_ALIGN(extra_space), PAGE_SIZE, GB(1), - &last_addr, NULL) ) + rc =3D pvh_steal_ram(ram, PAGE_ALIGN(extra_space), PAGE_SIZE, GB(1), + &last_addr, NULL); + if ( rc ) { - printk("Unable to find a memory region to load initrd and metadata= \n"); - return -ENOMEM; + printk("%pd: unable to find a memory region to %s metadata: %d\n", + d, mod->paddr ? "put" : "load initrd and", rc); + return rc; } =20 - if ( initrd !=3D NULL ) + if ( initrd && !mod->paddr ) { rc =3D hvm_copy_to_guest_phys(last_addr, __va(initrd->start + initrd->arch.head= room), @@ -878,28 +1017,29 @@ static int __init pvh_load_kernel( return rc; } =20 - mod.paddr =3D last_addr; - mod.size =3D initrd_len; + initrd_start =3D last_addr; last_addr +=3D elf_round_up(elf, initrd_len); - if ( initrd_cmdline ) - { - size_t len =3D strlen(initrd_cmdline) + 1; - - rc =3D hvm_copy_to_guest_phys(last_addr, initrd_cmdline, len, = v); - if ( rc ) - { - printk("Unable to copy module command line\n"); - return rc; - } - mod.cmdline_paddr =3D last_addr; - last_addr +=3D len; - } - last_addr =3D ROUNDUP(last_addr, PAGE_SIZE); } =20 /* Free temporary buffers. */ free_boot_modules(); =20 + if ( initrd_cmdline ) + { + size_t len =3D strlen(initrd_cmdline) + 1; + + rc =3D hvm_copy_to_guest_phys(last_addr, initrd_cmdline, len, v); + if ( rc ) + { + printk("%pd: unable to copy module command line\n", d); + return rc; + } + mod->cmdline_paddr =3D last_addr; + last_addr =3D ROUNDUP(last_addr + len, PAGE_SIZE); + } + else if ( initrd && !mod->paddr ) + last_addr =3D ROUNDUP(last_addr, PAGE_SIZE); + rc =3D hvm_copy_to_guest_phys(last_addr, bd->cmdline, cmdline_len, v); if ( rc ) { @@ -917,7 +1057,10 @@ static int __init pvh_load_kernel( =20 if ( initrd !=3D NULL ) { - rc =3D hvm_copy_to_guest_phys(last_addr, &mod, sizeof(mod), v); + if ( !mod->paddr ) + mod->paddr =3D initrd_start; + + rc =3D hvm_copy_to_guest_phys(last_addr, mod, sizeof(*mod), v); if ( rc ) { printk("Unable to copy guest modules\n"); @@ -925,7 +1068,7 @@ static int __init pvh_load_kernel( } start_info.modlist_paddr =3D last_addr; start_info.nr_modules =3D 1; - last_addr +=3D sizeof(mod); + last_addr +=3D sizeof(*mod); } =20 start_info.magic =3D XEN_HVM_START_MAGIC_VALUE; @@ -1508,6 +1651,8 @@ int __init dom0_construct_pvh(const stru struct rangeset *ram; struct acpi_info acpi =3D {}; struct vmx_info vmx =3D {}; + struct hvm_modlist_entry initrd =3D {}; + paddr_t blob_start, blob_end; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id); @@ -1592,7 +1737,10 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820); + pvh_place_initrd(bd, &elf, ram, &initrd, &blob_start, &blob_end); + + rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820, + PFN_DOWN(blob_start), PFN_UP(blob_end)); if ( rc ) { printk("Failed to setup Dom0 physical memory map\n"); @@ -1601,7 +1749,7 @@ int __init dom0_construct_pvh(const stru =20 xvfree(orig_e820); =20 - rc =3D pvh_load_kernel(bd, &elf, &start_info, ram); + rc =3D pvh_load_kernel(bd, &elf, &initrd, &start_info, ram); if ( rc ) { printk("Failed to load Dom0 kernel\n"); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885798; cv=none; d=zohomail.com; s=zohoarc; b=JVh9tIhTEylM0yhPgPt5Sx6lH2TcH04mkBr08X5l06wS9w9Z/sxYousAMvZhsJrdpkNNIrM0GnJOaKziEwvka6XgSC3axng2Fd+moZmYL4i4O/FKsnuoSRqR9nuvGb3jglCiG8ZNJk+hSORJRiLkoo5MaMukHFwrBuWGn5AvOaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885798; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bROrBCXMpePIikYQv5ywyJaqpPy7JdaGnAckdlts9Cc=; b=djB8mLcQ7C5nFXTF9SI5Yoc0R94L3cUFeQdTOfyVSe95LnPyWuH03A4bFuxuJhQ/Gn7tmpDjMq7b2VcYNYJ1vRf63LMfbWca0HIxwKlUDgAA9BT2xJ5CsgKFjdou+vEiUKa464v8fUnZmbefIlopwrzV+66aAN0I8rkay3gxNlA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885798559311.61434990296914; Thu, 5 Nov 2026 05:36:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474721.1681722 (Exim 4.92) (envelope-from ) id 1xOxdi-0000z8-Kb; Thu, 05 Nov 2026 13:36:26 +0000 Received: by outflank-mailman (output) from mailman id 1474721.1681722; Thu, 05 Nov 2026 13:36:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxdi-0000yz-Hf; Thu, 05 Nov 2026 13:36:26 +0000 Received: by outflank-mailman (input) for mailman id 1474721; Thu, 05 Nov 2026 13:36:25 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxdh-0000xK-N6 for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:36:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxdh-000ODP-3o for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:36:25 +0100 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8651-bab6-0a2a0a5309dd-0a2a4503a2f6-24 for ; Thu, 05 Nov 2026 14:36:25 +0100 Received: from [209.85.221.45] (helo=mail-wr1-f45.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec8658-fae8-0a2a45030019-d155dd2dd5e2-3 for ; Thu, 05 Nov 2026 14:36:25 +0100 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-48e47347279so1118731f8f.1 for ; Thu, 05 Nov 2026 05:36:24 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48fed45d71dsm10037875f8f.36.2026.11.05.05.36.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:36:24 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885784; x=1794490584; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=bROrBCXMpePIikYQv5ywyJaqpPy7JdaGnAckdlts9Cc=; b=ebJrcgiKWhjKbUC4Sj4ggy0pwyWITZUgq2vc3GuBD21c8VWSkMheechn2RcO1u7icn JXGME/OTpbmT4rqTDJXM3FA464CTWu2oECpE2FSUCGWzO0IVdzLC+HT9kOGe6AnucCfY husQwFMLetLSf1aaLIXC7npSjqaiUUGNrbEgRFwsfxUKQ03o5G9u4IGI2Tmb4EXKsxSX VQhIKQQTbQ9RAz/ixgrH/vWS+VnXCpx3mX+PyacFaUX49oH0FZwLD4XX2tqWZD66oiAe b04UbGa8/E/zBQI80Tc7PJtkw4TNpNJeXLrin3EARjkgjQuS4UfafFKom1b4ue0lYRyN HB0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885784; x=1794490584; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=bROrBCXMpePIikYQv5ywyJaqpPy7JdaGnAckdlts9Cc=; b=IXf417AUguGiwvzx3lvPNvZQaoAym0tH1KR3U7o0X526RaxP3m735VHKz0hMsscpvN gemvZ7uDPD6fshqo4zkUUdg/LYF7KO56HbTn042DmRSCP3n/up4HDfrKbS36iFP2F2tb 0vomc/xfVG18fd4lGnjNU+Hwkd45D2BRpsJxLWuasDF7yIwhfd8J866fBIy3ha+mpOpB HflOB0C/w4Tcz94UT8OfN9PGVMJ35LgoSGa0VVVh3DaB83hRqwCrb/KDVxr6zX5/uhBh fArw9uQJiVkog7qR+I6w6EG8uxYWhXy9nW2KMaFcx3oKXSi0pyFOXgWsxtbTKDtBF4FX fLvQ== X-Gm-Message-State: APuU4Z+PZp8omQhdZFemq4P6/dSCY/YrjXTRt1hcFHwt6wcea7+8I5W2 PXIO2QxzSIJyyulq97JxDikmdjEmzhAFjhMkhMn85oS4vSR2AHfIWRs7SkbBa3pH27g6gewfijj m8WCzgA== X-Gm-Gg: AYBFou3eSk+/YWISYwbVtGxamhxW8iId+FebFPUY7q2yTWoUsyHCaiYdpzg6NCdToBi rJ4l2Ivm/uoMI18dXI32HecxJqBjHDw/sM45XqWa2UmcDDH8uySzsX87d86mxsBwgyFgER3Cdzu iEWeO4/G8qnPWEyfTgCn9TIS4D/Ce3sT3uqTgjjwqbGfVKjQLZhUVrMlJRhccbqOt4MCLuotbBE HC3JubRV/Ja+mm9G2NAW0+e8TQQvKxB/oufCW3x3TKGzh1LDvAdeOVgDLBFZtPefIvPJK2Qa/yN fi50gWG1wNiIaHqbR7xc6TaRIXCte2nvL8DqxIw8vE0ahWxp3jG/ZngLshfnF1Z1Hdn8LvRlqvs pvhcl3qhdHSHzS0wxnaA2fpJ+MIzAusb5EHVLSsVqymfoicQ1nElIfbiVNhtifrN5gzmZTXhqjy z2Mk3B5Dsm3r/a3CiLH84fDKGS6YVuZ414XwQ4KxcBghHZ/QuYC0O6ae32pZcAon1mpGABFEpeq z6rZgrnL6QOhWogOwX2GkM0RtA/scbBFWAe0U9EaH75GK+iIsI+TeTIVol07rlmgRRBC3ahGkg/ dVl/dxLDsQLNv4Ctgyl1X6XfgecPY/WYq2SeOgYZtBvshZbmfFGuHKzDljPKr55JpNYaplrXwcP m0R1DLTaBFrtHwPfLPHLULMB2yFOPyKJPFOuYuA== X-Received: by 2002:a05:6000:4a16:b0:48d:f9dd:e3df with SMTP id ffacd0b85a97d-48e6e2fab79mr41873743f8f.18.1793885784510; Thu, 05 Nov 2026 05:36:24 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:36:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 11/14] x86/PVH: prefer smaller E820 regions for stealing from From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1793885785-752854E9-B6462698/10/78276251493 X-purgate-type: spam X-purgate-size: 1867 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885799506158500 Content-Type: text/plain; charset="utf-8" Nibbling from the end of large regions tends to split full 2Mb (or even full 1Gb) ranges, which Dom0 may otherwise be able to use superpage mappings for (when, like Linux, it e.g. has a direct-map). Signed-off-by: Jan Beulich --- On one of my test systems this doesn't work as neatly anymore as it did before. In v1, since the kernel range wasn't removed from the candidate set, the (relatively large) E820 region covering it wasn't used for the small ACPI ranges we need; instead a range of about 2.5Mb size next to the host's ACPI data was the best candidate there. Now, with the kernel starting at 2Mb, the 1Mb range [1Mb,2Mb) is the smallest candidate, which is a little unusual a place to put ACPI data. --- v2: Re-do from scratch, due to changes earlier in the series. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -184,8 +184,9 @@ static int __init pvh_populate_memory_ra } =20 struct steal_info { - unsigned long size, align; + unsigned long size, align, region_size; paddr_t addr, end; + bool nosteal; }; =20 static int cf_check __init find_ram( @@ -197,10 +198,12 @@ static int cf_check __init find_ram( { paddr_t addr =3D (e + 1 - info->size) & ~(info->align - 1); =20 - if ( addr >=3D s ) + if ( addr >=3D s && + (info->nosteal || e - s <=3D info->region_size) ) { info->addr =3D addr; info->end =3D e; + info->region_size =3D e - s; } } =20 @@ -219,7 +222,9 @@ static int __init pvh_steal_ram(struct r struct steal_info info =3D { .size =3D size, .align =3D align ?: 1, + .region_size =3D -1, .addr =3D INVALID_PADDR, + .nosteal =3D !end, }; =20 rangeset_report_ranges(ram, MB(1), limit - 1, find_ram, &info); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885823; cv=none; d=zohomail.com; s=zohoarc; b=iahwU6GXgI7ipXbmdqVhojOJ2+SmXgxScxTiFG00qLiE7tKW0j4U/JCzPfAfMmQ1bpPBoNs/TBs67ylRHiJxqI1YQtguquYOqOfBKvakWr/0+jKye5Sjjmokn/aO3m97mGyBBSYtj3wnRK7yaMY+O3cbDQpRBIgwwn89lCb5Blk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885823; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FfJeD3ix+Q2sHIalbTxwbncwzv13LvQuwahnvUzAa/k=; b=DU0NLOmD8F0C3dL1oMbLIVfkormMr3OnQvA/q1JhCWq6U9k6kkEa6ciiZI/CEoke6hgibbBqG9zPCb4KHRqw2sBeIGdKel9o7L8Szib5ZRIT2FKbHpGoWm8qq/DGNd3n6S7bULrW9BEollbB3KbescWxlqounlAloIWaazSS0C0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885823333231.39218391373277; Thu, 5 Nov 2026 05:37:03 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474731.1681731 (Exim 4.92) (envelope-from ) id 1xOxe3-0001YA-RL; Thu, 05 Nov 2026 13:36:47 +0000 Received: by outflank-mailman (output) from mailman id 1474731.1681731; Thu, 05 Nov 2026 13:36:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxe3-0001Y2-OI; Thu, 05 Nov 2026 13:36:47 +0000 Received: by outflank-mailman (input) for mailman id 1474731; Thu, 05 Nov 2026 13:36:46 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxe1-0001VL-V2 for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:36:46 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxe1-003y6U-Bl for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:36:45 +0100 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8661-e002-0a2a0a5209dd-0a2a450394d4-48 for ; Thu, 05 Nov 2026 14:36:45 +0100 Received: from [209.85.221.54] (helo=mail-wr1-f54.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec866c-fae8-0a2a45030019-d155dd36d4c2-3 for ; Thu, 05 Nov 2026 14:36:44 +0100 Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-48e00eee27dso1085478f8f.0 for ; Thu, 05 Nov 2026 05:36:44 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b572bba207sm63028385e9.10.2026.11.05.05.36.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:36:43 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885804; x=1794490604; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=FfJeD3ix+Q2sHIalbTxwbncwzv13LvQuwahnvUzAa/k=; b=C5TEFs1GLwTS+HFu2Z5eg2A1sNv6PAmYq15EeRY79gk3624nvjg27umuv7Snb1ZWtu aLHsKfX0ykZKmN9IICrtdi1k60pmlUX0EjSAwbFiXVp2P+qqY1fioKnDook7O8yPXT/J ouqp5QpVXzBXPRal0BBz+ceeeXjdItCFHOWLapqljcRSp/X0800dGf8GyEAEECG19+Bq /w3wGhcUvRGtaSrlcCtHD3riKJDawIe6tqQCPkqs1lZmAKxxBQchptY2HkU4xhYKy2xl 5FNv47PxdJC0dbD65zdbfLDWafz+4Sxcj7oK9XVrvsgPkeIJVcZVK3QaeZRWV9mGuj/a Mr8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885804; x=1794490604; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=FfJeD3ix+Q2sHIalbTxwbncwzv13LvQuwahnvUzAa/k=; b=X6Lffo/BZYAhA/TAi/UcB7eiP/rCPUElP5YWjqD/SkBRpap7V+z1EFlYTupW3r7xFG 1FUfL3LfkKIgKFVyYPiGgYqAcT/qjCcXk4vQOfpKlS/ARe+hJesLDM46cVCG4SiItbQI ySOl5hwyOXuIktMReKa5XnON+a5G4dTj7U8QEgbyhyhqqE0uPcHxBjKqK72P0qyVgV5M oVUNkVYNLMlVaWg5Hb43+Ql5f4kz1G/oGbRXnDkjA1OhNFdhrPnmY6dqZcjgmLbdLVIV cr9DgWaVayV5zjEWMk8XsZb5F9I1U1C8mFGeVX4BTcFILh8cBfzgaL2qNjBokjddxII8 ODJg== X-Gm-Message-State: APuU4Z/NyYM6DSo5oHkYi3XvLaWwdtkE4ktAWmTQaLZrZ8mQilK1hYc+ /d4tXtu5N/IVIkNUxbysyk5Qe40eWQi+mOihYr/rS7IjMbr9MLYYBQ5lpyqCY1dFTzCLrFy/BnG PlKwz8g== X-Gm-Gg: AYBFou0fkZjRjk4rORMP80fE0+4MxiF4+xWplXtQlIzVlWAxV0z30c+8VzCXBOuVEP7 x5TZ5HbvvHU7yTRA+SmdIUpkVI19Y8zJuSsxq5F65r2QoscVpIU7Cbspr1r2sf79uZsQtWcHYRe ErOnoidn+cq7PsmsiQuMTAJcsaxiVQsPzSGq4m66cjLDQtzekJpRNBBf9hc9canx3ATthF/BQKe ogseuJ9BC1QEq9rdDG2w8y0L1bDgli248ygsdaIT1Che4Js0Ct1fLTuHtnZ5sxfKtV73kab/4JM HgHOYrPzQcsZZM3oSxiogwt+zEvkzcYRoYIya6vj00ZswZDFIc1aBiwAaJzTz6ukEo/8Qii1JqH cIqWf62pCxjyt+Z9tKOqU1zfgxB19LPqEtYjK32NHrKW9D4ClpxoTLJfCNpLmuONhEJ/VcqYrYy vdF5vkQbZRnzDY5d0HmdE1F+ybuCNuluzH1pjXFSP5LJJHH+lnknZwr7EMXvfm6mjOW1UCCEPbM DCFK9uY+j2kFG3FCSXxHRttEIkFOrsEw5YyrxPcUVjxro231nTu3MZfofUmmOR3Rsc+62miZzZ4 v/W5vJzH8xJ4SwDzo4YiKORGuvR08XMOykokj1/tefMoTXZs6CDVRvZcIGSzT9PEuoNuAkqsmLg mVYO0U6kTuRDBtOA= X-Received: by 2002:a05:600c:1f93:b0:4a5:87b3:ddc1 with SMTP id 5b1f17b1804b1-4ac180f1ec7mr442644015e9.13.1793885804326; Thu, 05 Nov 2026 05:36:44 -0800 (PST) Message-ID: <67c62b56-e18d-464b-b2f0-0b3b4c184594@suse.com> Date: Thu, 5 Nov 2026 14:36:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 12/14] x86/PVH: log Dom0's E820 map earlier From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1793885804-6C6DE4E9-A17A8F5A/10/78276251493 X-purgate-type: spam X-purgate-size: 1900 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885823895158500 Do this as soon as it's final. For debug builds also mark it final, with assertions put in place to make sure it won't further be altered. (For a release build such further altering isn't the end of the world normally, so the situation is left alone there.) Switch to using %pd while moving the code up. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- v2: Set e820_finalized unconditionally. Re-base over changes earlier in the series. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -46,6 +46,9 @@ */ #define HVM_VM86_TSS_SIZE 265 =20 +/* Marker set once Dom0's E820 isn't supposed to change anymore */ +static bool __initdata e820_finalized; + static unsigned int __initdata acpi_intr_overrides; static struct acpi_madt_interrupt_override __initdata *intsrcovr; =20 @@ -248,6 +251,8 @@ static int __init pvh_add_mem_range(stru struct e820entry *map; unsigned int i; =20 + ASSERT(!e820_finalized); + for ( i =3D 0; i < d->arch.nr_e820; i++ ) { uint64_t rs =3D d->arch.e820[i].addr; @@ -1744,6 +1749,14 @@ int __init dom0_construct_pvh(const stru =20 pvh_place_initrd(bd, &elf, ram, &initrd, &blob_start, &blob_end); =20 + if ( opt_dom0_verbose ) + { + printk("%pd memory map:\n", d); + print_e820_memory_map(d->arch.e820, d->arch.nr_e820); + } + + e820_finalized =3D true; + rc =3D pvh_populate_p2m(d, orig_e820, nr_orig_e820, PFN_DOWN(blob_start), PFN_UP(blob_end)); if ( rc ) @@ -1781,12 +1794,6 @@ int __init dom0_construct_pvh(const stru if ( rc ) return rc; =20 - if ( opt_dom0_verbose ) - { - printk("Dom%u memory map:\n", d->domain_id); - print_e820_memory_map(d->arch.e820, d->arch.nr_e820); - } - return 0; } =20 From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885847; cv=none; d=zohomail.com; s=zohoarc; b=dBToiX2lcd2OGTvbfOo6Aixj9r4COrun5Kf4Oj8P67t7E/O9VKI0DJyYU9uySKe8ROxPWfr+fV0JnrWB6Tg3HuqujS//snOHCQ2BInBpTaSbwKUexUP1GJcZ4OQbW6FVGi/QFWsgqFWguFZHMbbgm/NhJdSqNc5QUAv1mIov/I0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885847; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=imShRlEMCMBWZ/mu1fyOE5mw0Ai2dYu4aKRjt4i+5QA=; b=dvxZR4tO0yH4HsWCist6CqMQejk7+kXgbQGFaoY+BkMBl+ctoWrKrAh12a2jpHonzuznxjoMs+HT//y3Ht4bVKsqooGyeblSmMK8xnWnOG0tVEpqkEh6hvoDoOMJYFHUrPZVtp0uCB5SlNgylRnMavDUTCpqTtTMKu37resM8t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885847546814.3836835034085; Thu, 5 Nov 2026 05:37:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474740.1681740 (Exim 4.92) (envelope-from ) id 1xOxeY-00028I-2b; Thu, 05 Nov 2026 13:37:18 +0000 Received: by outflank-mailman (output) from mailman id 1474740.1681740; Thu, 05 Nov 2026 13:37:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxeX-00028A-V7; Thu, 05 Nov 2026 13:37:17 +0000 Received: by outflank-mailman (input) for mailman id 1474740; Thu, 05 Nov 2026 13:37:16 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxeW-00026V-F8 for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:37:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxeV-0033DJ-Rt for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:37:15 +0100 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8683-2eae-0a2a0a5409dd-0a2a4509bd2a-36 for ; Thu, 05 Nov 2026 14:37:15 +0100 Received: from [209.85.208.44] (helo=mail-ed1-f44.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec868b-be1a-0a2a45090019-d155d02cb147-3 for ; Thu, 05 Nov 2026 14:37:15 +0100 Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-6b1aa2848d2so2996564a12.3 for ; Thu, 05 Nov 2026 05:37:15 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e4422d1sm175562066b.39.2026.11.05.05.37.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:37:14 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885835; x=1794490635; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=imShRlEMCMBWZ/mu1fyOE5mw0Ai2dYu4aKRjt4i+5QA=; b=FooMUcObf5qvF2Wn72ZyvLboeGYuDHmAlfnaOTEgegrH1wGdPE/FTzZG9VVVymxZyR AJbKVKUz5fiMBgF/G9sweiijuAAzwan77AvEZVz9sB1UpGFuZbBH1HeRyBEa9q5x7cXL OnGqcsR2jL8wIdnyYXDQCC8eIvVBu91A6vutBDS8rQUMCgN85qm6JZAmPSCcsSQrZn3O vyGG7iIby8kVcRHRSyIkElLWOAtzDIFvHHR9bwIWBH/RwFFwuAfVhkb6VhL3ec2Yqjzx 2HK3nIIalukZc/AZBoSPHpH3RcCeL5Gl/Bm7C6s3hgLluySeqr4rR38Judh24xLQYmQQ oY+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885835; x=1794490635; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=imShRlEMCMBWZ/mu1fyOE5mw0Ai2dYu4aKRjt4i+5QA=; b=pGx1Vu4FFcHHXwnLKTCNUIpQVNo/BhMCH5RMoarvvqTXD1ksCTr7RPIuMmFn8PZnuK DsbwOHrouiu7jG/bjGDvQHkgjPM5v3tvdXUKgvfXdbYQagDfWJ3UnDCnDRdqSL05dtgt PTt6pOudC7EuUoJERls04VFxX7/ywUMjU4CvuG1pltBycAJgUeX7vDvYZmaIwclmGsPB N/mKRban+t0pao5zE72+d/BmrshZIbUp4XgEhM+CizrjvE6IVFVVBDZte5fXExc+Feix KkXk99jKNk05bhPbyIET3TDZoBEQPZHFUPM9M/Dd68LuXdZvDKoK2muwgzMsTlElDoH+ +VGw== X-Gm-Message-State: APuU4Z9+SJDpqGxPBwGIJPRFHD6AEKc+vkeLzk2b63nJxeJ5rRmN/iZu Wg3MKc8iQczlsN4zD/0YxFXA0+0Makq5vOKcuo5GARwVDP1u6YP1cE0RZ/UHP21QxlCDqh5+pd5 19K++8g== X-Gm-Gg: AYBFou38+qcX0rW1OZ1K1X/uMwpG0eNjRQXhnOY6cjj0KmT3tZxPY4lRpmCcXVa9xCS 6DgLd6Z8J0EkL0RjYGkki+p/7mKgnaxCqzlk5x2LfCDL0O4EllD/ycvgpmcjRt695GMIpKFV3nE utJryYSb4s3Drmc1qa3LetPztIw6uEWn32KG2buBLw5d/xqhwa+40P50OuBdp7vPFq8rL+6AYeQ TDIIj0muXqUJdVNRXJWteiLkGzdwp23IG9O38KEEdCDAsvgmWmP9nPP0eMFnA07psA0W9cUoIod knaIvxeAqIXv+KjgDDcKMtzChmJk8AFzUcAm/FJRDwxEK7aVCNBqsgYDvfVuuWfmIBSy4NCQLPx kis+yzaan6T+95mXMsy4jGyrqs2w+BDJ5l+HDMYzjZ415tOC5m1MSHDlgUW3V9vjABBpZMIstpz OrsW1ES7eAf2EfamTBCGUw5YWKWKBNwhg7TMcJfjNh+t8PhUJBSrQeMseLuIkrXk5swHFZusr3H ne2VjfPV27s5m3aEpEj0Eyi+x9Gbw00LZfVmo+EH9hcf03QhCqGrtV/eJMAkWD0T3JCutWTjM30 JBjZS6l3Rmvy4ogMDmp25J2Whj5HA+A/pSxfabLpyl8lcr/Ep6SyKOaTs5wVtPU+M675rfEo10R dYuP+wXyHnZwIVrAn X-Received: by 2002:a17:906:9f92:b0:c41:5970:2360 with SMTP id a640c23a62f3a-c4ca7ad1d1fmr1645182966b.41.1793885835031; Thu, 05 Nov 2026 05:37:15 -0800 (PST) Message-ID: Date: Thu, 5 Nov 2026 14:37:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 13/14] x86/PVH: simplify writing of Dom0's RSDP From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1793885835-BFED6034-63BEEFB0/10/78276251493 X-purgate-type: spam X-purgate-size: 2871 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885848252158500 Now that we establish where the RSDP is to live before actually loading the kernel (and writing start-info there) we can simply hand the pointer there, eliminating the need for the (fragile) separate write to the field out of pvh_setup_acpi(). Signed-off-by: Jan Beulich Acked-by: Roger Pau Monn=C3=A9 --- Alternatively we could move start_info to the top-level function, have pvh_load_kernel() and pvh_setup_acpi() fill what need filling, and do the write from the top-level function. Yet it looks to me as if this was more churn for little extra gain. --- v2: Re-base over changes earlier in the series. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -943,7 +943,8 @@ static int __init pvh_load_kernel( struct elf_binary *elf, struct hvm_modlist_entry *mod, paddr_t *start_info_addr, - struct rangeset *ram) + struct rangeset *ram, + paddr_t rsdp) { struct domain *d =3D bd->d; struct boot_module *initrd =3D bd->initrd; @@ -1083,6 +1084,7 @@ static int __init pvh_load_kernel( =20 start_info.magic =3D XEN_HVM_START_MAGIC_VALUE; start_info.flags =3D SIF_PRIVILEGED | SIF_INITDOMAIN; + start_info.rsdp_paddr =3D rsdp; rc =3D hvm_copy_to_guest_phys(last_addr, &start_info, sizeof(start_inf= o), v); if ( rc ) { @@ -1563,10 +1565,7 @@ static int __init pvh_place_acpi( return 0; } =20 -static int __init pvh_setup_acpi( - struct domain *d, - struct acpi_info *info, - paddr_t start_info) +static int __init pvh_setup_acpi(struct domain *d, struct acpi_info *info) { int rc; struct acpi_table_rsdp *native_rsdp, rsdp =3D { @@ -1618,18 +1617,6 @@ static int __init pvh_setup_acpi( return rc; } =20 - /* Copy RSDP address to start_info. */ - rc =3D hvm_copy_to_guest_phys(start_info + - offsetof(struct hvm_start_info, rsdp_paddr= ), - &info->rsdp, - sizeof_field(struct hvm_start_info, rsdp_p= addr), - d->vcpu[0]); - if ( rc ) - { - printk("Unable to copy RSDP address to start info\n"); - return rc; - } - return 0; } =20 @@ -1767,7 +1754,7 @@ int __init dom0_construct_pvh(const stru =20 xvfree(orig_e820); =20 - rc =3D pvh_load_kernel(bd, &elf, &initrd, &start_info, ram); + rc =3D pvh_load_kernel(bd, &elf, &initrd, &start_info, ram, acpi.rsdp); if ( rc ) { printk("Failed to load Dom0 kernel\n"); @@ -1783,7 +1770,7 @@ int __init dom0_construct_pvh(const stru return rc; } =20 - rc =3D pvh_setup_acpi(d, &acpi, start_info); + rc =3D pvh_setup_acpi(d, &acpi); if ( rc ) { printk("Failed to setup Dom0 ACPI tables: %d\n", rc); From nobody Mon Nov 23 22:31:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1793885874; cv=none; d=zohomail.com; s=zohoarc; b=mQ5vuZBNP53JB7mRQwZeh/hbXGTOhnjhmUAiQFlBZghwG/9goPk+O/YK+4wrqifj6tiZ9CUTwo2rSAZJDgvM6V4MJPbT8M3wls/xOwdj42dfUl2lsDfQn+Jb293QL2RMKR25RZ5n59HEVsks1XGp/6n0EuNoE5P93hN5MnZOINw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793885874; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d2sVV/P+QXxHkGFl11/0QW1t/tIUxIiQ/ud1zR58BTo=; b=fHAo/03R3ecZ9wYGEEdfLH3q1G+fJvBbPwzwf7Glk4i/P2rH2ABfuHaqMBdzmhScrWaE6ryetcEj8zFDA0fv0z8CQsWq9birKomhEMf8qXIcbIQZ2DEKUX92dQ4sUlyDPXPSHZe1zu5HAdyo33CWSMD5EncWyxRSgvIY+eu3zFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793885874523490.18874154037576; Thu, 5 Nov 2026 05:37:54 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1474745.1681749 (Exim 4.92) (envelope-from ) id 1xOxes-0002a2-9X; Thu, 05 Nov 2026 13:37:38 +0000 Received: by outflank-mailman (output) from mailman id 1474745.1681749; Thu, 05 Nov 2026 13:37:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xOxes-0002Zu-6Q; Thu, 05 Nov 2026 13:37:38 +0000 Received: by outflank-mailman (input) for mailman id 1474745; Thu, 05 Nov 2026 13:37:36 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1xOxeq-0002Uh-Iw for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 13:37:36 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xOxep-009r25-VL for xen-devel@lists.xenproject.org; Thu, 05 Nov 2026 14:37:35 +0100 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aec8693-8faa-0a2a0a5109dd-0a2a45098b76-32 for ; Thu, 05 Nov 2026 14:37:35 +0100 Received: from [209.85.218.42] (helo=mail-ej1-f42.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aec869f-be1a-0a2a45090019-d155da2addfa-3 for ; Thu, 05 Nov 2026 14:37:35 +0100 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-c4301e334ceso156481066b.1 for ; Thu, 05 Nov 2026 05:37:35 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d0e140fa1sm175042366b.7.2026.11.05.05.37.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Nov 2026 05:37:34 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:Content-Language:References:Cc:To:From:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1793885855; x=1794490655; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to:content-type; bh=d2sVV/P+QXxHkGFl11/0QW1t/tIUxIiQ/ud1zR58BTo=; b=JAPmU/8QmXClX04VDJIOf3Gc11Dw56l0PzdkPwXK55tU7a8TKY/gArItxyPDQMrL8R 7OV1Y+jUUKQRiy5JRIDVpuY9ZtVnfhOGOWEdPpVDTTSI43wyOyl/3EtuvbVBt3b0BlJz Vz35bgl7T1ZHHd1cjUiKLjDsbO1yxu35u/foaKRt6ufx8gqjhCafUM2uMg7ROo+RV+Jg TkKFgdMsPXQK+R/wt58atgmVjU3FYoAhnP6lb6pZRTVZEEaXiPiFGhkuQhAytIXXiLDI mvevYgCWYUArkNkBeEdUr684Zs7TNExsVjCOw/kgVT91wFiDlccKIQYMmzLZMujzLN4d mDtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793885855; x=1794490655; h=content-transfer-encoding:content-type:in-reply-to:autocrypt :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=d2sVV/P+QXxHkGFl11/0QW1t/tIUxIiQ/ud1zR58BTo=; b=ayYeyaBaBSYH7avriiFXRNVd3seM8+XNKhuV161BOPWsjIbpDtAGgw4s2SEz3B3iFn 7Qeb/7rNJYa3sMIwrIPJRrAnUlSZX7XciwZGz2qT1FrwB6Df+nZXlGTl2A7NIZ+awr4c gmva6LBv5vcBGiYHoGED8GNi81P26U3gYE3GFO3X57+F1DDjn0ftmPjNKzWAaCw679/C YroneyKNVne/d0ZhlsAl3Y/+1RYCS5f0uGphptEMIn53amzJlXFOHoU7MvlRMRkmcLwn h79+tz25+nJOD1r+pldzY8y9BGrSPEiTHnMFWdliazKlope64Wql2EDnt++J5VE3Q2qK /Zjg== X-Gm-Message-State: APuU4Z8CT9zYoE+ilDX1dHVvn8P4jlXNhWcpNbWMQD1v3VaJKg7TlT2M FlZ5hTQcZ6/gtDZAjfNfVrP92DymJZ1V3t2Eb4qlBYhBjaDp5wD8j6/nYL5saC435os/AE2bG+e OGoleHA== X-Gm-Gg: AYBFou0SoCrSEklJOuu347/usnEIDRtJlM9yl48kBSNeP3xKQrGrHcCzX2OsEIEJgCK ULcif38IbQCAkvm0Wz88o9MQ/vX6CoJtbM5q+Smw1XQCMyrfJA6FhnSyl5HKHTQh68Hxbl+G+oN O0jyLYCHUrg3vRcNs4+H/1R/DyXtd+PdvQ9Q6WzjlK8L/IDzu1O0rIpFCVEXb9dvTYT6ODd6Oke cS4NOnieNyfGza9rgiyDQkKJdTy1geCCQIZByODrSb19zxAq1RQp1NJtJyDZUUphrelSOMJR78f JDMcNYTsJ8Io0AD2QIQt8K+B9TiEkXvfEYDWBtplWfaTLHogytG55VpdtzwN5NCgM5DJP+IPTFg jJTQtUsSJEi3rUG7lSEvn3BfkfIk2YXh3g2GH/8KoBHTbAZIqhdtn/BMFYr3YpyWkMKL1QlMuMQ u2rVOhx3v0wcvxp0JQ0KzaWtwgux7TDRV44Zlw8sNciuKwtLsWhFd+dMOxYBD6+q05tJwc/3mBr rQ503DM6SA/cabGfi8u0/PVM8g573r05uTdohbmWU3eF551xD78NPVYONQNz4UVIGBnnkCdoxq1 HZYpF3tqwDHM4bqi7iSGMeoErVBdO5EH9yeUunnLFNKDlZ44x0j58oWsBrXfXeuYbu5OdbfU2vx 5dc3ACh8VQ6rs+pc= X-Received: by 2002:a17:907:1c8e:b0:c49:c76f:dad4 with SMTP id a640c23a62f3a-c4ca7a6e69fmr1735171766b.31.1793885855282; Thu, 05 Nov 2026 05:37:35 -0800 (PST) Message-ID: <96282903-34bf-4395-9a1f-a9828ab7ac3e@suse.com> Date: Thu, 5 Nov 2026 14:37:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 14/14] x86/PVH: check Dom0 start_info for truncation; adjust entrypoint type From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Teddy Astie , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1793885855-BF4D3034-40E60711/10/78276251493 X-purgate-type: spam X-purgate-size: 2204 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1793885876865158500 While for start_info we now (supposedly) guarantee that it lives below 4Gb, check it nevertheless to play/stay safe. For the entrypoint address the situation is different: libelf already hands us a 32-bit quantity; if there was truncation there, it would be inside libelf (when extracting the value from the ELF notes). Reflect the 32-bit-ness in types used. Requested-by: Roger Pau Monn=C3=A9 Signed-off-by: Jan Beulich --- v2: New. --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -798,7 +798,7 @@ static bool __init check_and_adjust_load static int __init pvh_place_kernel( const struct boot_domain *bd, struct elf_binary *elf, - paddr_t *entry) + uint32_t *entry) { struct domain *d =3D bd->d; struct boot_module *image =3D bd->kernel; @@ -1097,7 +1097,7 @@ static int __init pvh_load_kernel( return 0; } =20 -static int __init pvh_setup_cpus(struct domain *d, paddr_t entry, +static int __init pvh_setup_cpus(struct domain *d, uint32_t entry, paddr_t start_info) { struct vcpu *v =3D d->vcpu[0]; @@ -1123,6 +1123,13 @@ static int __init pvh_setup_cpus(struct .cpu_regs.x86_32.tr_ar =3D 0x8b, }; =20 + if ( cpu_ctx.cpu_regs.x86_32.ebx !=3D start_info ) + { + printk("%pd: start-info address truncation: %p)\n", + d, _p(start_info)); + return -ERANGE; + } + sched_setup_dom0_vcpus(d); =20 rc =3D arch_set_info_hvm_guest(v, &cpu_ctx); @@ -1640,7 +1647,7 @@ static void __init pvh_setup_mmcfg(struc =20 int __init dom0_construct_pvh(const struct boot_domain *bd) { - paddr_t entry, start_info; + uint32_t entry; struct domain *d =3D bd->d; struct elf_binary elf; struct e820entry *orig_e820; @@ -1649,7 +1656,7 @@ int __init dom0_construct_pvh(const stru struct acpi_info acpi =3D {}; struct vmx_info vmx =3D {}; struct hvm_modlist_entry initrd =3D {}; - paddr_t blob_start, blob_end; + paddr_t start_info, blob_start, blob_end; int rc; =20 printk(XENLOG_INFO "*** Building a PVH Dom%d ***\n", d->domain_id);