1 From 903e6b636ff957419a5c19368ffc685536b7c3b6 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 25 Mar 2024 11:47:51 +0100
4 Subject: Revert "x86/mm/ident_map: Use gbpages only where full GB page should
7 From: Ingo Molnar <mingo@kernel.org>
9 [ Upstream commit c567f2948f57bdc03ed03403ae0234085f376b7d ]
11 This reverts commit d794734c9bbfe22f86686dc2909c25f5ffe1a572.
13 While the original change tries to fix a bug, it also unintentionally broke
14 existing systems, see the regressions reported at:
16 https://lore.kernel.org/all/3a1b9909-45ac-4f97-ad68-d16ef1ce99db@pavinjoseph.com/
18 Since d794734c9bbf was also marked for -stable, let's back it out before
21 Note that due to another upstream change the revert was not 100% automatic:
23 0a845e0f6348 mm/treewide: replace pud_large() with pud_leaf()
25 Signed-off-by: Ingo Molnar <mingo@kernel.org>
26 Cc: <stable@vger.kernel.org>
27 Cc: Russ Anderson <rja@hpe.com>
28 Cc: Steve Wahl <steve.wahl@hpe.com>
29 Cc: Dave Hansen <dave.hansen@linux.intel.com>
30 Link: https://lore.kernel.org/all/3a1b9909-45ac-4f97-ad68-d16ef1ce99db@pavinjoseph.com/
31 Fixes: d794734c9bbf ("x86/mm/ident_map: Use gbpages only where full GB page should be mapped.")
32 Signed-off-by: Sasha Levin <sashal@kernel.org>
34 arch/x86/mm/ident_map.c | 23 +++++------------------
35 1 file changed, 5 insertions(+), 18 deletions(-)
37 diff --git a/arch/x86/mm/ident_map.c b/arch/x86/mm/ident_map.c
38 index a204a332c71fc..968d7005f4a72 100644
39 --- a/arch/x86/mm/ident_map.c
40 +++ b/arch/x86/mm/ident_map.c
41 @@ -26,31 +26,18 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page,
42 for (; addr < end; addr = next) {
43 pud_t *pud = pud_page + pud_index(addr);
47 next = (addr & PUD_MASK) + PUD_SIZE;
51 - /* if this is already a gbpage, this portion is already mapped */
55 - /* Is using a gbpage allowed? */
56 - use_gbpage = info->direct_gbpages;
58 - /* Don't use gbpage if it maps more than the requested region. */
59 - /* at the begining: */
60 - use_gbpage &= ((addr & ~PUD_MASK) == 0);
61 - /* ... or at the end: */
62 - use_gbpage &= ((next & ~PUD_MASK) == 0);
64 - /* Never overwrite existing mappings */
65 - use_gbpage &= !pud_present(*pud);
68 + if (info->direct_gbpages) {
71 + if (pud_present(*pud))
75 pudval = __pud((addr - info->offset) | info->page_flag);