Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-9]: src/sys/arch/x86/acpi Pull up following revision(s) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/236d05420d5f
branches:  netbsd-9
changeset: 458350:236d05420d5f
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Sep 17 19:41:45 2019 +0000

description:
Pull up following revision(s) (requested by manu in ticket #204):

        sys/arch/x86/acpi/acpi_machdep.c: revision 1.27
        sys/arch/x86/acpi/acpi_machdep.c: revision 1.28

Attempt to obtain ACPI RSDP from the hypervisor for Xen PV

There are three possible way of obtaining the ACPI RSDP

- From Extended BIOS Data Area (EBDA) when kernel or Xen was booted from
  BIOS bootstrap
- From EFI SystemTable when kernel is booted from EFI bootstrap
- When Xen is booted from EFI bootstrap, EBDA is not mapped, and EFI
  SystemTable is not passed to the kernel. The only way to go is to
  obtain ACPI RSDP trhough an hypercall.

Note: EFI bootstrap support for booting Xen has not yet been committed.

Cast physical addresses via uintptr_t to ACPI_PHYSICAL_ADDRESS to deal
with all size variants of the types used here in different builds.

diffstat:

 sys/arch/x86/acpi/acpi_machdep.c |  66 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 62 insertions(+), 4 deletions(-)

diffs (94 lines):

diff -r 06eed41527bd -r 236d05420d5f sys/arch/x86/acpi/acpi_machdep.c
--- a/sys/arch/x86/acpi/acpi_machdep.c  Tue Sep 17 19:31:59 2019 +0000
+++ b/sys/arch/x86/acpi/acpi_machdep.c  Tue Sep 17 19:41:45 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.26.2.1 2019/09/17 19:41:45 martin Exp $ */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26 2019/05/01 07:26:28 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.26.2.1 2019/09/17 19:41:45 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -100,8 +100,61 @@
        ACPI_PHYSICAL_ADDRESS PhysicalAddress;
        ACPI_STATUS Status;
 
-#ifndef XENPV
-       /* If EFI is available, attempt to use it to locate the ACPI table. */
+#ifdef XENPV
+       /*
+        * Obtain the ACPI RSDP from the hypervisor. 
+        * This is the only way to go if Xen booted from EFI: the 
+        * Extended BIOS Data Area (EBDA) is not mapped, and Xen 
+        * does not pass an EFI SystemTable to the kernel.
+        */
+        struct xen_platform_op op = {
+                .cmd = XENPF_firmware_info,
+                .u.firmware_info = {
+                        .type = XEN_FW_EFI_INFO,  
+                        .index = XEN_FW_EFI_CONFIG_TABLE
+                }
+        };
+        union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+        if (HYPERVISOR_platform_op(&op) == 0) {
+               struct efi_cfgtbl *ct;
+               int i;
+
+               ct = AcpiOsMapMemory(info->cfg.addr, 
+                   sizeof(*ct) * info->cfg.nent);
+
+               for (i = 0; i < info->cfg.nent; i++) {
+                       if (memcmp(&ct[i].ct_uuid,
+                           &EFI_UUID_ACPI20, sizeof(EFI_UUID_ACPI20)) == 0) {
+                               PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
+                                   (uintptr_t)ct[i].ct_data;
+                               if (PhysicalAddress)
+                                       goto out;
+                                       
+                       }
+               }
+
+               for (i = 0; i < info->cfg.nent; i++) {
+                       if (memcmp(&ct[i].ct_uuid,
+                           &EFI_UUID_ACPI10, sizeof(EFI_UUID_ACPI10)) == 0) {
+                               PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
+                                   (uintptr_t)ct[i].ct_data;
+                               if (PhysicalAddress)
+                                       goto out;
+                                       
+                       }
+               }
+out:
+               AcpiOsUnmapMemory(ct, sizeof(*ct) * info->cfg.nent);
+
+               if (PhysicalAddress)
+                       return PhysicalAddress;
+       }
+#else
+       /* 
+        * Get the ACPI RSDP from EFI SystemTable. This works when the 
+        * kernel was loaded from EFI bootloader.
+        */
        if (efi_probe()) {
                PhysicalAddress = efi_getcfgtblpa(&EFI_UUID_ACPI20);
                if (!PhysicalAddress)
@@ -111,6 +164,11 @@
        }
 
 #endif
+       /*
+        * Find ACPI RSDP from Extended BIOS Data Area (EBDA). This
+        * works when the kernel was started from BIOS bootloader,
+        * or for Xen PV when Xen was started from BIOS bootloader.
+        */
        Status = AcpiFindRootPointer(&PhysicalAddress);
        if (ACPI_FAILURE(Status))
                PhysicalAddress = 0;



Home | Main Index | Thread Index | Old Index