Skip to content

Commit 3278996

Browse files
author
Vasily Gorbik
committed
s390/kasan: handle DCSS mapping in memory holes
When physical memory is defined under z/VM using DEF STOR CONFIG, there may be memory holes that are not hotpluggable memory. In such cases, DCSS mapping could be placed in one of these memory holes. Subsequently, attempting memory access to such DCSS mapping would result in a kasan failure because there is no shadow memory mapping for it. To maintain consistency with cases where DCSS mapping is positioned after the kernel identity mapping, which is then covered by kasan zero shadow mapping, handle the scenario above by populating zero shadow mapping for memory holes where DCSS mapping could potentially be placed. Reviewed-by: Heiko Carstens <[email protected]> Reviewed-by: Gerald Schaefer <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 63e8b94 commit 3278996

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/s390/boot/vmem.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static void kasan_populate_shadow(void)
5757
pmd_t pmd_z = __pmd(__pa(kasan_early_shadow_pte) | _SEGMENT_ENTRY);
5858
pud_t pud_z = __pud(__pa(kasan_early_shadow_pmd) | _REGION3_ENTRY);
5959
p4d_t p4d_z = __p4d(__pa(kasan_early_shadow_pud) | _REGION2_ENTRY);
60+
unsigned long memgap_start = 0;
6061
unsigned long untracked_end;
6162
unsigned long start, end;
6263
int i;
@@ -101,8 +102,12 @@ static void kasan_populate_shadow(void)
101102
* +- shadow end ----+---------+- shadow end ---+
102103
*/
103104

104-
for_each_physmem_usable_range(i, &start, &end)
105+
for_each_physmem_usable_range(i, &start, &end) {
105106
kasan_populate(start, end, POPULATE_KASAN_MAP_SHADOW);
107+
if (memgap_start && physmem_info.info_source == MEM_DETECT_DIAG260)
108+
kasan_populate(memgap_start, start, POPULATE_KASAN_ZERO_SHADOW);
109+
memgap_start = end;
110+
}
106111
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
107112
untracked_end = VMALLOC_START;
108113
/* shallowly populate kasan shadow for vmalloc and modules */

0 commit comments

Comments
 (0)