x86: EPT/MTRR interaction adjustments and cleanup
cover x86: EPT/MTRR interaction adjustments and cleanup
1: x86/hvm: refine the judgment on IDENT_PT for EMT
2: x86/HVM: fix memory type merging in epte_get_entry_emt() 3: x86/HVM: consolidate passthrough handling in epte_get_entry_emt() 4: x86/HVM: use manifest constants / enumerators for memory types 5: x86/HVM: adjust data definitions in mtrr.c
With this series in place (or actually the first three patches thereof, as the rest is cleanup), apart from the need to fully drop the dependency on HVM_PARAM_IDENT_PT (see the discussion started
at http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg02150.html)
the other main question is whether the dependency on iommu_snoop is really correct: I don't see why the IOMMU's snooping capability would affect the cachability of memory accesses - especially in the GPU passthrough case, RAM pages may need mapping as UC/WC
if the GPU is permitted direct access to them - uniformly using WB here seems to be calling for problems.
PATCH 1/5 x86/hvm: refine the judgment on IDENT_PT for EMT
When trying to get the EPT EMT type, the judgment on HVM_PARAM_IDENT_PT is not correct which always returns WB type if the parameter is not set. Remove the related code.
We can't fully drop the dependency yet, but we should certainly avoid overriding cases already properly handled. The reason for this is that the guest setting up its MTRRs happens _after_ the EPT tables got already constructed, and no code is in place to propagate this to the EPT code. Without this check we're forcing the guest to run with all of its memory uncachable until something happens to re-write every single EPT entry. But of course this has to be just a temporary solution.
In the same spirit we should defer the "very early" (when the guest is still being constructed and has no vCPU yet) override to the last possible point.
xen/arch/x86/hvm/mtrr.c +4 -8
@@ -689,13 +689,8 @@ uint8_t epte_get_entry_emt(struct domain *ipat =0 ; -if ( (current->domain != d) && - ((d->vcpu ==NULL ) || ((v = d->vcpu[0 ]) ==NULL )) ) -return MTRR_TYPE_WRBACK ; - -if ( !is_pvh_vcpu (v) && - !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ) -return MTRR_TYPE_WRBACK ; +if ( v->domain != d ) + v = d->vcpu ? d->vcpu[0 ] :NULL ;if ( !mfn_valid (mfn_x (mfn)) )return MTRR_TYPE_UNCACHABLE ;
@@ -718,7 +713,8 @@ uint8_t epte_get_entry_emt(struct domainreturn MTRR_TYPE_WRBACK ; } - gmtrr_mtype =is_hvm_vcpu (v) ? + gmtrr_mtype =is_hvm_domain (d) && v && + d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ?get_mtrr_type (&v->arch.hvm_vcpu.mtrr, (gfn <<PAGE_SHIFT )) :MTRR_TYPE_WRBACK ;
x86/hvm: refine the judgment on IDENT_PT for EMT
When trying to get the EPT EMT type, the judgment on HVM_PARAM_IDENT_PT is not correct which always returns WB type if the parameter is not set. Remove the related code.
We can't fully drop the dependency yet, but we should certainly avoid overriding cases already properly handled. The reason for this is that the guest setting up its MTRRs happens _after_ the EPT tables got already constructed, and no code is in place to propagate this to the EPT code. Without this check we're forcing the guest to run with all of its memory uncachable until something happens to re-write every single EPT entry. But of course this has to be just a temporary solution.
In the same spirit we should defer the "very early" (when the guest is still being constructed and has no vCPU yet) override to the last possible point.
xen/arch/x86/hvm/mtrr.c +4 -8
@@ -689,13 +689,8 @@ uint8_t epte_get_entry_emt(struct domain *ipat =0 ; -if ( (current->domain != d) && - ((d->vcpu ==NULL ) || ((v = d->vcpu[0 ]) ==NULL )) ) -return MTRR_TYPE_WRBACK ; - -if ( !is_pvh_vcpu (v) && - !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ) -return MTRR_TYPE_WRBACK ; +if ( v->domain != d ) + v = d->vcpu ? d->vcpu[0 ] :NULL ;if ( !mfn_valid (mfn_x (mfn)) )return MTRR_TYPE_UNCACHABLE ;
@@ -718,7 +713,8 @@ uint8_t epte_get_entry_emt(struct domainreturn MTRR_TYPE_WRBACK ; } - gmtrr_mtype =is_hvm_vcpu (v) ? + gmtrr_mtype =is_hvm_domain (d) && v && + d->arch.hvm_domain.params[HVM_PARAM_IDENT_PT ] ?get_mtrr_type (&v->arch.hvm_vcpu.mtrr, (gfn <<PAGE_SHIFT )) :MTRR_TYPE_WRBACK ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 2/5 x86/HVM: fix memory type merging in epte_get_entry_emt()
In reply to Jan BeulichUsing the minimum numeric value of guest and host specified memory types is too simplistic - it works only correctly for a subset of types. It is in particular the WT/WP combination that needs conversion to UC if the two types conflict.
xen/arch/x86/hvm/mtrr.c +31 -1
@@ -719,5 +719,35 @@ uint8_t epte_get_entry_emt(struct domainMTRR_TYPE_WRBACK ; hmtrr_mtype =get_mtrr_type (&mtrr_state, (mfn_x (mfn) <<PAGE_SHIFT )); -return ((gmtrr_mtype <= hmtrr_mtype) ? gmtrr_mtype : hmtrr_mtype); + +/* If both types match we're fine. */ +if (likely (gmtrr_mtype == hmtrr_mtype) ) +return hmtrr_mtype; + +/* If either type is UC, we have to go with that one. */ +if ( gmtrr_mtype ==MTRR_TYPE_UNCACHABLE || + hmtrr_mtype ==MTRR_TYPE_UNCACHABLE ) +return MTRR_TYPE_UNCACHABLE ; + +/* If either type is WB, we have to go with the other one. */ +if ( gmtrr_mtype ==MTRR_TYPE_WRBACK ) +return hmtrr_mtype; +if ( hmtrr_mtype ==MTRR_TYPE_WRBACK ) +return gmtrr_mtype; + +/* +* At this point we have disagreeing WC, WT, or WP types. The only +* combination that can be cleanly resolved is WT:WP. The ones involving +* WC need to be converted to UC, both due to the memory ordering +* differences and because WC disallows reads to be cached (WT and WP +* permit this), while WT and WP require writes to go straight to memory +* (WC can buffer them). +*/ +if ( (gmtrr_mtype ==MTRR_TYPE_WRTHROUGH && + hmtrr_mtype ==MTRR_TYPE_WRPROT ) || + (gmtrr_mtype ==MTRR_TYPE_WRPROT && + hmtrr_mtype ==MTRR_TYPE_WRTHROUGH ) ) +return MTRR_TYPE_WRPROT ; + +return MTRR_TYPE_UNCACHABLE ; }
PATCH 3/5 x86/HVM: consolidate passthrough handling in epte_get_entry_emt()
In reply to Jan BeulichIt is inconsistent to depend on iommu_enabled alone: For a guest without devices passed through to it, it is of no concern whether the IOMMU is enabled.
There's one rather special case to take care of: VMX code marks the LAPIC access page as MMIO. The added assertion needs to take this into consideration, and the subsequent handling of the direct MMIO case was inconsistent too: That page would have been WB in the absence of an IOMMU, but UC in the presence of it, while in fact the cachabilty of this page is entirely unrelated to an IOMMU being in use.
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2090,9 +2090,9 @@ static int vmx_alloc_vlapic_mapping(struif ( apic_va ==NULL )return -ENOMEM ;share_xen_page_with_guest (virt_to_page (apic_va), d, XENSHARE_writable); + d->arch.hvm_domain.vmx.apic_access_mfn =virt_to_mfn (apic_va);set_mmio_p2m_entry (d,paddr_to_pfn (APIC_DEFAULT_PHYS_BASE ),_mfn (virt_to_mfn (apic_va))); - d->arch.hvm_domain.vmx.apic_access_mfn =virt_to_mfn (apic_va);return 0 ; }
xen/arch/x86/hvm/mtrr.c +8 -2
@@ -698,14 +698,20 @@ uint8_t epte_get_entry_emt(struct domainif (hvm_get_mem_pinned_cacheattr (d, gfn, &type) )return type; -if ( !iommu_enabled ) +if ( !iommu_enabled || + (rangeset_is_empty (d->iomem_caps) && +rangeset_is_empty (d->arch.ioport_caps) && + !has_arch_pdevs (d)) ) { +ASSERT (!direct_mmio || +mfn_x (mfn) == d->arch.hvm_domain.vmx.apic_access_mfn); *ipat =1 ;return MTRR_TYPE_WRBACK ; }if ( direct_mmio ) -return MTRR_TYPE_UNCACHABLE ; +return mfn_x (mfn) != d->arch.hvm_domain.vmx.apic_access_mfn + ?MTRR_TYPE_UNCACHABLE :MTRR_TYPE_WRBACK ;if ( iommu_snoop ) {
x86/HVM: consolidate passthrough handling in epte_get_entry_emt()
It is inconsistent to depend on iommu_enabled alone: For a guest without devices passed through to it, it is of no concern whether the IOMMU is enabled.
There's one rather special case to take care of: VMX code marks the LAPIC access page as MMIO. The added assertion needs to take this into consideration, and the subsequent handling of the direct MMIO case was inconsistent too: That page would have been WB in the absence of an IOMMU, but UC in the presence of it, while in fact the cachabilty of this page is entirely unrelated to an IOMMU being in use.
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -2090,9 +2090,9 @@ static int vmx_alloc_vlapic_mapping(struif ( apic_va ==NULL )return -ENOMEM ;share_xen_page_with_guest (virt_to_page (apic_va), d, XENSHARE_writable); + d->arch.hvm_domain.vmx.apic_access_mfn =virt_to_mfn (apic_va);set_mmio_p2m_entry (d,paddr_to_pfn (APIC_DEFAULT_PHYS_BASE ),_mfn (virt_to_mfn (apic_va))); - d->arch.hvm_domain.vmx.apic_access_mfn =virt_to_mfn (apic_va);return 0 ; }
xen/arch/x86/hvm/mtrr.c +8 -2
@@ -698,14 +698,20 @@ uint8_t epte_get_entry_emt(struct domainif (hvm_get_mem_pinned_cacheattr (d, gfn, &type) )return type; -if ( !iommu_enabled ) +if ( !iommu_enabled || + (rangeset_is_empty (d->iomem_caps) && +rangeset_is_empty (d->arch.ioport_caps) && + !has_arch_pdevs (d)) ) { +ASSERT (!direct_mmio || +mfn_x (mfn) == d->arch.hvm_domain.vmx.apic_access_mfn); *ipat =1 ;return MTRR_TYPE_WRBACK ; }if ( direct_mmio ) -return MTRR_TYPE_UNCACHABLE ; +return mfn_x (mfn) != d->arch.hvm_domain.vmx.apic_access_mfn + ?MTRR_TYPE_UNCACHABLE :MTRR_TYPE_WRBACK ;if ( iommu_snoop ) {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 4/5 x86/HVM: use manifest constants / enumerators for memory types
In reply to Jan Beulich... instead of literal numbers, thus making it possible for the reader to understand the code without having to look up the meaning of these numbers.
xen/arch/x86/hvm/hvm.c +10 -3
@@ -235,9 +235,16 @@ int hvm_set_guest_pat(struct vcpu *v, u6uint8_t *value = (uint8_t *)&guest_pat;for ( i =0 ; i <8 ; i++ ) -if (unlikely (!(value[i] ==0 || value[i] ==1 || - value[i] ==4 || value[i] ==5 || - value[i] ==6 || value[i] ==7 )) ) { +switch ( value[i] ) + { +case PAT_TYPE_UC_MINUS : +case PAT_TYPE_UNCACHABLE : +case PAT_TYPE_WRBACK : +case PAT_TYPE_WRCOMB : +case PAT_TYPE_WRPROT : +case PAT_TYPE_WRTHROUGH : +break ; +default :HVM_DBG_LOG (DBG_LEVEL_MSR ,"invalid guest PAT: %" PRIx64"\n" , guest_pat);return 0 ;
xen/arch/x86/hvm/mtrr.c +41 -28
107 lines not on this page · raw message
xen/include/asm-x86/mtrr.h +0 -1
@@ -20,7 +20,6 @@enum {PAT_TYPE_UNCACHABLE =0 ,PAT_TYPE_WRCOMB =1 , -PAT_TYPE_RESERVED =2 ,PAT_TYPE_WRTHROUGH =4 ,PAT_TYPE_WRPROT =5 ,PAT_TYPE_WRBACK =6 ,
x86/HVM: use manifest constants / enumerators for memory types
... instead of literal numbers, thus making it possible for the reader to understand the code without having to look up the meaning of these numbers.
xen/arch/x86/hvm/hvm.c +10 -3
@@ -235,9 +235,16 @@ int hvm_set_guest_pat(struct vcpu *v, u6uint8_t *value = (uint8_t *)&guest_pat;for ( i =0 ; i <8 ; i++ ) -if (unlikely (!(value[i] ==0 || value[i] ==1 || - value[i] ==4 || value[i] ==5 || - value[i] ==6 || value[i] ==7 )) ) { +switch ( value[i] ) + { +case PAT_TYPE_UC_MINUS : +case PAT_TYPE_UNCACHABLE : +case PAT_TYPE_WRBACK : +case PAT_TYPE_WRCOMB : +case PAT_TYPE_WRPROT : +case PAT_TYPE_WRTHROUGH : +break ; +default :HVM_DBG_LOG (DBG_LEVEL_MSR ,"invalid guest PAT: %" PRIx64"\n" , guest_pat);return 0 ;
xen/arch/x86/hvm/mtrr.c +41 -28
107 lines not on this page · raw message
xen/include/asm-x86/mtrr.h +0 -1
@@ -20,7 +20,6 @@enum {PAT_TYPE_UNCACHABLE =0 ,PAT_TYPE_WRCOMB =1 , -PAT_TYPE_RESERVED =2 ,PAT_TYPE_WRTHROUGH =4 ,PAT_TYPE_WRPROT =5 ,PAT_TYPE_WRBACK =6 ,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 4/5 x86/HVM: use manifest constants / enumerators for memory types
... instead of literal numbers, thus making it possible for the reader to understand the code without having to look up the meaning of these numbers.
---
v2: Spotted two more cases (in get_mtrr_type()).
xen/arch/x86/hvm/hvm.c +10 -3
@@ -235,9 +235,16 @@ int hvm_set_guest_pat(struct vcpu *v, u6uint8_t *value = (uint8_t *)&guest_pat;for ( i =0 ; i <8 ; i++ ) -if (unlikely (!(value[i] ==0 || value[i] ==1 || - value[i] ==4 || value[i] ==5 || - value[i] ==6 || value[i] ==7 )) ) { +switch ( value[i] ) + { +case PAT_TYPE_UC_MINUS : +case PAT_TYPE_UNCACHABLE : +case PAT_TYPE_WRBACK : +case PAT_TYPE_WRCOMB : +case PAT_TYPE_WRPROT : +case PAT_TYPE_WRTHROUGH : +break ; +default :HVM_DBG_LOG (DBG_LEVEL_MSR ,"invalid guest PAT: %" PRIx64"\n" , guest_pat);return 0 ;
xen/arch/x86/hvm/mtrr.c +44 -30
121 lines not on this page · raw message
xen/include/asm-x86/mtrr.h +0 -1
@@ -20,7 +20,6 @@enum {PAT_TYPE_UNCACHABLE =0 ,PAT_TYPE_WRCOMB =1 , -PAT_TYPE_RESERVED =2 ,PAT_TYPE_WRTHROUGH =4 ,PAT_TYPE_WRPROT =5 ,PAT_TYPE_WRBACK =6 ,
x86/HVM: use manifest constants / enumerators for memory types
... instead of literal numbers, thus making it possible for the reader to understand the code without having to look up the meaning of these numbers.
---
v2: Spotted two more cases (in get_mtrr_type()).
xen/arch/x86/hvm/hvm.c +10 -3
@@ -235,9 +235,16 @@ int hvm_set_guest_pat(struct vcpu *v, u6uint8_t *value = (uint8_t *)&guest_pat;for ( i =0 ; i <8 ; i++ ) -if (unlikely (!(value[i] ==0 || value[i] ==1 || - value[i] ==4 || value[i] ==5 || - value[i] ==6 || value[i] ==7 )) ) { +switch ( value[i] ) + { +case PAT_TYPE_UC_MINUS : +case PAT_TYPE_UNCACHABLE : +case PAT_TYPE_WRBACK : +case PAT_TYPE_WRCOMB : +case PAT_TYPE_WRPROT : +case PAT_TYPE_WRTHROUGH : +break ; +default :HVM_DBG_LOG (DBG_LEVEL_MSR ,"invalid guest PAT: %" PRIx64"\n" , guest_pat);return 0 ;
xen/arch/x86/hvm/mtrr.c +44 -30
121 lines not on this page · raw message
xen/include/asm-x86/mtrr.h +0 -1
@@ -20,7 +20,6 @@enum {PAT_TYPE_UNCACHABLE =0 ,PAT_TYPE_WRCOMB =1 , -PAT_TYPE_RESERVED =2 ,PAT_TYPE_WRTHROUGH =4 ,PAT_TYPE_WRPROT =5 ,PAT_TYPE_WRBACK =6 ,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 5/5 x86/HVM: adjust data definitions in mtrr.c
In reply to Jan Beulich- use proper section attributes
- use initializers where possible
- clean up pat_type_2_pte_flags()
xen/arch/x86/hvm/mtrr.c +17 -15
@@ -70,10 +70,14 @@ static const uint8_t mm_type_tbl[MTRR_NU* Reverse lookup table, to find a pat type according to MTRR and effective * memory type. This table is dynamically generated. */ -static uint8_t mtrr_epat_tbl[MTRR_NUM_TYPES ][MEMORY_NUM_TYPES ]; +static uint8_t __read_mostly mtrr_epat_tbl[MTRR_NUM_TYPES ][MEMORY_NUM_TYPES ] = + { [0 ...MTRR_NUM_TYPES -1 ] = + { [0 ...MEMORY_NUM_TYPES -1 ] =INVALID_MEM_TYPE } + };/* Lookup table for PAT entry of a given PAT value in host PAT. */ -static uint8_t pat_entry_tbl[PAT_TYPE_NUMS ]; +static uint8_t __read_mostly pat_entry_tbl[PAT_TYPE_NUMS ] = + { [0 ...PAT_TYPE_NUMS -1 ] =INVALID_MEM_TYPE };static void get_mtrr_range (uint64_t base_msr,uint64_t mask_msr,uint64_t *base,uint64_t *end)
@@ -149,23 +153,21 @@ bool_t is_var_mtrr_overlapped(struct mtr#define MTRRphysBase_MSR (reg) (0x200 + 2 * (reg))#define MTRRphysMask_MSR (reg) (0x200 + 2 * (reg) + 1) -static int hvm_mtrr_pat_init (void ) +static int __init hvm_mtrr_pat_init (void ) {unsigned int i, j, phys_addr; -memset (&mtrr_epat_tbl,INVALID_MEM_TYPE ,sizeof (mtrr_epat_tbl));for ( i =0 ; i <MTRR_NUM_TYPES ; i++ ) {for ( j =0 ; j <PAT_TYPE_NUMS ; j++ ) { -int32_t tmp = mm_type_tbl[i][j]; -if ( (tmp >=0 ) && (tmp <MEMORY_NUM_TYPES ) ) +unsigned int tmp = mm_type_tbl[i][j]; + +if ( tmp <MEMORY_NUM_TYPES ) mtrr_epat_tbl[i][tmp] = j; } } -memset (&pat_entry_tbl,INVALID_MEM_TYPE , -PAT_TYPE_NUMS *sizeof (pat_entry_tbl[0 ]));for ( i =0 ; i <PAT_TYPE_NUMS ; i++ ) {for ( j =0 ; j <PAT_TYPE_NUMS ; j++ )
@@ -190,16 +192,16 @@ __initcall(hvm_mtrr_pat_init);uint8_t pat_type_2_pte_flags (uint8_t pat_type) { -int32_t pat_entry = pat_entry_tbl[pat_type]; +unsigned int pat_entry = pat_entry_tbl[pat_type]; -/* INVALID_MEM_TYPE, means doesn't find the pat_entry in host pat for -* a given pat_type. If host pat covers all the pat types, -* it can't happen. +/* +* INVALID_MEM_TYPE, means doesn't find the pat_entry in host PAT for a +* given pat_type. If host PAT covers all the PAT types, it can't happen. */ -if (likely (pat_entry !=INVALID_MEM_TYPE ) ) -return pat_entry_2_pte_flags[pat_entry]; +if (unlikely (pat_entry ==INVALID_MEM_TYPE ) ) + pat_entry = pat_entry_tbl[PAT_TYPE_UNCACHABLE ]; -return pat_entry_2_pte_flags[pat_entry_tbl[PAT_TYPE_UNCACHABLE ]]; +return pat_entry_2_pte_flags[pat_entry]; }int hvm_vcpu_cacheattr_init (struct vcpu *v)
x86/HVM: adjust data definitions in mtrr.c
- use proper section attributes
- use initializers where possible
- clean up pat_type_2_pte_flags()
xen/arch/x86/hvm/mtrr.c +17 -15
@@ -70,10 +70,14 @@ static const uint8_t mm_type_tbl[MTRR_NU* Reverse lookup table, to find a pat type according to MTRR and effective * memory type. This table is dynamically generated. */ -static uint8_t mtrr_epat_tbl[MTRR_NUM_TYPES ][MEMORY_NUM_TYPES ]; +static uint8_t __read_mostly mtrr_epat_tbl[MTRR_NUM_TYPES ][MEMORY_NUM_TYPES ] = + { [0 ...MTRR_NUM_TYPES -1 ] = + { [0 ...MEMORY_NUM_TYPES -1 ] =INVALID_MEM_TYPE } + };/* Lookup table for PAT entry of a given PAT value in host PAT. */ -static uint8_t pat_entry_tbl[PAT_TYPE_NUMS ]; +static uint8_t __read_mostly pat_entry_tbl[PAT_TYPE_NUMS ] = + { [0 ...PAT_TYPE_NUMS -1 ] =INVALID_MEM_TYPE };static void get_mtrr_range (uint64_t base_msr,uint64_t mask_msr,uint64_t *base,uint64_t *end)
@@ -149,23 +153,21 @@ bool_t is_var_mtrr_overlapped(struct mtr#define MTRRphysBase_MSR (reg) (0x200 + 2 * (reg))#define MTRRphysMask_MSR (reg) (0x200 + 2 * (reg) + 1) -static int hvm_mtrr_pat_init (void ) +static int __init hvm_mtrr_pat_init (void ) {unsigned int i, j, phys_addr; -memset (&mtrr_epat_tbl,INVALID_MEM_TYPE ,sizeof (mtrr_epat_tbl));for ( i =0 ; i <MTRR_NUM_TYPES ; i++ ) {for ( j =0 ; j <PAT_TYPE_NUMS ; j++ ) { -int32_t tmp = mm_type_tbl[i][j]; -if ( (tmp >=0 ) && (tmp <MEMORY_NUM_TYPES ) ) +unsigned int tmp = mm_type_tbl[i][j]; + +if ( tmp <MEMORY_NUM_TYPES ) mtrr_epat_tbl[i][tmp] = j; } } -memset (&pat_entry_tbl,INVALID_MEM_TYPE , -PAT_TYPE_NUMS *sizeof (pat_entry_tbl[0 ]));for ( i =0 ; i <PAT_TYPE_NUMS ; i++ ) {for ( j =0 ; j <PAT_TYPE_NUMS ; j++ )
@@ -190,16 +192,16 @@ __initcall(hvm_mtrr_pat_init);uint8_t pat_type_2_pte_flags (uint8_t pat_type) { -int32_t pat_entry = pat_entry_tbl[pat_type]; +unsigned int pat_entry = pat_entry_tbl[pat_type]; -/* INVALID_MEM_TYPE, means doesn't find the pat_entry in host pat for -* a given pat_type. If host pat covers all the pat types, -* it can't happen. +/* +* INVALID_MEM_TYPE, means doesn't find the pat_entry in host PAT for a +* given pat_type. If host PAT covers all the PAT types, it can't happen. */ -if (likely (pat_entry !=INVALID_MEM_TYPE ) ) -return pat_entry_2_pte_flags[pat_entry]; +if (unlikely (pat_entry ==INVALID_MEM_TYPE ) ) + pat_entry = pat_entry_tbl[PAT_TYPE_UNCACHABLE ]; -return pat_entry_2_pte_flags[pat_entry_tbl[PAT_TYPE_UNCACHABLE ]]; +return pat_entry_2_pte_flags[pat_entry]; }int hvm_vcpu_cacheattr_init (struct vcpu *v)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, February 25, 2014 6:21 PM
To: xen-devel
Cc: Xu, Dongxiao; Dong, Eddie; Nakajima, Jun; Zhang, Yang Z; Keir Fraser
Subject: [PATCH 0/5] x86: EPT/MTRR interaction adjustments and cleanup
Quoted 5 lines
1: x86/hvm: refine the judgment on
IDENT_PTfor EMT
2: x86/HVM: fix memory type merging inepte_get_entry_emt()3: x86/HVM: consolidate passthrough handling inepte_get_entry_emt()4: x86/HVM: use manifest constants / enumerators for memory types 5: x86/HVM: adjust data definitions inmtrr.c
For 1-3 (related to logic change), they look good to me.
Thanks,
Dongxiao
Quoted 13 lines
With this series in place (or actually the first three patches thereof, as the rest is cleanup), apart from the need to fully drop the dependency on
HVM_PARAM_IDENT_PT(see the discussion started
at http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg02150.html)
the other main question is whether the dependency oniommu_snoopis really correct: I don't see why the IOMMU's snooping capability would affect the cachability of memory accesses - especially in the GPU passthrough case, RAM pages may need mapping as UC/WC
if the GPU is permitted direct access to them - uniformly using WB here seems to be calling for problems.Signed-off-by Jan Beulich <[email protected]>
Quoted 8 lines
Quoted 8 lines
Quoted 1 line · Dongxiao
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, February 25, 2014 6:21 PM
To: xen-devel
Cc: Xu, Dongxiao; Dong, Eddie; Nakajima, Jun; Zhang, Yang Z; Keir Fraser
Subject: [PATCH 0/5] x86: EPT/MTRR interaction adjustments and cleanup
Quoted 7 lines
Quoted 5 lines
1: x86/hvm: refine the judgment on
IDENT_PTfor EMT
2: x86/HVM: fix memory type merging inepte_get_entry_emt()3: x86/HVM: consolidate passthrough handling inepte_get_entry_emt()4: x86/HVM: use manifest constants / enumerators for memory types 5: x86/HVM: adjust data definitions inmtrr.cFor 1-3 (related to logic change), they look good to me.
Please be explicit here - I would _think_ that I can translate this to a Reviewed-by, but I'm not sure.
Further, with you commenting on 1-3 only, do you have any reservations towards 4 and/or 5?
Jan
Quoted 12 lines
Quoted 12 lines
With this series in place (or actually the first three patches thereof, as the rest is cleanup), apart from the need to fully drop the dependency on
HVM_PARAM_IDENT_PT(see the discussion started
at http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg02150.html)
the other main question is whether the dependency oniommu_snoopis really correct: I don't see why the IOMMU's snooping capability would affect the cachability of memory accesses - especially in the GPU passthrough case, RAM pages may need mapping as UC/WC
if the GPU is permitted direct access to them - uniformly using WB here seems to be calling for problems.Signed-off-by Jan Beulich <[email protected]>
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Jan Beulich
Sent: Tuesday, March 04, 2014 4:13 PM
To: Xu, Dongxiao
Cc: Zhang, Yang Z; xen-devel; KeirFraser; Dong, Eddie; Nakajima, Jun
Subject: Re: [Xen-devel] [PATCH 0/5] x86: EPT/MTRR interaction adjustments and cleanupQuoted 14 lines
Quoted 13 lines
Quoted 1 line · Dongxiao
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Tuesday, February 25, 2014 6:21 PM
To: xen-devel
Cc: Xu, Dongxiao; Dong, Eddie; Nakajima, Jun; Zhang, Yang Z; Keir Fraser
Subject: [PATCH 0/5] x86: EPT/MTRR interaction adjustments and cleanup1: x86/hvm: refine the judgment on
IDENT_PTfor EMT
2: x86/HVM: fix memory type merging inepte_get_entry_emt()3: x86/HVM: consolidate passthrough handling inepte_get_entry_emt()4: x86/HVM: use manifest constants / enumerators for memory types 5: x86/HVM: adjust data definitions inmtrr.c
Quoted 4 lines
Quoted 1 line
For 1-3 (related to logic change), they look good to me.
Please be explicit here - I would _think_ that I can translate this to a Reviewed-by, but I'm not sure.
Yes, sure.
Quoted 3 lines
Further, with you commenting on 1-3 only, do you have any reservations towards 4 and/or 5?
No reservations on 4 and 5. The two patches are mainly related to code clean up, thus I didn't review them in detail.
Thanks,
Dongxiao
Quoted 24 lines
Jan
Quoted 4 lines
Quoted 4 lines
With this series in place (or actually the first three patches thereof, as the rest is cleanup), apart from the need to fully drop the dependency on
HVM_PARAM_IDENT_PT(see the discussion started athttp://lists.xenproject.org/archives/html/xen-devel/2014-02/msg02150.html)
Quoted 8 lines
Quoted 8 lines
the other main question is whether the dependency on
iommu_snoopis really correct: I don't see why the IOMMU's snooping capability would affect the cachability of memory accesses - especially in the GPU passthrough case, RAM pages may need mapping as UC/WC if the GPU is permitted direct access to them - uniformly using WB here seems to be calling for problems.Signed-off-by Jan Beulich <[email protected]>_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 18 lines · Jan Beulich
1: x86/hvm: refine the judgment on
IDENT_PTfor EMT
2: x86/HVM: fix memory type merging inepte_get_entry_emt()3: x86/HVM: consolidate passthrough handling inepte_get_entry_emt()4: x86/HVM: use manifest constants / enumerators for memory types 5: x86/HVM: adjust data definitions inmtrr.cWith this series in place (or actually the first three patches thereof, as the rest is cleanup), apart from the need to fully drop the dependency on
HVM_PARAM_IDENT_PT(see the discussion started
at http://lists.xenproject.org/archives/html/xen-devel/2014-02/msg02150.html)
the other main question is whether the dependency oniommu_snoopis really correct: I don't see why the IOMMU's snooping capability would affect the cachability of memory accesses - especially in the GPU passthrough case, RAM pages may need mapping as UC/WC
if the GPU is permitted direct access to them - uniformly using WB here seems to be calling for problems.
Quoted 1 line
Signed-off-by Jan Beulich<[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel