From owner-svn-src-head@freebsd.org Fri Sep 8 19:45:38 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8F6DE06C68; Fri, 8 Sep 2017 19:45:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B88E1680FE; Fri, 8 Sep 2017 19:45:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v88Jjbth098365; Fri, 8 Sep 2017 19:45:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v88JjbmQ098364; Fri, 8 Sep 2017 19:45:37 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201709081945.v88JjbmQ098364@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 8 Sep 2017 19:45:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323326 - head/sys/x86/iommu X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/x86/iommu X-SVN-Commit-Revision: 323326 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 19:45:39 -0000 Author: kib Date: Fri Sep 8 19:45:37 2017 New Revision: 323326 URL: https://svnweb.freebsd.org/changeset/base/323326 Log: Use IOAPIC PCI rid as the interrupt TLP source id for DMAR interrupt remapping. VT-d specification requires use of PCI rid as source id for IOAPICs enumerated by PCI bus. The values from the DMAR ACPI table should be only used when IOAPIC is not on PCI. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Hardware provided by: Intel MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D12205 Modified: head/sys/x86/iommu/intel_drv.c Modified: head/sys/x86/iommu/intel_drv.c ============================================================================== --- head/sys/x86/iommu/intel_drv.c Fri Sep 8 19:39:20 2017 (r323325) +++ head/sys/x86/iommu/intel_drv.c Fri Sep 8 19:45:37 2017 (r323326) @@ -71,6 +71,9 @@ __FBSDID("$FreeBSD$"); #ifdef DEV_APIC #include "pcib_if.h" +#include +#include +#include #endif #define DMAR_FAULT_IRQ_RID 0 @@ -788,6 +791,9 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t ACPI_DMAR_DEVICE_SCOPE *devscope; ACPI_DMAR_PCI_PATH *path; char *ptr, *ptrend; +#ifdef DEV_APIC + int error; +#endif int i; for (i = 0; i < dmar_devcnt; i++) { @@ -809,6 +815,17 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t continue; if (devscope->EnumerationId != id) continue; +#ifdef DEV_APIC + if (entry_type == ACPI_DMAR_SCOPE_TYPE_IOAPIC) { + error = ioapic_get_rid(id, rid); + /* + * If our IOAPIC has PCI bindings then + * use the PCI device rid. + */ + if (error == 0) + return (unit); + } +#endif if (devscope->Length - sizeof(ACPI_DMAR_DEVICE_SCOPE) == 2) { if (rid != NULL) { @@ -818,12 +835,11 @@ dmar_find_nonpci(u_int id, u_int entry_type, uint16_t path->Device, path->Function); } return (unit); - } else { - /* XXXKIB */ - printf( - "dmar_find_nonpci: id %d type %d path length != 2\n", - id, entry_type); } + printf( + "dmar_find_nonpci: id %d type %d path length != 2\n", + id, entry_type); + break; } } return (NULL);