x86/vm_event: add gdtr_base to the vm_event structure
PATCH v2 1/1 x86/vm_event: add gdtr_base to the vm_event structure
Receiving this register is useful for introspecting 32-bit Windows when the event being trapped happened while in ring3.
---
v2: add gdtr limit
--- xen/arch/x86/vm_event.c | 6 ++++++ xen/include/public/vm_event.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
xen/arch/x86/vm_event.c +6 -0
@@ -179,6 +179,11 @@ static void vm_event_pack_segment_register(enum x86_segment segment, reg->es_sel = seg.sel;break ; +case x86_seg_gdtr: + reg->gdtr_base = seg.base; + reg->gdtr_limit = seg.limit; +break ; +default :ASSERT_UNREACHABLE (); }
@@ -238,6 +243,7 @@ void vm_event_fill_regs(vm_event_request_t *req)vm_event_pack_segment_register (x86_seg_ss, &req->data.regs.x86);vm_event_pack_segment_register (x86_seg_ds, &req->data.regs.x86);vm_event_pack_segment_register (x86_seg_es, &req->data.regs.x86); +vm_event_pack_segment_register (x86_seg_gdtr, &req->data.regs.x86); req->data.regs.x86.shadow_gs = ctxt.shadow_gs; req->data.regs.x86.dr6 = ctxt.dr6;
xen/include/public/vm_event.h +4 -2
@@ -29,7 +29,7 @@#include "xen.h" -#define VM_EVENT_INTERFACE_VERSION 0x00000004 +#define VM_EVENT_INTERFACE_VERSION 0x00000005#if defined(__XEN__) || defined(__XEN_TOOLS__)
@@ -198,6 +198,7 @@ struct vm_event_regs_x86 {uint64_t msr_efer;uint64_t msr_star;uint64_t msr_lstar; +uint64_t gdtr_base;uint32_t cs_base;uint32_t ss_base;uint32_t ds_base;
@@ -211,13 +212,14 @@ struct vm_event_regs_x86 {struct vm_event_x86_selector_reg fs;struct vm_event_x86_selector_reg gs;uint64_t shadow_gs; +uint16_t gdtr_limit;uint16_t cs_sel;uint16_t ss_sel;uint16_t ds_sel;uint16_t es_sel;uint16_t fs_sel;uint16_t gs_sel; -uint32_t _pad; +uint16_t _pad; };/*
Signature · 7 lines
2.20.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Tamas K Lengyel
Receiving this register is useful for introspecting 32-bit Windows when the event being trapped happened while in ring3.
Signed-off-by Tamas K Lengyel <[email protected]>Cc Razvan Cojocaru <[email protected]>Cc Tamas K Lengyel <[email protected]>Cc Jan Beulich <[email protected]>Cc Andrew Cooper <[email protected]>Cc Wei Liu <[email protected]>Cc Roger Pau Monne <[email protected]>
Quoted 2 lines
---
v2: add gdtr limit
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 64 lines · Tamas K Lengyel
Receiving this register is useful for introspecting 32-bit Windows when the event being trapped happened while in ring3.
Signed-off-by Tamas K Lengyel <[email protected]>Cc Razvan Cojocaru <[email protected]>Cc Tamas K Lengyel <[email protected]>Cc Jan Beulich <[email protected]>Cc Andrew Cooper <[email protected]>Cc Wei Liu <[email protected]>Cc Roger Pau Monne <[email protected]>---
v2: add gdtr limit--- xen/arch/x86/vm_event.c | 6 ++++++ xen/include/public/vm_event.h | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)xen/arch/x86/vm_event.c +6
-0@@ -179,6 +179,11 @@ static void vm_event_pack_segment_register(enum x86_segment segment, reg->es_sel = seg.sel;break ; +case x86_seg_gdtr: + reg->gdtr_base = seg.base; + reg->gdtr_limit = seg.limit; +break ; +default :ASSERT_UNREACHABLE (); }@@ -238,6 +243,7 @@ void vm_event_fill_regs(vm_event_request_t *req)vm_event_pack_segment_register (x86_seg_ss, &req->data.regs.x86);vm_event_pack_segment_register (x86_seg_ds, &req->data.regs.x86);vm_event_pack_segment_register (x86_seg_es, &req->data.regs.x86); +vm_event_pack_segment_register (x86_seg_gdtr, &req->data.regs.x86); req->data.regs.x86.shadow_gs = ctxt.shadow_gs; req->data.regs.x86.dr6 = ctxt.dr6;xen/include/public/vm_event.h +2
-1@@ -29,7 +29,7 @@#include "xen.h" -#define VM_EVENT_INTERFACE_VERSION 0x00000004 +#define VM_EVENT_INTERFACE_VERSION 0x00000005#if defined(__XEN__) || defined(__XEN_TOOLS__)@@ -198,6 +198,7 @@ struct vm_event_regs_x86 {uint64_t msr_efer;uint64_t msr_star;uint64_t msr_lstar; +uint64_t gdtr_base;uint32_t cs_base;uint32_t ss_base;uint32_t ds_base;
xen/include/public/vm_event.h struct vm_event_regs_x86 { · line 215
Quoted 4 lines
xen/include/public/vm_event.h +1
-0@@ -211,13 +212,14 @@ struct vm_event_regs_x86 {struct vm_event_x86_selector_reg fs;struct vm_event_x86_selector_reg gs;uint64_t shadow_gs; +uint16_t gdtr_limit;
Whoops, just noticed that limit actually needs 20-bits. I'll just grow this to 32 and drop the pad at the end.
xen/include/public/vm_event.h struct vm_event_regs_x86 { · line 223
Quoted 9 lines
xen/include/public/vm_event.h +1
-1uint16_t cs_sel;uint16_t ss_sel;uint16_t ds_sel;uint16_t es_sel;uint16_t fs_sel;uint16_t gs_sel; -uint32_t _pad; +uint16_t _pad; };
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Tamas K Lengyel
xen/include/public/vm_event.h struct vm_event_regs_x86 { · line 215
Quoted 5 lines
xen/include/public/vm_event.h +1
-0@@ -211,13 +212,14 @@ struct vm_event_regs_x86 {struct vm_event_x86_selector_reg fs;struct vm_event_x86_selector_reg gs;uint64_t shadow_gs; +uint16_t gdtr_limit;Whoops, just noticed that limit actually needs 20-bits. I'll just grow this to 32 and drop the pad at the end.
There is no such thing as a GDT or an IDT with a limit beyond 16 bits. (Furthermore, an IDT with a limit beyond 12 bits is just a waste of memory).
VT-x performs a consistency check on every vmentry that the VMCS_{G,I}DTR_LIMIT fields are within 16 bits, despite being encoded as 32bit fields. SVM specifies the higher 16 bits as ignored.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Andrew Cooper
Quoted 7 lines · Tamas K Lengyel
xen/include/public/vm_event.h struct vm_event_regs_x86 { · line 215
Quoted 5 lines
xen/include/public/vm_event.h +1
-0@@ -211,13 +212,14 @@ struct vm_event_regs_x86 {struct vm_event_x86_selector_reg fs;struct vm_event_x86_selector_reg gs;uint64_t shadow_gs; +uint16_t gdtr_limit;Whoops, just noticed that limit actually needs 20-bits. I'll just grow this to 32 and drop the pad at the end.
Quoted 7 lines
There is no such thing as a GDT or an IDT with a limit beyond 16 bits. (Furthermore, an IDT with a limit beyond 12 bits is just a waste of memory).
VT-x performs a consistency check on every vmentry that the VMCS_{G,I}DTR_LIMIT fields are within 16 bits, despite being encoded as 32bit fields. SVM specifies the higher 16 bits as ignored.
Thanks for the clarification - in that case v2 of this patch is correct.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel