Tidy up the viridian code a little and flesh out the APIC assist MSR
PATCH 1/1 Tidy up the viridian code a little and flesh out the APIC assist MSR
# HG changeset patch
# User Paul Durrant <[email protected]>
# Date 1316063461 -3600
# Node ID a08073c5cf28ab76893102cc7a8d20bf3e5e15ae
# Parent e90438f6e6d1585a71b18784a99c162b5d95f390
Tidy up the viridian code a little and flesh out the APIC assist MSR handling code.
We don't say we that handle that MSR but Windows assumes it. In Windows 7 it just wrote to the MSR and we used to handle that ok. Windows 8 also reads from the MSR so we need to keep a record of the contents.
xen/arch/x86/hvm/viridian.c +91 -48
@@ -96,9 +96,43 @@ int cpuid_viridian_leaves(unsigned int lreturn 1 ; } -static void enable_hypercall_page (void ) +void dump_guest_os_id (struct domain *d) { -struct domain *d = current->domain; +gdprintk (XENLOG_INFO ,"GUEST_OS_ID:\n" ); +gdprintk (XENLOG_INFO ,"\tvendor: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.vendor); +gdprintk (XENLOG_INFO ,"\tos: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.os); +gdprintk (XENLOG_INFO ,"\tmajor: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.major); +gdprintk (XENLOG_INFO ,"\tminor: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.minor); +gdprintk (XENLOG_INFO ,"\tsp: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.service_pack); +gdprintk (XENLOG_INFO ,"\tbuild: %x\n" , + d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +} + +void dump_hypercall (struct domain *d) +{ +gdprintk (XENLOG_INFO ,"HYPERCALL:\n" ); +gdprintk (XENLOG_INFO ,"\tenabled: %x\n" , + d->arch.hvm_domain.viridian.hypercall_gpa.fields.enabled); +gdprintk (XENLOG_INFO ,"\tpfn: %lx\n" , + (unsigned long )d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn); +} + +void dump_apic_assist (struct vcpu *v) +{ +gdprintk (XENLOG_INFO ,"APIC_ASSIST[%d]:\n" , v->vcpu_id); +gdprintk (XENLOG_INFO ,"\tenabled: %x\n" , + v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled); +gdprintk (XENLOG_INFO ,"\tpfn: %lx\n" , + (unsigned long )v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn); +} + +static void enable_hypercall_page (struct domain *d) +{unsigned long gmfn = d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn;unsigned long mfn =gmfn_to_mfn (d, gmfn);uint8_t *p;
@@ -130,9 +164,43 @@ static void enable_hypercall_page(void)put_page_and_type (mfn_to_page (mfn)); } +void initialize_apic_assist (struct vcpu *v) +{ +struct domain *d = v->domain; +unsigned long gmfn = v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn; +unsigned long mfn =gmfn_to_mfn (d, gmfn); +uint8_t *p; + +/* +* We don't support the APIC assist page, and that fact is reflected in +* our CPUID flags. However, Newer versions of Windows have a bug which +* means that they don't recognise that, and tries to use the page +* anyway. We therefore have to fake up just enough to keep windows happy. +* +* See http://msdn.microsoft.com/en-us/library/ff538657%28VS.85%29.aspx for +* details of how Windows uses the page. +*/ + +if ( !mfn_valid (mfn) || + !get_page_and_type (mfn_to_page (mfn), d, PGT_writable_page) ) + { +gdprintk (XENLOG_WARNING ,"Bad GMFN %lx (MFN %lx)\n" , gmfn, mfn); +return ; + } + + p =map_domain_page (mfn); + + *(u32 *)p =0 ; + +unmap_domain_page (p); + +put_page_and_type (mfn_to_page (mfn)); +} +int wrmsr_viridian_regs (uint32_t idx,uint64_t val) { -struct domain *d = current->domain; +struct vcpu *v = current; +struct domain *d = v->domain;if ( !is_viridian_domain (d) )return 0 ;
@@ -142,44 +210,29 @@ int wrmsr_viridian_regs(uint32_t idx, uicase VIRIDIAN_MSR_GUEST_OS_ID :perfc_incr (mshv_wrmsr_osid); d->arch.hvm_domain.viridian.guest_os_id.raw = val; -gdprintk (XENLOG_INFO ,"Guest os:\n" ); -gdprintk (XENLOG_INFO ,"\tvendor: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.vendor); -gdprintk (XENLOG_INFO ,"\tos: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.os); -gdprintk (XENLOG_INFO ,"\tmajor: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.major); -gdprintk (XENLOG_INFO ,"\tminor: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.minor); -gdprintk (XENLOG_INFO ,"\tsp: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.service_pack); -gdprintk (XENLOG_INFO ,"\tbuild: %x\n" , - d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +dump_guest_os_id (d);break ;case VIRIDIAN_MSR_HYPERCALL :perfc_incr (mshv_wrmsr_hc_page); -gdprintk (XENLOG_INFO ,"Set hypercall page %" PRIx64".\n" , val); -if ( d->arch.hvm_domain.viridian.guest_os_id.raw ==0 ) -break ; d->arch.hvm_domain.viridian.hypercall_gpa.raw = val; +dump_hypercall (d);if ( d->arch.hvm_domain.viridian.hypercall_gpa.fields.enabled ) -enable_hypercall_page (); +enable_hypercall_page (d);break ;case VIRIDIAN_MSR_VP_INDEX :perfc_incr (mshv_wrmsr_vp_index); -gdprintk (XENLOG_INFO ,"Set VP index %" PRIu64".\n" , val);break ;case VIRIDIAN_MSR_EOI :perfc_incr (mshv_wrmsr_eoi); -vlapic_EOI_set (vcpu_vlapic (current)); +vlapic_EOI_set (vcpu_vlapic (v));break ;case VIRIDIAN_MSR_ICR : {u32 eax = (u32 )val, edx = (u32)(val >>32 ); -struct vlapic *vlapic =vcpu_vlapic (current); +struct vlapic *vlapic =vcpu_vlapic (v);perfc_incr (mshv_wrmsr_icr); eax &= ~(1 <<12 ); edx &=0xff000000 ;
@@ -191,31 +244,15 @@ int wrmsr_viridian_regs(uint32_t idx, uicase VIRIDIAN_MSR_TPR :perfc_incr (mshv_wrmsr_tpr); -vlapic_set_reg (vcpu_vlapic (current),APIC_TASKPRI , (uint8_t )val); +vlapic_set_reg (vcpu_vlapic (v),APIC_TASKPRI , (uint8_t )val);break ;case VIRIDIAN_MSR_APIC_ASSIST : -/* -* We don't support the APIC assist page, and that fact is reflected in -* our CPUID flags. However, Windows 7 build 7000 has a bug which means -* that it doesn't recognise that, and tries to use the page anyway. We -* therefore have to fake up just enough to keep win7 happy. -* Fortunately, that's really easy: just setting the first four bytes -* in the page to zero effectively disables the page again, so that's -* what we do. Semantically, the first four bytes are supposed to be a -* flag saying whether the guest really needs to issue an EOI. Setting -* that flag to zero means that it must always issue one, which is what -* we want. Once a page has been repurposed as an APIC assist page the -* guest isn't allowed to set anything in it, so the flag remains zero -* and all is fine. The guest is allowed to clear flags in the page, -* but that doesn't cause us any problems. -*/ -if ( val &1 )/* APIC assist page enabled? */ - { -uint32_t word =0 ; -paddr_t page_start = val & ~1ul ; - (void )hvm_copy_to_guest_phys (page_start, &word,sizeof (word)); - } +perfc_incr (mshv_wrmsr_apic_msr); + v->arch.hvm_vcpu.viridian.apic_assist.raw = val; +dump_apic_assist (v); +if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled) +initialize_apic_assist (v);break ;default :
@@ -228,20 +265,21 @@ int wrmsr_viridian_regs(uint32_t idx, uiint rdmsr_viridian_regs (uint32_t idx,uint64_t *val) {struct vcpu *v = current; +struct domain *d = v->domain; -if ( !is_viridian_domain (v->domain) ) +if ( !is_viridian_domain (d) )return 0 ;switch ( idx ) {case VIRIDIAN_MSR_GUEST_OS_ID :perfc_incr (mshv_rdmsr_osid); - *val = v->domain->arch.hvm_domain.viridian.guest_os_id.raw; + *val = d->arch.hvm_domain.viridian.guest_os_id.raw;break ;case VIRIDIAN_MSR_HYPERCALL :perfc_incr (mshv_rdmsr_hc_page); - *val = v->domain->arch.hvm_domain.viridian.hypercall_gpa.raw; + *val = d->arch.hvm_domain.viridian.hypercall_gpa.raw;break ;case VIRIDIAN_MSR_VP_INDEX :
@@ -260,6 +298,11 @@ int rdmsr_viridian_regs(uint32_t idx, ui *val =vlapic_get_reg (vcpu_vlapic (v),APIC_TASKPRI );break ; +case VIRIDIAN_MSR_APIC_ASSIST : +perfc_incr (mshv_rdmsr_apic_msr); + *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; +break ; +default :return 0 ; }
xen/include/asm-x86/hvm/vcpu.h +3 -0
@@ -23,6 +23,7 @@#include <xen/tasklet.h> #include <asm/hvm/io.h> #include <asm/hvm/vlapic.h> +#include <asm/hvm/viridian.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/svm/vmcb.h>
@@ -163,6 +164,8 @@ struct hvm_vcpu {int inject_trap;/* -1 for nothing to inject */ int inject_error_code;unsigned long inject_cr2; + + struct viridian_vcpu viridian; };#endif /* __ASM_X86_HVM_VCPU_H__ */
xen/include/asm-x86/hvm/viridian.h +15 -0
@@ -9,6 +9,21 @@ #ifndef __ASM_X86_HVM_VIRIDIAN_H__ #define __ASM_X86_HVM_VIRIDIAN_H__ +union viridian_apic_assist +{ uint64_t raw; + struct + { + uint64_t enabled:1; + uint64_t reserved_preserved:11; + uint64_t pfn:48; + } fields; +}; + +struct viridian_vcpu +{ + union viridian_apic_assist apic_assist; +}; + union viridian_guest_os_id { uint64_t raw;
xen/include/asm-x86/perfc_defn.h +2 -0
@@ -120,12 +120,14 @@ PERFCOUNTER(mshv_rdmsr_hc_page, PERFCOUNTER(mshv_rdmsr_vp_index, "MS Hv rdmsr vp index") PERFCOUNTER(mshv_rdmsr_icr, "MS Hv rdmsr icr") PERFCOUNTER(mshv_rdmsr_tpr, "MS Hv rdmsr tpr") +PERFCOUNTER(mshv_rdmsr_apic_assist, "MS Hv rdmsr APIC assist") PERFCOUNTER(mshv_wrmsr_osid, "MS Hv wrmsr Guest OS ID") PERFCOUNTER(mshv_wrmsr_hc_page, "MS Hv wrmsr hypercall page") PERFCOUNTER(mshv_wrmsr_vp_index, "MS Hv wrmsr vp index") PERFCOUNTER(mshv_wrmsr_icr, "MS Hv wrmsr icr") PERFCOUNTER(mshv_wrmsr_tpr, "MS Hv wrmsr tpr") PERFCOUNTER(mshv_wrmsr_eoi, "MS Hv wrmsr eoi") +PERFCOUNTER(mshv_wrmsr_apic_assist, "MS Hv wrmsr APIC assist") PERFCOUNTER(realmode_emulations, "realmode instructions emulated")PERFCOUNTER (realmode_exits,"vmexits from realmode" )
Quoted 11 lines · Paul Durrant
# HG changeset patch
# User Paul Durrant <[email protected]>
# Date 1316063461 -3600
# Node IDa08073c5cf28ab76893102cc7a8d20bf3e5e15ae
# Parente90438f6e6d1585a71b18784a99c162b5d95f390
Tidy up the viridian code a little and flesh out the APIC assist MSR handling code.We don't say we that handle that MSR but Windows assumes it. In Windows 7 it just wrote to the MSR and we used to handle that ok. Windows 8 also reads from the MSR so we need to keep a record of the contents.
Does this work properly across save/restore?
-- Keir
Quoted 301 lines
Signed-off-by Paul Durrant <[email protected]>diff -r
e90438f6e6d1-ra08073c5cf28xen/arch/x86/hvm/viridian.cxen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +36
-2@@ -96,9 +96,43 @@ int cpuid_viridian_leaves(unsigned int l return 1; } -static void enable_hypercall_page(void) +void dump_guest_os_id(struct domain *d) { - struct domain *d = current->domain; + gdprintk(XENLOG_INFO, "GUEST_OS_ID:\n"); + gdprintk(XENLOG_INFO, "\tvendor: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.vendor); + gdprintk(XENLOG_INFO, "\tos: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.os); + gdprintk(XENLOG_INFO, "\tmajor: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.major); + gdprintk(XENLOG_INFO, "\tminor: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.minor); + gdprintk(XENLOG_INFO, "\tsp: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.service_pack); + gdprintk(XENLOG_INFO, "\tbuild: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +} + +void dump_hypercall(struct domain *d) +{ + gdprintk(XENLOG_INFO, "HYPERCALL:\n"); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + d->arch.hvm_domain.viridian.hypercall_gpa.fields.enabled); + gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsigned long)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn); +} + +void dump_apic_assist(struct vcpu *v) +{ + gdprintk(XENLOG_INFO, "APIC_ASSIST[%d]:\n", v->vcpu_id); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled); + gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsigned long)v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn); +} + +static void enable_hypercall_page(struct domain *d) +{ unsigned long gmfn = d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn;unsigned long mfn = gmfn_to_mfn(d, gmfn); uint8_t *p;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +12
-0@@ -130,9 +164,43 @@ static void enable_hypercall_page(void) put_page_and_type(mfn_to_page(mfn)); } +void initialize_apic_assist(struct vcpu *v) +{ + struct domain *d = v->domain; + unsigned long gmfn = v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn; + unsigned long mfn = gmfn_to_mfn(d, gmfn); + uint8_t *p; + + /* + * We don't support the APIC assist page, and that fact is reflected in + * our CPUID flags. However, Newer versions of Windows have a bug which + * means that they don't recognise that, and tries to use the page + * anyway. We therefore have to fake up just enough to keep windowshappy.
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ * + * See http://msdn.microsoft.com/en-us/library/ff538657%28VS.85%29.aspxfor
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +27
-24+ * details of how Windows uses the page. + */ + + if ( !mfn_valid(mfn) || + !get_page_and_type(mfn_to_page(mfn), d, PGT_writable_page) ) + { + gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n", gmfn, mfn); + return; + } + + p = map_domain_page(mfn); + + *(u32 *)p = 0; + + unmap_domain_page(p); + + put_page_and_type(mfn_to_page(mfn)); +} + int wrmsr_viridian_regs(uint32_t idx, uint64_t val) { - struct domain *d = current->domain; + struct vcpu *v = current; + struct domain *d = v->domain; if ( !is_viridian_domain(d) ) return 0;@@ -142,44 +210,29 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_wrmsr_osid); d->arch.hvm_domain.viridian.guest_os_id.raw = val; - gdprintk(XENLOG_INFO, "Guest os:\n"); - gdprintk(XENLOG_INFO, "\tvendor: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.vendor); - gdprintk(XENLOG_INFO, "\tos: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.os); - gdprintk(XENLOG_INFO, "\tmajor: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.major); - gdprintk(XENLOG_INFO, "\tminor: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.minor); - gdprintk(XENLOG_INFO, "\tsp: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.service_pack); - gdprintk(XENLOG_INFO, "\tbuild: %x\n", - d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); + dump_guest_os_id(d); break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_wrmsr_hc_page); - gdprintk(XENLOG_INFO, "Set hypercall page %"PRIx64".\n", val); - if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 ) - break; d->arch.hvm_domain.viridian.hypercall_gpa.raw = val; + dump_hypercall(d); if ( d->arch.hvm_domain.viridian.hypercall_gpa.fields.enabled ) - enable_hypercall_page(); + enable_hypercall_page(d); break; case VIRIDIAN_MSR_VP_INDEX: perfc_incr(mshv_wrmsr_vp_index); - gdprintk(XENLOG_INFO, "Set VP index %"PRIu64".\n", val); break; case VIRIDIAN_MSR_EOI: perfc_incr(mshv_wrmsr_eoi); - vlapic_EOI_set(vcpu_vlapic(current)); + vlapic_EOI_set(vcpu_vlapic(v)); break; case VIRIDIAN_MSR_ICR: { u32 eax = (u32)val, edx = (u32)(val >> 32); - struct vlapic *vlapic = vcpu_vlapic(current); + struct vlapic *vlapic = vcpu_vlapic(v); perfc_incr(mshv_wrmsr_icr); eax &= ~(1 << 12); edx &= 0xff000000;@@ -191,31 +244,15 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_TPR: perfc_incr(mshv_wrmsr_tpr); - vlapic_set_reg(vcpu_vlapic(current), APIC_TASKPRI, (uint8_t)val); + vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI, (uint8_t)val); break; case VIRIDIAN_MSR_APIC_ASSIST: - /* - * We don't support the APIC assist page, and that fact is reflectedin
- * our CPUID flags. However, Windows 7 build 7000 has a bug which
means
- * that it doesn't recognise that, and tries to use the page anyway.
Wexen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-4- * therefore have to fake up just enough to keep win7 happy. - * Fortunately, that's really easy: just setting the first four bytes - * in the page to zero effectively disables the page again, so that's - * what we do. Semantically, the first four bytes are supposed to bea
- * flag saying whether the guest really needs to issue an EOI.
Setting
- * that flag to zero means that it must always issue one, which is
what
- * we want. Once a page has been repurposed as an APIC assist page
the
- * guest isn't allowed to set anything in it, so the flag remains
zeroxen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-12- * and all is fine. The guest is allowed to clear flags in the page, - * but that doesn't cause us any problems. - */ - if ( val & 1 ) /* APIC assist page enabled? */ - { - uint32_t word = 0; - paddr_t page_start = val & ~1ul; - (void)hvm_copy_to_guest_phys(page_start, &word, sizeof(word)); - } + perfc_incr(mshv_wrmsr_apic_msr); + v->arch.hvm_vcpu.viridian.apic_assist.raw = val; + dump_apic_assist(v); + if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled) + initialize_apic_assist(v); break; default:@@ -228,20 +265,21 @@ int wrmsr_viridian_regs(uint32_t idx, ui int rdmsr_viridian_regs(uint32_t idx, uint64_t *val) { struct vcpu *v = current; + struct domain *d = v->domain; - if ( !is_viridian_domain(v->domain) ) + if ( !is_viridian_domain(d) ) return 0; switch ( idx ) { case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_rdmsr_osid); - *val = v->domain->arch.hvm_domain.viridian.guest_os_id.raw; + *val = d->arch.hvm_domain.viridian.guest_os_id.raw; break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_rdmsr_hc_page); - *val = v->domain->arch.hvm_domain.viridian.hypercall_gpa.raw; + *val = d->arch.hvm_domain.viridian.hypercall_gpa.raw; break; case VIRIDIAN_MSR_VP_INDEX:@@ -260,6 +298,11 @@ int rdmsr_viridian_regs(uint32_t idx, ui *val = vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI); break; + case VIRIDIAN_MSR_APIC_ASSIST: + perfc_incr(mshv_rdmsr_apic_msr); + *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; + break; + default: return 0; }diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-x86/hvm/vcpu.hxen/include/asm-x86/hvm/vcpu.h Thu Sep 15 06:11:01 2011 +0100 renamed from xen/include/asm-x86/hvm/vcpu.h Wed Sep 14 11:38:13 2011 +0100 +3
-0@@ -23,6 +23,7 @@ #include <xen/tasklet.h> #include <asm/hvm/io.h> #include <asm/hvm/vlapic.h> +#include <asm/hvm/viridian.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/svm/vmcb.h>@@ -163,6 +164,8 @@ struct hvm_vcpu { int inject_trap; /* -1 for nothing to inject */ int inject_error_code; unsigned long inject_cr2; + + struct viridian_vcpu viridian; }; #endif /* __ASM_X86_HVM_VCPU_H__ */diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-x86/hvm/viridian.hxen/include/asm-x86/hvm/viridian.h Thu Sep 15 06:11:01 2011 +0100 renamed from xen/include/asm-x86/hvm/viridian.h Wed Sep 14 11:38:13 2011 +0100 +15
-0@@ -9,6 +9,21 @@ #ifndef __ASM_X86_HVM_VIRIDIAN_H__ #define __ASM_X86_HVM_VIRIDIAN_H__ +union viridian_apic_assist +{ uint64_t raw; + struct + { + uint64_t enabled:1; + uint64_t reserved_preserved:11; + uint64_t pfn:48; + } fields; +}; + +struct viridian_vcpu +{ + union viridian_apic_assist apic_assist; +}; + union viridian_guest_os_id { uint64_t raw;diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-x86/perfc_defn.hxen/include/asm-x86/perfc_defn.h Thu Sep 15 06:11:01 2011 +0100 renamed from xen/include/asm-x86/perfc_defn.h Wed Sep 14 11:38:13 2011 +0100 +2
-0@@ -120,12 +120,14 @@ PERFCOUNTER(mshv_rdmsr_hc_page, PERFCOUNTER(mshv_rdmsr_vp_index, "MS Hv rdmsr vp index") PERFCOUNTER(mshv_rdmsr_icr, "MS Hv rdmsr icr") PERFCOUNTER(mshv_rdmsr_tpr, "MS Hv rdmsr tpr") +PERFCOUNTER(mshv_rdmsr_apic_assist, "MS Hv rdmsr APIC assist") PERFCOUNTER(mshv_wrmsr_osid, "MS Hv wrmsr Guest OS ID") PERFCOUNTER(mshv_wrmsr_hc_page, "MS Hv wrmsr hypercall page") PERFCOUNTER(mshv_wrmsr_vp_index, "MS Hv wrmsr vp index") PERFCOUNTER(mshv_wrmsr_icr, "MS Hv wrmsr icr") PERFCOUNTER(mshv_wrmsr_tpr, "MS Hv wrmsr tpr") PERFCOUNTER(mshv_wrmsr_eoi, "MS Hv wrmsr eoi") +PERFCOUNTER(mshv_wrmsr_apic_assist, "MS Hv wrmsr APIC assist") PERFCOUNTER(realmode_emulations, "realmode instructions emulated") PERFCOUNTER(realmode_exits, "vmexits from realmode")_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Good point. I guess I may need to explicitly save/restore the apic assist pfn. I'll check.
Paul
Quoted 379 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 14 September 2011 23:38
To: Paul Durrant; [email protected]
Subject: Re: [Xen-devel] [PATCH] Tidy up the viridian code a little and flesh out the APIC assist MSRQuoted 2 lines · Paul Durrant
# HG changeset patch
# User Paul Durrant <[email protected]> # Date 1316063461 -3600
Quoted 3 lines
# Node ID
a08073c5cf28ab76893102cc7a8d20bf3e5e15ae
# Parente90438f6e6d1585a71b18784a99c162b5d95f390Tidy up the viridian code a little and flesh out the APIC assistMSR
Quoted 5 lines
handling code.
We don't say we that handle that MSR but Windows assumes it. In Windows 7 it just wrote to the MSR and we used to handle that ok. Windows 8 also reads from the MSR so we need to keep a record of
the contents.
Does this work properly across save/restore?
-- Keir
Quoted 61 lines
Signed-off-by Paul Durrant <[email protected]>diff -r
e90438f6e6d1-ra08073c5cf28xen/arch/x86/hvm/viridian.cxen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +12
-2@@ -96,9 +96,43 @@ int cpuid_viridian_leaves(unsigned int l return 1; } -static void enable_hypercall_page(void) +void dump_guest_os_id(struct domain *d) { - struct domain *d = current->domain; + gdprintk(XENLOG_INFO, "GUEST_OS_ID:\n"); + gdprintk(XENLOG_INFO, "\tvendor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); + gdprintk(XENLOG_INFO, "\tos: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.os); + gdprintk(XENLOG_INFO, "\tmajor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.major); + gdprintk(XENLOG_INFO, "\tminor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.minor); + gdprintk(XENLOG_INFO, "\tsp: %x\n", + d-arch.hvm_domain.viridian.guest_os_id.fields.service_pack);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +9
-0+ gdprintk(XENLOG_INFO, "\tbuild: %x\n", + +d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +} + +void dump_hypercall(struct domain *d) { + gdprintk(XENLOG_INFO, "HYPERCALL:\n"); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + d-arch.hvm_domain.viridian.hypercall_gpa.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsignedlong)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+} + +void dump_apic_assist(struct vcpu *v) { + gdprintk(XENLOG_INFO, "APIC_ASSIST[%d]:\n", v->vcpu_id); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + v-arch.hvm_vcpu.viridian.apic_assist.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsigned +long)v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn); +} + +static void enable_hypercall_page(struct domain *d) { unsigned long gmfn =d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn; unsigned long mfn = gmfn_to_mfn(d, gmfn); uint8_t *p;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0@@ -130,9 +164,43 @@ static void enable_hypercall_page(void) put_page_and_type(mfn_to_page(mfn)); }xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 175
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +8
-0+void initialize_apic_assist(struct vcpu *v) { + struct domain *d = v->domain; + unsigned long gmfn = v- arch.hvm_vcpu.viridian.apic_assist.fields.pfn; + unsigned long mfn = gmfn_to_mfn(d, gmfn); + uint8_t *p; + + /* + * We don't support the APIC assist page, and that fact isreflected in
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 176
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * our CPUID flags. However, Newer versions of Windows have abug which
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 177
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * means that they don't recognise that, and tries to use thepage
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 12 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ * anyway. We therefore have to fake up just enough to keep + windowshappy.
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +3
-0+ * + * See + http://msdn.microsoft.com/en-us/library/ff538657%28VS.85%29.aspxfor
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0+ * details of how Windows uses the page. + */ + + if ( !mfn_valid(mfn) || + !get_page_and_type(mfn_to_page(mfn), d,
PGT_writable_page) )xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ { + gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n",gmfn, mfn);
Quoted 38 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-12+ return; + } + + p = map_domain_page(mfn); + + *(u32 *)p = 0; + + unmap_domain_page(p); + + put_page_and_type(mfn_to_page(mfn)); +} + int wrmsr_viridian_regs(uint32_t idx, uint64_t val) { - struct domain *d = current->domain; + struct vcpu *v = current; + struct domain *d = v->domain; if ( !is_viridian_domain(d) ) return 0;@@ -142,44 +210,29 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_wrmsr_osid); d->arch.hvm_domain.viridian.guest_os_id.raw = val; - gdprintk(XENLOG_INFO, "Guest os:\n"); - gdprintk(XENLOG_INFO, "\tvendor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); - gdprintk(XENLOG_INFO, "\tos: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.os); - gdprintk(XENLOG_INFO, "\tmajor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.major); - gdprintk(XENLOG_INFO, "\tminor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.minor); - gdprintk(XENLOG_INFO, "\tsp: %x\n", - d-xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 168
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-3arch.hvm_domain.viridian.guest_os_id.fields.service_pack); - gdprintk(XENLOG_INFO, "\tbuild: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.build_number); + dump_guest_os_id(d); break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_wrmsr_hc_page); - gdprintk(XENLOG_INFO, "Set hypercall page %"PRIx64".\n",val);
Quoted 29 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +3
-5- if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 ) - break; d->arch.hvm_domain.viridian.hypercall_gpa.raw = val; + dump_hypercall(d); if ( d- arch.hvm_domain.viridian.hypercall_gpa.fields.enabled ) - enable_hypercall_page(); + enable_hypercall_page(d); break; case VIRIDIAN_MSR_VP_INDEX: perfc_incr(mshv_wrmsr_vp_index); - gdprintk(XENLOG_INFO, "Set VP index %"PRIu64".\n", val); break; case VIRIDIAN_MSR_EOI: perfc_incr(mshv_wrmsr_eoi); - vlapic_EOI_set(vcpu_vlapic(current)); + vlapic_EOI_set(vcpu_vlapic(v)); break;case VIRIDIAN_MSR_ICR: { u32 eax = (u32)val, edx = (u32)(val >> 32);xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-1- struct vlapic *vlapic = vcpu_vlapic(current); + struct vlapic *vlapic = vcpu_vlapic(v); perfc_incr(mshv_wrmsr_icr); eax &= ~(1 << 12); edx &= 0xff000000;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 194
Quoted 4 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-1@@ -191,31 +244,15 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_TPR: perfc_incr(mshv_wrmsr_tpr); - vlapic_set_reg(vcpu_vlapic(current), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 247
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 199
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-2break; case VIRIDIAN_MSR_APIC_ASSIST: - /* - * We don't support the APIC assist page, and that factis reflected
Quoted 2 lines
in
- * our CPUID flags. However, Windows 7 build 7000 has abug which
Quoted 2 lines
means
- * that it doesn't recognise that, and tries to use thepage anyway.
Quoted 2 lines
We
- * therefore have to fake up just enough to keep win7happy.
Quoted 1 line
- * Fortunately, that's really easy: just setting the
first four bytes
Quoted 1 line
- * in the page to zero effectively disables the page
again, so that's
Quoted 1 line
- * what we do. Semantically, the first four bytes are
supposed to be
Quoted 2 lines
a
- * flag saying whether the guest really needs to issue anEOI.
Quoted 2 lines
Setting
- * that flag to zero means that it must always issue one,which is
Quoted 2 lines
what
- * we want. Once a page has been repurposed as an APICassist page
Quoted 2 lines
the
- * guest isn't allowed to set anything in it, so the flagremains
Quoted 2 lines
zero
- * and all is fine. The guest is allowed to clear flagsin the page,
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 7 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-7- * but that doesn't cause us any problems. - */ - if ( val & 1 ) /* APIC assist page enabled? */ - { - uint32_t word = 0; - paddr_t page_start = val & ~1ul; - (void)hvm_copy_to_guest_phys(page_start, &word,sizeof(word));
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-1- } + perfc_incr(mshv_wrmsr_apic_msr); + v->arch.hvm_vcpu.viridian.apic_assist.raw = val; + dump_apic_assist(v); + if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled) + initialize_apic_assist(v); break; default:@@ -228,20 +265,21 @@ int wrmsr_viridian_regs(uint32_t idx, uiint
Quoted 37 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +4
-3rdmsr_viridian_regs(uint32_t idx, uint64_t *val) { struct vcpu *v = current; + struct domain *d = v->domain; - if ( !is_viridian_domain(v->domain) ) + if ( !is_viridian_domain(d) ) return 0; switch ( idx ) { case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_rdmsr_osid); - *val = v->domain- arch.hvm_domain.viridian.guest_os_id.raw; + *val = d->arch.hvm_domain.viridian.guest_os_id.raw; break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_rdmsr_hc_page); - *val = v->domain- arch.hvm_domain.viridian.hypercall_gpa.raw; + *val = d->arch.hvm_domain.viridian.hypercall_gpa.raw; break;case
VIRIDIAN_MSR_VP_INDEX:xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0@@ -260,6 +298,11 @@ int rdmsr_viridian_regs(uint32_t idx, ui *val = vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI); break; + case VIRIDIAN_MSR_APIC_ASSIST: + perfc_incr(mshv_rdmsr_apic_msr); + *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; + break; + default: return 0; }Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/hvm/vcpu.hQuoted 1 line
---
a/xen/include/asm-x86/hvm/vcpu.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/hvm/vcpu.hThu Sep 15 06:11:01 2011+0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 struct hvm_vcpu { · line 164
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -23,6 +23,7 @@ #include <xen/tasklet.h> #include <asm/hvm/io.h> #include <asm/hvm/vlapic.h> +#include <asm/hvm/viridian.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/svm/vmcb.h>@@ -163,6 +164,8 @@ struct hvm_vcpu { int inject_trap; /* -1 for nothing to inject*/
Quoted 34 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0int inject_error_code; unsigned long inject_cr2; + + struct viridian_vcpu viridian; }; #endif /* __ASM_X86_HVM_VCPU_H__ */diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-x86/hvm/viridian.h
---a/xen/include/asm-x86/hvm/viridian.hWed Sep 14 11:38:13 2011 +0100
+++b/xen/include/asm-x86/hvm/viridian.hThu Sep 15 06:11:01 2011 +++ +0100xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-0@@ -9,6 +9,21 @@ #ifndef __ASM_X86_HVM_VIRIDIAN_H__ #define __ASM_X86_HVM_VIRIDIAN_H__ +union viridian_apic_assist +{ uint64_t raw; + struct + { + uint64_t enabled:1; + uint64_t reserved_preserved:11; + uint64_t pfn:48; + } fields; +}; + +struct viridian_vcpu +{ + union viridian_apic_assist apic_assist; }; + union viridian_guest_os_id { uint64_t raw;Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/perfc_defn.hQuoted 1 line
---
a/xen/include/asm-x86/perfc_defn.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/perfc_defn.hThu Sep 15 06:11:01 2011+0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 123
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -120,12 +120,14 @@ PERFCOUNTER(mshv_rdmsr_hc_page, PERFCOUNTER(mshv_rdmsr_vp_index, "MS Hv rdmsr vp index") PERFCOUNTER(mshv_rdmsr_icr, "MS Hv rdmsr icr") PERFCOUNTER(mshv_rdmsr_tpr, "MS Hv rdmsr tpr") +PERFCOUNTER(mshv_rdmsr_apic_assist, "MS Hv rdmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 124
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_osid, "MS Hv wrmsr Guest OSID")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 125
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_hc_page, "MS Hv wrmsr hypercallpage")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 130
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0PERFCOUNTER(mshv_wrmsr_vp_index, "MS Hv wrmsr vp index") PERFCOUNTER(mshv_wrmsr_icr, "MS Hv wrmsr icr") PERFCOUNTER(mshv_wrmsr_tpr, "MS Hv wrmsr tpr") PERFCOUNTER(mshv_wrmsr_eoi, "MS Hv wrmsr eoi") +PERFCOUNTER(mshv_wrmsr_apic_assist, "MS Hv wrmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 131
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_emulations, "realmode instructionsemulated")
Quoted 6 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_exits, "vmexits from realmode")_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Might need a shiny new Viridian struct type for our save format, which can then be extended with more Viridian-y stuff as required.
-- Keir
Quoted 385 lines · Paul Durrant
Good point. I guess I may need to explicitly save/restore the apic assist pfn. I'll check.
Paul
Quoted 379 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 14 September 2011 23:38
To: Paul Durrant; [email protected]
Subject: Re: [Xen-devel] [PATCH] Tidy up the viridian code a little and flesh out the APIC assist MSRQuoted 2 lines · Paul Durrant
# HG changeset patch
# User Paul Durrant <[email protected]> # Date 1316063461 -3600
Quoted 3 lines
# Node ID
a08073c5cf28ab76893102cc7a8d20bf3e5e15ae
# Parente90438f6e6d1585a71b18784a99c162b5d95f390Tidy up the viridian code a little and flesh out the APIC assistMSR
Quoted 5 lines
handling code.
We don't say we that handle that MSR but Windows assumes it. In Windows 7 it just wrote to the MSR and we used to handle that ok. Windows 8 also reads from the MSR so we need to keep a record of
the contents.
Does this work properly across save/restore?
-- Keir
Quoted 61 lines
Signed-off-by Paul Durrant <[email protected]>diff -r
e90438f6e6d1-ra08073c5cf28xen/arch/x86/hvm/viridian.cxen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +12
-2@@ -96,9 +96,43 @@ int cpuid_viridian_leaves(unsigned int l return 1; } -static void enable_hypercall_page(void) +void dump_guest_os_id(struct domain *d) { - struct domain *d = current->domain; + gdprintk(XENLOG_INFO, "GUEST_OS_ID:\n"); + gdprintk(XENLOG_INFO, "\tvendor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); + gdprintk(XENLOG_INFO, "\tos: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.os); + gdprintk(XENLOG_INFO, "\tmajor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.major); + gdprintk(XENLOG_INFO, "\tminor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.minor); + gdprintk(XENLOG_INFO, "\tsp: %x\n", + d-arch.hvm_domain.viridian.guest_os_id.fields.service_pack);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +9
-0+ gdprintk(XENLOG_INFO, "\tbuild: %x\n", + +d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +} + +void dump_hypercall(struct domain *d) { + gdprintk(XENLOG_INFO, "HYPERCALL:\n"); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + d-arch.hvm_domain.viridian.hypercall_gpa.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsignedlong)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+} + +void dump_apic_assist(struct vcpu *v) { + gdprintk(XENLOG_INFO, "APIC_ASSIST[%d]:\n", v->vcpu_id); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + v-arch.hvm_vcpu.viridian.apic_assist.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsigned +long)v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn); +} + +static void enable_hypercall_page(struct domain *d) { unsigned long gmfn =d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn; unsigned long mfn = gmfn_to_mfn(d, gmfn); uint8_t *p;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0@@ -130,9 +164,43 @@ static void enable_hypercall_page(void) put_page_and_type(mfn_to_page(mfn)); }xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 175
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +8
-0+void initialize_apic_assist(struct vcpu *v) { + struct domain *d = v->domain; + unsigned long gmfn = v- arch.hvm_vcpu.viridian.apic_assist.fields.pfn; + unsigned long mfn = gmfn_to_mfn(d, gmfn); + uint8_t *p; + + /* + * We don't support the APIC assist page, and that fact isreflected in
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 176
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * our CPUID flags. However, Newer versions of Windows have abug which
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 177
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * means that they don't recognise that, and tries to use thepage
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 12 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ * anyway. We therefore have to fake up just enough to keep + windowshappy.
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +3
-0+ * + * See + http://msdn.microsoft.com/en-us/library/ff538657%28VS.85%29.aspxfor
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0+ * details of how Windows uses the page. + */ + + if ( !mfn_valid(mfn) || + !get_page_and_type(mfn_to_page(mfn), d,
PGT_writable_page) )xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ { + gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n",gmfn, mfn);
Quoted 38 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-12+ return; + } + + p = map_domain_page(mfn); + + *(u32 *)p = 0; + + unmap_domain_page(p); + + put_page_and_type(mfn_to_page(mfn)); +} + int wrmsr_viridian_regs(uint32_t idx, uint64_t val) { - struct domain *d = current->domain; + struct vcpu *v = current; + struct domain *d = v->domain; if ( !is_viridian_domain(d) ) return 0;@@ -142,44 +210,29 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_wrmsr_osid); d->arch.hvm_domain.viridian.guest_os_id.raw = val; - gdprintk(XENLOG_INFO, "Guest os:\n"); - gdprintk(XENLOG_INFO, "\tvendor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); - gdprintk(XENLOG_INFO, "\tos: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.os); - gdprintk(XENLOG_INFO, "\tmajor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.major); - gdprintk(XENLOG_INFO, "\tminor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.minor); - gdprintk(XENLOG_INFO, "\tsp: %x\n", - d-xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 168
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-3arch.hvm_domain.viridian.guest_os_id.fields.service_pack); - gdprintk(XENLOG_INFO, "\tbuild: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.build_number); + dump_guest_os_id(d); break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_wrmsr_hc_page); - gdprintk(XENLOG_INFO, "Set hypercall page %"PRIx64".\n",val);
Quoted 29 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +3
-5- if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 ) - break; d->arch.hvm_domain.viridian.hypercall_gpa.raw = val; + dump_hypercall(d); if ( d- arch.hvm_domain.viridian.hypercall_gpa.fields.enabled ) - enable_hypercall_page(); + enable_hypercall_page(d); break; case VIRIDIAN_MSR_VP_INDEX: perfc_incr(mshv_wrmsr_vp_index); - gdprintk(XENLOG_INFO, "Set VP index %"PRIu64".\n", val); break; case VIRIDIAN_MSR_EOI: perfc_incr(mshv_wrmsr_eoi); - vlapic_EOI_set(vcpu_vlapic(current)); + vlapic_EOI_set(vcpu_vlapic(v)); break;case VIRIDIAN_MSR_ICR: { u32 eax = (u32)val, edx = (u32)(val >> 32);xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-1- struct vlapic *vlapic = vcpu_vlapic(current); + struct vlapic *vlapic = vcpu_vlapic(v); perfc_incr(mshv_wrmsr_icr); eax &= ~(1 << 12); edx &= 0xff000000;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 194
Quoted 4 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-1@@ -191,31 +244,15 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_TPR: perfc_incr(mshv_wrmsr_tpr); - vlapic_set_reg(vcpu_vlapic(current), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 247
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 199
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-2break; case VIRIDIAN_MSR_APIC_ASSIST: - /* - * We don't support the APIC assist page, and that factis reflected
Quoted 2 lines
in
- * our CPUID flags. However, Windows 7 build 7000 has abug which
Quoted 2 lines
means
- * that it doesn't recognise that, and tries to use thepage anyway.
Quoted 2 lines
We
- * therefore have to fake up just enough to keep win7happy.
Quoted 1 line
- * Fortunately, that's really easy: just setting the
first four bytes
Quoted 1 line
- * in the page to zero effectively disables the page
again, so that's
Quoted 1 line
- * what we do. Semantically, the first four bytes are
supposed to be
Quoted 2 lines
a
- * flag saying whether the guest really needs to issue anEOI.
Quoted 2 lines
Setting
- * that flag to zero means that it must always issue one,which is
Quoted 2 lines
what
- * we want. Once a page has been repurposed as an APICassist page
Quoted 2 lines
the
- * guest isn't allowed to set anything in it, so the flagremains
Quoted 2 lines
zero
- * and all is fine. The guest is allowed to clear flagsin the page,
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 7 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-7- * but that doesn't cause us any problems. - */ - if ( val & 1 ) /* APIC assist page enabled? */ - { - uint32_t word = 0; - paddr_t page_start = val & ~1ul; - (void)hvm_copy_to_guest_phys(page_start, &word,sizeof(word));
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-1- } + perfc_incr(mshv_wrmsr_apic_msr); + v->arch.hvm_vcpu.viridian.apic_assist.raw = val; + dump_apic_assist(v); + if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled) + initialize_apic_assist(v); break; default:@@ -228,20 +265,21 @@ int wrmsr_viridian_regs(uint32_t idx, uiint
Quoted 37 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +4
-3rdmsr_viridian_regs(uint32_t idx, uint64_t *val) { struct vcpu *v = current; + struct domain *d = v->domain; - if ( !is_viridian_domain(v->domain) ) + if ( !is_viridian_domain(d) ) return 0; switch ( idx ) { case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_rdmsr_osid); - *val = v->domain- arch.hvm_domain.viridian.guest_os_id.raw; + *val = d->arch.hvm_domain.viridian.guest_os_id.raw; break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_rdmsr_hc_page); - *val = v->domain- arch.hvm_domain.viridian.hypercall_gpa.raw; + *val = d->arch.hvm_domain.viridian.hypercall_gpa.raw; break;case
VIRIDIAN_MSR_VP_INDEX:xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0@@ -260,6 +298,11 @@ int rdmsr_viridian_regs(uint32_t idx, ui *val = vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI); break; + case VIRIDIAN_MSR_APIC_ASSIST: + perfc_incr(mshv_rdmsr_apic_msr); + *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; + break; + default: return 0; }Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/hvm/vcpu.hQuoted 1 line
---
a/xen/include/asm-x86/hvm/vcpu.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/hvm/vcpu.hThu Sep 15 06:11:01 2011+0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 struct hvm_vcpu { · line 164
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -23,6 +23,7 @@ #include <xen/tasklet.h> #include <asm/hvm/io.h> #include <asm/hvm/vlapic.h> +#include <asm/hvm/viridian.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/svm/vmcb.h>@@ -163,6 +164,8 @@ struct hvm_vcpu { int inject_trap; /* -1 for nothing to inject*/
Quoted 34 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0int inject_error_code; unsigned long inject_cr2; + + struct viridian_vcpu viridian; }; #endif /* __ASM_X86_HVM_VCPU_H__ */diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-x86/hvm/viridian.h
---a/xen/include/asm-x86/hvm/viridian.hWed Sep 14 11:38:13 2011 +0100
+++b/xen/include/asm-x86/hvm/viridian.hThu Sep 15 06:11:01 2011 +++ +0100xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-0@@ -9,6 +9,21 @@ #ifndef __ASM_X86_HVM_VIRIDIAN_H__ #define __ASM_X86_HVM_VIRIDIAN_H__ +union viridian_apic_assist +{ uint64_t raw; + struct + { + uint64_t enabled:1; + uint64_t reserved_preserved:11; + uint64_t pfn:48; + } fields; +}; + +struct viridian_vcpu +{ + union viridian_apic_assist apic_assist; }; + union viridian_guest_os_id { uint64_t raw;Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/perfc_defn.hQuoted 1 line
---
a/xen/include/asm-x86/perfc_defn.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/perfc_defn.hThu Sep 15 06:11:01 2011+0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 123
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -120,12 +120,14 @@ PERFCOUNTER(mshv_rdmsr_hc_page, PERFCOUNTER(mshv_rdmsr_vp_index, "MS Hv rdmsr vp index") PERFCOUNTER(mshv_rdmsr_icr, "MS Hv rdmsr icr") PERFCOUNTER(mshv_rdmsr_tpr, "MS Hv rdmsr tpr") +PERFCOUNTER(mshv_rdmsr_apic_assist, "MS Hv rdmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 124
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_osid, "MS Hv wrmsr Guest OSID")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 125
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_hc_page, "MS Hv wrmsr hypercallpage")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 130
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0PERFCOUNTER(mshv_wrmsr_vp_index, "MS Hv wrmsr vp index") PERFCOUNTER(mshv_wrmsr_icr, "MS Hv wrmsr icr") PERFCOUNTER(mshv_wrmsr_tpr, "MS Hv wrmsr tpr") PERFCOUNTER(mshv_wrmsr_eoi, "MS Hv wrmsr eoi") +PERFCOUNTER(mshv_wrmsr_apic_assist, "MS Hv wrmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 131
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_emulations, "realmode instructionsemulated")
Quoted 6 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_exits, "vmexits from realmode")_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Yep. I'm hoping to start making use of apic assist once I've got specific evtchn -> hvm irq mappings working. I can get windows to give me edge triggered interrupts so hopefully I can persuade it to skip the eoi by setting the apic assist bit prior to injection. Keeping track of the pfn will, of course, become quite important at this point :-) For now, I don't think windows reads the msr again after boot so losing the value across a save/restore probably doesn't matter much.
Paul
Quoted 416 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 15 September 2011 07:32
To: Paul Durrant; [email protected]
Subject: Re: [Xen-devel] [PATCH] Tidy up the viridian code a little and flesh out the APIC assist MSRMight need a shiny new Viridian struct type for our save format, which can then be extended with more Viridian-y stuff as required.
-- Keir
Quoted 1 line · Paul Durrant
Good point. I guess I may need to explicitly save/restore the apic
assist pfn.
Quoted 9 lines
I'll check.
Paul
Quoted 5 lines
-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: 14 September 2011 23:38
To: Paul Durrant; [email protected]
Subject: Re: [Xen-devel] [PATCH] Tidy up the viridian code alittle
Quoted 3 lines
Quoted 3 lines
and flesh out the APIC assist MSR
On 15/09/2011 06:13, "Paul Durrant" <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
# HG changeset patch
# User Paul Durrant <[email protected]> # Date 1316063461-
Quoted 9 lines
Quoted 9 lines
3600
Quoted 3 lines
# Node ID
a08073c5cf28ab76893102cc7a8d20bf3e5e15ae
# Parente90438f6e6d1585a71b18784a99c162b5d95f390Tidy up the viridian code a little and flesh out the APIC assistMSR
Quoted 4 lines
handling code.
We don't say we that handle that MSR but Windows assumes it. In Windows 7 it just wrote to the MSR and we used to handle that
ok.
Quoted 79 lines
Quoted 79 lines
Quoted 1 line
Windows 8 also reads from the MSR so we need to keep a record of
the contents.
Does this work properly across save/restore?
-- Keir
Quoted 61 lines
Signed-off-by Paul Durrant <[email protected]>diff -r
e90438f6e6d1-ra08073c5cf28xen/arch/x86/hvm/viridian.cxen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +12
-2@@ -96,9 +96,43 @@ int cpuid_viridian_leaves(unsigned int l return 1; } -static void enable_hypercall_page(void) +void dump_guest_os_id(struct domain *d) { - struct domain *d = current->domain; + gdprintk(XENLOG_INFO, "GUEST_OS_ID:\n"); + gdprintk(XENLOG_INFO, "\tvendor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); + gdprintk(XENLOG_INFO, "\tos: %x\n", + d->arch.hvm_domain.viridian.guest_os_id.fields.os); + gdprintk(XENLOG_INFO, "\tmajor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.major); + gdprintk(XENLOG_INFO, "\tminor: %x\n", + d- arch.hvm_domain.viridian.guest_os_id.fields.minor); + gdprintk(XENLOG_INFO, "\tsp: %x\n", + d-arch.hvm_domain.viridian.guest_os_id.fields.service_pack);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +9
-0+ gdprintk(XENLOG_INFO, "\tbuild: %x\n", + +d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); +} + +void dump_hypercall(struct domain *d) { + gdprintk(XENLOG_INFO, "HYPERCALL:\n"); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + d-arch.hvm_domain.viridian.hypercall_gpa.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsignedlong)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+} + +void dump_apic_assist(struct vcpu *v) { + gdprintk(XENLOG_INFO, "APIC_ASSIST[%d]:\n", v->vcpu_id); + gdprintk(XENLOG_INFO, "\tenabled: %x\n", + v-arch.hvm_vcpu.viridian.apic_assist.fields.enabled);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +6
-0+ gdprintk(XENLOG_INFO, "\tpfn: %lx\n", + (unsigned +long)v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn); +} + +static void enable_hypercall_page(struct domain *d) { unsigned long gmfn =d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn; unsigned long mfn = gmfn_to_mfn(d, gmfn); uint8_t *p;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0@@ -130,9 +164,43 @@ static void enable_hypercall_page(void) put_page_and_type(mfn_to_page(mfn)); }xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 175
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +8
-0+void initialize_apic_assist(struct vcpu *v) { + struct domain *d = v->domain; + unsigned long gmfn = v- arch.hvm_vcpu.viridian.apic_assist.fields.pfn; + unsigned long mfn = gmfn_to_mfn(d, gmfn); + uint8_t *p; + + /* + * We don't support the APIC assist page, and that fact isreflected in
Quoted 1 line
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 static void enable_hypercall_page(void) · line 176
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * our CPUID flags. However, Newer versions of Windows havea
Quoted 2 lines
Quoted 2 lines
bug which
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ * means that they don't recognise that, and tries to usethe
Quoted 7 lines
Quoted 7 lines
page
Quoted 6 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ * anyway. We therefore have to fake up just enough to keep + windowshappy.
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +3
-0+ * + * See + http://msdn.microsoft.com/en-us/library/ff538657%28VS.85%29.aspx
Quoted 55 lines
Quoted 55 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 6 lines
for
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0+ * details of how Windows uses the page. + */ + + if ( !mfn_valid(mfn) || + !get_page_and_type(mfn_to_page(mfn), d,
PGT_writable_page) )xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0+ { + gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n",gmfn, mfn);
Quoted 45 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +15
-14+ return; + } + + p = map_domain_page(mfn); + + *(u32 *)p = 0; + + unmap_domain_page(p); + + put_page_and_type(mfn_to_page(mfn)); +} + int wrmsr_viridian_regs(uint32_t idx, uint64_t val) { - struct domain *d = current->domain; + struct vcpu *v = current; + struct domain *d = v->domain; if ( !is_viridian_domain(d) ) return 0;@@ -142,44 +210,29 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_wrmsr_osid); d->arch.hvm_domain.viridian.guest_os_id.raw = val; - gdprintk(XENLOG_INFO, "Guest os:\n"); - gdprintk(XENLOG_INFO, "\tvendor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.vendor); - gdprintk(XENLOG_INFO, "\tos: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.os); - gdprintk(XENLOG_INFO, "\tmajor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.major); - gdprintk(XENLOG_INFO, "\tminor: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.minor); - gdprintk(XENLOG_INFO, "\tsp: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.service_pack); - gdprintk(XENLOG_INFO, "\tbuild: %x\n", - d- arch.hvm_domain.viridian.guest_os_id.fields.build_number); + dump_guest_os_id(d); break;Quoted 3 lines
Quoted 3 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 168
Quoted 3 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-1case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_wrmsr_hc_page); - gdprintk(XENLOG_INFO, "Set hypercall page%"PRIx64".\n",
Quoted 11 lines
Quoted 11 lines
val);
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-3- if ( d->arch.hvm_domain.viridian.guest_os_id.raw == 0 ) - break; d->arch.hvm_domain.viridian.hypercall_gpa.raw = val; + dump_hypercall(d); if ( d- arch.hvm_domain.viridian.hypercall_gpa.fields.enabled ) - enable_hypercall_page(); + enable_hypercall_page(d); break;Quoted 3 lines
Quoted 3 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 179
Quoted 3 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-1case VIRIDIAN_MSR_VP_INDEX: perfc_incr(mshv_wrmsr_vp_index); - gdprintk(XENLOG_INFO, "Set VP index %"PRIu64".\n",val);
Quoted 38 lines
Quoted 38 lines
Quoted 16 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-1break; case VIRIDIAN_MSR_EOI: perfc_incr(mshv_wrmsr_eoi); - vlapic_EOI_set(vcpu_vlapic(current)); + vlapic_EOI_set(vcpu_vlapic(v)); break;case VIRIDIAN_MSR_ICR: { u32 eax = (u32)val, edx = (u32)(val >> 32);xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-1- struct vlapic *vlapic = vcpu_vlapic(current); + struct vlapic *vlapic = vcpu_vlapic(v); perfc_incr(mshv_wrmsr_icr); eax &= ~(1 << 12); edx &= 0xff000000;xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 194
Quoted 4 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-1@@ -191,31 +244,15 @@ int wrmsr_viridian_regs(uint32_t idx, ui case VIRIDIAN_MSR_TPR: perfc_incr(mshv_wrmsr_tpr); - vlapic_set_reg(vcpu_vlapic(current), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 247
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ vlapic_set_reg(vcpu_vlapic(v), APIC_TASKPRI,(uint8_t)val);
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui · line 199
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-2break; case VIRIDIAN_MSR_APIC_ASSIST: - /* - * We don't support the APIC assist page, and that factis reflected
Quoted 2 lines
in
- * our CPUID flags. However, Windows 7 build 7000 has abug which
Quoted 2 lines
means
- * that it doesn't recognise that, and tries to use thepage anyway.
Quoted 2 lines
We
- * therefore have to fake up just enough to keep win7happy.
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
- * Fortunately, that's really easy: just setting the
first four bytes
Quoted 1 line
- * in the page to zero effectively disables the page
again, so that's
Quoted 1 line
- * what we do. Semantically, the first four bytes are
supposed to be
Quoted 2 lines
a
- * flag saying whether the guest really needs to issuean
Quoted 3 lines
Quoted 3 lines
EOI.
Quoted 2 lines
Setting
- * that flag to zero means that it must always issueone,
Quoted 6 lines
Quoted 6 lines
which is
Quoted 2 lines
what
- * we want. Once a page has been repurposed as an APICassist page
Quoted 2 lines
the
- * guest isn't allowed to set anything in it, so theflag
Quoted 67 lines
Quoted 4 lines
remains
Quoted 2 lines
zero
- * and all is fine. The guest is allowed to clear flagsin the page,
Quoted 13 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100
Quoted 7 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-7- * but that doesn't cause us any problems. - */ - if ( val & 1 ) /* APIC assist page enabled? */ - { - uint32_t word = 0; - paddr_t page_start = val & ~1ul; - (void)hvm_copy_to_guest_phys(page_start, &word,sizeof(word));
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +4
-1- } + perfc_incr(mshv_wrmsr_apic_msr); + v->arch.hvm_vcpu.viridian.apic_assist.raw = val; + dump_apic_assist(v); + if (v-arch.hvm_vcpu.viridian.apic_assist.fields.enabled)
Quoted 49 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 int wrmsr_viridian_regs(uint32_t idx, ui
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0+ initialize_apic_assist(v); break; default:@@ -228,20 +265,21 @@ int wrmsr_viridian_regs(uint32_t idx, uiint
Quoted 37 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +4
-3rdmsr_viridian_regs(uint32_t idx, uint64_t *val) { struct vcpu *v = current; + struct domain *d = v->domain; - if ( !is_viridian_domain(v->domain) ) + if ( !is_viridian_domain(d) ) return 0; switch ( idx ) { case VIRIDIAN_MSR_GUEST_OS_ID: perfc_incr(mshv_rdmsr_osid); - *val = v->domain- arch.hvm_domain.viridian.guest_os_id.raw; + *val = d->arch.hvm_domain.viridian.guest_os_id.raw; break; case VIRIDIAN_MSR_HYPERCALL: perfc_incr(mshv_rdmsr_hc_page); - *val = v->domain- arch.hvm_domain.viridian.hypercall_gpa.raw; + *val = d->arch.hvm_domain.viridian.hypercall_gpa.raw; break;case
VIRIDIAN_MSR_VP_INDEX:xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +5
-0@@ -260,6 +298,11 @@ int rdmsr_viridian_regs(uint32_t idx, ui *val = vlapic_get_reg(vcpu_vlapic(v), APIC_TASKPRI); break; + case VIRIDIAN_MSR_APIC_ASSIST: + perfc_incr(mshv_rdmsr_apic_msr); + *val = v->arch.hvm_vcpu.viridian.apic_assist.raw; + break; + default: return 0; }Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/hvm/vcpu.hQuoted 1 line
---
a/xen/include/asm-x86/hvm/vcpu.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/hvm/vcpu.hThu Sep 15 06:11:01 2011+0100
Quoted 10 lines
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 struct hvm_vcpu { · line 164
Quoted 10 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -23,6 +23,7 @@ #include <xen/tasklet.h> #include <asm/hvm/io.h> #include <asm/hvm/vlapic.h> +#include <asm/hvm/viridian.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/svm/vmcb.h>@@ -163,6 +164,8 @@ struct hvm_vcpu { int inject_trap; /* -1 for nothing toinject
Quoted 10 lines
Quoted 10 lines
*/
Quoted 9 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +2
-0int inject_error_code; unsigned long inject_cr2; + + struct viridian_vcpu viridian; }; #endif /* __ASM_X86_HVM_VCPU_H__ */ diff -r e90438f6e6d1 -r
a08073c5cf28xen/include/asm-x86/hvm/viridian.h---a/xen/include/asm-x86/hvm/viridian.hWed Sep 14 11:38:132011
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
+0100
+++b/xen/include/asm-x86/hvm/viridian.hThu Sep 15 06:11:012011
Quoted 55 lines
Quoted 54 lines
Quoted 22 lines
+++ +0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +14
-0@@ -9,6 +9,21 @@ #ifndef __ASM_X86_HVM_VIRIDIAN_H__ #define __ASM_X86_HVM_VIRIDIAN_H__ +union viridian_apic_assist +{ uint64_t raw; + struct + { + uint64_t enabled:1; + uint64_t reserved_preserved:11; + uint64_t pfn:48; + } fields; +}; + +struct viridian_vcpu +{ + union viridian_apic_assist apic_assist; }; + union viridian_guest_os_id { uint64_t raw;Quoted 1 line
diff -r
e90438f6e6d1-ra08073c5cf28xen/include/asm-
x86/perfc_defn.hQuoted 1 line
---
a/xen/include/asm-x86/perfc_defn.hWed Sep 14 11:38:13 2011+0100
Quoted 1 line
+++
b/xen/include/asm-x86/perfc_defn.hThu Sep 15 06:11:01 2011+0100
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 123
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0@@ -120,12 +120,14 @@ PERFCOUNTER(mshv_rdmsr_hc_page, PERFCOUNTER(mshv_rdmsr_vp_index, "MS Hv rdmsr vp index") PERFCOUNTER(mshv_rdmsr_icr, "MS Hv rdmsr icr") PERFCOUNTER(mshv_rdmsr_tpr, "MS Hv rdmsr tpr") +PERFCOUNTER(mshv_rdmsr_apic_assist, "MS Hv rdmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 124
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_osid, "MS Hv wrmsr Guest OSID")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 125
Quoted 1 line
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(mshv_wrmsr_hc_page, "MS Hv wrmsr hypercallpage")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 130
Quoted 5 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +1
-0PERFCOUNTER(mshv_wrmsr_vp_index, "MS Hv wrmsr vp index") PERFCOUNTER(mshv_wrmsr_icr, "MS Hv wrmsr icr") PERFCOUNTER(mshv_wrmsr_tpr, "MS Hv wrmsr tpr") PERFCOUNTER(mshv_wrmsr_eoi, "MS Hv wrmsr eoi") +PERFCOUNTER(mshv_wrmsr_apic_assist, "MS Hv wrmsr APICassist")
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 PERFCOUNTER(mshv_rdmsr_hc_page, · line 131
Quoted 2 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_emulations, "realmode instructionsemulated")
Quoted 6 lines
xen/arch/x86/hvm/viridian.c Thu Sep 15 06:11:01 2011 +0100 renamed from xen/arch/x86/hvm/viridian.c Wed Sep 14 11:38:13 2011 +0100 +0
-0PERFCOUNTER(realmode_exits, "vmexits from realmode")_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel