lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGM2reYevKGh7pqvK5O7oLB5FYkuU31v7t_AMDYt0=Q+jsVEqw@mail.gmail.com>
Date:   Tue, 24 Jul 2018 22:41:19 -0400
From:   Pavel Tatashin <pasha.tatashin@...cle.com>
To:     Guenter Roeck <linux@...ck-us.net>, peterz@...radead.org
Cc:     LKML <linux-kernel@...r.kernel.org>, mingo@...nel.org,
        tglx@...utronix.de, hpa@...or.com,
        linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/timers] sched/clock: Enable sched clock early

Peter,

The problem is in this stack

start_kernel
  local_irq_enable
  late_time_init
  sched_clock_init
    generic_sched_clock_init
      sched_clock_register
        WARN_ON(!irqs_disabled());

Before this work, sched_clock_init() was called prior to enabling
interrupts, but now after. So, we hit this WARN_ON() in
sched_clock_register().

The question is why do we need this warning in sched_clock_register? I
guess because we want to make this section of the code atomic:

195         new_epoch = read();  <- from here
196         cyc = cd.actual_read_sched_clock();
197         ns = rd.epoch_ns + cyc_to_ns((cyc - rd.epoch_cyc) &
rd.sched_clock_mask, rd.mult, rd.shift);
198         cd.actual_read_sched_clock = read;
199
200         rd.read_sched_clock     = read;
201         rd.sched_clock_mask     = new_mask;
202         rd.mult                 = new_mult;
203         rd.shift                = new_shift;
204         rd.epoch_cyc            = new_epoch;
205         rd.epoch_ns             = ns;
206
207         update_clock_read_data(&rd); <- to here

If we need it, we can surround the sched_clock_register() with
local_irq_disable/local_irq_enable:

diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index cbc72c2c1fca..5015b165b55b 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -243,8 +243,11 @@ void __init generic_sched_clock_init(void)
         * If no sched_clock() function has been provided at that point,
         * make it the final one one.
         */
-       if (cd.actual_read_sched_clock == jiffy_sched_clock_read)
+       if (cd.actual_read_sched_clock == jiffy_sched_clock_read) {
+               local_irq_disable();
                sched_clock_register(jiffy_sched_clock_read, BITS_PER_LONG, HZ);
+               local_irq_enable();
+       }

        update_sched_clock();

Thank you,
Pavel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ