Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:07:25 -0000
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r346561 - stable/11/sys/arm/arm
Message-ID:  <201904221523.x3MFN7IX074050@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Mon Apr 22 15:23:06 2019
New Revision: 346561
URL: https://svnweb.freebsd.org/changeset/base/346561

Log:
  MFC r346312:
  
  Only set up the interrupts that will actually be used in arm generic_timer.
  
  The code previously set up interrupt handlers for all the interrupt
  resources available, including for timers that are not in use.  That could
  lead to interrupt storms.  For example, if boot firmware enabled the virtual
  timer but the kernel is using the physical timer, it could get flooded with
  interrupts on the virtual timer which it cannot shut off.  By only setting
  up an interrupt handler for the hardware that will actually be used, any
  interrupts from other timer units will remain masked in the interrupt
  controller.
  
  Differential Revision:	https://reviews.freebsd.org/D19871

Modified:
  stable/11/sys/arm/arm/generic_timer.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/arm/generic_timer.c
==============================================================================
--- stable/11/sys/arm/arm/generic_timer.c	Mon Apr 22 15:20:46 2019	(r346560)
+++ stable/11/sys/arm/arm/generic_timer.c	Mon Apr 22 15:23:06 2019	(r346561)
@@ -359,7 +359,7 @@ arm_tmr_attach(device_t dev)
 	pcell_t clock;
 #endif
 	int error;
-	int i;
+	int i, first_timer, last_timer;
 
 	sc = device_get_softc(dev);
 	if (arm_tmr_sc)
@@ -391,17 +391,25 @@ arm_tmr_attach(device_t dev)
 		return (ENXIO);
 	}
 
-#ifdef __arm__
-	sc->physical = true;
-#else /* __aarch64__ */
-	/* If we do not have a virtual timer use the physical. */
-	sc->physical = (sc->res[2] == NULL) ? true : false;
+#ifdef __aarch64__
+	/* Use the virtual timer if we have one. */
+	if (sc->res[2] != NULL) {
+		sc->physical = false;
+		first_timer = 2;
+		last_timer = 2;
+	} else
 #endif
+	/* Otherwise set up the secure and non-secure physical timers. */
+	{
+		sc->physical = true;
+		first_timer = 0;
+		last_timer = 1;
+	}
 
 	arm_tmr_sc = sc;
 
 	/* Setup secure, non-secure and virtual IRQs handler */
-	for (i = 0; i < 3; i++) {
+	for (i = first_timer; i <= last_timer; i++) {
 		/* If we do not have the interrupt, skip it. */
 		if (sc->res[i] == NULL)
 			continue;





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