Skip to contentSkip to conversation

x86/hvm: Expose MSR_SHADOW_GS_BASE

PATCH In review Alexandru Isaila 4 participants 4 messages Sep 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm: Expose MSR_SHADOW_GS_BASE

This patch is adding an new param in the hvm_hw_cpu structure so it can be exposed to user space.

---
 xen/arch/x86/hvm/hvm.c                 | 4 ++++
 xen/include/public/arch-x86/hvm/save.h | 2 ++
 2 files changed, 6 insertions(+)
xen/arch/x86/hvm/hvm.c +4 -0
index 6cb903d..519333c 100644
@@ -834,6 +834,8 @@ static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
         ctxt.gs_base = seg.base;
         ctxt.gs_arbytes = seg.attr;
 
+        rdmsrl(MSR_SHADOW_GS_BASE, ctxt.shadow_gs_base);
+
         hvm_get_segment_register(v, x86_seg_tr, &seg);
         ctxt.tr_sel = seg.sel;
         ctxt.tr_limit = seg.limit;
@@ -1090,6 +1092,8 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
     seg.attr = ctxt.gs_arbytes;
     hvm_set_segment_register(v, x86_seg_gs, &seg);
 
+    wrmsrl(MSR_SHADOW_GS_BASE, ctxt.shadow_gs_base);
+
     seg.sel = ctxt.tr_sel;
     seg.limit = ctxt.tr_limit;
     seg.base = ctxt.tr_base;
xen/include/public/arch-x86/hvm/save.h +2 -0
index fd7bf3f..e6e8e87 100644
@@ -134,6 +134,8 @@ struct hvm_hw_cpu {
     /* msr for em64t */
     uint64_t shadow_gs;
 
+    uint64_t shadow_gs_base;
+
     /* msr content saved/restored. */
     uint64_t msr_flags; /* Obsolete, ignored. */
     uint64_t msr_lstar;
Signature · 7 lines
2.7.4


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

xen/include/public/arch-x86/hvm/save.h struct hvm_hw_cpu { · line 138

Quoted 10 lines · Alexandru Isaila
xen/include/public/arch-x86/hvm/save.h +2 -0
index fd7bf3f..e6e8e87 100644
@@ -134,6 +134,8 @@ struct hvm_hw_cpu {
     /* msr for em64t */
     uint64_t shadow_gs;
 
+    uint64_t shadow_gs_base;
+

You presumably haven't tried migrating across this boundary? (Things will explode rather impressively when you try to restore LSTAR into SMASK.)

What's wrong with the shadow_gs in context here?

~Andrew

xen/include/public/arch-x86/hvm/save.h struct hvm_hw_cpu { · line 141

Quoted 3 lines
xen/include/public/arch-x86/hvm/save.h +0 -0
     /* msr content saved/restored. */
     uint64_t msr_flags; /* Obsolete, ignored. */
     uint64_t msr_lstar;

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

#2 lore raw
Quoted 9 lines · Andrew Cooper
Quoted 8 lines · Alexandru Isaila
xen/include/public/arch-x86/hvm/save.h +0 -0
index fd7bf3f..e6e8e87 100644
@@ -134,6 +134,8 @@ struct hvm_hw_cpu {
      /* msr for em64t */
      uint64_t shadow_gs;
 
Quoted 7 lines

xen/include/public/arch-x86/hvm/save.h struct hvm_hw_cpu { · line 138

Quoted 2 lines
xen/include/public/arch-x86/hvm/save.h +2 -0
+    uint64_t shadow_gs_base;
+

You presumably haven't tried migrating across this boundary? (Things will explode rather impressively when you try to restore LSTAR into SMASK.)

What's wrong with the shadow_gs in context here?

Nothing, we've missed that, while grepping xen/ for MSR_SHADOW_GS_BASE and 0xc0000102. My fault, should have checked more thoroughly. Apologies.

Thanks,
Razvan

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

#3 lore raw
In reply to Alexandru Isaila
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 01.09.17 at 12:44, <[email protected]> wrote:

This patch is adding an new param in the hvm_hw_cpu structure so it can be exposed to user space.

But you don't say why.

xen/include/public/arch-x86/hvm/save.h struct hvm_hw_cpu { · line 137

Quoted 7 lines
xen/include/public/arch-x86/hvm/save.h +1 -0
@@ -134,6 +134,8 @@ struct hvm_hw_cpu {
     /* msr for em64t */
     uint64_t shadow_gs;
 
+    uint64_t shadow_gs_base;

You can't alter a public interface structure like this. The one here is used for migration, so migrating guests from an older hypervisor would break.

But what's more funny - you're adding a field next to what looks like already has the value you're after.

Jan

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