Messages in this thread | | | Date | Wed, 2 Feb 2022 12:28:59 -0800 | From | Ira Weiny <> | Subject | Re: [PATCH V8 04/44] x86/pkeys: Add additional PKEY helper macros |
| |
On Wed, Feb 02, 2022 at 12:26:44PM -0800, Dave Hansen wrote: > On 2/2/22 12:21, Ira Weiny wrote: > > On Fri, Jan 28, 2022 at 02:47:30PM -0800, Dave Hansen wrote: > >> #define PKR_WD_MASK(pkey) (PKR_WD_BIT << PKR_PKEY_SHIFT(pkey)) > >> > >> Which says, "generate a write-disabled mask for this pkey". > > > > I think the confusion comes from me having used these as mask values rather > > than what PKR_AD_KEY() was intended to be used for. > > > > In the previous patch PKR_AD_KEY() is used to set up the default user pkey > > value... > > > > u32 init_pkru_value = PKR_AD_KEY( 1) | PKR_AD_KEY( 2) | PKR_AD_KEY( 3) | > > PKR_AD_KEY( 4) | PKR_AD_KEY( 5) | PKR_AD_KEY( 6) | > > PKR_AD_KEY( 7) | PKR_AD_KEY( 8) | PKR_AD_KEY( 9) | > > PKR_AD_KEY(10) | PKR_AD_KEY(11) | PKR_AD_KEY(12) | > > PKR_AD_KEY(13) | PKR_AD_KEY(14) | PKR_AD_KEY(15); > > > > Hah, I'm complaining about my own code. > > > u32 init_pkru_value = PKR_AD_MASK( 1) | PKR_AD_MASK( 2) | PKR_AD_MASK( 3) | > > PKR_AD_MASK( 4) | PKR_AD_MASK( 5) | PKR_AD_MASK( 6) | > > PKR_AD_MASK( 7) | PKR_AD_MASK( 8) | PKR_AD_MASK( 9) | > > PKR_AD_MASK(10) | PKR_AD_MASK(11) | PKR_AD_MASK(12) | > > PKR_AD_MASK(13) | PKR_AD_MASK(14) | PKR_AD_MASK(15); > > > > It seems odd to me. Does it seem odd to you? > > Looks OK to me. It's build a "value" out of a bunch of individual masks. > > > Looking at the final code I think I'm going to just drop the usages in this > > patch and add PKR_WD_KEY() where it is used first. > > > > Also, how about PKR_KEY_INIT_{AD|WD|RW}() as a name? > > For the PKR_AD_KEY() macro?
Yes if I drop this patch then the only place these are used is to initialize the registers.
Ira
| |