[PATCH] xen/kexec: Clear unused registers before jumping into an image

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

 



Clear unused registers before jumping into an image. This way
loaded image could not assume that any register has an specific
info about earlier running Xen hypervisor. However, it also
does not mean that the image may expect that a given register
is zeroed. The image MUST assume that every register has a random
value or in other words it is uninitialized or has undefined state.

Signed-off-by: Daniel Kiper <daniel.kiper at oracle.com>
---
 xen/arch/x86/x86_64/kexec_reloc.S |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/xen/arch/x86/x86_64/kexec_reloc.S b/xen/arch/x86/x86_64/kexec_reloc.S
index 7a16c85..e7eef79 100644
--- a/xen/arch/x86/x86_64/kexec_reloc.S
+++ b/xen/arch/x86/x86_64/kexec_reloc.S
@@ -71,6 +71,29 @@ identity_mapped:
         jnz     call_32_bit
 
 call_64_bit:
+        /*
+         * Clear unused registers before jumping into an image. This way
+         * loaded image could not assume that any register has an specific
+         * info about earlier running Xen hypervisor. However, it also
+         * does not mean that the image may expect that a given register
+         * is zeroed. The image MUST assume that every register has a random
+         * value or in other words it is uninitialized or has undefined state.
+         */
+        xorl    %eax, %eax
+        xorl    %ebx, %ebx
+        xorl    %ecx, %ecx
+        xorl    %edx, %edx
+        xorl    %esi, %esi
+        xorl    %edi, %edi
+        xorl    %r8d, %r8d
+        xorl    %r9d, %r9d
+        xorl    %r10d, %r10d
+        xorl    %r11d, %r11d
+        xorl    %r12d, %r12d
+        xorl    %r13d, %r13d
+        xorl    %r14d, %r14d
+        xorl    %r15d, %r15d
+
         /* Call the image entry point.  This should never return. */
         callq   *%rbp
         ud2
@@ -164,6 +187,20 @@ compatibility_mode:
         xorl    %eax, %eax
         movl    %eax, %cr4
 
+        /*
+         * Clear unused registers before jumping into an image. This way
+         * loaded image could not assume that any register has an specific
+         * info about earlier running Xen hypervisor. However, it also
+         * does not mean that the image may expect that a given register
+         * is zeroed. The image MUST assume that every register has a random
+         * value or in other words it is uninitialized or has undefined state.
+         */
+        xorl    %ebx, %ebx
+        xorl    %ecx, %ecx
+        xorl    %edx, %edx
+        xorl    %esi, %esi
+        xorl    %edi, %edi
+
         /* Call the image entry point.  This should never return. */
         call    *%ebp
         ud2
-- 
1.7.10.4




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux