Skip to content

Commit

Permalink
Merge tag 'x86_urgent_for_v6.8_rc5' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/tip/tip

Pull x86 fix from Borislav Petkov:

 - Use a GB page for identity mapping only when memory of this size is
   requested so that mapping of reserved regions is prevented which
   would otherwise lead to system crashes on UV machines

* tag 'x86_urgent_for_v6.8_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/mm/ident_map: Use gbpages only where full GB page should be mapped.
  • Loading branch information
Linus Torvalds committed Feb 18, 2024
2 parents 7cb7c32 + d794734 commit ddac3d8
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions arch/x86/mm/ident_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,31 @@ 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 (info->direct_gbpages) {
pud_t pudval;
/* if this is already a gbpage, this portion is already mapped */
if (pud_large(*pud))
continue;

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

if (pud_present(*pud))
continue;
/* 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) {
pud_t pudval;

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

0 comments on commit ddac3d8

Please sign in to comment.