* [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code
@ 2024-07-18 10:10 Jan Beulich
2024-07-18 13:29 ` Jason Andryuk
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jan Beulich @ 2024-07-18 10:10 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org; +Cc: Andrew Cooper, Roger Pau Monné
Therefore with SHADOW_PAGING=n this is better compiled out, to avoid
leaving around unreachable/dead code.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_stat
return 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 )
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code
2024-07-18 10:10 [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code Jan Beulich
@ 2024-07-18 13:29 ` Jason Andryuk
2024-07-18 16:14 ` Roger Pau Monné
2024-07-18 17:06 ` Andrew Cooper
2 siblings, 0 replies; 5+ messages in thread
From: Jason Andryuk @ 2024-07-18 13:29 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Roger Pau Monné
On 2024-07-18 06:10, Jan Beulich wrote:
> Therefore with SHADOW_PAGING=n this is better compiled out, to avoid
> leaving around unreachable/dead code.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code
2024-07-18 10:10 [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code Jan Beulich
2024-07-18 13:29 ` Jason Andryuk
@ 2024-07-18 16:14 ` Roger Pau Monné
2024-07-18 17:06 ` Andrew Cooper
2 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monné @ 2024-07-18 16:14 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper
On Thu, Jul 18, 2024 at 12:10:00PM +0200, Jan Beulich wrote:
> Therefore with SHADOW_PAGING=n this is better compiled out, to avoid
> leaving around unreachable/dead code.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code
2024-07-18 10:10 [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code Jan Beulich
2024-07-18 13:29 ` Jason Andryuk
2024-07-18 16:14 ` Roger Pau Monné
@ 2024-07-18 17:06 ` Andrew Cooper
2024-07-19 7:12 ` Roger Pau Monné
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2024-07-18 17:06 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org; +Cc: Roger Pau Monné
On 18/07/2024 11:10 am, Jan Beulich wrote:
> Therefore with SHADOW_PAGING=n this is better compiled out, to avoid
> leaving around unreachable/dead code.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/hvm/mtrr.c
> +++ b/xen/arch/x86/hvm/mtrr.c
> @@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_stat
> return 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 )
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code
2024-07-18 17:06 ` Andrew Cooper
@ 2024-07-19 7:12 ` Roger Pau Monné
0 siblings, 0 replies; 5+ messages in thread
From: Roger Pau Monné @ 2024-07-19 7:12 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Jan Beulich, xen-devel@lists.xenproject.org
On Thu, Jul 18, 2024 at 06:06:54PM +0100, Andrew Cooper wrote:
> On 18/07/2024 11:10 am, Jan Beulich wrote:
> > Therefore with SHADOW_PAGING=n this is better compiled out, to avoid
> > leaving around unreachable/dead code.
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >
> > --- a/xen/arch/x86/hvm/mtrr.c
> > +++ b/xen/arch/x86/hvm/mtrr.c
> > @@ -271,6 +271,8 @@ int mtrr_get_type(const struct mtrr_stat
> > return 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 )
>
> 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.)
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-19 7:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-18 10:10 [PATCH] x86/HVM: get_pat_flags() is needed only by shadow code Jan Beulich
2024-07-18 13:29 ` Jason Andryuk
2024-07-18 16:14 ` Roger Pau Monné
2024-07-18 17:06 ` Andrew Cooper
2024-07-19 7:12 ` Roger Pau Monné
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.