From nobody Wed Aug 21 15:24:01 2024 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 4Wpqqj6958z5V3Jn; Wed, 21 Aug 2024 15:24:01 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wpqqj3K2Bz4RnC; Wed, 21 Aug 2024 15:24:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724253841; 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=qXSJteVB7+gqMBGZpdmFHNPe9pk/spvkJOUxBMRIWRI=; b=UrQPjOshHxaDoJT5ochA6YpLY0G06ZYWv2bp1UGeD/GhL2gZPOXEEUjo95MQc9CTquffW+ TwpEQzWGNE+aGET5fW+VyUzwuqLj0jD96do25etbsyibyltDJcYwsVyIUvYdBzjEXBPgHC c1dADg9I+kcOF3tSiWdEHoB3pqizQJ0NJsXU7g4JyxtUe2bzGu3Qy75Rioxu3pILifYL3l er2eBt6GnHVydqPIzd02G8FH22xr878sd8DcT8yACM+xwsZ6X5OZjjjmNJWJF0K+JIuTV6 8Sr7L+8uBbfXCk1BY5EnSF1T3UPuA6FUMVP/g3DViYzjX6LQaFo3nmszlypd9g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724253841; a=rsa-sha256; cv=none; b=dYrGLjYvhFCZjlcqX+5K3k6tENDcT7kM2BT52eI3xnCGa6iEuBaSRNJj8UEZ573hq4mp4f odr3mFFrV9VF04kv8ZS7EKlDFjOu55L0u8uKwYnpxEtPULtNw0Sg2cVZWfPuXO+I9+/URz FzjS6S6Vspu5hNevbFK2UCFq737Vt51h9TB99NzickFCHWOoVyCHlQ6LDo8zDHqpfYGqJ5 /Tfq7kWdPYT8I3/pd0YhGkUTIsqBeQ3K6P5cDy+/Hulg4CukEJWGe1NfUAb0zjihlx/mBe o5B3B+kIVEO4piaV5voryN6JMnkUSqPNi0gryPn0s6mh0OSa0aWK/XPpTGQi7Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724253841; 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=qXSJteVB7+gqMBGZpdmFHNPe9pk/spvkJOUxBMRIWRI=; b=Mm6xylV3LYFDYRDwnuP1kOZ18sIlUzy30Pe6rHg9vrlSZsGxCUTK0YpT1FDXtt5rQluNHf qZNsRe+lejM+RIuz5bpWDpRMDr61sdDRrTrPi2V16rXKWqR34FV8qjuW23B+Yh/4+JIoZa wUlJpZ1wb1Yuj/GUQNvkUFXGGjmN2j/UpUgpCS9KELZS7K0JT4qcevfbR4lcxdTBz14uc4 sTtNL/AXsTDPhdoSjLg0QltyRA2eWjdt/dH5q0T14s7Gd+yAALZsddkA/NllolVXt/QHe6 TuqJRXblDYbBKnJtgASBvQXD53OLc8GjPdGTRfOTo4bBTmyUnWMeilCYTZ6naw== 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 4Wpqqj2HmJzq6Z; Wed, 21 Aug 2024 15:24:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 47LFO1sB070208; Wed, 21 Aug 2024 15:24:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47LFO1qT070205; Wed, 21 Aug 2024 15:24:01 GMT (envelope-from git) Date: Wed, 21 Aug 2024 15:24:01 GMT Message-Id: <202408211524.47LFO1qT070205@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 45543d3424d4 - main - DMAR: clear dmar_devs[unit] if attach failed 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45543d3424d46f84a5399879e190fc359dcefbd4 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=45543d3424d46f84a5399879e190fc359dcefbd4 commit 45543d3424d46f84a5399879e190fc359dcefbd4 Author: Konstantin Belousov AuthorDate: 2024-08-20 14:41:33 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-21 15:23:07 +0000 DMAR: clear dmar_devs[unit] if attach failed This should stop attempts to use a unit which was not completely initialized, but referenced by ACPI DMAR table during scoped devices operions. PR: 280817 Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46382 --- sys/x86/iommu/intel_drv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 0b25620114cd..636534173715 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -422,6 +422,7 @@ dmar_attach(device_t dev) &unit->reg_rid, RF_ACTIVE); if (unit->regs == NULL) { device_printf(dev, "cannot allocate register window\n"); + dmar_devs[unit->iommu.unit] = NULL; return (ENOMEM); } unit->hw_ver = dmar_read4(unit, DMAR_VER_REG); @@ -449,6 +450,7 @@ dmar_attach(device_t dev) error = dmar_alloc_irq(dev, unit, DMAR_INTR_FAULT); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } if (DMAR_HAS_QI(unit)) { @@ -463,6 +465,7 @@ dmar_attach(device_t dev) error = dmar_alloc_irq(dev, unit, DMAR_INTR_QI); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } } @@ -496,12 +499,14 @@ dmar_attach(device_t dev) if (error != 0) { DMAR_UNLOCK(unit); dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } error = dmar_inv_ctx_glob(unit); if (error != 0) { DMAR_UNLOCK(unit); dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } if ((unit->hw_ecap & DMAR_ECAP_DI) != 0) { @@ -509,6 +514,7 @@ dmar_attach(device_t dev) if (error != 0) { DMAR_UNLOCK(unit); dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } } @@ -517,16 +523,19 @@ dmar_attach(device_t dev) error = dmar_init_fault_log(unit); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } error = dmar_init_qi(unit); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } error = dmar_init_irt(unit); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } @@ -542,6 +551,7 @@ dmar_attach(device_t dev) error = iommu_init_busdma(&unit->iommu); if (error != 0) { dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } @@ -551,6 +561,7 @@ dmar_attach(device_t dev) if (error != 0) { DMAR_UNLOCK(unit); dmar_release_resources(dev, unit); + dmar_devs[unit->iommu.unit] = NULL; return (error); } DMAR_UNLOCK(unit);