Fix access_with_adjusted_size() on big-endian
A message that is not in the archive (sent off-list or not yet received): [email protected]
Peter Maydell
Reviewed-byQuoted 11 lines · Philippe Mathieu-Daudé
Hi,
This series fix a bug I'v been hunting for a long time.
With BE regions, if the guest used smaller access than the region implementation, the shift value is negative, but since
access_fn()uses unsigned type for shift, it result in a huge positive value, then accessors shift the value which eventually becomes 0.The fix is simply to use signed type for the shift, and shift to the opposite direction for negative values.
Series
I guess we don't have very many devices that are BE and that allow the guest to access them with a smaller width than their implemented width...
thanks
-- PMM
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Philippe Mathieu-Daudé
Hi,
This series fix a bug I'v been hunting for a long time.
With BE regions, if the guest used smaller access than the region implementation, the shift value is negative, but since
access_fn()uses unsigned type for shift, it result in a huge positive value, then accessors shift the value which eventually becomes 0.
Quoted 5 lines
Quoted 2 lines
The fix is simply to use signed type for the shift, and shift to the opposite direction for negative values.
Series
Reviewed-by Peter Maydell <[email protected]>
Thanks for reviewing this.
Quoted 3 lines
I guess we don't have very many devices that are BE and that allow the guest to access them with a smaller width than their implemented width...
Do you think is it worth using the '(un)likely()' macros?
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Philippe Mathieu-Daudé
Hi,
This series fix a bug I'v been hunting for a long time.
With BE regions, if the guest used smaller access than the region implementation, the shift value is negative, but since
access_fn()uses unsigned type for shift, it result in a huge positive value, then accessors shift the value which eventually becomes 0.Quoted 5 lines
Quoted 2 lines
The fix is simply to use signed type for the shift, and shift to the opposite direction for negative values.
Series
Reviewed-by Peter Maydell <[email protected]>
Quoted 7 lines
Thanks for reviewing this.
Quoted 3 lines
I guess we don't have very many devices that are BE and that allow the guest to access them with a smaller width than their implemented width...
Do you think is it worth using the '(un)likely()' macros?
Probably not; that was just a comment on why we haven't run into the bug sooner.
thanks
-- PMM