mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tests/pdx: fix overflow from conversion from page index to address on 32bit
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: cb50e40337 ("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>
This commit is contained in:
1 parent
17a9070d22
commit
87774bbc39
1 file changed
+4
-4
@@ -208,8 +208,8 @@ int main(int argc, char **argv)
|
|||||||
if ( !tests[i].ranges[j].start && !tests[i].ranges[j].end )
|
if ( !tests[i].ranges[j].start && !tests[i].ranges[j].end )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pfn_pdx_add_region(tests[i].ranges[j].start << PAGE_SHIFT,
|
pfn_pdx_add_region(pfn_to_paddr(tests[i].ranges[j].start),
|
||||||
size << PAGE_SHIFT);
|
pfn_to_paddr(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( pfn_pdx_compression_setup(0) != tests[i].compress )
|
if ( pfn_pdx_compression_setup(0) != tests[i].compress )
|
||||||
@@ -233,8 +233,8 @@ int main(int argc, char **argv)
|
|||||||
if ( !start && !end )
|
if ( !start && !end )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( !pdx_is_region_compressible(start << PAGE_SHIFT, 1) ||
|
if ( !pdx_is_region_compressible(pfn_to_paddr(start), 1) ||
|
||||||
!pdx_is_region_compressible((end - 1) << PAGE_SHIFT, 1) )
|
!pdx_is_region_compressible(pfn_to_paddr(end - 1), 1) )
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"PFN compression invalid, pages %#lx and %#lx should be compressible\n",
|
"PFN compression invalid, pages %#lx and %#lx should be compressible\n",
|
||||||
|
|||||||