Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/arch/x86/x86 Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/875af46c814d
branches:  netbsd-8
changeset: 934924:875af46c814d
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jun 20 16:05:06 2020 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1560):

        sys/arch/x86/x86/cpu_rng.c: revision 1.16

Use x86_read_psl/x86_disable_intr/x86_read_psl to defer interrupts.

Using x86_disable_intr/x86_enable_intr causes a bit of a snag when we
try it early at boot before we're ready to handle interrupts, because
it has the effect of enabling interrupts!

Fixes instant reset at boot on VIA CPUs.  The instant reset on boot
is new since the entropy rework, which initialized the x86 CPU RNG
earlier than before, but in principle this could also cause other
problems while not early at boot too.

XXX pullup

diffstat:

 sys/arch/x86/x86/cpu_rng.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r bacf3c1d2377 -r 875af46c814d sys/arch/x86/x86/cpu_rng.c
--- a/sys/arch/x86/x86/cpu_rng.c        Tue Jun 16 10:29:16 2020 +0000
+++ b/sys/arch/x86/x86/cpu_rng.c        Sat Jun 20 16:05:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.5 2016/02/29 00:17:54 riastradh Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.5.12.1 2020/06/20 16:05:06 martin Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -136,6 +136,7 @@
 static size_t
 cpu_rng_via(cpu_rng_t *out)
 {
+       u_long psl;
        uint32_t creg0, rndsts;
 
        /*
@@ -149,9 +150,9 @@
         * even if such a fault is generated.
         *
         * XXX can this really happen if we don't use "rep xstorrng"?
-        *
         */
        kpreempt_disable();
+       psl = x86_read_psl();
        x86_disable_intr();
        creg0 = rcr0();
        lcr0(creg0 & ~(CR0_EM|CR0_TS)); /* Permit access to SIMD/FPU path */
@@ -165,7 +166,7 @@
            : "=a" (rndsts), "+D" (out) : "d" (0) : "memory");
        /* Put CR0 back how it was */
        lcr0(creg0);
-       x86_enable_intr();
+       x86_write_psl(psl);
        kpreempt_enable();
 
        /*



Home | Main Index | Thread Index | Old Index