diff options
| -rw-r--r-- | arch/x86/kvm/mmu.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index b1f6451022e5..f7c2dee452a1 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
| @@ -488,16 +488,24 @@ static void kvm_mmu_reset_all_pte_masks(void) | |||
| 488 | * If the CPU has 46 or less physical address bits, then set an | 488 | * If the CPU has 46 or less physical address bits, then set an |
| 489 | * appropriate mask to guard against L1TF attacks. Otherwise, it is | 489 | * appropriate mask to guard against L1TF attacks. Otherwise, it is |
| 490 | * assumed that the CPU is not vulnerable to L1TF. | 490 | * assumed that the CPU is not vulnerable to L1TF. |
| 491 | * | ||
| 492 | * Some Intel CPUs address the L1 cache using more PA bits than are | ||
| 493 | * reported by CPUID. Use the PA width of the L1 cache when possible | ||
| 494 | * to achieve more effective mitigation, e.g. if system RAM overlaps | ||
| 495 | * the most significant bits of legal physical address space. | ||
| 491 | */ | 496 | */ |
| 492 | low_phys_bits = boot_cpu_data.x86_phys_bits; | 497 | shadow_nonpresent_or_rsvd_mask = 0; |
| 493 | if (boot_cpu_data.x86_phys_bits < | 498 | low_phys_bits = boot_cpu_data.x86_cache_bits; |
| 499 | if (boot_cpu_data.x86_cache_bits < | ||
| 494 | 52 - shadow_nonpresent_or_rsvd_mask_len) { | 500 | 52 - shadow_nonpresent_or_rsvd_mask_len) { |
| 495 | shadow_nonpresent_or_rsvd_mask = | 501 | shadow_nonpresent_or_rsvd_mask = |
| 496 | rsvd_bits(boot_cpu_data.x86_phys_bits - | 502 | rsvd_bits(boot_cpu_data.x86_cache_bits - |
| 497 | shadow_nonpresent_or_rsvd_mask_len, | 503 | shadow_nonpresent_or_rsvd_mask_len, |
| 498 | boot_cpu_data.x86_phys_bits - 1); | 504 | boot_cpu_data.x86_cache_bits - 1); |
| 499 | low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; | 505 | low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len; |
| 500 | } | 506 | } else |
| 507 | WARN_ON_ONCE(boot_cpu_has_bug(X86_BUG_L1TF)); | ||
| 508 | |||
| 501 | shadow_nonpresent_or_rsvd_lower_gfn_mask = | 509 | shadow_nonpresent_or_rsvd_lower_gfn_mask = |
| 502 | GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT); | 510 | GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT); |
| 503 | } | 511 | } |
