Skip to content

Commit

Permalink
Return page size as unsigned long
Browse files Browse the repository at this point in the history
Currently page_size() returns unsigned int value that is after "bitwise
not" is promoted to unsigned long value e.g. in uffd.c
handle_page_fault. Since the value is unsigned promotion is done with 0
MSB that results in lost of MSB pagefault address bits. So make
page_size to return  unsigned long to avoid such situation.

Signed-off-by: Vladislav Khmelevsky <[email protected]>
  • Loading branch information
yota9 authored and avagin committed Sep 28, 2023
1 parent 8b5f3af commit 1e4f5fb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compel/plugins/std/infect.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static struct rt_sigframe *sigframe;
*/
static unsigned __page_size;

unsigned __attribute((weak)) page_size(void)
unsigned long __attribute((weak)) page_size(void)
{
return __page_size;
}
Expand Down
2 changes: 1 addition & 1 deletion criu/pie/restorer.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool fault_injected(enum faults f)
* Hint: compel on aarch64 shall learn relocs for that.
*/
static unsigned __page_size;
unsigned page_size(void)
unsigned long page_size(void)
{
return __page_size;
}
Expand Down
4 changes: 2 additions & 2 deletions include/common/arch/aarch64/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extern unsigned __page_size;
extern unsigned __page_shift;

static inline unsigned page_size(void)
static inline unsigned long page_size(void)
{
if (!__page_size)
__page_size = sysconf(_SC_PAGESIZE);
Expand All @@ -37,7 +37,7 @@ static inline unsigned page_shift(void)

#else /* CR_NOGLIBC */

extern unsigned page_size(void);
extern unsigned long page_size(void);
#define PAGE_SIZE page_size()

#endif /* CR_NOGLIBC */
Expand Down
4 changes: 2 additions & 2 deletions include/common/arch/loongarch64/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static unsigned __page_size;
static unsigned __page_shift;

static inline unsigned page_size(void)
static inline unsigned long page_size(void)
{
if (!__page_size)
__page_size = sysconf(_SC_PAGESIZE);
Expand All @@ -31,7 +31,7 @@ static inline unsigned page_shift(void)
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
#else /* CR_NOGLIBC */

extern unsigned page_size(void);
extern unsigned long page_size(void);
#define PAGE_SIZE page_size()

#endif /* CR_NOGLIBC */
Expand Down
4 changes: 2 additions & 2 deletions include/common/arch/mips/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static unsigned __page_size;
static unsigned __page_shift;

static inline unsigned page_size(void)
static inline unsigned long page_size(void)
{
if (!__page_size)
__page_size = sysconf(_SC_PAGESIZE);
Expand All @@ -31,7 +31,7 @@ static inline unsigned page_shift(void)
#define PAGE_PFN(addr) ((addr) / PAGE_SIZE)
#else /* CR_NOGLIBC */

extern unsigned page_size(void);
extern unsigned long page_size(void);
#define PAGE_SIZE page_size()

#endif /* CR_NOGLIBC */
Expand Down
4 changes: 2 additions & 2 deletions include/common/arch/ppc64/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
extern unsigned __page_size;
extern unsigned __page_shift;

static inline unsigned page_size(void)
static inline unsigned long page_size(void)
{
if (!__page_size)
__page_size = sysconf(_SC_PAGESIZE);
Expand All @@ -37,7 +37,7 @@ static inline unsigned page_shift(void)

#else /* CR_NOGLIBC */

extern unsigned page_size(void);
extern unsigned long page_size(void);
#define PAGE_SIZE page_size()

#endif /* CR_NOGLIBC */
Expand Down

0 comments on commit 1e4f5fb

Please sign in to comment.