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

[Xen-changelog] [xen staging] x86/boot: Annotate the Real Mode entry points



commit 4597226a356f75e8addee02e87b3a5bae21af8ea
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed May 1 18:14:03 2019 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon May 13 10:35:38 2019 +0100

    x86/boot: Annotate the Real Mode entry points
    
    ... because its already hard enough to follow.  Cross reference the 
locations
    in C which set the entrypoints up, and state the alignment requirements and
    entry conditions.
    
    Drop a redundant .align 16, and panic() in do_boot_cpu() if the AP 
trampoline
    isn't set up properly rather than blindly continuing and letting the APs
    execute junk, or shifting part of the address into unrelated fields in ICR.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/boot/trampoline.S |  7 +++++++
 xen/arch/x86/boot/wakeup.S     | 10 +++++++++-
 xen/arch/x86/smpboot.c         |  5 ++++-
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 125bdb5a58..7c6a2328d2 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -38,6 +38,13 @@
 
         .code16
 
+/*
+ * do_boot_cpu() programs the Startup-IPI to point here.  Due to the SIPI
+ * format, the relocated entrypoint must be 4k aligned.
+ *
+ * It is entered in Real Mode, with %cs = trampoline_realmode_entry >> 4 and
+ * %ip = 0.
+ */
 GLOBAL(trampoline_realmode_entry)
         mov     %cs,%ax
         mov     %ax,%ds
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index 89df2617ae..e3cb9e033a 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -2,7 +2,15 @@
 
 #define wakesym(sym) (sym - wakeup_start)
 
-        .align 16
+/*
+ * acpi_sleep_prepare() programs the S3 wakeup vector to point here.
+ *
+ * The ACPI spec says that we shall be entered in Real Mode with:
+ *   %cs = wakeup_start >> 4
+ *   %ip = wakeup_start & 0xf
+ *
+ * As wakeup_start is 16-byte aligned, %ip is 0 in practice.
+ */
 ENTRY(wakeup_start)
         cli
         cld
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index b7a0a4a419..4f65c8d52e 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -548,9 +548,12 @@ static int do_boot_cpu(int apicid, int cpu)
 
     booting_cpu = cpu;
 
-    /* start_eip had better be page-aligned! */
     start_eip = setup_trampoline();
 
+    /* start_eip needs be page aligned, and below the 1M boundary. */
+    if ( start_eip & ~0xff000 )
+        panic("AP trampoline %#lx not suitably positioned\n", start_eip);
+
     /* So we see what's up   */
     if ( opt_cpu_info )
         printk("Booting processor %d/%d eip %lx\n",
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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