Skip to content

Commit 850612c

Browse files
committed
s390/set_memory: add __set_memory() variant
Add a __set_memory_yy() variant for all set_memory_yy() implementations. The new variant takes start and end void pointers, which allows them to be used without the usual unsigned long cast. However more important: the new variant can be used for areas larger than 8TB. The old variant comes with an "int numpages" parameter, which overflows with more than 8TB. Given that for debug_pagealloc set_memory_4k() is used on the whole kernel mapping this is not only a theoretical problem, but must be fixed. Changing all set_memory_yy() variants only on s390 to take an "unsigned long numpages" parameter is not possible, since the common module code requires an int parameter from all architectures on these functions. See module_set_memory(). Therefore change/fix this on s390 only with a new interface, and address common code later. Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent c22a4c8 commit 850612c

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

arch/s390/include/asm/set_memory.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,32 @@ enum {
2424
#define SET_MEMORY_INV BIT(_SET_MEMORY_INV_BIT)
2525
#define SET_MEMORY_DEF BIT(_SET_MEMORY_DEF_BIT)
2626

27-
int __set_memory(unsigned long addr, int numpages, unsigned long flags);
27+
int __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags);
2828

2929
#define set_memory_rox set_memory_rox
3030

31-
#define __SET_MEMORY_FUNC(fname, flags) \
32-
static inline int fname(unsigned long addr, int numpages) \
33-
{ \
34-
return __set_memory(addr, numpages, (flags)); \
31+
/*
32+
* Generate two variants of each set_memory() function:
33+
*
34+
* set_memory_yy(unsigned long addr, int numpages);
35+
* __set_memory_yy(void *start, void *end);
36+
*
37+
* The second variant exists for both convenience to avoid the usual
38+
* (unsigned long) casts, but unlike the first variant it can also be used
39+
* for areas larger than 8TB, which may happen at memory initialization.
40+
*/
41+
#define __SET_MEMORY_FUNC(fname, flags) \
42+
static inline int fname(unsigned long addr, int numpages) \
43+
{ \
44+
return __set_memory(addr, numpages, (flags)); \
45+
} \
46+
\
47+
static inline int __##fname(void *start, void *end) \
48+
{ \
49+
unsigned long numpages; \
50+
\
51+
numpages = (end - start) >> PAGE_SHIFT; \
52+
return __set_memory((unsigned long)start, numpages, (flags)); \
3553
}
3654

3755
__SET_MEMORY_FUNC(set_memory_ro, SET_MEMORY_RO)

arch/s390/mm/pageattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static int change_page_attr_alias(unsigned long addr, unsigned long end,
373373
return rc;
374374
}
375375

376-
int __set_memory(unsigned long addr, int numpages, unsigned long flags)
376+
int __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags)
377377
{
378378
unsigned long end;
379379
int rc;

0 commit comments

Comments
 (0)