Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Michael Shavit via Toybox
On Fri, Sep 1, 2023 at 5:24 AM Rob Landley wrote: > > On 8/31/23 13:38, Michael Shavit wrote: > > On Thu, Aug 31, 2023 at 8:26 PM Michael Shavit wrote: > >> > >> On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: > >> > > >> >// DATA? Report out of range values as errors rather than truncati

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Michael Shavit via Toybox
On Fri, Sep 1, 2023 at 5:13 AM Rob Landley wrote: > > On 8/31/23 07:26, Michael Shavit wrote: > > On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: > >> Could you send me the test case you hit that motivated this change? (I > >> haven't > >> got a tests/devmem.test yet and am not 100% sure how

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Rob Landley
On 8/31/23 13:38, Michael Shavit wrote: > On Thu, Aug 31, 2023 at 8:26 PM Michael Shavit wrote: >> >> On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: >> > >> >// DATA? Report out of range values as errors rather than truncating. >> > - if (writing) data = atolx_range(toys.optargs[2], 0,

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Rob Landley
On 8/31/23 07:26, Michael Shavit wrote: > On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: >> Could you send me the test case you hit that motivated this change? (I >> haven't >> got a tests/devmem.test yet and am not 100% sure how I'd even set that up in >> mkroot under qemu, but I should work

[Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Michael Shavit via Toybox
Replace the left-shift method of computing the maximum allowed write as it may exibit undefined behavior. Add and use an unsigned version of atolx to support writing any 64bit value. * When bytes equals 8, devmem will left-shift an unsigned long long by 64 bits which is undefined behavior if siz

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Michael Shavit via Toybox
On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: > > On 8/31/23 02:00, Michael Shavit wrote: > > Replace the left-shift method of computing the maximum allowed write as > > it may exibit undefined behavior. > > Add and use an unsigned version of atolx to support writing any 64bit > > value. > >

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Michael Shavit via Toybox
On Thu, Aug 31, 2023 at 8:26 PM Michael Shavit wrote: > > On Thu, Aug 31, 2023 at 6:57 PM Rob Landley wrote: > > > >// DATA? Report out of range values as errors rather than truncating. > > - if (writing) data = atolx_range(toys.optargs[2], 0, (1ULL<<(8*bytes))-1); > > + if (writing && (dat

Re: [Toybox] [PATCH] devmem: Fix 8 byte wide writes

2023-08-31 Thread Rob Landley
On 8/31/23 02:00, Michael Shavit wrote: > Replace the left-shift method of computing the maximum allowed write as > it may exibit undefined behavior. > Add and use an unsigned version of atolx to support writing any 64bit > value. > > * When bytes equals 8, devmem will left-shift an unsigned long