|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH for-next 2/3] xen/x86: Introduce static inline wrappers for l{idt, gdt, ldt, tr}()
This avoids indirection and parameter constraint issues. Doing so relaxes the
load_LDT() constraints from %ax to any general purpose register.
The triple-fault reboot method stays as is, to avoid the int3 possibly getting
moved relative to the lidt.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
---
xen/arch/x86/cpu/common.c | 8 ++++----
xen/arch/x86/domain.c | 6 ++++--
xen/common/efi/runtime.c | 4 ++--
xen/include/asm-x86/desc.h | 20 ++++++++++++++++++++
xen/include/asm-x86/ldt.h | 6 ++----
5 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 78f5667..9c50ec6 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -697,10 +697,10 @@ void load_system_tables(void)
offsetof(struct tss_struct, __cacheline_filler) - 1,
SYS_DESC_tss_busy);
- asm volatile ("lgdt %0" : : "m" (gdtr) );
- asm volatile ("lidt %0" : : "m" (idtr) );
- asm volatile ("ltr %w0" : : "rm" (TSS_ENTRY << 3) );
- asm volatile ("lldt %w0" : : "rm" (0) );
+ lgdt(&gdtr);
+ lidt(&idtr);
+ ltr(TSS_ENTRY << 3);
+ lldt(0);
/*
* Bottom-of-stack must be 16-byte aligned!
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 466a1a2..dfe905f 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1625,7 +1625,8 @@ static void __context_switch(void)
{
gdt_desc.limit = LAST_RESERVED_GDT_BYTE;
gdt_desc.base = (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY);
- asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+
+ lgdt(&gdt_desc);
}
write_ptbase(n);
@@ -1635,7 +1636,8 @@ static void __context_switch(void)
{
gdt_desc.limit = LAST_RESERVED_GDT_BYTE;
gdt_desc.base = GDT_VIRT_START(n);
- asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+
+ lgdt(&gdt_desc);
}
if ( pd != nd )
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index c38f00a..3dbc2e8 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -108,7 +108,7 @@ struct efi_rs_state efi_rs_enter(void)
FIRST_RESERVED_GDT_ENTRY)
};
- asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+ lgdt(&gdt_desc);
}
write_cr3(virt_to_maddr(efi_l4_pgtable));
@@ -128,7 +128,7 @@ void efi_rs_leave(struct efi_rs_state *state)
.base = GDT_VIRT_START(current)
};
- asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+ lgdt(&gdt_desc);
}
irq_exit();
efi_rs_on_cpu = NR_CPUS;
diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h
index da924bf..1ec320e 100644
--- a/xen/include/asm-x86/desc.h
+++ b/xen/include/asm-x86/desc.h
@@ -197,6 +197,26 @@ DECLARE_PER_CPU(struct desc_struct *, compat_gdt_table);
extern void load_TR(void);
+static inline void lgdt(const struct desc_ptr *gdtr)
+{
+ asm volatile ("lgdt %0" :: "m" (*gdtr));
+}
+
+static inline void lidt(const struct desc_ptr *idtr)
+{
+ asm volatile ("lidt %0" :: "m" (*idtr));
+}
+
+static inline void lldt(unsigned int sel)
+{
+ asm volatile ("lldt %w0" :: "rm" (sel));
+}
+
+static inline void ltr(unsigned int sel)
+{
+ asm volatile ("ltr %w0" :: "rm" (sel));
+}
+
#endif /* !__ASSEMBLY__ */
#endif /* __ARCH_DESC_H */
diff --git a/xen/include/asm-x86/ldt.h b/xen/include/asm-x86/ldt.h
index 289ae19..589daf8 100644
--- a/xen/include/asm-x86/ldt.h
+++ b/xen/include/asm-x86/ldt.h
@@ -10,16 +10,14 @@ static inline void load_LDT(struct vcpu *v)
unsigned long ents;
if ( (ents = v->arch.pv_vcpu.ldt_ents) == 0 )
- {
- __asm__ __volatile__ ( "lldt %%ax" : : "a" (0) );
- }
+ lldt(0);
else
{
desc = (!is_pv_32bit_vcpu(v)
? this_cpu(gdt_table) : this_cpu(compat_gdt_table))
+ LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY;
_set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, SYS_DESC_ldt);
- __asm__ __volatile__ ( "lldt %%ax" : : "a" (LDT_ENTRY << 3) );
+ lldt(LDT_ENTRY << 3);
}
}
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |