Skip to content

Commit 29f6f35

Browse files
rossphilipsongregkh
authored andcommitted
x86/boot: Add setup_indirect support in early_memremap_is_setup_data()
commit 445c147 upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b3444e5 commit 29f6f35

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

arch/x86/mm/ioremap.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,22 +694,51 @@ static bool memremap_is_setup_data(resource_size_t phys_addr,
694694
static bool __init early_memremap_is_setup_data(resource_size_t phys_addr,
695695
unsigned long size)
696696
{
697+
struct setup_indirect *indirect;
697698
struct setup_data *data;
698699
u64 paddr, paddr_next;
699700

700701
paddr = boot_params.hdr.setup_data;
701702
while (paddr) {
702-
unsigned int len;
703+
unsigned int len, size;
703704

704705
if (phys_addr == paddr)
705706
return true;
706707

707708
data = early_memremap_decrypted(paddr, sizeof(*data));
709+
if (!data) {
710+
pr_warn("failed to early memremap setup_data entry\n");
711+
return false;
712+
}
713+
714+
size = sizeof(*data);
708715

709716
paddr_next = data->next;
710717
len = data->len;
711718

712-
early_memunmap(data, sizeof(*data));
719+
if ((phys_addr > paddr) && (phys_addr < (paddr + len))) {
720+
early_memunmap(data, sizeof(*data));
721+
return true;
722+
}
723+
724+
if (data->type == SETUP_INDIRECT) {
725+
size += len;
726+
early_memunmap(data, sizeof(*data));
727+
data = early_memremap_decrypted(paddr, size);
728+
if (!data) {
729+
pr_warn("failed to early memremap indirect setup_data\n");
730+
return false;
731+
}
732+
733+
indirect = (struct setup_indirect *)data->data;
734+
735+
if (indirect->type != SETUP_INDIRECT) {
736+
paddr = indirect->addr;
737+
len = indirect->len;
738+
}
739+
}
740+
741+
early_memunmap(data, size);
713742

714743
if ((phys_addr > paddr) && (phys_addr < (paddr + len)))
715744
return true;

0 commit comments

Comments
 (0)