x86/AMD support data breakpoint extension registers
v4 cover x86/AMD support data breakpoint extension registers
1: SVM: support data breakpoint extension registers 2: PV: support data breakpoint extension registers
The tools side patch isn't intended for committing at this point - it seems more reasonable to handle the migration aspect of this once Andrew's re-write is in place. Hence the patch is included here just for reference, and the series is titled to consist of only 2 patches.
3: libxc/PV: save/restore data breakpoint extension registers
v4: Avoid DR7 write in activate_debugregs() when called from set_debugreg()
(in patch 2; both other patches unchanged).
Aravind - it wasn't clear from your most recent response whether the Reviewed-by applied to only the feature mask changes (previously in a single series with the changes here) or also to these ones, so I left it off. Please clarify.
PATCH v4 1/2 SVM: support data breakpoint extension registers
Leveraging the generic MSR save/restore logic introduced a little while ago.
tools/libxc/xc_cpufeature.h +1 -0
@@ -125,6 +125,7 @@#define X86_FEATURE_NODEID_MSR 19/* NodeId MSR */ #define X86_FEATURE_TBM 21/* trailing bit manipulations */ #define X86_FEATURE_TOPOEXT 22/* topology extensions CPUID leafs */ +#define X86_FEATURE_DBEXT 26/* data breakpoint extension */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */ #define X86_FEATURE_FSGSBASE 0/* {RD,WR}{FS,GS}BASE instructions */
tools/libxc/xc_cpuid_x86.c +2 -1
@@ -110,9 +110,10 @@ static void amd_xc_cpuid_policy(bitmaskof (X86_FEATURE_3DNOWPREFETCH ) |bitmaskof (X86_FEATURE_OSVW ) |bitmaskof (X86_FEATURE_XOP ) | +bitmaskof (X86_FEATURE_LWP ) |bitmaskof (X86_FEATURE_FMA4 ) |bitmaskof (X86_FEATURE_TBM ) | - bitmaskof(X86_FEATURE_LWP)); + bitmaskof(X86_FEATURE_DBEXT)); regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */ (is_pae ? bitmaskof(X86_FEATURE_NX) : 0) | (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
xen/arch/x86/hvm/hvm.c +3 -0
@@ -3080,6 +3080,9 @@ void hvm_cpuid(unsigned int input, unsig/* Only provide PSE36 when guest runs in 32bit PAE or in long mode */ if ( !(hvm_pae_enabled (v) ||hvm_long_mode_enabled (v)) ) *edx &= ~cpufeat_mask (X86_FEATURE_PSE36 ); +/* Hide data breakpoint extensions if the hardware has not support. */ +if ( !boot_cpu_has (X86_FEATURE_DBEXT ) ) + *ecx &= ~cpufeat_mask (X86_FEATURE_DBEXT );break ;case 0x80000008 :
xen/arch/x86/hvm/svm/svm.c +138 -1
200 lines not on this page · raw message
xen/include/asm-x86/cpufeature.h +1 -0
@@ -134,6 +134,7 @@#define X86_FEATURE_NODEID_MSR (6*32+19)/* NodeId MSR */ #define X86_FEATURE_TBM (6*32+21)/* trailing bit manipulations */ #define X86_FEATURE_TOPOEXT (6*32+22)/* topology extensions CPUID leafs */ +#define X86_FEATURE_DBEXT (6*32+26)/* data breakpoint extension */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 7 */ #define X86_FEATURE_FSGSBASE (7*32+ 0)/* {RD,WR}{FS,GS}BASE instructions */
xen/include/asm-x86/hvm/svm/vmcb.h +3 -0
@@ -515,6 +515,9 @@ struct arch_svm_struct {uint64_t guest_lwp_cfg;/* guest version */ uint64_t cpu_lwp_cfg;/* CPU version */ +/* data breakpoint extension MSRs */ +uint32_t dr_mask[4 ]; +/* OSVW MSRs */ struct {u64 length;
xen/include/asm-x86/hvm/vcpu.h +1 -1
@@ -140,7 +140,7 @@ struct hvm_vcpu {int xen_port; -bool_t flag_dr_dirty; +u8 flag_dr_dirty;bool_t debug_state_latch;bool_t single_step;
xen/include/asm-x86/msr-index.h +5 -0
@@ -208,6 +208,11 @@#define MSR_AMD64_DC_CFG 0xc0011022#define AMD64_NB_CFG_CF8_EXT_ENABLE_BIT 46 +#define MSR_AMD64_DR0_ADDRESS_MASK 0xc0011027 +#define MSR_AMD64_DR1_ADDRESS_MASK 0xc0011019 +#define MSR_AMD64_DR2_ADDRESS_MASK 0xc001101a +#define MSR_AMD64_DR3_ADDRESS_MASK 0xc001101b +/* AMD Family10h machine check MSRs */ #define MSR_F10_MC4_MISC1 0xc0000408#define MSR_F10_MC4_MISC2 0xc0000409
x86/SVM: support data breakpoint extension registers
Leveraging the generic MSR save/restore logic introduced a little while ago.
tools/libxc/xc_cpufeature.h +1 -0
@@ -125,6 +125,7 @@#define X86_FEATURE_NODEID_MSR 19/* NodeId MSR */ #define X86_FEATURE_TBM 21/* trailing bit manipulations */ #define X86_FEATURE_TOPOEXT 22/* topology extensions CPUID leafs */ +#define X86_FEATURE_DBEXT 26/* data breakpoint extension */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */ #define X86_FEATURE_FSGSBASE 0/* {RD,WR}{FS,GS}BASE instructions */
tools/libxc/xc_cpuid_x86.c +2 -1
@@ -110,9 +110,10 @@ static void amd_xc_cpuid_policy(bitmaskof (X86_FEATURE_3DNOWPREFETCH ) |bitmaskof (X86_FEATURE_OSVW ) |bitmaskof (X86_FEATURE_XOP ) | +bitmaskof (X86_FEATURE_LWP ) |bitmaskof (X86_FEATURE_FMA4 ) |bitmaskof (X86_FEATURE_TBM ) | - bitmaskof(X86_FEATURE_LWP)); + bitmaskof(X86_FEATURE_DBEXT)); regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */ (is_pae ? bitmaskof(X86_FEATURE_NX) : 0) | (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
xen/arch/x86/hvm/hvm.c +3 -0
@@ -3080,6 +3080,9 @@ void hvm_cpuid(unsigned int input, unsig/* Only provide PSE36 when guest runs in 32bit PAE or in long mode */ if ( !(hvm_pae_enabled (v) ||hvm_long_mode_enabled (v)) ) *edx &= ~cpufeat_mask (X86_FEATURE_PSE36 ); +/* Hide data breakpoint extensions if the hardware has not support. */ +if ( !boot_cpu_has (X86_FEATURE_DBEXT ) ) + *ecx &= ~cpufeat_mask (X86_FEATURE_DBEXT );break ;case 0x80000008 :
xen/arch/x86/hvm/svm/svm.c +138 -1
200 lines not on this page · raw message
xen/include/asm-x86/cpufeature.h +1 -0
@@ -134,6 +134,7 @@#define X86_FEATURE_NODEID_MSR (6*32+19)/* NodeId MSR */ #define X86_FEATURE_TBM (6*32+21)/* trailing bit manipulations */ #define X86_FEATURE_TOPOEXT (6*32+22)/* topology extensions CPUID leafs */ +#define X86_FEATURE_DBEXT (6*32+26)/* data breakpoint extension */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 7 */ #define X86_FEATURE_FSGSBASE (7*32+ 0)/* {RD,WR}{FS,GS}BASE instructions */
xen/include/asm-x86/hvm/svm/vmcb.h +3 -0
@@ -515,6 +515,9 @@ struct arch_svm_struct {uint64_t guest_lwp_cfg;/* guest version */ uint64_t cpu_lwp_cfg;/* CPU version */ +/* data breakpoint extension MSRs */ +uint32_t dr_mask[4 ]; +/* OSVW MSRs */ struct {u64 length;
xen/include/asm-x86/hvm/vcpu.h +1 -1
@@ -140,7 +140,7 @@ struct hvm_vcpu {int xen_port; -bool_t flag_dr_dirty; +u8 flag_dr_dirty;bool_t debug_state_latch;bool_t single_step;
xen/include/asm-x86/msr-index.h +5 -0
@@ -208,6 +208,11 @@#define MSR_AMD64_DC_CFG 0xc0011022#define AMD64_NB_CFG_CF8_EXT_ENABLE_BIT 46 +#define MSR_AMD64_DR0_ADDRESS_MASK 0xc0011027 +#define MSR_AMD64_DR1_ADDRESS_MASK 0xc0011019 +#define MSR_AMD64_DR2_ADDRESS_MASK 0xc001101a +#define MSR_AMD64_DR3_ADDRESS_MASK 0xc001101b +/* AMD Family10h machine check MSRs */ #define MSR_F10_MC4_MISC1 0xc0000408#define MSR_F10_MC4_MISC2 0xc0000409
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
Quoted 8 lines · Jan Beulich
Leveraging the generic MSR save/restore logic introduced a little while ago.
Signed-off-by Jan Beulich <[email protected]>Reviewed-by George Dunlap <[email protected]>
Thanks,
-Aravind.
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
In reply to Jan Beulich(Sorry for being late).
Quoted 18 lines · Jan Beulich
xen/arch/x86/hvm/svm/svm.c +7
-0@@ -1451,6 +1551,8 @@ static int svm_msr_read_intercept(unsignswitch ( msr ) { +unsigned int ecx; +case MSR_IA32_SYSENTER_CS : *msr_content = v->arch.hvm_svm.guest_sysenter_cs;break ;@@ -1526,6 +1628,21 @@ static int svm_msr_read_intercept(unsignvpmu_do_rdmsr (msr, msr_content);break ; +case MSR_AMD64_DR0_ADDRESS_MASK : +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = v->arch.hvm_svm.dr_mask[0 ];
xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1645
Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +10
-0+break ; + + case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = + v->arch.hvm_svm.dr_mask[msr -MSR_AMD64_DR1_ADDRESS_MASK +1 ]; +break ; +
Can you merge these two cases (here and in write_intercept)? They are doing logically the same thing, the only difference is index calculation (and you can have a macro or something similar for that).
-boris
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 22.04.14 at 16:04, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
xen/arch/x86/hvm/svm/svm.c +11
-0@@ -1526,6 +1628,21 @@ static int svm_msr_read_intercept(unsignvpmu_do_rdmsr (msr, msr_content);break ; +case MSR_AMD64_DR0_ADDRESS_MASK : +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = v->arch.hvm_svm.dr_mask[0 ]; +break ; + + case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf;
Quoted 8 lines
xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1645
Quoted 4 lines
xen/arch/x86/hvm/svm/svm.c +4
-0+ *msr_content = + v->arch.hvm_svm.dr_mask[msr -MSR_AMD64_DR1_ADDRESS_MASK +1 ]; +break ; +Can you merge these two cases (here and in
write_intercept)? They are doing logically the same thing, the only difference is index calculation (and you can have a macro or something similar for that).
Do you really think this would be better - since the MSR numbers aren't contiguous (and since one might want to consider adding support for Fam15 supporting just the DR0 extension), I think they would better be kept separate.
Jan
Boris Ostrovsky
Reviewed-byRe: [PATCH v4 1/2] SVM: support data breakpoint extension registers
Quoted 24 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 22.04.14 at 16:04, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
xen/arch/x86/hvm/svm/svm.c +10
-0@@ -1526,6 +1628,21 @@ static int svm_msr_read_intercept(unsignvpmu_do_rdmsr (msr, msr_content);break ; +case MSR_AMD64_DR0_ADDRESS_MASK : +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = v->arch.hvm_svm.dr_mask[0 ]; +break ; + + case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) )Quoted 8 lines
xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1645
Quoted 5 lines
xen/arch/x86/hvm/svm/svm.c +5
-0+ goto gpf; + *msr_content = + v->arch.hvm_svm.dr_mask[msr -MSR_AMD64_DR1_ADDRESS_MASK +1 ]; +break ; +Can you merge these two cases (here and in
write_intercept)? They are doing logically the same thing, the only difference is index calculation (and you can have a macro or something similar for that).
Quoted 4 lines
Do you really think this would be better - since the MSR numbers aren't contiguous (and since one might want to consider adding support for Fam15 supporting just the DR0 extension), I think they would better be kept separate.
These MSR are tied to CPUID bit so if they are going to change then it will require a new bit anyway.
But it's a nit really so
-boris
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 22.04.14 at 16:17, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 24 lines
Quoted 1 line
Quoted 1 line · On 22.04.14 at 16:04, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
xen/arch/x86/hvm/svm/svm.c +5
-0@@ -1526,6 +1628,21 @@ static int svm_msr_read_intercept(unsignvpmu_do_rdmsr (msr, msr_content);break ; +case MSR_AMD64_DR0_ADDRESS_MASK : +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = v->arch.hvm_svm.dr_mask[0 ];xen/arch/x86/hvm/svm/svm.c static int svm_msr_read_intercept(unsign · line 1645
Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +10
-0+break ; + + case MSR_AMD64_DR1_ADDRESS_MASK ... MSR_AMD64_DR3_ADDRESS_MASK: +hvm_cpuid (0x80000001 ,NULL ,NULL , &ecx,NULL ); +if ( !test_bit (X86_FEATURE_DBEXT &31 , &ecx) ) + goto gpf; + *msr_content = + v->arch.hvm_svm.dr_mask[msr -MSR_AMD64_DR1_ADDRESS_MASK +1 ]; +break ; +Can you merge these two cases (here and in
write_intercept)? They are doing logically the same thing, the only difference is index calculation (and you can have a macro or something similar for that).
Quoted 7 lines
Quoted 4 lines
Do you really think this would be better - since the MSR numbers aren't contiguous (and since one might want to consider adding support for Fam15 supporting just the DR0 extension), I think they would better be kept separate.
These MSR are tied to CPUID bit so if they are going to change then it will require a new bit anyway.
Not according to my reading of the doc - Fam16 introduced the CPUID bit and supports MSRs for all four DRs, whereas Fam15 doesn't have a CPUID bit indicating just the MSR attached to DR0 being supported. As that's therefore coupled to family, a guest may expect the MSR to be available if seeing a Fam15 CPU.
Jan
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
In reply to Jan BeulichQuoted 34 lines · Jan Beulich
Leveraging the generic MSR save/restore logic introduced a little while ago.
Signed-off-by Jan Beulich <[email protected]>Reviewed-by George Dunlap <[email protected]>tools/libxc/xc_cpufeature.h +1
-0@@ -125,6 +125,7 @@#define X86_FEATURE_NODEID_MSR 19/* NodeId MSR */ #define X86_FEATURE_TBM 21/* trailing bit manipulations */ #define X86_FEATURE_TOPOEXT 22/* topology extensions CPUID leafs */ +#define X86_FEATURE_DBEXT 26/* data breakpoint extension */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx) */ #define X86_FEATURE_FSGSBASE 0/* {RD,WR}{FS,GS}BASE instructions */ tools/libxc/xc_cpuid_x86.c +2
-1@@ -110,9 +110,10 @@ static void amd_xc_cpuid_policy(bitmaskof (X86_FEATURE_3DNOWPREFETCH ) |bitmaskof (X86_FEATURE_OSVW ) |bitmaskof (X86_FEATURE_XOP ) | +bitmaskof (X86_FEATURE_LWP ) |bitmaskof (X86_FEATURE_FMA4 ) |bitmaskof (X86_FEATURE_TBM ) | - bitmaskof(X86_FEATURE_LWP)); + bitmaskof(X86_FEATURE_DBEXT)); regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */ (is_pae ? bitmaskof(X86_FEATURE_NX) : 0) | (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsig · line 3083
Quoted 4 lines
xen/arch/x86/hvm/hvm.c +1
-0@@ -3080,6 +3080,9 @@ void hvm_cpuid(unsigned int input, unsig/* Only provide PSE36 when guest runs in 32bit PAE or in long mode */ if ( !(hvm_pae_enabled (v) ||hvm_long_mode_enabled (v)) ) *edx &= ~cpufeat_mask (X86_FEATURE_PSE36 ); +/* Hide data breakpoint extensions if the hardware has not support. */
s/not/no/ is more grammatical.
Other than that for the tools bit (and I realise I overshot with that comment): Acked-by: Ian Campbell <[email protected]>
Re: [PATCH v4 1/2] SVM: support data breakpoint extension registers
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 24.04.14 at 10:21, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsig · line 3080
Quoted 4 lines · Jan Beulich
xen/arch/x86/hvm/hvm.c +0
-0@@ -3080,6 +3080,9 @@ void hvm_cpuid(unsigned int input, unsig/* Only provide PSE36 when guest runs in 32bit PAE or in long mode */
xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsig
Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1
-0if ( !(hvm_pae_enabled (v) ||hvm_long_mode_enabled (v)) ) *edx &= ~cpufeat_mask (X86_FEATURE_PSE36 ); +/* Hide data breakpoint extensions if the hardware has not support.
Quoted 6 lines
*/
s/not/no/ is more grammatical.
Other than that for the tools bit (and I realise I overshot with that comment
In no way - I have no idea why I wrote "not" (fingers on autopilot?)...
Quoted 1 line
): Acked-by: Ian Campbell <[email protected]>
Thanks, Jan
PATCH v4 2/2 x86/PV: support data breakpoint extension registers
In reply to Jan BeulichIntroducing an extension to XEN_DOMCTL_[gs]et_ext_vcpucontext similar to the generic MSR save/restore logic recently added for HVM.
This also moves some debug register related declarations/definition to the header intended for these.
---
v4: Avoid DR7 write in activate_debugregs() when called from set_debugreg().
xen/arch/x86/acpi/suspend.c +1 -0
@@ -9,6 +9,7 @@#include <xen/smp.h> #include <asm/processor.h> #include <asm/msr.h> +#include <asm/debugreg.h> #include <asm/flushtlb.h> #include <asm/hvm/hvm.h> #include <asm/hvm/support.h>
xen/arch/x86/domain.c +1 -8
@@ -1341,14 +1341,7 @@ static void paravirt_ctxt_switch_to(struwrite_cr4 (cr4);if (unlikely (v->arch.debugreg[7 ] &DR7_ACTIVE_MASK ) ) - { -write_debugreg (0 , v->arch.debugreg[0 ]); -write_debugreg (1 , v->arch.debugreg[1 ]); -write_debugreg (2 , v->arch.debugreg[2 ]); -write_debugreg (3 , v->arch.debugreg[3 ]); -write_debugreg (6 , v->arch.debugreg[6 ]); -write_debugreg (7 , v->arch.debugreg[7 ]); - } +activate_debugregs (v);if ( (v->domain->arch.tsc_mode ==TSC_MODE_PVRDTSCP ) &&boot_cpu_has (X86_FEATURE_RDTSCP ) )
xen/arch/x86/domctl.c +78 -4
127 lines not on this page · raw message
xen/arch/x86/traps.c +62 -6
92 lines not on this page · raw message
xen/include/asm-x86/debugreg.h +12 -0
@@ -64,4 +64,16 @@#define DR_GLOBAL_EXACT_ENABLE (0x00000200ul)/* Global exact enable */ #define DR_GENERAL_DETECT (0x00002000ul)/* General detect enable */ +#define write_debugreg (reg, val) do { \ + unsigned long __val = val; \ + asm volatile ( "mov %0,%%db" #reg : : "r" (__val) ); \ +} while (0) +#define read_debugreg (reg) ({ \ + unsigned long __val; \ + asm volatile ( "mov %%db" #reg ",%0" : "=r" (__val) ); \ + __val; \ +}) +long set_debugreg (struct vcpu *,unsigned int reg,unsigned long value); +void activate_debugregs (const struct vcpu *); +#endif /* _X86_DEBUGREG_H */
xen/include/asm-x86/domain.h +3 -0
@@ -374,6 +374,9 @@ struct pv_vcpuunsigned long shadow_ldt_mapcnt;spinlock_t shadow_ldt_lock; +/* data breakpoint extension MSRs */ +uint32_t dr_mask[4 ]; +/* Deferred VA-based update state. */ bool_t need_update_runstate_area;struct vcpu_time_info pending_system_time;
xen/include/asm-x86/processor.h +0 -11
@@ -462,17 +462,6 @@ long set_gdt(struct vcpu *d,unsigned long *frames, unsigned int entries); -#define write_debugreg (reg, val) do { \ - unsigned long __val = val; \ - asm volatile ( "mov %0,%%db" #reg : : "r" (__val) ); \ -} while (0) -#define read_debugreg (reg) ({ \ - unsigned long __val; \ - asm volatile ( "mov %%db" #reg ",%0" : "=r" (__val) ); \ - __val; \ -}) -long set_debugreg (struct vcpu *p,int reg,unsigned long value); -/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */ static always_inline void rep_nop(void) {
xen/include/public/domctl.h +13 -1
@@ -36,7 +36,7 @@#include "grant_table.h" #include "hvm/save.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x00000009 +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000a/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -564,6 +564,16 @@ typedef struct xen_domctl_pin_mem_cacheaDEFINE_XEN_GUEST_HANDLE (xen_domctl_pin_mem_cacheattr_t); +#if defined(__i386__) || defined(__x86_64__) +struct xen_domctl_ext_vcpu_msr { +uint32_t index; +uint32_t reserved; +uint64_aligned_t value; +}; +typedef struct xen_domctl_ext_vcpu_msr xen_domctl_ext_vcpu_msr_t ; +DEFINE_XEN_GUEST_HANDLE (xen_domctl_ext_vcpu_msr_t); +#endif +/* XEN_DOMCTL_set_ext_vcpucontext */ /* XEN_DOMCTL_get_ext_vcpucontext */ struct xen_domctl_ext_vcpucontext {
@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;
@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;#endif };typedef struct xen_domctl_ext_vcpucontext xen_domctl_ext_vcpucontext_t ;
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 10 lines · Jan Beulich
Introducing an extension to XEN_DOMCTL_[gs]et_ext_vcpucontext similar to the generic MSR save/restore logic recently added for HVM.
This also moves some debug register related declarations/definition to the header intended for these.
Signed-off-by Jan Beulich <[email protected]>---
Thanks,
-Aravind.
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
In reply to Jan Beulichxen/include/public/domctl.h struct xen_domctl_ext_vcpucontext { · line 605
Quoted 13 lines · Jan Beulich
xen/include/public/domctl.h +2
-0@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;
I must be missing something because I can't see where the tools are initialising msrs, nor does the hypervisor appear to check it is valid before trying to save stuff to it (although that would be caught by the copy_to_user I expect).
Also how does one go about determining the correct msr_count before retrieving this state?
(I have a feeling I asked this before, but I can't find any references. Perhaps it was in the context of the similar HVM patch...)
Ian.
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 12:23, <[email protected]> wrote:
xen/include/public/domctl.h struct xen_domctl_ext_vcpucontext { · line 605
Quoted 13 lines · Jan Beulich
xen/include/public/domctl.h +2
-0@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;I must be missing something because I can't see where the tools are initialising msrs, nor does the hypervisor appear to check it is valid before trying to save stuff to it (although that would be caught by the
copy_to_userI expect).
Quoted 2 lines
Also how does one go about determining the correct
msr_countbefore retrieving this state?
When msr_count is zero and MSRs are there that need storing, the call will return -ENOBUFS and set msr_count to the required (minimum) value. Furthermore the field is only being looked at if the size stored inside the structure covers the entire msrs field. And yes, if msr_count is non-zero but msrs doesn't point to a valid memory block, copy_to_guest() will catch this (as usual).
So as is the tools are fine not explicitly setting msr_count (it's being implicitly set to zero) - state save will fail in that case. It's the 3rd (unfinished and now delayed until after Andrew's re-write) patch that would be dealing with that error, re-issuing the call after allocating a suitable array.
Jan
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 24 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 12:23, <[email protected]> wrote:
xen/include/public/domctl.h struct xen_domctl_ext_vcpucontext { · line 605
Quoted 13 lines · Jan Beulich
xen/include/public/domctl.h +2
-0@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;I must be missing something because I can't see where the tools are initialising msrs, nor does the hypervisor appear to check it is valid before trying to save stuff to it (although that would be caught by the
copy_to_userI expect).Quoted 2 lines
Also how does one go about determining the correct
msr_countbefore retrieving this state?
Quoted 6 lines
When
msr_countis zero and MSRs are there that need storing, the call will return-ENOBUFSand setmsr_countto the required (minimum) value. Furthermore the field is only being looked at if the size stored inside the structure covers the entire msrs field. And yes, ifmsr_countis non-zero but msrs doesn't point to a valid memory block,copy_to_guest()will catch this (as usual).
All makes sense. Worth a comment though?
Quoted 5 lines
So as is the tools are fine not explicitly setting
msr_count(it's being implicitly set to zero) - state save will fail in that case. It's the 3rd (unfinished and now delayed until after Andrew's re-write) patch that would be dealing with that error, re-issuing the call after allocating a suitable array.
That would be a bisection hazard wouldn't it? The tools side needs to be part of this patch I think. In any case I suppose this series should wait until the 3rd patch is available?
Ian.
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 26 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:23, <[email protected]> wrote:
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 12:23, <[email protected]> wrote:
xen/include/public/domctl.h struct xen_domctl_ext_vcpucontext { · line 605
Quoted 13 lines · Jan Beulich
xen/include/public/domctl.h +2
-0@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;I must be missing something because I can't see where the tools are initialising msrs, nor does the hypervisor appear to check it is valid before trying to save stuff to it (although that would be caught by the
copy_to_userI expect).Also how does one go about determining the correct
msr_countbefore retrieving this state?
Quoted 8 lines
Quoted 6 lines
When
msr_countis zero and MSRs are there that need storing, the call will return-ENOBUFSand setmsr_countto the required (minimum) value. Furthermore the field is only being looked at if the size stored inside the structure covers the entire msrs field. And yes, ifmsr_countis non-zero but msrs doesn't point to a valid memory block,copy_to_guest()will catch this (as usual).All makes sense. Worth a comment though?
Not sure - it's no more subtle than other code in the handling of that specific sub-hypercall. But yes, by my own argumentation elsewhere maybe I shouldn't be extending badness - if only I saw ways of describing things like this without just converting C to human language (which doesn't seem all that helpful)...
Quoted 7 lines
Quoted 5 lines
So as is the tools are fine not explicitly setting
msr_count(it's being implicitly set to zero) - state save will fail in that case. It's the 3rd (unfinished and now delayed until after Andrew's re-write) patch that would be dealing with that error, re-issuing the call after allocating a suitable array.That would be a bisection hazard wouldn't it?
Only with guests using the extension and wanting to be migrated.
Quoted 3 lines
The tools side needs to be
part of this patch I think. In any case I suppose this series should wait until the 3rd patch is available?
That might mean I'd have to carry this for months. I'd rather want to get this in as is, and live with save/migration not working for guests using the extension. Even more so that I'm hoping to get someone more fluent in libxc speak to take care of that.
Jan
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 33 lines · Jan Beulich
Quoted 33 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:23, <[email protected]> wrote:
Quoted 30 lines · Jan Beulich
Quoted 21 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 12:23, <[email protected]> wrote:
xen/include/public/domctl.h struct xen_domctl_ext_vcpucontext { · line 605
Quoted 13 lines · Jan Beulich
xen/include/public/domctl.h +2
-0@@ -583,6 +593,7 @@ struct xen_domctl_ext_vcpucontext {uint16_t sysenter_callback_cs;uint8_t syscall32_disables_events;uint8_t sysenter_disables_events; +uint16_t msr_count; #if defined(__GNUC__) union { uint64_aligned_t mcg_cap;@@ -591,6 +602,7 @@ struct xen_domctl_ext_vcpucontext {#else struct hvm_vmce_vcpu vmce;#endif +XEN_GUEST_HANDLE_64 (xen_domctl_ext_vcpu_msr_t) msrs;I must be missing something because I can't see where the tools are initialising msrs, nor does the hypervisor appear to check it is valid before trying to save stuff to it (although that would be caught by the
copy_to_userI expect).Quoted 2 lines
Also how does one go about determining the correct
msr_countbefore retrieving this state?When
msr_countis zero and MSRs are there that need storing, the call will return-ENOBUFSand setmsr_countto the required (minimum) value. Furthermore the field is only being looked at if the size stored inside the structure covers the entire msrs field. And yes, ifmsr_countis non-zero but msrs doesn't point to a valid memory block,copy_to_guest()will catch this (as usual).
Quoted 7 lines
Quoted 1 line
All makes sense. Worth a comment though?
Not sure - it's no more subtle than other code in the handling of that specific sub-hypercall. But yes, by my own argumentation elsewhere maybe I shouldn't be extending badness - if only I saw ways of describing things like this without just converting C to human language (which doesn't seem all that helpful)...
Nothing the behaviour of msr_count you describe doesn't sound like just converting the C to human readable to me, unless you expect readers of this interface header to go digging into the implementation to figure this out, which shouldn't be needed (that's the point of docs after all! )
Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
So as is the tools are fine not explicitly setting
msr_count(it's being implicitly set to zero) - state save will fail in that case. It's the 3rd (unfinished and now delayed until after Andrew's re-write) patch that would be dealing with that error, re-issuing the call after allocating a suitable array.That would be a bisection hazard wouldn't it?
Only with guests using the extension and wanting to be migrated.
I hadn't realised there was this condition as well (since hte feature looks more generic at the level I'm looking at it).
So any such guests would fail to migrate today anyway, right?
Quoted 8 lines
Quoted 3 lines
The tools side needs to be
part of this patch I think. In any case I suppose this series should wait until the 3rd patch is available?That might mean I'd have to carry this for months. I'd rather want to get this in as is, and live with save/migration not working for guests using the extension. Even more so that I'm hoping to get someone more fluent in libxc speak to take care of that.
Yes, so long as it isn't a regression I think that is fine.
Ian.
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:39, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:23, <[email protected]> wrote:
All makes sense. Worth a comment though?
Not sure - it's no more subtle than other code in the handling of that specific sub-hypercall. But yes, by my own argumentation elsewhere maybe I shouldn't be extending badness - if only I saw ways of describing things like this without just converting C to human language (which doesn't seem all that helpful)...
Quoted 4 lines
Nothing the behaviour of
msr_countyou describe doesn't sound like just converting the C to human readable to me, unless you expect readers of this interface header to go digging into the implementation to figure this out, which shouldn't be needed (that's the point of docs after all!)
Oh, right, I didn't realize your comment was in the context of the public header changes - I blindly assumed them to be on the code implementing the interface extension. Will see to put something like the above in there.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
So as is the tools are fine not explicitly setting
msr_count(it's being implicitly set to zero) - state save will fail in that case. It's the 3rd (unfinished and now delayed until after Andrew's re-write) patch that would be dealing with that error, re-issuing the call after allocating a suitable array.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
That would be a bisection hazard wouldn't it?
Only with guests using the extension and wanting to be migrated.
I hadn't realised there was this condition as well (since hte feature looks more generic at the level I'm looking at it).
So any such guests would fail to migrate today anyway, right?
I think such a guest wouldn't make it to migration, but would rather be killed (by sending it a #GP it may not expect) for an invalid MSR write. I.e. the improvement of this patch is to make it work at all, but fail on attempts to be migrated.
Jan
Re: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 17 lines
Quoted 12 lines
Quoted 2 lines · On 23.04.14 at 14:50, <[email protected]> wrote:
Quoted 1 line · On 23.04.14 at 14:39, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:23, <[email protected]> wrote:
All makes sense. Worth a comment though?
Not sure - it's no more subtle than other code in the handling of that specific sub-hypercall. But yes, by my own argumentation elsewhere maybe I shouldn't be extending badness - if only I saw ways of describing things like this without just converting C to human language (which doesn't seem all that helpful)...
Quoted 4 lines
Nothing the behaviour of
msr_countyou describe doesn't sound like just converting the C to human readable to me, unless you expect readers of this interface header to go digging into the implementation to figure this out, which shouldn't be needed (that's the point of docs after all!)
Quoted 4 lines
Oh, right, I didn't realize your comment was in the context of the public header changes - I blindly assumed them to be on the code implementing the interface extension. Will see to put something like the above in there.
/*
* When, for the "get" version, msr_count is too small to cover all MSRs
* the hypervisor needs to be saved, the call will return -ENOBUFS and
* set msr_count to the required (minimum) value. Furthermore, for both
* "get" and "set", that field as well as the msrs one only get looked at
* if the size field above covers the structure up to the entire msrs one. */
Jan
Ian Campbell
Acked-byRe: [PATCH v4 2/2] x86/PV: support data breakpoint extension registers
Quoted 30 lines · Jan Beulich
Quoted 17 lines
Quoted 12 lines
Quoted 2 lines · On 23.04.14 at 14:50, <[email protected]> wrote:
Quoted 1 line · On 23.04.14 at 14:39, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 23.04.14 at 14:23, <[email protected]> wrote:
All makes sense. Worth a comment though?
Not sure - it's no more subtle than other code in the handling of that specific sub-hypercall. But yes, by my own argumentation elsewhere maybe I shouldn't be extending badness - if only I saw ways of describing things like this without just converting C to human language (which doesn't seem all that helpful)...
Quoted 4 lines
Nothing the behaviour of
msr_countyou describe doesn't sound like just converting the C to human readable to me, unless you expect readers of this interface header to go digging into the implementation to figure this out, which shouldn't be needed (that's the point of docs after all!)Quoted 4 lines
Oh, right, I didn't realize your comment was in the context of the public header changes - I blindly assumed them to be on the code implementing the interface extension. Will see to put something like the above in there.
/*
* When, for the "get" version,msr_countis too small to cover all MSRs
* the hypervisor needs to be saved, the call will return-ENOBUFSand
* setmsr_countto the required (minimum) value. Furthermore, for both
* "get" and "set", that field as well as the msrs one only get looked at
* if the size field above covers the structure up to the entire msrs one. */
Quoted 1 line
From the ARM (complete lack of impact) and generic headers pov with this
comment in the appropriate place:
[PATCH v4 3/2] libxc/PV: save/restore data breakpoint extension registers
In reply to Jan BeulichRequiring the handling of the generic MSR extension to XEN_DOMCTL_[gs]et_ext_vcpucontext.
tools/libxc/xc_domain_restore.c +63 -7
@@ -38,6 +38,7 @@#include <stdlib.h> #include <unistd.h> +#include <assert.h> #include "xg_private.h" #include "xg_save_restore.h"
@@ -590,8 +591,13 @@ static int buffer_tail_pv(xc_interface * uint32_t vcpuextstate_size) {unsigned int i; -size_t pfnlen, vcpulen; +size_t pfnlen, vcpulen, total; +int alloc =0 ;struct domain_info_context *dinfo = &ctx->dinfo; +union { +const unsigned char *raw; +xen_domctl_ext_vcpucontext_t *evc; + } ptr;/* TODO: handle changing pfntab and vcpu counts */ /* PFN tab */
@@ -634,11 +640,42 @@ static int buffer_tail_pv(xc_interface *ERROR ("Error allocating VCPU ctxt tail buffer" ); goto free_pfntab; } + alloc =1 ; }// DPRINTF("Reading VCPUS: %d bytes\n", vcpulen); -if (RDEXACT (fd, buf->vcpubuf, vcpulen) ) { -PERROR ("Error when reading ctxt" ); - goto free_vcpus; +for ( total = i =0 , ptr.raw = buf->vcpubuf; ext_vcpucontext; ) { +if (RDEXACT (fd, buf->vcpubuf + total, vcpulen) ) { +PERROR ("Error when reading ctxt" ); + goto free_vcpus; + } + total += vcpulen; +for ( vcpulen =0 ; i < buf->vcpucount; ++i ) { +size_t msrlen; + +if ( (const unsigned char *)(ptr.evc +1 ) > buf->vcpubuf + total ) +break ; +if ( ptr.evc->size < + (offsetof(xen_domctl_ext_vcpucontext_t , msrs) + +sizeof (ptr.evc->msrs)) ) + ptr.evc->msr_count =0 ; + msrlen = ptr.evc->msr_count *sizeof (xen_domctl_ext_vcpu_msr_t); + vcpulen += msrlen; + ptr.raw +=128 + msrlen + vcpuextstate_size; + } +if ( !vcpulen ) { +assert (i == buf->vcpucount); +break ; + } +if ( alloc ) { +void *nbuf =realloc (buf->vcpubuf, total + vcpulen); + +if ( !nbuf ) { +ERROR ("Error growing VCPU ctxt tail buffer" ); + goto free_vcpus; + } + ptr.raw = nbuf + (ptr.raw - buf->vcpubuf); + buf->vcpubuf = nbuf; + } }/* load shared_info_page */
@@ -2130,9 +2167,28 @@ int xc_domain_restore(xc_interface *xch, goto vcpu_ext_state_restore;memcpy (&domctl.u.ext_vcpucontext, vcpup,128 ); vcpup +=128 ; - domctl.cmd = XEN_DOMCTL_set_ext_vcpucontext; - domctl.domain = dom; - frc =xc_domctl (xch, &domctl); +if ( domctl.u.ext_vcpucontext.msr_count ) + { +xen_domctl_ext_vcpu_msr_t *msrs = (void *)vcpup; +size_t sz = domctl.u.ext_vcpucontext.msr_count *sizeof (*msrs); +DECLARE_HYPERCALL_BOUNCE (msrs, sz,XC_HYPERCALL_BUFFER_BOUNCE_IN ); + +if (xc_hypercall_bounce_pre (xch, msrs) ) + { +PERROR ("Can't bounce in vcpu%d MSRs" , i); + goto out; + } +set_xen_guest_handle (domctl.u.ext_vcpucontext.msrs, msrs); + domctl.cmd = XEN_DOMCTL_set_ext_vcpucontext; + domctl.domain = dom; + frc =xc_domctl (xch, &domctl); +xc_hypercall_bounce_post (xch, msrs); + vcpup += sz; + }else { + domctl.cmd = XEN_DOMCTL_set_ext_vcpucontext; + domctl.domain = dom; + frc =xc_domctl (xch, &domctl); + }if ( frc !=0 ) {PERROR ("Couldn't set extended vcpu%d info" , i);
tools/libxc/xc_domain_save.c +32 -2
@@ -836,6 +836,9 @@ int xc_domain_save(xc_interface *xch, in/* base of the region in which domain memory is mapped */ unsigned char *region_base =NULL ; +/* MSR extensions to xen_domctl_ext_vcpucontext_t */ +DECLARE_HYPERCALL_BUFFER (xen_domctl_ext_vcpu_msr_t, msrs); +/* A copy of the CPU eXtended States of the guest. */ DECLARE_HYPERCALL_BUFFER (void, buffer);
@@ -1960,16 +1963,42 @@ int xc_domain_save(xc_interface *xch, in domctl.domain = dom;memset (&domctl.u,0 ,sizeof (domctl.u)); domctl.u.ext_vcpucontext.vcpu = i; -if (xc_domctl (xch, &domctl) <0 ) + frc =xc_domctl (xch, &domctl); +if ( frc <0 && errno ==ENOBUFS && + domctl.u.ext_vcpucontext.size >= + (offsetof(xen_domctl_ext_vcpucontext_t , msrs) + +sizeof (domctl.u.ext_vcpucontext.msrs)) && + domctl.u.ext_vcpucontext.msr_count ) + { + msrs =xc_hypercall_buffer_alloc (xch, msrs, + domctl.u.ext_vcpucontext.msr_count * +sizeof (*msrs)); +set_xen_guest_handle (domctl.u.ext_vcpucontext.msrs, msrs); + frc = msrs ?xc_domctl (xch, &domctl) :-1 ; +/* Don't save the actual pointer. */ +set_xen_guest_handle_raw (domctl.u.ext_vcpucontext.msrs,NULL ); + } +if ( frc <0 ) {PERROR ("No extended context for VCPU%d" , i); goto out; }if (wrexact (io_fd, &domctl.u.ext_vcpucontext,128 ) ) { -PERROR ("Error when writing to state file (2)" ); +PERROR ("Error when writing to state file (ext ctxt)" ); goto out; } +if ( msrs ) + { +if (wrexact (io_fd, msrs, + domctl.u.ext_vcpucontext.msr_count *sizeof (*msrs)) ) + { +PERROR ("Error when writing to state file (MSRs)" ); + goto out; + } +xc_hypercall_buffer_free (xch, msrs); + msrs =NULL ; + }/* Start to fetch CPU eXtended States */ /* Get buffer size first */
@@ -2134,6 +2163,7 @@ int xc_domain_save(xc_interface *xch, inxc_hypercall_buffer_free_pages (xch, to_send,NRPAGES (bitmap_size (dinfo->p2m_size)));xc_hypercall_buffer_free_pages (xch, to_skip,NRPAGES (bitmap_size (dinfo->p2m_size))); +xc_hypercall_buffer_free (xch, msrs);free (pfn_type);free (pfn_batch);
tools/libxc/xg_save_restore.h +3 -0
@@ -62,6 +62,9 @@* the block size. * "extv" : Presence indicates use of extended VCPU context in * tail, data size is 0. +* This block may be followed by an array of +* xen_domctl_ext_vcpu_msr_t as indicated by +* xen_domctl_ext_vcpucontext_t's msr_count field. * * p2m (PV-only): *
libxc/PV: save/restore data breakpoint extension registers
Requiring the handling of the generic MSR extension to XEN_DOMCTL_[gs]et_ext_vcpucontext.
tools/libxc/xc_domain_restore.c +63 -7
97 lines not on this page · raw message
tools/libxc/xc_domain_save.c +32 -2
@@ -836,6 +836,9 @@ int xc_domain_save(xc_interface *xch, in/* base of the region in which domain memory is mapped */ unsigned char *region_base =NULL ; +/* MSR extensions to xen_domctl_ext_vcpucontext_t */ +DECLARE_HYPERCALL_BUFFER (xen_domctl_ext_vcpu_msr_t, msrs); +/* A copy of the CPU eXtended States of the guest. */ DECLARE_HYPERCALL_BUFFER (void, buffer);
@@ -1960,16 +1963,42 @@ int xc_domain_save(xc_interface *xch, in domctl.domain = dom;memset (&domctl.u,0 ,sizeof (domctl.u)); domctl.u.ext_vcpucontext.vcpu = i; -if (xc_domctl (xch, &domctl) <0 ) + frc =xc_domctl (xch, &domctl); +if ( frc <0 && errno ==ENOBUFS && + domctl.u.ext_vcpucontext.size >= + (offsetof(xen_domctl_ext_vcpucontext_t , msrs) + +sizeof (domctl.u.ext_vcpucontext.msrs)) && + domctl.u.ext_vcpucontext.msr_count ) + { + msrs =xc_hypercall_buffer_alloc (xch, msrs, + domctl.u.ext_vcpucontext.msr_count * +sizeof (*msrs)); +set_xen_guest_handle (domctl.u.ext_vcpucontext.msrs, msrs); + frc = msrs ?xc_domctl (xch, &domctl) :-1 ; +/* Don't save the actual pointer. */ +set_xen_guest_handle_raw (domctl.u.ext_vcpucontext.msrs,NULL ); + } +if ( frc <0 ) {PERROR ("No extended context for VCPU%d" , i); goto out; }if (wrexact (io_fd, &domctl.u.ext_vcpucontext,128 ) ) { -PERROR ("Error when writing to state file (2)" ); +PERROR ("Error when writing to state file (ext ctxt)" ); goto out; } +if ( msrs ) + { +if (wrexact (io_fd, msrs, + domctl.u.ext_vcpucontext.msr_count *sizeof (*msrs)) ) + { +PERROR ("Error when writing to state file (MSRs)" ); + goto out; + } +xc_hypercall_buffer_free (xch, msrs); + msrs =NULL ; + }/* Start to fetch CPU eXtended States */ /* Get buffer size first */
@@ -2134,6 +2163,7 @@ int xc_domain_save(xc_interface *xch, inxc_hypercall_buffer_free_pages (xch, to_send,NRPAGES (bitmap_size (dinfo->p2m_size)));xc_hypercall_buffer_free_pages (xch, to_skip,NRPAGES (bitmap_size (dinfo->p2m_size))); +xc_hypercall_buffer_free (xch, msrs);free (pfn_type);free (pfn_batch);
tools/libxc/xg_save_restore.h +3 -0
@@ -62,6 +62,9 @@* the block size. * "extv" : Presence indicates use of extended VCPU context in * tail, data size is 0. +* This block may be followed by an array of +* xen_domctl_ext_vcpu_msr_t as indicated by +* xen_domctl_ext_vcpucontext_t's msr_count field. * * p2m (PV-only): *
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ping: [PATCH v4 0/2] x86/AMD support data breakpoint extension registers
In reply to Jan BeulichQuoted 2 lines
Quoted 1 line
Quoted 1 line · On 16.04.14 at 16:23, <[email protected]> wrote:
1: SVM: support data breakpoint extension registers
This would minimally need an ack by an SVM maintainer; acks for the (trivial) tools side as well as the other x86 changes would be nice too.
Quoted 1 line
2: PV: support data breakpoint extension registers
This needs an ack from one of THE REST maintainers on the public interface change; an ack for the x86 changes would be desirable.
Thanks, Jan
Quoted 23 lines
The tools side patch isn't intended for committing at this point - it seems more reasonable to handle the migration aspect of this once Andrew's re-write is in place. Hence the patch is included here just for reference, and the series is titled to consist of only 2 patches.
3: libxc/PV: save/restore data breakpoint extension registers
v4: Avoid DR7 write in
activate_debugregs()when called fromset_debugreg()
(in patch 2; both other patches unchanged).Aravind - it wasn't clear from your most recent response whether the Reviewed-by applied to only the feature mask changes (previously in a single series with the changes here) or also to these ones, so I left it off. Please clarify.
Signed-off-by Jan Beulich <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel