git: bc9a5b049797 - main - xen/acpi: only evaluate Processor objects matching online CPUs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Nov 2022 15:54:35 UTC
The branch main has been updated by royger:
URL: https://cgit.FreeBSD.org/src/commit/?id=bc9a5b049797fb7484dc1448f5d806955499f1f0
commit bc9a5b049797fb7484dc1448f5d806955499f1f0
Author: Roger Pau Monné <royger@FreeBSD.org>
AuthorDate: 2022-11-29 15:21:51 +0000
Commit: Roger Pau Monné <royger@FreeBSD.org>
CommitDate: 2022-11-29 15:36:34 +0000
xen/acpi: only evaluate Processor objects matching online CPUs
Current Xen Processor driver will evaluate any Processor object on the
ACPI tables regardless of whether the processor is online or not.
Avoid doing so for processors that are not online, as evaluating
methods of processors that are not online could lead to accesses to
invalid memory, and in any case the data that the driver fetches from
the Processor ACPI object only makes sense for processors that are
online.
Note the CPU related data fetched from Xen using XENPF_get_cpuinfo
hypercall could be cached, I leave that as a future optimization.
Sponsored by: Citrix Systems R&D
Fixes: b93f47eaeef7 ('xen/acpi: upload Cx and Px data to Xen')
---
sys/dev/xen/cpu/xen_acpi_cpu.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/sys/dev/xen/cpu/xen_acpi_cpu.c b/sys/dev/xen/cpu/xen_acpi_cpu.c
index 724634b9fa5f..e95da324bda0 100644
--- a/sys/dev/xen/cpu/xen_acpi_cpu.c
+++ b/sys/dev/xen/cpu/xen_acpi_cpu.c
@@ -506,6 +506,31 @@ xen_acpi_cpu_probe(device_t dev)
return (BUS_PROBE_SPECIFIC);
}
+static bool
+is_processor_online(unsigned int acpi_id)
+{
+ unsigned int i, maxid;
+ struct xen_platform_op op = {
+ .cmd = XENPF_get_cpuinfo,
+ };
+ int ret = HYPERVISOR_platform_op(&op);
+
+ if (ret)
+ return (false);
+
+ maxid = op.u.pcpu_info.max_present;
+ for (i = 0; i <= maxid; i++) {
+ op.u.pcpu_info.xen_cpuid = i;
+ ret = HYPERVISOR_platform_op(&op);
+ if (ret)
+ continue;
+ if (op.u.pcpu_info.acpi_id == acpi_id)
+ return (op.u.pcpu_info.flags & XEN_PCPU_FLAGS_ONLINE);
+ }
+
+ return (false);
+}
+
static int
xen_acpi_cpu_attach(device_t dev)
{
@@ -544,6 +569,10 @@ xen_acpi_cpu_attach(device_t dev)
}
}
+ if (!is_processor_online(sc->cpu_acpi_id))
+ /* Processor is not online, attach the driver and ignore it. */
+ return (0);
+
/*
* Install the notify handler now: even if we fail to parse or upload
* the states it shouldn't prevent us from attempting to parse further