[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/mkelf32: Actually pad load segment to 2 MiB boundary


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
  • Date: Fri, 17 Apr 2026 11:54:24 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qbv598KG+/Z+nmSjFRqOtp2uxNwXfJQuKAFY7O9Q7pg=; b=RyRw7l+I1TckJu52HF1HCaRHD73FVYUfb/KYjpHJ+St5594v6TwpZz3DONIqbMKSkMuhrXsho2bc5k98WVYoNN9G91EDRVXWxD1nYkt47x3hEMZda6gKhpGn4cBtYs/0ruG0BOJ9F5oaem7h/bs9PO87Llw+gK8jYJMzNASUyQNFmRYMlrN13gR+loMLkKX/NKto+0+RxSOsCmg1uQXq2cl5Bqzo6L25VUmg5C5/wnFehWtQg8NPvzzUUWn0Cnr+iENHSZt6ZAyjX/qveH12vxYxUqQdrzRT8qg1fiCrHJTa6x3RkyBMvnqdsCZkWgKwC7rJfCRU0sDda24Z8ZuOag==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QW33sK7jeTkZPUcfIerziAeFNX7W59m55/JQ4hrA38FvEHMHxr8JH1zF8cX6WykxYvQVWeZePbhi7V5O4xyuVk7nyniJ076lsnv7vU3IyEFAZqixBZtydZaR0EXPlnFIlpHe/Y3H5oVzLNAH02lH5mlYUaFIeItY6pE6fh0sNqRcVJVClkSbA34sCEfq/JqIECAUUqMy39yNBxdJCCS1noOveh5L1rqouAp8dCHqi0pLFPmoSzhl3P2zKsrMtQDlNIK8Lnu9+iyeU1rm/30upmUCfnIQMNDoVDxSqNEPM01dSBtaAtZLWstwpjLuDNSomxKAPKnKuit0sZVtZmZTFA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Fri, 17 Apr 2026 10:55:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Fix the code which tries to pad the load segment to 2 MiB but only pads
it to a 1 MiB boundary.

This manifested itself as a page fault while scrubbing RAM during boot.
Xen failed to mark its location as reserved in the E820 because the last
2 MiB superpage overlapped a reserved region which meant the memory was
given to the allocator despite being RO.

Fixes: 4fb075201f54 ("x86/mkelf32: pad load segment to 2Mb boundary")
Signed-off-by: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
---
 xen/arch/x86/boot/mkelf32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/boot/mkelf32.c b/xen/arch/x86/boot/mkelf32.c
index 373ba4ddd593..469d1ba0af41 100644
--- a/xen/arch/x86/boot/mkelf32.c
+++ b/xen/arch/x86/boot/mkelf32.c
@@ -345,7 +345,7 @@ int main(int argc, char **argv)
      * the Xen image using 2M pages.  To avoid running into adjacent non-RAM
      * regions, pad the segment to the next 2M boundary.
      */
-    mem_siz = ((uint32_t)in64_phdr.p_memsz + (1U << 20) - 1) & (-1U << 20);
+    mem_siz = ((uint32_t)in64_phdr.p_memsz + (1U << 21) - 1) & (-1U << 21);
 
     note_sz = note_base = offset = 0;
     if ( num_phdrs > 1 )
-- 
2.53.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.