* [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation
@ 2023-07-09 6:49 Linke Li
[not found] ` <f7fab4fc-a8db-d2f7-52e9-3522f7c298b8@web.de>
0 siblings, 1 reply; 3+ messages in thread
From: Linke Li @ 2023-07-09 6:49 UTC (permalink / raw)
To: linux-mips; +Cc: linux-kernel, tsbogend, Linke Li
From: Linke Li <lilinke99@gmail.com>
Make PAGE_MASK an unsigned long, like it is on x86, to avoid:
../arch/mips/include/asm/ginvt.h:44:20: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
addr &= PAGE_MASK << 1;
In the MIPS architecture, the PAGE_MASK definition in arch/mips/include/asm/page.h leads to
shifting a negative signed value, which is undefined according to the language specification.
To address this issue, the PAGE_MASK definition is modified to be unsigned long and ensure
well-defined behavior.
Signed-off-by: Linke Li <lilinke99@gmail.com>
---
arch/mips/include/asm/page.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index 5978a8dfb917..3061a5586954 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -33,7 +33,7 @@
#define PAGE_SHIFT 16
#endif
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
-#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
+#define PAGE_MASK (~(PAGE_SIZE - 1))
/*
* This is used for calculating the real page sizes
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation
[not found] ` <f7fab4fc-a8db-d2f7-52e9-3522f7c298b8@web.de>
@ 2023-07-10 6:08 ` linke li
[not found] ` <CAKdjhyAOfbsxthU38=vSPJ080YxQvbGpbc5pupbz1gUQ=USwrQ@mail.gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: linke li @ 2023-07-10 6:08 UTC (permalink / raw)
To: Markus Elfring
Cc: linux-mips, kernel-janitors, LKML, Linke Li,
Thomas Bogendörfer
> How do you think about a wording variant like the following?
What you said is exactly what I want to express.
> Would you like to add the tag “Fixes”?
I agree with that.
Thank you for your feedback and suggestion.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation
[not found] ` <CAKdjhyAOfbsxthU38=vSPJ080YxQvbGpbc5pupbz1gUQ=USwrQ@mail.gmail.com>
@ 2023-07-25 8:48 ` Thomas Bogendoerfer
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2023-07-25 8:48 UTC (permalink / raw)
To: linke li; +Cc: Markus Elfring, linux-mips, kernel-janitors, LKML, Linke Li
On Mon, Jul 10, 2023 at 02:02:00PM +0800, linke li wrote:
> > How do you think about a wording variant like the following?
>
> What you said is exactly what I want to express.
>
> > Would you like to add the tag “Fixes”?
>
> I agree with that.
>
> Thank you for your feedback and suggestion.
plesas resend with this changes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-25 9:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-09 6:49 [PATCH] MIPS: Fix undefined behavior in PAGE_MASK calculation Linke Li
[not found] ` <f7fab4fc-a8db-d2f7-52e9-3522f7c298b8@web.de>
2023-07-10 6:08 ` linke li
[not found] ` <CAKdjhyAOfbsxthU38=vSPJ080YxQvbGpbc5pupbz1gUQ=USwrQ@mail.gmail.com>
2023-07-25 8:48 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox