Re: [PATCH v15 06/23] selftests/vm/pkeys: Typecast the pkey register
Dave Hansen writes: > On 12/18/19 12:59 PM, Michal Suchánek wrote: >>> I'd really just rather do %016lx *everywhere* than sprinkle the >>> PKEY_REG_FMTs around. >> Does lx work with u32 without warnings? > > Either way, I'd be happy to just make the x86 one u64 to make the whole > thing look more sane, It's userspace so you don't get u64, you only get __u64. And then you'll hit the fact that by default __u64 is unsigned long on powerpc and unsigned long long on x86, meaning you still can't use the same printf specifier. To avoid that you should define __SANE_USERSPACE_TYPES__ before including any headers, and then you'll get unsigned long long for __u64 everywhere and you can just use %llx. cheers
Re: [PATCH v15 06/23] selftests/vm/pkeys: Typecast the pkey register
On Wed, Dec 18, 2019 at 01:01:46PM -0800, Dave Hansen wrote: > On 12/18/19 12:59 PM, Michal Suchánek wrote: > >> I'd really just rather do %016lx *everywhere* than sprinkle the > >> PKEY_REG_FMTs around. > > Does lx work with u32 without warnings? > > Either way, I'd be happy to just make the x86 one u64 to make the whole > thing look more sane, So long as it still works with u64 on x86 it should be pretty future-proof. Does not look like we are getting 128bit registers for anything but math units any time soon. Thanks Michal
Re: [PATCH v15 06/23] selftests/vm/pkeys: Typecast the pkey register
On 12/18/19 12:59 PM, Michal Suchánek wrote: >> I'd really just rather do %016lx *everywhere* than sprinkle the >> PKEY_REG_FMTs around. > Does lx work with u32 without warnings? Either way, I'd be happy to just make the x86 one u64 to make the whole thing look more sane,
Re: [PATCH v15 06/23] selftests/vm/pkeys: Typecast the pkey register
On Wed, Dec 18, 2019 at 12:46:50PM -0800, Dave Hansen wrote: > On 12/17/19 11:51 PM, Sandipan Das wrote: > > write_pkey_reg(pkey_reg); > > - dprintf4("pkey_reg now: %08x\n", read_pkey_reg()); > > + dprintf4("pkey_reg now: "PKEY_REG_FMT"\n", read_pkey_reg()); > > } > > > > #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) > > diff --git a/tools/testing/selftests/vm/pkey-x86.h > > b/tools/testing/selftests/vm/pkey-x86.h > > index 2f04ade8ca9c..5f40901219d3 100644 > > --- a/tools/testing/selftests/vm/pkey-x86.h > > +++ b/tools/testing/selftests/vm/pkey-x86.h > > @@ -46,6 +46,8 @@ > > #define HPAGE_SIZE (1UL<<21) > > #define PAGE_SIZE 4096 > > #define MB (1<<20) > > +#define pkey_reg_t u32 > > +#define PKEY_REG_FMT "%016x" > > How big is the ppc one? u64 > > I'd really just rather do %016lx *everywhere* than sprinkle the > PKEY_REG_FMTs around. Does lx work with u32 without warnings? It's likely the size difference that requires a format specifier definition. > > BTW, why are you doing a %016lx for a u32? It's "%016x" without 'l' for x86 and with 'l' for ppc64. Thanks Michal
Re: [PATCH v15 06/23] selftests/vm/pkeys: Typecast the pkey register
On 12/17/19 11:51 PM, Sandipan Das wrote: > write_pkey_reg(pkey_reg); > - dprintf4("pkey_reg now: %08x\n", read_pkey_reg()); > + dprintf4("pkey_reg now: "PKEY_REG_FMT"\n", read_pkey_reg()); > } > > #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) > diff --git a/tools/testing/selftests/vm/pkey-x86.h > b/tools/testing/selftests/vm/pkey-x86.h > index 2f04ade8ca9c..5f40901219d3 100644 > --- a/tools/testing/selftests/vm/pkey-x86.h > +++ b/tools/testing/selftests/vm/pkey-x86.h > @@ -46,6 +46,8 @@ > #define HPAGE_SIZE (1UL<<21) > #define PAGE_SIZE4096 > #define MB (1<<20) > +#define pkey_reg_t u32 > +#define PKEY_REG_FMT "%016x" How big is the ppc one? I'd really just rather do %016lx *everywhere* than sprinkle the PKEY_REG_FMTs around. BTW, why are you doing a %016lx for a u32?