|
30 | 30 | #include <linux/crash_dump.h>
|
31 | 31 | #include <linux/hugetlb.h>
|
32 | 32 | #include <linux/acpi_iort.h>
|
| 33 | +#include <linux/kmemleak.h> |
33 | 34 |
|
34 | 35 | #include <asm/boot.h>
|
35 | 36 | #include <asm/fixmap.h>
|
@@ -101,6 +102,11 @@ static void __init reserve_crashkernel(void)
|
101 | 102 | pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
|
102 | 103 | crash_base, crash_base + crash_size, crash_size >> 20);
|
103 | 104 |
|
| 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); |
104 | 110 | crashk_res.start = crash_base;
|
105 | 111 | crashk_res.end = crash_base + crash_size - 1;
|
106 | 112 | }
|
@@ -222,7 +228,21 @@ early_param("mem", early_mem);
|
222 | 228 |
|
223 | 229 | void __init arm64_memblock_init(void)
|
224 | 230 | {
|
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 | + } |
226 | 246 |
|
227 | 247 | /* Remove memory above our supported physical address size */
|
228 | 248 | memblock_remove(1ULL << PHYS_MASK_SHIFT, ULLONG_MAX);
|
|
0 commit comments