From owner-svn-src-all@freebsd.org Mon Apr 30 20:29:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FD98FB5DE8; Mon, 30 Apr 2018 20:29:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 514CB7E4FA; Mon, 30 Apr 2018 20:29:29 +0000 (UTC) (envelope-from jhb@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C52018131; Mon, 30 Apr 2018 20:29:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3UKTTAW011260; Mon, 30 Apr 2018 20:29:29 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3UKTT8Q011259; Mon, 30 Apr 2018 20:29:29 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201804302029.w3UKTT8Q011259@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 30 Apr 2018 20:29:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r333126 - in stable: 10/sys/x86/x86 11/sys/x86/x86 X-SVN-Group: stable-10 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 10/sys/x86/x86 11/sys/x86/x86 X-SVN-Commit-Revision: 333126 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Apr 2018 20:29:29 -0000 Author: jhb Date: Mon Apr 30 20:29:28 2018 New Revision: 333126 URL: https://svnweb.freebsd.org/changeset/base/333126 Log: MFC 332735: Fix two off-by-one errors when allocating MSI and MSI-X interrupts. x86 enforces an (arbitray) limit on the number of available MSI and MSI-X interrupts to simplify code (in particular, interrupt_source[] is statically sized). This means that an attempt to allocate an MSI vector needs to fail if it would go beyond the limit, but the checks for exceeding the limit had an off-by-one error. In the case of MSI-X which allocates interrupts one at a time this meant that IRQ 768 kept getting handed out multiple times for msix_alloc() instead of failing because all MSI IRQs were in use. Modified: stable/10/sys/x86/x86/msi.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/x86/x86/msi.c Directory Properties: stable/11/ (props changed) Modified: stable/10/sys/x86/x86/msi.c ============================================================================== --- stable/10/sys/x86/x86/msi.c Mon Apr 30 20:18:32 2018 (r333125) +++ stable/10/sys/x86/x86/msi.c Mon Apr 30 20:29:28 2018 (r333126) @@ -381,7 +381,7 @@ again: /* Do we need to create some new sources? */ if (cnt < count) { /* If we would exceed the max, give up. */ - if (i + (count - cnt) > FIRST_MSI_INT + NUM_MSI_INTS) { + if (i + (count - cnt) >= FIRST_MSI_INT + NUM_MSI_INTS) { mtx_unlock(&msi_lock); free(mirqs, M_MSI); return (ENXIO); @@ -559,7 +559,7 @@ again: /* Do we need to create a new source? */ if (msi == NULL) { /* If we would exceed the max, give up. */ - if (i + 1 > FIRST_MSI_INT + NUM_MSI_INTS) { + if (i + 1 >= FIRST_MSI_INT + NUM_MSI_INTS) { mtx_unlock(&msi_lock); return (ENXIO); }