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

2023-10-10 Thread enh via Toybox
the attached patch gives us your nice "%lx>%d bytes" error for all cases. On Mon, Oct 9, 2023 at 9:42 PM Rob Landley wrote: > > On 10/9/23 17:04, enh wrote: > > On Mon, Oct 9, 2023 at 2:45 PM Rob Landley wrote: > >> > >> On 10/9/23 10:26, enh wrote: > >> >> Let me know how commit 5f153b56214f

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

2023-10-09 Thread Rob Landley
On 10/9/23 17:04, enh wrote: > On Mon, Oct 9, 2023 at 2:45 PM Rob Landley wrote: >> >> On 10/9/23 10:26, enh wrote: >> >> Let me know how commit 5f153b56214f works? I don't have a test environment >> >> for this, but it seems to produce the errors right on 32 and 64 bit at >> >> least... >> > >>

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

2023-10-09 Thread enh via Toybox
On Mon, Oct 9, 2023 at 2:45 PM Rob Landley wrote: > > On 10/9/23 10:26, enh wrote: > >> Let me know how commit 5f153b56214f works? I don't have a test environment > >> for this, but it seems to produce the errors right on 32 and 64 bit at > >> least... > > > > it's a bit early in the morning for

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

2023-10-09 Thread Rob Landley
On 10/9/23 10:26, enh wrote: >> Let me know how commit 5f153b56214f works? I don't have a test environment >> for this, but it seems to produce the errors right on 32 and 64 bit at >> least... > > it's a bit early in the morning for me, but doesn't the change from > `unsigned long long` to

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

2023-10-09 Thread enh via Toybox
it's a bit early in the morning for me, but doesn't the change from `unsigned long long` to `unsigned long` mean that by the time you test the result it can't be too large because you've already truncated? On Sat, Oct 7, 2023 at 11:39 PM Rob Landley wrote: > > On 10/6/23 14:59, enh wrote: > > On

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

2023-10-08 Thread Rob Landley
On 10/6/23 14:59, enh wrote: > On Fri, Oct 6, 2023 at 12:35 PM Michael Shavit via Toybox > wrote: >> >> On Fri, Oct 6, 2023 at 4:41 AM Rob Landley wrote: >> > >> > I could adjust _just_ addr to use unsigned long instead of unsigned long >> > long, >> > but I don't want two atollu()/atolu() and

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

2023-10-06 Thread enh via Toybox
On Fri, Oct 6, 2023 at 12:35 PM Michael Shavit via Toybox wrote: > > On Fri, Oct 6, 2023 at 4:41 AM Rob Landley wrote: > > > > I could adjust _just_ addr to use unsigned long instead of unsigned long > > long, > > but I don't want two atollu()/atolu() and letting you do a longer address > >

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

2023-10-06 Thread Michael Shavit via Toybox
On Fri, Oct 6, 2023 at 4:41 AM Rob Landley wrote: > > I could adjust _just_ addr to use unsigned long instead of unsigned long long, > but I don't want two atollu()/atolu() and letting you do a longer address and > silently truncating it isn't great either. Also, a 32-bit platform can't do an >

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

2023-10-06 Thread Rob Landley
On 8/31/23 02:00, Michael Shavit via Toybox 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

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

2023-09-19 Thread Michael Shavit via Toybox
LGTM! Thanks :) . On Tue, Sep 19, 2023 at 4:34 AM Rob Landley wrote: > > On 9/18/23 18:08, Michael Shavit wrote: > > On Thu, Aug 31, 2023 at 3:57 AM Rob Landley wrote: > >> +unsigned long long atollu(char *str) > >> +{ > >> + char *end = str; > >> + unsigned long long llu = strtoul(str, ,

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

2023-09-19 Thread Rob Landley
On 9/18/23 18:08, Michael Shavit wrote: > On Thu, Aug 31, 2023 at 3:57 AM Rob Landley wrote: >> +unsigned long long atollu(char *str) >> +{ >> + char *end = str; >> + unsigned long long llu = strtoul(str, , 0); > > Sorry I didn't notice this earlier, but hort...@google.com pointed out > that

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

2023-09-18 Thread Michael Shavit via Toybox
On Thu, Aug 31, 2023 at 3:57 AM Rob Landley wrote: > +unsigned long long atollu(char *str) > +{ > + char *end = str; > + unsigned long long llu = strtoul(str, , 0); Sorry I didn't notice this earlier, but hort...@google.com pointed out that we should be using strtoull() here. This supposedly

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

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

[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

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 &&

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