From nobody Tue Nov 29 15:54:35 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NM6NC3MSdz4j8L9; Tue, 29 Nov 2022 15:54:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NM6NC2sRcz4Mqn; Tue, 29 Nov 2022 15:54:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669737275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tfCg3N3XeCzBvwgM2ws3eamfvH/cYDPilyjHU9Fak34=; b=Y+QWfHjdx9JhWDXNdwnX/CNw8jrrJ0n8kXXniBSkTrMTEc0YNC4Zh1p9pNeAlg98u4kX6Y 9rw7MTMrkTVLJq0lrlIAOlV+5EDBU3JgV14CYGvNv+SQqz79NE/Q+Sveb7vthwVoTXu9SL IZa8OHJJuxz/GH7WqR2+4wWjjEVZqEfJFYZq2V6anzuHNNyu093vP9m427TPUOIqCYsqZ7 F2Tim+B819cxVkx3n340EA9A9t/LpgFwh2RFhqtmQtsTRia/zwLBuiJoAdHxCwEDRZm3io vXZN/t+jeG1RtwyNIvh0A3iTUbo3JRJinICmfzPCIPhUT1IoI7Bjq/NlwIgBuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669737275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tfCg3N3XeCzBvwgM2ws3eamfvH/cYDPilyjHU9Fak34=; b=IXV/7uvGtpjQlGgjWuu+I0alG6f//udV/7/vnuRqVQSepHx+WG8vht7DOxTKErwHn/L0SL kfUBp2XX+kzBIaxmUMgM9vl7Gf8CIOmncuaZGqOLMe4dlhHBghDItIiyFf4eX4zJBxU+i7 Vo01Z71cBuFiWbyavfdb+5H5nbrKjtupn7SXGMj6SOgq2UT57KUXPBIv0/xzjfWLtqUich oHhF5/Sai/2Do/OrgHZY14ElKueb8cZKIqdA5b43WRkMRLgCpAK0RG5v+FZw/zkdTysa3I UQzQ2/lPk9Ze/R+W/FxFh45e3F01hsS0cjmroOxnrJAj7PUTTqQ/QkPx3Icxhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669737275; a=rsa-sha256; cv=none; b=Vm43CgSk+i3+IYwnQQ8R7lX+peR/i/qyZoAEMTd78lYR+02c23Eg1PAr7zZpzfEEdT30Sw kaNtkUhD/wbE0q3W0aRxyLMGa/uAwO2l0YJK+rMekVmnd8WhWuLbRMHaxCLg6TurWAJJft xQjx1By/fJEC+LQ0E/mV+32b4iWIFdne2QZTBqz2XBni86t3MTY6KuWndx6vB0GjIhAUGC 2kIBnb+fOKnY6YM91qlBksj3m5KRTh6KQCU+qNDQ4gwSAz8Egfh7w65YYU8jl8Ib9LXtdG g7TKD01mJIBfRWuHsADT3HvS34mpbDdPWbiMmVeYYVHnv/rgkjvPZ3Ud4qFSgA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NM6NC1xPWzNMS; Tue, 29 Nov 2022 15:54:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2ATFsZQH098824; Tue, 29 Nov 2022 15:54:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ATFsZXI098823; Tue, 29 Nov 2022 15:54:35 GMT (envelope-from git) Date: Tue, 29 Nov 2022 15:54:35 GMT Message-Id: <202211291554.2ATFsZXI098823@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Roger=20Pau=20Monn=C3=A9?= Subject: git: bc9a5b049797 - main - xen/acpi: only evaluate Processor objects matching online CPUs List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: royger X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bc9a5b049797fb7484dc1448f5d806955499f1f0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by royger: URL: https://cgit.FreeBSD.org/src/commit/?id=bc9a5b049797fb7484dc1448f5d806955499f1f0 commit bc9a5b049797fb7484dc1448f5d806955499f1f0 Author: Roger Pau Monné AuthorDate: 2022-11-29 15:21:51 +0000 Commit: Roger Pau Monné 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