Skip to content

Commit 3770e52

Browse files
arndbakpm00
authored andcommitted
mm: extend max struct page size for kmsan
After x86 enabled support for KMSAN, it has become possible to have larger 'struct page' than was expected when commit 5470dea ("mm: use mm_zero_struct_page from SPARC on all 64b architectures") was merged: include/linux/mm.h:156:10: warning: no case matching constant switch condition '96' switch (sizeof(struct page)) { Extend the maximum accordingly. Link: https://lkml.kernel.org/r/[email protected] Fixes: 5470dea ("mm: use mm_zero_struct_page from SPARC on all 64b architectures") Fixes: 4ca8cc8 ("x86: kmsan: enable KMSAN builds for x86") Fixes: f80be45 ("kmsan: add KMSAN runtime core") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Pasha Tatashin <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Alex Sierra <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: John Hubbard <[email protected]> Cc: Liam R. Howlett <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ac86f54 commit 3770e52

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

include/linux/mm.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
137137
* define their own version of this macro in <asm/pgtable.h>
138138
*/
139139
#if BITS_PER_LONG == 64
140-
/* This function must be updated when the size of struct page grows above 80
140+
/* This function must be updated when the size of struct page grows above 96
141141
* or reduces below 56. The idea that compiler optimizes out switch()
142142
* statement, and only leaves move/store instructions. Also the compiler can
143143
* combine write statements if they are both assignments and can be reordered,
@@ -148,12 +148,18 @@ static inline void __mm_zero_struct_page(struct page *page)
148148
{
149149
unsigned long *_pp = (void *)page;
150150

151-
/* Check that struct page is either 56, 64, 72, or 80 bytes */
151+
/* Check that struct page is either 56, 64, 72, 80, 88 or 96 bytes */
152152
BUILD_BUG_ON(sizeof(struct page) & 7);
153153
BUILD_BUG_ON(sizeof(struct page) < 56);
154-
BUILD_BUG_ON(sizeof(struct page) > 80);
154+
BUILD_BUG_ON(sizeof(struct page) > 96);
155155

156156
switch (sizeof(struct page)) {
157+
case 96:
158+
_pp[11] = 0;
159+
fallthrough;
160+
case 88:
161+
_pp[10] = 0;
162+
fallthrough;
157163
case 80:
158164
_pp[9] = 0;
159165
fallthrough;

0 commit comments

Comments
 (0)