git: a14b26a6bd3f - main - acpi: Unmap RSDP in more error cases

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 01 Sep 2022 16:42:21 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a14b26a6bd3f34f27960e02948385993962e32d0

commit a14b26a6bd3f34f27960e02948385993962e32d0
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-09-01 16:39:20 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-09-01 16:39:20 +0000

    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);