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

[Xen-devel] [PATCH RFC 1/4] 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 e9588b3c0d..8c0d3181d0 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -634,6 +634,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.
  *
@@ -645,8 +674,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 =
@@ -663,29 +691,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®.