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

[Xen-devel] [PATCH RFC v2 08/12] xen/x86: use dedicated function for tss initialization



Carve out the TSS initialization from load_system_tables().

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 xen/arch/x86/cpu/common.c    | 56 ++++++++++++++++++++++++--------------------
 xen/include/asm-x86/system.h |  1 +
 2 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 4306e59650..f9ec05c3ee 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -702,6 +702,35 @@ void __init early_cpu_init(void)
        early_cpu_detect();
 }
 
+void tss_init(struct tss_struct *tss, unsigned long stack_bottom)
+{
+       unsigned long stack_top = stack_bottom & ~(STACK_SIZE - 1);
+
+       *tss = (struct tss_struct){
+               /* Main stack for interrupts/exceptions. */
+               .rsp0 = stack_bottom,
+
+               /* Ring 1 and 2 stacks poisoned. */
+               .rsp1 = 0x8600111111111111ul,
+               .rsp2 = 0x8600111111111111ul,
+
+               /*
+                * MCE, NMI and Double Fault handlers get their own stacks.
+                * All others poisoned.
+                */
+               .ist = {
+                       [IST_MCE - 1] = stack_top + IST_MCE * PAGE_SIZE,
+                       [IST_DF  - 1] = stack_top + IST_DF  * PAGE_SIZE,
+                       [IST_NMI - 1] = stack_top + IST_NMI * PAGE_SIZE,
+
+                       [IST_MAX ... ARRAY_SIZE(tss->ist) - 1] =
+                               0x8600111111111111ul,
+               },
+
+               .bitmap = IOBMP_INVALID_OFFSET,
+       };
+}
+
 /*
  * Sets up system tables and descriptors.
  *
@@ -713,8 +742,7 @@ void __init early_cpu_init(void)
 void load_system_tables(void)
 {
        unsigned int cpu = smp_processor_id();
-       unsigned long stack_bottom = get_stack_bottom(),
-               stack_top = stack_bottom & ~(STACK_SIZE - 1);
+       unsigned long stack_bottom = get_stack_bottom();
 
        struct tss_struct *tss = &this_cpu(init_tss);
        struct desc_struct *gdt =
@@ -731,29 +759,7 @@ void load_system_tables(void)
                .limit = (IDT_ENTRIES * sizeof(idt_entry_t)) - 1,
        };
 
-       *tss = (struct tss_struct){
-               /* Main stack for interrupts/exceptions. */
-               .rsp0 = stack_bottom,
-
-               /* Ring 1 and 2 stacks poisoned. */
-               .rsp1 = 0x8600111111111111ul,
-               .rsp2 = 0x8600111111111111ul,
-
-               /*
-                * MCE, NMI and Double Fault handlers get their own stacks.
-                * All others poisoned.
-                */
-               .ist = {
-                       [IST_MCE - 1] = stack_top + IST_MCE * PAGE_SIZE,
-                       [IST_DF  - 1] = stack_top + IST_DF  * PAGE_SIZE,
-                       [IST_NMI - 1] = stack_top + IST_NMI * PAGE_SIZE,
-
-                       [IST_MAX ... ARRAY_SIZE(tss->ist) - 1] =
-                               0x8600111111111111ul,
-               },
-
-               .bitmap = IOBMP_INVALID_OFFSET,
-       };
+       tss_init(tss, stack_bottom);
 
        _set_tssldt_desc(
                gdt + TSS_ENTRY,
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index 8ac170371b..2cf50d1d49 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -230,6 +230,7 @@ static inline int local_irq_is_enabled(void)
 
 void trap_init(void);
 void init_idt_traps(void);
+void tss_init(struct tss_struct *tss, unsigned long stack_bottom);
 void load_system_tables(void);
 void percpu_traps_init(void);
 void subarch_percpu_traps_init(void);
-- 
2.13.6


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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