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

[PATCH v2 7/7] x86/kexec: Zero GPRs before entering new kernel


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Date: Mon, 22 Jun 2026 16:18:33 +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=ka899mqYRjHfWYgSOCloGz1lQeceEJ3Vxja9LrEfdBM=; b=XxZppfaJPPFSmFCsog/D3osF4z/7kmhg7iN6N/+HTlL9NcA2TPrg5xvX032tA44+SDC4mKl5Gas6XbKtIQk+q3gNXIblIk4Lj+/uWfn/Mqadye9OPAzeJMco0YF4jHkFaJvTNtraM9NH5IoO07gp4ntbqha2xtyX7knebd24R83DD3A0wCzCSV/6CKfA0IGyYQnpMBctvvIF7Rrkbks2i1ZnZt1WiVWw227mpUzCFlUkl8Z4wSBMuwo4ZwQ+7lWTZGBzHnXy5fbzuKU5hkXJsdW+fjNCmQ5cnkA9RLh2N0T6F03listTW/rL/b7KWLMTt93nU5MMmF042N2DGRSyjg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EMmB3QhPtYDJbH2qE52b5UXC6m5xhKlXJd6UoFjPK+4pvd3PRWU850Fdsyk22ipVjWTYoOVKG/ji0VPQIyE1uoM0kKDgOeTbOmJ2CkYwrep+sjoDDjsoxpOjk1/mZ4OQKyqeVOjzpw5+2vT9n9aEMA6L13EXrYbpJY2/wsAsPjC5KU1HKU6ncdihS+iA3EvFbvOHIdEDqZVxtr4/mZuBRPSqpg68EPhEoH013SVJLcdQfs/KBsmvlI93I+LCBkDIqL63u4CynzYxUBvcoIaFTHunmXQ2371/Qg9WRhjxydklCzOPcuFv0lOhgZfNJFhFFTK7lhwRQQKAv6ASkQE8ZQ==
  • 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: jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, ross.lagerwall@xxxxxxxxxx, Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Delivery-date: Mon, 22 Jun 2026 15:18:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Purgatory zeros these general purpose registers before jumping to the
new kernel. When doing kexec on an EFI kernel there is no purgatory so
we need to zero the registers here instead. This change shouldn't affect
the functionality of legacy kexec.

Signed-off-by: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
---
Changes in v2:
- Move the 32bit lines to the correct place
- Reword the patch subject line
- Fix indentation
---
 xen/arch/x86/x86_64/kexec_reloc.S | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/xen/arch/x86/x86_64/kexec_reloc.S 
b/xen/arch/x86/x86_64/kexec_reloc.S
index ab9fa7f2b8..f8ec457a19 100644
--- a/xen/arch/x86/x86_64/kexec_reloc.S
+++ b/xen/arch/x86/x86_64/kexec_reloc.S
@@ -78,6 +78,20 @@ FUNC(kexec_reloc, PAGE_SIZE)
         testq   $KEXEC_RELOC_FLAG_COMPAT, %r8
         jnz     .L_call_32_bit
 
+        xor     %edi, %edi
+        xor     %eax, %eax
+        xor     %ebx, %ebx
+        xor     %ecx, %ecx
+        xor     %edx, %edx
+        xor     %r8d, %r8d
+        xor     %r9d, %r9d
+        xor     %r10d, %r10d
+        xor     %r11d, %r11d
+        xor     %r12d, %r12d
+        xor     %r13d, %r13d
+        xor     %r14d, %r14d
+        xor     %r15d, %r15d
+
         /* Jump to the image entry point */
         jmp     *%rbp
 
@@ -94,6 +108,7 @@ FUNC(kexec_reloc, PAGE_SIZE)
         lea     compatibility_mode(%rip), %rax
         push    $0x10
         push    %rax
+
         lretq
 END(kexec_reloc)
 
@@ -171,6 +186,11 @@ FUNC_LOCAL(compatibility_mode)
         xorl    %eax, %eax
         movl    %eax, %cr4
 
+        xor     %edi, %edi
+        xor     %ebx, %ebx
+        xor     %ecx, %ecx
+        xor     %edx, %edx
+
         /* Jump to the image entry point. */
         jmp     *%ebp
 END(compatibility_mode)
-- 
2.52.0




 


Rackspace

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