Skip to contentSkip to conversation

x86/svm: Drop the set_segment_register() macro

PATCH In review Andrew Cooper 3 participants 3 messages Sep 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/svm: Drop the set_segment_register() macro

Replace its sole users with a single piece of inline assembly which is more flexable about its register constraints, rather than forcing the use of %ax.

While editing this area, reflow the comment to remove trailing whitespace and use fewer lines.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>

---
 xen/arch/x86/hvm/svm/svm.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
xen/arch/x86/hvm/svm/svm.c +5 -11
index 679e615..0ed3e73 100644
@@ -69,9 +69,6 @@ u32 svm_feature_flags;
 /* Indicates whether guests may use EFER.LMSLE. */
 bool_t cpu_has_lmsl;
 
-#define set_segment_register(name, value)  \
-    asm volatile ( "movw %%ax ,%%" STR(name) "" : : "a" (value) )
-
 static void svm_update_guest_efer(struct vcpu *);
 
 static struct hvm_function_table svm_function_table;
@@ -1023,15 +1020,12 @@ static void svm_ctxt_switch_to(struct vcpu *v)
     struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
     int cpu = smp_processor_id();
 
-    /* 
-     * This is required, because VMRUN does consistency check
-     * and some of the DOM0 selectors are pointing to 
-     * invalid GDT locations, and cause AMD processors
-     * to shutdown.
+    /*
+     * This is required, because VMRUN does consistency check and some of the
+     * DOM0 selectors are pointing to invalid GDT locations, and cause AMD
+     * processors to shutdown.
      */
-    set_segment_register(ds, 0);
-    set_segment_register(es, 0);
-    set_segment_register(ss, 0);
+    asm volatile ("mov %0, %%ds; mov %0, %%es; mov %0, %%ss;" :: "r" (0));
 
     /*
      * Cannot use ISTs for NMI/#MC/#DF while we are running with the guest TR.
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 26.09.16 at 16:45, <[email protected]> wrote:

Replace its sole users with a single piece of inline assembly which is more flexable about its register constraints, rather than forcing the use of %ax.

While editing this area, reflow the comment to remove trailing whitespace and use fewer lines.

No functional change.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 6 lines · Andrew Cooper

Replace its sole users with a single piece of inline assembly which is more flexable about its register constraints, rather than forcing the use of %ax.

While editing this area, reflow the comment to remove trailing whitespace and use fewer lines.

Quoted 7 lines

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel