All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: "Anthony PERARD" <anthony.perard@vates.tech>,
	"Edwin Török" <edwin.torok@citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH] tests/pdx: fix overflow from conversion from page index to address on 32bit
Date: Thu, 12 Mar 2026 09:25:12 +0100	[thread overview]
Message-ID: <bb3e166a-9842-48d9-8170-ab5e4e53c57d@suse.com> (raw)
In-Reply-To: <20260312080206.52648-1-roger.pau@citrix.com>

On 12.03.2026 09:02, Roger Pau Monne wrote:
> When building the PDX test harness as a 32bit executable the page shifts
> done on unsigned long types can overflow.  Instead use pfn_to_paddr(),
> which casts the values to paddr_t previous to doing the shift.
> 
> Fixes: cb50e4033717 ("test/pdx: add PDX compression unit tests")
> Reported-by: Edwin Török <edwin.torok@citrix.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> --- a/tools/tests/pdx/test-pdx.c
> +++ b/tools/tests/pdx/test-pdx.c
> @@ -208,8 +208,8 @@ int main(int argc, char **argv)
>              if ( !tests[i].ranges[j].start && !tests[i].ranges[j].end )
>                  break;
>  
> -            pfn_pdx_add_region(tests[i].ranges[j].start << PAGE_SHIFT,
> -                               size << PAGE_SHIFT);
> +            pfn_pdx_add_region(pfn_to_paddr(tests[i].ranges[j].start),
> +                               pfn_to_paddr(size));
>          }
>  
>          if ( pfn_pdx_compression_setup(0) != tests[i].compress )
> @@ -233,8 +233,8 @@ int main(int argc, char **argv)
>              if ( !start && !end )
>                  break;
>  
> -            if ( !pdx_is_region_compressible(start << PAGE_SHIFT, 1) ||
> -                 !pdx_is_region_compressible((end - 1) << PAGE_SHIFT, 1) )
> +            if ( !pdx_is_region_compressible(pfn_to_paddr(start), 1) ||
> +                 !pdx_is_region_compressible(pfn_to_paddr(end - 1), 1) )
>              {
>                  printf(
>      "PFN compression invalid, pages %#lx and %#lx should be compressible\n",

Largely unrelated remark, from going through all of the PAGE_SHIFT uses: Isn't
the __LP64__ conditional excluding quite a few too many array elements in
main()'s tests[]?

Jan


  reply	other threads:[~2026-03-12  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12  8:02 [PATCH] tests/pdx: fix overflow from conversion from page index to address on 32bit Roger Pau Monne
2026-03-12  8:25 ` Jan Beulich [this message]
2026-03-12  8:36   ` 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=bb3e166a-9842-48d9-8170-ab5e4e53c57d@suse.com \
    --to=jbeulich@suse.com \
    --cc=anthony.perard@vates.tech \
    --cc=edwin.torok@citrix.com \
    --cc=roger.pau@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 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.