Skip to content

Commit e99f23c

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Catalin Marinas: - Limit the linear region to 51-bit when KVM is running in nVHE mode. Otherwise, depending on the placement of the ID map, kernel-VA to hyp-VA translations may produce addresses that either conflict with other HYP mappings or generate addresses outside of the 52-bit addressable range. - Instruct kmemleak not to scan the memory reserved for kdump as this range is removed from the kernel linear map and therefore not accessible. * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: kdump: Skip kmemleak scan reserved memory for kdump arm64: mm: limit linear region to 51 bits for KVM in nVHE mode
2 parents 23ef827 + 85f58eb commit e99f23c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

arch/arm64/mm/init.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/crash_dump.h>
3131
#include <linux/hugetlb.h>
3232
#include <linux/acpi_iort.h>
33+
#include <linux/kmemleak.h>
3334

3435
#include <asm/boot.h>
3536
#include <asm/fixmap.h>
@@ -101,6 +102,11 @@ static void __init reserve_crashkernel(void)
101102
pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
102103
crash_base, crash_base + crash_size, crash_size >> 20);
103104

105+
/*
106+
* The crashkernel memory will be removed from the kernel linear
107+
* map. Inform kmemleak so that it won't try to access it.
108+
*/
109+
kmemleak_ignore_phys(crash_base);
104110
crashk_res.start = crash_base;
105111
crashk_res.end = crash_base + crash_size - 1;
106112
}
@@ -222,7 +228,21 @@ early_param("mem", early_mem);
222228

223229
void __init arm64_memblock_init(void)
224230
{
225-
const s64 linear_region_size = PAGE_END - _PAGE_OFFSET(vabits_actual);
231+
s64 linear_region_size = PAGE_END - _PAGE_OFFSET(vabits_actual);
232+
233+
/*
234+
* Corner case: 52-bit VA capable systems running KVM in nVHE mode may
235+
* be limited in their ability to support a linear map that exceeds 51
236+
* bits of VA space, depending on the placement of the ID map. Given
237+
* that the placement of the ID map may be randomized, let's simply
238+
* limit the kernel's linear map to 51 bits as well if we detect this
239+
* configuration.
240+
*/
241+
if (IS_ENABLED(CONFIG_KVM) && vabits_actual == 52 &&
242+
is_hyp_mode_available() && !is_kernel_in_hyp_mode()) {
243+
pr_info("Capping linear region to 51 bits for KVM in nVHE mode on LVA capable hardware.\n");
244+
linear_region_size = min_t(u64, linear_region_size, BIT(51));
245+
}
226246

227247
/* Remove memory above our supported physical address size */
228248
memblock_remove(1ULL << PHYS_MASK_SHIFT, ULLONG_MAX);

0 commit comments

Comments
 (0)