Mesa (master): gallium/util: make sure cache line size is not zero

Roland Scheidegger sroland at kemper.freedesktop.org
Mon Jan 5 16:59:21 UTC 2015


Module: Mesa
Branch: master
Commit: 5fea39ace311723dab53460ae7b51b80746e0d3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5fea39ace311723dab53460ae7b51b80746e0d3f

Author: Leonid Shatz <leonid.shatz at ravellosystems.com>
Date:   Wed Dec 31 19:07:44 2014 +0100

gallium/util: make sure cache line size is not zero

The "normal" detection (querying clflush size) already made sure it is
non-zero, however another method did not. This lead to crashes if this
value happened to be zero (apparently can happen in virtualized environments
at least).
This fixes https://bugs.freedesktop.org/show_bug.cgi?id=87913

Cc: "10.4" <mesa-stable at lists.freedesktop.org>

---

 src/gallium/auxiliary/util/u_cpu_detect.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
index 28197f4..23ab46c 100644
--- a/src/gallium/auxiliary/util/u_cpu_detect.c
+++ b/src/gallium/auxiliary/util/u_cpu_detect.c
@@ -409,8 +409,12 @@ util_cpu_detect(void)
       }
 
       if (regs[0] >= 0x80000006) {
+         /* should we really do this if the clflush size above worked? */
+         unsigned int cacheline;
          cpuid(0x80000006, regs2);
-         util_cpu_caps.cacheline = regs2[2] & 0xFF;
+         cacheline = regs2[2] & 0xFF;
+         if (cacheline > 0)
+            util_cpu_caps.cacheline = cacheline;
       }
 
       if (!util_cpu_caps.has_sse) {




More information about the mesa-commit mailing list