xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>,
	andrew.cooper3@citrix.com, daniel.kiper@oracle.com,
	alex.thorlton@hpe.com, jbeulich@suse.com
Subject: [PATCH 1/3] xen/x86: split boot trampoline into permanent and temporary part
Date: Tue, 21 Mar 2017 14:10:21 +0100	[thread overview]
Message-ID: <20170321131023.26810-2-jgross@suse.com> (raw)
In-Reply-To: <20170321131023.26810-1-jgross@suse.com>

The hypervisor needs a trampoline in low memory for early boot and
later for bringing up cpus and during wakeup from suspend. Today this
trampoline is kept completely even if most of it isn't needed later.

Split the trampoline into a permanent part and a temporary part needed
at early boot only. Introduce a new entry at the boundary.

Reduce the stack for wakeup coding in order for the permanent
trampoline to fit in a single page. 4k of stack seems excessive, about
3.5k should be more than enough.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/arch/x86/boot/head.S       |  2 ++
 xen/arch/x86/boot/trampoline.S | 29 +++++++++++++++++++++++++++--
 xen/arch/x86/boot/wakeup.S     |  4 +++-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index a2177c3..39e760c 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -587,6 +587,8 @@ cmdline_parse_early:
 reloc:
 #include "reloc.S"
 
+        .align 16
+
 ENTRY(trampoline_start)
 #include "trampoline.S"
 ENTRY(trampoline_end)
diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S
index 2715d17..073fdee 100644
--- a/xen/arch/x86/boot/trampoline.S
+++ b/xen/arch/x86/boot/trampoline.S
@@ -1,4 +1,20 @@
-        .code16
+/*
+ * Trampoline code relocated to low memory.
+ *
+ * Care must taken when referencing symbols: they live in the relocated
+ * trampoline and in the hypervisor binary. The hypervisor symbols can either
+ * be accessed by their virtual address or by the physical address. When
+ * using the physical address eventually the physical start address of the
+ * hypervisor must be taken into account: after early boot the hypervisor
+ * will copy itself to high memory and writes its physical start address to
+ * trampoline_xen_phys_start in the low memory trampoline copy.
+ *
+ * Parts of the trampoline are needed for early boot only, while some other
+ * parts are needed as long as the hypervisor is active (e.g. wakeup code
+ * after suspend, bringup code for secondary cpus). The permanent parts should
+ * not reference any temporary low memory trampoline parts as those parts are
+ * not guaranteed to persist.
+ */
 
 /* NB. bootsym() is only usable in real mode, or via BOOT_PSEUDORM_DS. */
 #undef bootsym
@@ -18,6 +34,10 @@
         .long 111b - (off) - .;            \
         .popsection
 
+/* Start of the permanent trampoline code. */
+
+        .code16
+
 GLOBAL(trampoline_realmode_entry)
         mov     %cs,%ax
         mov     %ax,%ds
@@ -131,6 +151,12 @@ start64:
         movabs  $__high_start,%rax
         jmpq    *%rax
 
+#include "wakeup.S"
+
+ENTRY(trampoline_temp_start)
+
+/* From here on early boot only. */
+
         .code32
 trampoline_boot_cpu_entry:
         cmpb    $0,bootsym_rel(skip_realmode,5)
@@ -246,4 +272,3 @@ rm_idt: .word   256*4-1, 0, 0
 #include "mem.S"
 #include "edd.S"
 #include "video.S"
-#include "wakeup.S"
diff --git a/xen/arch/x86/boot/wakeup.S b/xen/arch/x86/boot/wakeup.S
index 08ea9b2..67c9e8f 100644
--- a/xen/arch/x86/boot/wakeup.S
+++ b/xen/arch/x86/boot/wakeup.S
@@ -173,6 +173,8 @@ bogus_saved_magic:
         movw    $0x0e00 + 'S', 0xb8014
         jmp     bogus_saved_magic
 
+/* Stack for wakeup: rest of first trampoline page. */
         .align  16
-        .fill   PAGE_SIZE,1,0
+.Lwakeup_stack_start:
+        .fill   PAGE_SIZE - (.Lwakeup_stack_start - trampoline_start),1,0
 wakeup_stack:
-- 
2.10.2


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-03-21 13:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-21 13:10 [PATCH 0/3] xen: support of large memory maps Juergen Gross
2017-03-21 13:10 ` Juergen Gross [this message]
2017-03-22 11:33   ` [PATCH 1/3] xen/x86: split boot trampoline into permanent and temporary part Jan Beulich
     [not found]   ` <58D26F070200007800146281@suse.com>
2017-03-22 11:50     ` Juergen Gross
2017-03-21 13:10 ` [PATCH 2/3] xen/x86: use trampoline e820 buffer for BIOS interface only Juergen Gross
2017-03-22 13:12   ` Jan Beulich
     [not found]   ` <58D2865F02000078001463C2@suse.com>
2017-03-22 15:01     ` Juergen Gross
2017-03-22 15:23       ` Jan Beulich
     [not found]       ` <58D2A4EB0200007800146563@suse.com>
2017-03-22 15:25         ` Juergen Gross
2017-03-21 13:10 ` [PATCH 3/3] xen/x86: support larger memory map from EFI Juergen Gross
2017-03-22 13:19   ` Jan Beulich
     [not found]   ` <58D287DC02000078001463D8@suse.com>
2017-03-22 15:05     ` Juergen Gross
2017-03-21 13:26 ` [PATCH 0/3] xen: support of large memory maps Daniel Kiper
2017-03-22 15:17 ` Alex Thorlton
2017-03-22 15:22   ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170321131023.26810-2-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=alex.thorlton@hpe.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=daniel.kiper@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).