Skip to content

Commit 445c147

Browse files
rossphilipsonsuryasaimadhu
authored andcommitted
x86/boot: Add setup_indirect support in early_memremap_is_setup_data()
The x86 boot documentation describes the setup_indirect structures and how they are used. Only one of the two functions in ioremap.c that needed to be modified to be aware of the introduction of setup_indirect functionality was updated. Adds comparable support to the other function where it was missing. Fixes: b3c72fc ("x86/boot: Introduce setup_indirect") Signed-off-by: Ross Philipson <ross.philipson@oracle.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/1645668456-22036-3-git-send-email-ross.philipson@oracle.com
1 parent 7228918 commit 445c147

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

arch/x86/mm/ioremap.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,22 +676,51 @@ static bool memremap_is_setup_data(resource_size_t phys_addr,
676676
static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
677677
unsigned long size)
678678
{
679+
struct setup_indirect *indirect;
679680
struct setup_data *data;
680681
u64 paddr, paddr_next;
681682

682683
paddr = boot_params.hdr.setup_data;
683684
while (paddr) {
684-
unsigned int len;
685+
unsigned int len, size;
685686

686687
if (phys_addr == paddr)
687688
return true;
688689

689690
data = early_memremap_decrypted(paddr, sizeof(*data));
691+
if (!data) {
692+
pr_warn("failed to early memremap setup_data entry\n");
693+
return false;
694+
}
695+
696+
size = sizeof(*data);
690697

691698
paddr_next = data->next;
692699
len = data->len;
693700

694-
early_memunmap(data, sizeof(*data));
701+
if ((phys_addr > paddr) && (phys_addr < (paddr + len))) {
702+
early_memunmap(data, sizeof(*data));
703+
return true;
704+
}
705+
706+
if (data->type == SETUP_INDIRECT) {
707+
size += len;
708+
early_memunmap(data, sizeof(*data));
709+
data = early_memremap_decrypted(paddr, size);
710+
if (!data) {
711+
pr_warn("failed to early memremap indirect setup_data\n");
712+
return false;
713+
}
714+
715+
indirect = (struct setup_indirect *)data->data;
716+
717+
if (indirect->type != SETUP_INDIRECT) {
718+
paddr = indirect->addr;
719+
len = indirect->len;
720+
}
721+
}
722+
723+
early_memunmap(data, size);
695724

696725
if ((phys_addr > paddr) && (phys_addr < (paddr + len)))
697726
return true;

0 commit comments

Comments
 (0)