Skip to content

Commit

Permalink
Revert "x86/mm/ident_map: Use gbpages only where full GB page should …
Browse files Browse the repository at this point in the history
…be mapped."

[ Upstream commit c567f29 ]

This reverts commit d794734.

While the original change tries to fix a bug, it also unintentionally broke
existing systems, see the regressions reported at:

  https://lore.kernel.org/all/3a1b9909-45ac-4f97-ad68-d16ef1ce99db@pavinjoseph.com/

Since d794734 was also marked for -stable, let's back it out before
causing more damage.

Note that due to another upstream change the revert was not 100% automatic:

  0a845e0 mm/treewide: replace pud_large() with pud_leaf()

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: <stable@vger.kernel.org>
Cc: Russ Anderson <rja@hpe.com>
Cc: Steve Wahl <steve.wahl@hpe.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/all/3a1b9909-45ac-4f97-ad68-d16ef1ce99db@pavinjoseph.com/
Fixes: d794734 ("x86/mm/ident_map: Use gbpages only where full GB page should be mapped.")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Ingo Molnar authored and gregkh committed Apr 10, 2024
1 parent 907835e commit fbc0a83
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions arch/x86/mm/ident_map.c
Expand Up @@ -26,31 +26,18 @@ static int ident_pud_init(struct x86_mapping_info *info, pud_t *pud_page,
for (; addr < end; addr = next) {
pud_t *pud = pud_page + pud_index(addr);
pmd_t *pmd;
bool use_gbpage;

next = (addr & PUD_MASK) + PUD_SIZE;
if (next > end)
next = end;

/* if this is already a gbpage, this portion is already mapped */
if (pud_leaf(*pud))
continue;

/* Is using a gbpage allowed? */
use_gbpage = info->direct_gbpages;

/* Don't use gbpage if it maps more than the requested region. */
/* at the begining: */
use_gbpage &= ((addr & ~PUD_MASK) == 0);
/* ... or at the end: */
use_gbpage &= ((next & ~PUD_MASK) == 0);

/* Never overwrite existing mappings */
use_gbpage &= !pud_present(*pud);

if (use_gbpage) {
if (info->direct_gbpages) {
pud_t pudval;

if (pud_present(*pud))
continue;

addr &= PUD_MASK;
pudval = __pud((addr - info->offset) | info->page_flag);
set_pud(pud, pudval);
continue;
Expand Down

0 comments on commit fbc0a83

Please sign in to comment.