@@ -103,8 +103,8 @@ void __init kernel_randomize_memory(void)
return;
/*
- * Upper limit for direct mapping size is 1/4 of whole virtual
- * address space
+ * Upper limit for direct mapping size is half of kernel address
+ * space.
*/
kaslr_regions[0].size_tb = 1 << (__VIRTUAL_MASK_SHIFT - 1 - TB_SHIFT);
kaslr_regions[1].size_tb = VMALLOC_SIZE_TB;
@@ -117,7 +117,7 @@ void __init kernel_randomize_memory(void)
setup_direct_mapping_size();
- memory_tb = direct_mapping_size * mktme_nr_keyids + 1;
+ memory_tb = direct_mapping_size * (mktme_nr_keyids + 1);
/* Adapt phyiscal memory region size based on available memory */
if (memory_tb < kaslr_regions[0].size_tb)
@@ -110,7 +110,7 @@ void __init setup_direct_mapping_size(void)
*
* Disable MKTME instead.
*/
- if (direct_mapping_size > available_va / mktme_nr_keyids + 1) {
+ if (direct_mapping_size > available_va / (mktme_nr_keyids + 1)) {
pr_err("x86/mktme: Disabled. Not enough virtual address space\n");
pr_err("x86/mktme: Consider switching to 5-level paging\n");
mktme_disable();