|
42 | 42 | #include <linux/memblock.h>
|
43 | 43 | #include <linux/hugetlb.h>
|
44 | 44 | #include <linux/slab.h>
|
| 45 | +#include <linux/of_fdt.h> |
| 46 | +#include <linux/libfdt.h> |
45 | 47 |
|
46 | 48 | #include <asm/pgalloc.h>
|
47 | 49 | #include <asm/page.h>
|
@@ -344,12 +346,43 @@ static int __init parse_disable_radix(char *p)
|
344 | 346 | }
|
345 | 347 | early_param("disable_radix", parse_disable_radix);
|
346 | 348 |
|
| 349 | +/* |
| 350 | + * If we're running under a hypervisor, we currently can't do radix |
| 351 | + * since we don't have the code to do the H_REGISTER_PROC_TBL hcall. |
| 352 | + * We tell that we're running under a hypervisor by looking for the |
| 353 | + * /chosen/ibm,architecture-vec-5 property. |
| 354 | + */ |
| 355 | +static void early_check_vec5(void) |
| 356 | +{ |
| 357 | + unsigned long root, chosen; |
| 358 | + int size; |
| 359 | + const u8 *vec5; |
| 360 | + |
| 361 | + root = of_get_flat_dt_root(); |
| 362 | + chosen = of_get_flat_dt_subnode_by_name(root, "chosen"); |
| 363 | + if (chosen == -FDT_ERR_NOTFOUND) |
| 364 | + return; |
| 365 | + vec5 = of_get_flat_dt_prop(chosen, "ibm,architecture-vec-5", &size); |
| 366 | + if (!vec5) |
| 367 | + return; |
| 368 | + cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX; |
| 369 | +} |
| 370 | + |
347 | 371 | void __init mmu_early_init_devtree(void)
|
348 | 372 | {
|
349 | 373 | /* Disable radix mode based on kernel command line. */
|
350 | 374 | if (disable_radix)
|
351 | 375 | cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX;
|
352 | 376 |
|
| 377 | + /* |
| 378 | + * Check /chosen/ibm,architecture-vec-5 if running as a guest. |
| 379 | + * When running bare-metal, we can use radix if we like |
| 380 | + * even though the ibm,architecture-vec-5 property created by |
| 381 | + * skiboot doesn't have the necessary bits set. |
| 382 | + */ |
| 383 | + if (early_radix_enabled() && !(mfmsr() & MSR_HV)) |
| 384 | + early_check_vec5(); |
| 385 | + |
353 | 386 | if (early_radix_enabled())
|
354 | 387 | radix__early_init_devtree();
|
355 | 388 | else
|
|
0 commit comments