From a14b26a6bd3f34f27960e02948385993962e32d0 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Sep 2022 10:39:20 -0600 Subject: [PATCH] acpi: Unmap RSDP in more error cases Add missing pmap_unmapbios() calls for when we return 0. Otherwise we can leave the table mapped when it is of no use. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D36405 --- sys/amd64/acpica/acpi_machdep.c | 6 ++++++ sys/arm64/acpica/acpi_machdep.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c index bbeb7cef44c5..1a9f44969d03 100644 --- a/sys/amd64/acpica/acpi_machdep.c +++ b/sys/amd64/acpica/acpi_machdep.c @@ -203,12 +203,16 @@ acpi_find_table(const char *sig) if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { if (bootverbose) printf("ACPI: RSDP failed extended checksum\n"); + pmap_unmapbios((vm_offset_t)rsdp, + sizeof(ACPI_TABLE_RSDP)); return (0); } xsdt = map_table(rsdp->XsdtPhysicalAddress, ACPI_SIG_XSDT); if (xsdt == NULL) { if (bootverbose) printf("ACPI: Failed to map XSDT\n"); + pmap_unmapbios((vm_offset_t)rsdp, + sizeof(ACPI_TABLE_RSDP)); return (0); } count = (xsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / @@ -224,6 +228,8 @@ acpi_find_table(const char *sig) if (rsdt == NULL) { if (bootverbose) printf("ACPI: Failed to map RSDT\n"); + pmap_unmapbios((vm_offset_t)rsdp, + sizeof(ACPI_TABLE_RSDP)); return (0); } count = (rsdt->Header.Length - sizeof(ACPI_TABLE_HEADER)) / diff --git a/sys/arm64/acpica/acpi_machdep.c b/sys/arm64/acpica/acpi_machdep.c index 8ce4e521860b..6145dfbbc78b 100644 --- a/sys/arm64/acpica/acpi_machdep.c +++ b/sys/arm64/acpica/acpi_machdep.c @@ -176,6 +176,8 @@ acpi_find_table(const char *sig) if (AcpiTbChecksum((UINT8 *)rsdp, ACPI_RSDP_XCHECKSUM_LENGTH)) { if (bootverbose) printf("ACPI: RSDP failed extended checksum\n"); + pmap_unmapbios((vm_offset_t)rsdp, + sizeof(ACPI_TABLE_RSDP)); return (0); } xsdt = map_table(rsdp->XsdtPhysicalAddress, ACPI_SIG_XSDT);