Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Apr 2018 20:29:29 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
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
Message-ID:  <201804302029.w3UKTT8Q011259@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804302029.w3UKTT8Q011259>