aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Pau Monné <royger@FreeBSD.org>2022-11-29 15:21:51 +0000
committerRoger Pau Monné <royger@FreeBSD.org>2022-11-29 15:36:34 +0000
commitbc9a5b049797fb7484dc1448f5d806955499f1f0 (patch)
tree3cbdae5c799600eb21f409ff7dcb401340dd9eab
parentbad602850e56d9e3b4900c0063a40dd29ea448fe (diff)
downloadsrc-bc9a5b049797fb7484dc1448f5d806955499f1f0.tar.gz
src-bc9a5b049797fb7484dc1448f5d806955499f1f0.zip
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')
-rw-r--r--sys/dev/xen/cpu/xen_acpi_cpu.c29
1 files changed, 29 insertions, 0 deletions
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