linux/arch/s390
Heiko Carstens f8d8977a3d s390/time: convert tod_clock_base to union
Convert tod_clock_base to union tod_clock. This simplifies quite a bit
of code and also fixes a bug in read_persistent_clock64();

void read_persistent_clock64(struct timespec64 *ts)
{
        __u64 delta;

        delta = initial_leap_seconds + TOD_UNIX_EPOCH;
        get_tod_clock_ext(clk);
        *(__u64 *) &clk[1] -= delta;
        if (*(__u64 *) &clk[1] > delta)
                clk[0]--;
        ext_to_timespec64(clk, ts);
}

Assume &clk[1] == 3 and delta == 2; then after the substraction the if
condition becomes true and the epoch part of the clock is decremented
by one because of an assumed overflow, even though there is none.

Fix this by using 128 bit arithmetics and let the compiler do the
right thing:

void read_persistent_clock64(struct timespec64 *ts)
{
        union tod_clock clk;
        u64 delta;

        delta = initial_leap_seconds + TOD_UNIX_EPOCH;
        store_tod_clock_ext(&clk);
        clk.eitod -= delta;
        ext_to_timespec64(&clk, ts);
}

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2021-02-13 17:17:54 +01:00
..
appldata s390/appldata: use struct_size() helper 2020-06-29 16:32:34 +02:00
boot kasan, x86, s390: update undef CONFIG_KASAN 2020-12-22 12:55:08 -08:00
configs s390/vdso: implement generic vdso time namespace support 2021-02-09 15:57:05 +01:00
crypto s390/crypto: improve retry logic in case of master key change 2021-01-27 13:00:48 +01:00
hypfs fs_parse: fold fs_parameter_desc/fs_parameter_spec 2020-02-07 14:48:37 -05:00
include s390/time: convert tod_clock_base to union 2021-02-13 17:17:54 +01:00
kernel s390/time: convert tod_clock_base to union 2021-02-13 17:17:54 +01:00
kvm s390: convert to generic entry 2021-01-19 12:29:26 +01:00
lib s390: convert to generic entry 2021-01-19 12:29:26 +01:00
mm s390: convert to generic entry 2021-01-19 12:29:26 +01:00
net s390/bpf: Fix multiple tail calls 2020-09-14 18:21:31 -07:00
oprofile s390/unwind: introduce stack unwind API 2019-05-02 13:54:11 +02:00
pci s390/pci: refactor zpci_create_device() 2021-02-09 15:57:04 +01:00
purgatory - Add support for the hugetlb_cma command line option to allocate gigantic 2020-12-14 16:22:26 -08:00
tools .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kbuild s390/numa: move code to arch/s390/kernel 2020-08-11 18:16:55 +02:00
Kconfig s390,alpha: switch to 64-bit ino_t 2021-02-13 17:17:53 +01:00
Kconfig.debug s390: convert to generic entry 2021-01-19 12:29:26 +01:00
Makefile s390/decompressor: add stacktrace support 2020-11-20 19:19:11 +01:00