All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/kexec: Clear unused registers before jumping into an image
@ 2013-11-15 15:56 Daniel Kiper
  2013-11-15 20:07 ` David Vrabel
  2013-11-15 20:07 ` David Vrabel
  0 siblings, 2 replies; 30+ messages in thread
From: Daniel Kiper @ 2013-11-15 15:56 UTC (permalink / raw)
  To: andrew.cooper3, david.vrabel, ebiederm, george.dunlap, jbeulich,
	keir, kexec, xen-devel
  Cc: Daniel Kiper

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@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


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 30+ messages in thread
* [PATCH] xen/kexec: Clear unused registers before jumping into an image
@ 2013-11-15 15:56 Daniel Kiper
  0 siblings, 0 replies; 30+ messages in thread
From: Daniel Kiper @ 2013-11-15 15:56 UTC (permalink / raw)
  To: andrew.cooper3, david.vrabel, ebiederm, george.dunlap, jbeulich,
	keir, kexec, xen-devel
  Cc: Daniel Kiper

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@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

^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2013-11-19 19:52 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 15:56 [PATCH] xen/kexec: Clear unused registers before jumping into an image Daniel Kiper
2013-11-15 20:07 ` David Vrabel
2013-11-15 21:30   ` Daniel Kiper
2013-11-15 21:30   ` Daniel Kiper
2013-11-18  9:29   ` Jan Beulich
2013-11-18  9:29   ` Jan Beulich
2013-11-18 11:08     ` Daniel Kiper
2013-11-18 11:08     ` Daniel Kiper
2013-11-18 11:27       ` Jan Beulich
2013-11-18 11:53         ` Daniel Kiper
2013-11-18 11:53         ` Daniel Kiper
2013-11-18 11:27       ` Jan Beulich
2013-11-18 11:23     ` David Vrabel
2013-11-18 11:47       ` Daniel Kiper
2013-11-18 12:05         ` George Dunlap
2013-11-18 12:41           ` Daniel Kiper
2013-11-18 13:13             ` Petr Tesarik
2013-11-18 14:06               ` George Dunlap
2013-11-18 14:06               ` George Dunlap
2013-11-19 19:35                 ` Konrad Rzeszutek Wilk
2013-11-19 19:35                 ` [Xen-devel] " Konrad Rzeszutek Wilk
2013-11-19 19:51                   ` Konrad Rzeszutek Wilk
2013-11-19 19:51                   ` [Xen-devel] " Konrad Rzeszutek Wilk
2013-11-18 13:13             ` Petr Tesarik
2013-11-18 12:41           ` Daniel Kiper
2013-11-18 12:05         ` George Dunlap
2013-11-18 11:47       ` Daniel Kiper
2013-11-18 11:23     ` David Vrabel
2013-11-15 20:07 ` David Vrabel
  -- strict thread matches above, loose matches on Subject: below --
2013-11-15 15:56 Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.