Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/include/linux Fix mistake in array_ind...



details:   https://anonhg.NetBSD.org/src/rev/c0d892086bad
branches:  trunk
changeset: 1028060:c0d892086bad
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 01:45:38 2021 +0000

description:
Fix mistake in array_index_nospec.

j must be constrained to be in the same register on input or output;
otherwise the compiler may put them in different places, expect the
asm code to write to the output register, and read garbage from the
output register when we fail to put anything there.

diffstat:

 sys/external/bsd/drm2/include/linux/nospec.h |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 2d861e65de13 -r c0d892086bad sys/external/bsd/drm2/include/linux/nospec.h
--- a/sys/external/bsd/drm2/include/linux/nospec.h      Sun Dec 19 01:45:30 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/nospec.h      Sun Dec 19 01:45:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nospec.h,v 1.2 2021/12/19 01:44:02 riastradh Exp $     */
+/*     $NetBSD: nospec.h,v 1.3 2021/12/19 01:45:38 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
         * reading from and writing to j but actually does nothing.
         */
        j = i;
-       asm volatile ("" : "=r"(j) : "r"(j));
+       asm volatile ("" : "=r"(j) : "0"(j));
 
        /* If i >= n, then diff has the high bit set; otherwise clear.  */
        diff = n - 1 - j;



Home | Main Index | Thread Index | Old Index