x86/HVM: get_pat_flags() is needed only by shadow code
PATCH 1/1 x86/HVM: get_pat_flags() is needed only by shadow code
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid leaving around unreachable/dead code.
xen/arch/x86/hvm/mtrr.c +4 -0
@@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_statreturn overlap_mtrr_pos; } +#ifdef CONFIG_SHADOW_PAGING +/* * return the memory type from PAT. * NOTE: valid only when paging is enabled.
@@ -359,6 +361,8 @@ uint32_t get_pat_flags(struct vcpu *v,return pat_type_2_pte_flags (pat_entry_value); } +#endif /* CONFIG_SHADOW_PAGING */ +static inline bool valid_mtrr_type (uint8_t type) { switch ( type )
Quoted 4 lines · Jan Beulich
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid leaving around unreachable/dead code.
Signed-off-by Jan Beulich <[email protected]>
Quoted 4 lines · Jan Beulich
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid leaving around unreachable/dead code.
Signed-off-by Jan Beulich <[email protected]>
I was going to suggest moving this to shadow specific code, but I see it accesses some static variables or macros defined in mtrr.c.
Thanks, Roger.
Quoted 17 lines · Jan Beulich
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid leaving around unreachable/dead code.
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/mtrr.c +2
-0@@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_statreturn overlap_mtrr_pos; } +#ifdef CONFIG_SHADOW_PAGING +/* * return the memory type from PAT. * NOTE: valid only when paging is enabled.
xen/arch/x86/hvm/mtrr.c uint32_t get_pat_flags(struct vcpu *v, · line 368
Quoted 8 lines
xen/arch/x86/hvm/mtrr.c +2
-0@@ -359,6 +361,8 @@ uint32_t get_pat_flags(struct vcpu *v,return pat_type_2_pte_flags (pat_entry_value); } +#endif /* CONFIG_SHADOW_PAGING */ +static inline bool valid_mtrr_type (uint8_t type) { switch ( type )
While I can see this is true, the fact it is indicates that we have bugs/problems elsewhere.
It is not only the shadow code that has to combine attributes like this, so we've either got opencoding elsewhere, or a bad abstraction.
(This is an observation, rather than a specific objection.)
~Andrew
Quoted 30 lines · Andrew Cooper
Quoted 17 lines · Jan Beulich
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid leaving around unreachable/dead code.
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/hvm/mtrr.c +2
-0@@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_statreturn overlap_mtrr_pos; } +#ifdef CONFIG_SHADOW_PAGING +/* * return the memory type from PAT. * NOTE: valid only when paging is enabled. xen/arch/x86/hvm/mtrr.c uint32_t get_pat_flags(struct vcpu *v, · line 368
Quoted 8 lines
xen/arch/x86/hvm/mtrr.c +2
-0@@ -359,6 +361,8 @@ uint32_t get_pat_flags(struct vcpu *v,return pat_type_2_pte_flags (pat_entry_value); } +#endif /* CONFIG_SHADOW_PAGING */ +static inline bool valid_mtrr_type (uint8_t type) { switch ( type )While I can see this is true, the fact it is indicates that we have bugs/problems elsewhere.
Quoted 4 lines
It is not only the shadow code that has to combine attributes like this, so we've either got opencoding elsewhere, or a bad abstraction.
(This is an observation, rather than a specific objection.)
Won't shadow always need a specific helper, in order to combine both MTRRs and guest PAT attributes, while HAP only needs to merge MTRR attributes?
Not that current code couldn't be better structured.
Thanks, Roger.