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>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Michal Orzel <michal.orzel@amd.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] pdx: cast PAGE_SIZE value ahead of shifting
Date: Thu, 14 Aug 2025 12:28:34 +0200	[thread overview]
Message-ID: <aJ26UmemwxyyTioE@macbook.local> (raw)
In-Reply-To: <e644c968-ab68-49f4-801e-0f161fd85f2e@suse.com>

On Thu, Aug 14, 2025 at 09:18:45AM +0200, Jan Beulich wrote:
> On 13.08.2025 14:55, Roger Pau Monne wrote:
> > --- a/xen/common/pdx.c
> > +++ b/xen/common/pdx.c
> > @@ -288,7 +288,7 @@ bool __init pfn_pdx_compression_setup(paddr_t base)
> >  
> >      pfn_pdx_hole_shift  = hole_shift;
> >      pfn_pdx_bottom_mask = (1UL << bottom_shift) - 1;
> > -    ma_va_bottom_mask   = (PAGE_SIZE << bottom_shift) - 1;
> > +    ma_va_bottom_mask   = ((paddr_t)PAGE_SIZE << bottom_shift) - 1;
> 
> Given
> 
> #define PAGE_SIZE           (_AC(1,L) << PAGE_SHIFT)
> 
> this shouldn't be needed, except maybe for Arm32. There, however, ...
> 
> >      pfn_hole_mask       = ((1UL << hole_shift) - 1) << bottom_shift;
> 
> ... this and the shift immediately ahead would also be a problem afaict,
> which makes me conclude this isn't what Coverity has looked at. I expect
> the problem is with the toolstack side definition of PAGE_SIZE, which imo
> would rather be addressed there. (And yes, I'm pretty averse to arbitrary
> casts like this being introduced.)

As I've realized while looking at this, wouldn't ma_va_bottom_mask
also better be of type paddr_t, since it's not operating on pfns, but
physical addresses.  I didn't adjust the type of ma_va_bottom_mask,
but I would be happy to do it if you agree.

Thanks, roger.


  reply	other threads:[~2025-08-14 10:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 12:55 [PATCH] pdx: cast PAGE_SIZE value ahead of shifting Roger Pau Monne
2025-08-13 12:58 ` Andrew Cooper
2025-08-14  7:18 ` Jan Beulich
2025-08-14 10:28   ` Roger Pau Monné [this message]
2025-08-14 10:45     ` Jan Beulich
2025-08-14 13:01       ` Roger Pau Monné
2025-08-14 13:15         ` Jan Beulich
2025-08-14 14:57           ` Roger Pau Monné
2025-08-14 15:04             ` Jan Beulich
2025-08-14 13:19         ` Andrew Cooper

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=aJ26UmemwxyyTioE@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --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.