x86/shadow: adjust cachability flags handling
RFC PATCH 1/1 x86/shadow: adjust cachability flags handling
For one, including _PAGE_PAT in the pass-through flags is valid only for L1 entries (otherwise _PAGE_PSE_PAT would need looking at). Looking around I _think_ that for page directories we'd always get a valid MFN passed in here, and hence I _think_ the assertion is correct.
And second we need to avoid or-ing guest PAT/PCD/PWT with ones coming from pat_type_2_pte_flags()/get_pat_flags(). An alternative to the pass_thru_flags check might be to use mfn_valid(target_mfn).
xen/arch/x86/mm/shadow/multi.c +4 -0
@@ -580,7 +580,10 @@ _sh_propagate(struct vcpu *v,if (guest_supports_nx (v) ) pass_thru_flags |= _PAGE_NX_BIT;if ( !shadow_mode_refcounts (d) && !mfn_valid (target_mfn) ) + { +ASSERT (level ==1 ); pass_thru_flags |= _PAGE_PAT | _PAGE_PCD | _PAGE_PWT; + } sflags = gflags & pass_thru_flags;/*
@@ -588,6 +591,7 @@ _sh_propagate(struct vcpu *v,* caching attributes in the shadows to match what was asked for. */ if ( (level ==1 ) &&is_hvm_domain (d) && + !(pass_thru_flags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) && !is_xen_heap_mfn (mfn_x (target_mfn)) ) {unsigned int type;
Quoted 12 lines · Jan Beulich
For one, including
_PAGE_PATin the pass-through flags is valid only for L1 entries (otherwise_PAGE_PSE_PATwould need looking at). Looking around I _think_ that for page directories we'd always get a valid MFN passed in here, and hence I _think_ the assertion is correct.And second we need to avoid or-ing guest PAT/PCD/PWT with ones coming from pat_type_2_pte_flags()/get_pat_flags(). An alternative to the
pass_thru_flagscheck might be to usemfn_valid(target_mfn).
xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 584
Quoted 5 lines
xen/arch/x86/mm/shadow/multi.c +2
-0@@ -580,7 +580,10 @@ _sh_propagate(struct vcpu *v,if (guest_supports_nx (v) ) pass_thru_flags |= _PAGE_NX_BIT;if ( !shadow_mode_refcounts (d) && !mfn_valid (target_mfn) ) + { +ASSERT (level ==1 );
Yes, this assertion is correct -- enforced by this block just above:
if ( !mfn_valid(target_mfn)
&& !(level == 1 && (!shadow_mode_refcounts(d)
|| p2mt == p2m_mmio_direct)) )
{
ASSERT((ft == ft_prefetch));
*sp = shadow_l1e_empty();
goto done;
}xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 594
Quoted 10 lines
xen/arch/x86/mm/shadow/multi.c +2
-0pass_thru_flags |= _PAGE_PAT | _PAGE_PCD | _PAGE_PWT; + } sflags = gflags & pass_thru_flags;/* @@ -588,6 +591,7 @@ _sh_propagate(struct vcpu *v,* caching attributes in the shadows to match what was asked for. */ if ( (level == 1) && is_hvm_domain(d) && + !(pass_thru_flags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) &&
I don't think this is necessary -- is_hvm_domain() implies shadow_mode_refcounts(), so we won't have set these flags in pass_thru_flags above.
If you want to make a change for clarity, I'd be happier with ASSERT(!(gflags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT))) here.
Cheers,
Tim.
Quoted 10 lines
xen/arch/x86/mm/shadow/multi.c +0
-0!is_xen_heap_mfn(mfn_x(target_mfn)) ) {unsigned int type;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 22 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 12 lines · Jan Beulich
For one, including
_PAGE_PATin the pass-through flags is valid only for L1 entries (otherwise_PAGE_PSE_PATwould need looking at). Looking around I _think_ that for page directories we'd always get a valid MFN passed in here, and hence I _think_ the assertion is correct.And second we need to avoid or-ing guest PAT/PCD/PWT with ones coming from pat_type_2_pte_flags()/get_pat_flags(). An alternative to the
pass_thru_flagscheck might be to usemfn_valid(target_mfn).xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 584
Quoted 5 lines
xen/arch/x86/mm/shadow/multi.c +2
-0@@ -580,7 +580,10 @@ _sh_propagate(struct vcpu *v,if (guest_supports_nx (v) ) pass_thru_flags |= _PAGE_NX_BIT;if ( !shadow_mode_refcounts (d) && !mfn_valid (target_mfn) ) + { +ASSERT (level ==1 );Yes, this assertion is correct -- enforced by this block just above:
Quoted 8 lines
if ( !mfn_valid(target_mfn)
&& !(level == 1 && (!shadow_mode_refcounts(d)
|| p2mt == p2m_mmio_direct)) )
{
ASSERT((ft == ft_prefetch));
*sp = shadow_l1e_empty();
goto done;
}I see. Question then is whether, together with the below, another assertion here is really worthwhile.
Quoted 15 lines
xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 594
Quoted 10 lines
xen/arch/x86/mm/shadow/multi.c +2
-0pass_thru_flags |= _PAGE_PAT | _PAGE_PCD | _PAGE_PWT; + } sflags = gflags & pass_thru_flags;/* @@ -588,6 +591,7 @@ _sh_propagate(struct vcpu *v,* caching attributes in the shadows to match what was asked for. */ if ( (level == 1) && is_hvm_domain(d) && + !(pass_thru_flags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) &&I don't think this is necessary --
is_hvm_domain()impliesshadow_mode_refcounts(), so we won't have set these flags inpass_thru_flagsabove.
Quoted 2 lines
If you want to make a change for clarity, I'd be happier with
ASSERT(!(gflags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)))here.
But I suppose you really meant to use sflags here; I think there's nothing wrong with gflags having any of these set.
Jan
Quoted 31 lines · Jan Beulich
Quoted 22 lines
Quoted 1 line
Quoted 1 line · Tim Deegan
Quoted 12 lines · Jan Beulich
For one, including
_PAGE_PATin the pass-through flags is valid only for L1 entries (otherwise_PAGE_PSE_PATwould need looking at). Looking around I _think_ that for page directories we'd always get a valid MFN passed in here, and hence I _think_ the assertion is correct.And second we need to avoid or-ing guest PAT/PCD/PWT with ones coming from pat_type_2_pte_flags()/get_pat_flags(). An alternative to the
pass_thru_flagscheck might be to usemfn_valid(target_mfn).xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 584
Quoted 5 lines
xen/arch/x86/mm/shadow/multi.c +2
-0@@ -580,7 +580,10 @@ _sh_propagate(struct vcpu *v,if (guest_supports_nx (v) ) pass_thru_flags |= _PAGE_NX_BIT;if ( !shadow_mode_refcounts (d) && !mfn_valid (target_mfn) ) + { +ASSERT (level ==1 );Yes, this assertion is correct -- enforced by this block just above:
Quoted 8 lines
if ( !mfn_valid(target_mfn) && !(level == 1 && (!shadow_mode_refcounts(d) || p2mt == p2m_mmio_direct)) ) { ASSERT((ft == ft_prefetch)); *sp = shadow_l1e_empty(); goto done; }
Quoted 2 lines
I see. Question then is whether, together with the below, another assertion here is really worthwhile.
I think the one below would be enough.
Quoted 15 lines
Quoted 15 lines
xen/arch/x86/mm/shadow/multi.c _sh_propagate(struct vcpu *v, · line 594
Quoted 10 lines
xen/arch/x86/mm/shadow/multi.c +2
-0pass_thru_flags |= _PAGE_PAT | _PAGE_PCD | _PAGE_PWT; + } sflags = gflags & pass_thru_flags;/* @@ -588,6 +591,7 @@ _sh_propagate(struct vcpu *v,* caching attributes in the shadows to match what was asked for. */ if ( (level == 1) && is_hvm_domain(d) && + !(pass_thru_flags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) &&I don't think this is necessary --
is_hvm_domain()impliesshadow_mode_refcounts(), so we won't have set these flags inpass_thru_flagsabove.
Quoted 4 lines
Quoted 2 lines
If you want to make a change for clarity, I'd be happier with
ASSERT(!(gflags & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)))here.But I suppose you really meant to use sflags here
Oops, yes I did.
Cheers,
Tim.