xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] x86/hap: use the right cache attributes when MTRR is disabled
Date: Tue, 2 Aug 2016 13:25:53 +0200	[thread overview]
Message-ID: <20160802112553.jca42g57o4jsedrg@mac> (raw)
In-Reply-To: <579F8804020000780010167D@prv-mh.provo.novell.com>

On Mon, Aug 01, 2016 at 09:33:56AM -0600, Jan Beulich wrote:
> >>> On 26.07.16 at 18:15, <roger.pau@citrix.com> wrote:
> > --- a/xen/arch/x86/hvm/mtrr.c
> > +++ b/xen/arch/x86/hvm/mtrr.c
> > @@ -814,10 +814,17 @@ int epte_get_entry_emt(struct domain *d, unsigned long gfn, mfn_t mfn,
> >      if ( gmtrr_mtype == -EADDRNOTAVAIL )
> >          return -1;
> >  
> > -    gmtrr_mtype = is_hvm_domain(d) && v ?
> 
> Where did the is_hvm_domain() go? Let's not break PVHv1 just yet.

Hm, TBH I don't see why this is needed, AFAICT PVHv1 guests will never have 
MTRR enabled, so they will just go into the MTRR_TYPE_WRBACK case.

> > -                  get_mtrr_type(&v->arch.hvm_vcpu.mtrr,
> > -                                gfn << PAGE_SHIFT, order) :
> > -                  MTRR_TYPE_WRBACK;
> > +    if ( v && v->arch.hvm_vcpu.mtrr.enabled )
> > +        /* MTRR is enabled, use MTRR */
> > +        gmtrr_mtype = get_mtrr_type(&v->arch.hvm_vcpu.mtrr, gfn << PAGE_SHIFT,
> > +                                    order);
> > +    else if ( v && !hvm_paging_enabled(v) )
> > +        /* MTRR is not enabled and paging is disabled, force UC */
> > +        gmtrr_mtype = MTRR_TYPE_UNCACHABLE;
> > +    else
> > +        /* MTRR is not enabled and paging is enabled, use PAT */
> > +        gmtrr_mtype = MTRR_TYPE_WRBACK;
> 
> I think this would then better be
> 
>     if ( v )

Aren't all guests going to fall into this case, and thus MTRR_TYPE_WRBACK is 
going to be returned without even checking if the guest has MTRR enabled or 
not? Do you mean "if ( !v )" instead?

>         gmtrr_mtype = MTRR_TYPE_WRBACK;
>     else if ( v->arch.hvm_vcpu.mtrr.enabled )
>         /* MTRR is enabled, use MTRR */
>         gmtrr_mtype = get_mtrr_type(&v->arch.hvm_vcpu.mtrr, gfn << PAGE_SHIFT,
>                                     order);
>     else if ( !hvm_paging_enabled(v) )
>         /* MTRR is not enabled and paging is disabled, force UC */
>         gmtrr_mtype = MTRR_TYPE_UNCACHABLE;
>     else
>         /* MTRR is not enabled and paging is enabled, use PAT */
>         gmtrr_mtype = MTRR_TYPE_WRBACK;
> 
> albeit even then using vCPU 0 feels wrong when d != current->domain.
> Plus v->arch.hvm_vcpu.mtrr.enabled isn't really a boolean, so I think
> its use also needs refining.

Yes, I've realized that the check against v->arch.hvm_vcpu.mtrr.enabled is 
wrong, I will change it, but I'm not sure how to fix the d != 
current->domain comments that you mention.

> And finally please fix the comment style.

Right, thanks for the review.

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-08-02 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 16:15 [PATCH] x86/hap: use the right cache attributes when MTRR is disabled Roger Pau Monne
2016-08-01 15:33 ` Jan Beulich
2016-08-02 11:25   ` Roger Pau Monne [this message]
2016-08-02 11:54     ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160802112553.jca42g57o4jsedrg@mac \
    --to=roger.pau@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).