All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <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 v3 1/3] x86/dom0: correctly set the maximum ->iomem_caps bound for PVH
Date: Thu, 20 Feb 2025 09:49:57 +0100	[thread overview]
Message-ID: <Z7bstaBXDP6gdnH-@macbook.local> (raw)
In-Reply-To: <6b0eb8ba-f42c-4a24-9dbd-3e6f78b818c1@suse.com>

On Thu, Feb 20, 2025 at 09:22:40AM +0100, Jan Beulich wrote:
> On 19.02.2025 17:48, Roger Pau Monne wrote:
> > The logic in dom0_setup_permissions() sets the maximum bound in
> > ->iomem_caps unconditionally using paddr_bits, which is not correct for HVM
> > based domains.  Instead use domain_max_paddr_bits() to get the correct
> > maximum paddr bits for each possible domain type.
> > 
> > Switch to using PFN_DOWN() instead of PAGE_SHIFT, as that's shorter.
> > 
> > Fixes: 53de839fb409 ('x86: constrain MFN range Dom0 may access')
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > The fixes tag might be dubious, IIRC at that time we had PVHv1 dom0, which
> > would likely also need such adjustment, but not the current PVHv2.
> 
> Probably better to omit it then. It would be one of the changes moving to
> PVHv2 that missed making the adjustment.

Well, PVHv1 would have needed such adjustment, as it was also limited
to hap_paddr_bits instead of paddr_bits.

> > --- a/xen/arch/x86/dom0_build.c
> > +++ b/xen/arch/x86/dom0_build.c
> > @@ -481,7 +481,8 @@ int __init dom0_setup_permissions(struct domain *d)
> >  
> >      /* The hardware domain is initially permitted full I/O capabilities. */
> >      rc = ioports_permit_access(d, 0, 0xFFFF);
> > -    rc |= iomem_permit_access(d, 0UL, (1UL << (paddr_bits - PAGE_SHIFT)) - 1);
> > +    rc |= iomem_permit_access(d, 0UL,
> > +                              PFN_DOWN(1UL << domain_max_paddr_bits(d)) - 1);
> 
> Why PFN_DOWN() rather than subtracting PAGE_SHIFT? That's two shifts rather
> than just one.

cosmetic: line length (it's mentioned in the commit message).  I can
switch back to PAGE_SHIFT, didn't think it was a big deal since it's
a one time only calculation.

> Personally I'd prefer if we continued using the subtraction,
> but either way:
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks, will switch back to PAGE_SHIFT if it doesn't turn out to be
too ugly.


  reply	other threads:[~2025-02-20  8:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 16:48 [PATCH v3 0/3] x86/dom0: be less restrictive with the Interrupt Address Range Roger Pau Monne
2025-02-19 16:48 ` [PATCH v3 1/3] x86/dom0: correctly set the maximum ->iomem_caps bound for PVH Roger Pau Monne
2025-02-20  8:22   ` Jan Beulich
2025-02-20  8:49     ` Roger Pau Monné [this message]
2025-02-20 13:02       ` Jan Beulich
2025-02-19 16:48 ` [PATCH v3 2/3] x86/iommu: account for IOMEM caps when populating dom0 IOMMU page-tables Roger Pau Monne
2025-02-20  8:29   ` Jan Beulich
2025-02-19 16:48 ` [PATCH v3 3/3] x86/dom0: be less restrictive with the Interrupt Address Range Roger Pau Monne
2025-02-20  8:33   ` Jan Beulich
2025-02-20  8:55     ` Roger Pau Monné
2025-02-20 13:30       ` Jan Beulich
2025-02-20 15:40         ` Roger Pau Monné
2025-02-20 16:05           ` Jan Beulich
2025-02-20 16:16             ` Roger Pau Monné
2025-03-05 14:27 ` [PATCH v3 0/3] " Jan Beulich
2025-03-05 14:35   ` Roger Pau Monné
2025-03-05 14:54     ` Jan Beulich
2025-03-05 17:42       ` Roger Pau Monné

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=Z7bstaBXDP6gdnH-@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.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 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.