s390x/tcg: avoid overflows in time2tod/tod2time
commit14055ce53c2d901d826ffad7fb7d6bb8ab46bdfd
authorDavid Hildenbrand <david@redhat.com>
Wed, 27 Jun 2018 13:44:02 +0000 (27 15:44 +0200)
committerCornelia Huck <cohuck@redhat.com>
Mon, 2 Jul 2018 08:37:38 +0000 (2 10:37 +0200)
treeea862f25f01811e86b14928bbcd00ed42a20940f
parent87273151110b7736b34ae3e37ad778c28c36d643
s390x/tcg: avoid overflows in time2tod/tod2time

Big values for the TOD/ns clock can result in some overflows that can be
avoided. Not all overflows can be handled however, as the conversion either
multiplies by 4.096 or divided by 4.096.

Apply the trick used in the Linux kernel in arch/s390/include/asm/timex.h
for tod_to_ns() and use the same trick also for the conversion in the
other direction.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180627134410.4901-2-david@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
target/s390x/internal.h