Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1475894
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. |
| Date | 2016-09-04 11:10 +0200 |
| Message-ID | <sdBB7-88b-9@gated-at.bofh.it> (permalink) |
| References | <scSum-5Eu-29@gated-at.bofh.it> <scSum-5Eu-27@gated-at.bofh.it> <sd1xE-32Z-5@gated-at.bofh.it> <sdzSG-7Pf-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Sun, 4 Sep 2016, Liav Rehana wrote:
Please do not top post and trim your reply.
> The root of the problem is that in case the multiplication of delta and
> tkr->mult in the line that I've changed is too big that the MSB of the
> result is set, then the shift will cause an unwanted sign extension.
I completely understand that, but as I said before:
> > This typecast is just a baindaid. What happens if you double the
> > suspend time? The multiplication will simply overflow. So the proper
> > fix is to sanity check delta and do multiple conversions if delta is
> > big enough. Preferrably this happens somewhere at the call site and
> > not in this hotpath function.
> That sign extension will be avoided completely if the variable nsec was
> unsigned (u64 instead of s64), so I think the correct solution for this
> is to change the type of nsec to u64.
That's a different story and its not a solution for the general problem of
delta * mult >= (1 << 31) or delta * mult >= (1 << 32)
Thanks,
tglx
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-09-02 11:00 +0200
Re: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-09-02 20:40 +0200
Re: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-09-02 20:50 +0200
RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Liav Rehana <liavr@mellanox.com> - 2016-09-04 09:20 +0200
RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-09-04 11:10 +0200
RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Thomas Gleixner <tglx@linutronix.de> - 2016-09-04 12:50 +0200
RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. Liav Rehana <liavr@mellanox.com> - 2016-09-05 00:50 +0200
Re: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation. John Stultz <john.stultz@linaro.org> - 2016-09-07 05:30 +0200
csiph-web