From mboxrd@z Thu Jan 1 00:00:00 1970 From: dave.hansen at intel.com (Dave Hansen) Date: Fri, 16 Mar 2018 15:05:19 -0700 Subject: [PATCH v12 05/22] selftests/vm: generic function to handle shadow key register In-Reply-To: <1519264541-7621-6-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> <1519264541-7621-6-git-send-email-linuxram@us.ibm.com> Message-ID: <92951c0a-0468-6d3c-efef-2d9da53fd10f@intel.com> On 02/21/2018 05:55 PM, Ram Pai wrote: > +static inline u32 pkey_to_shift(int pkey) > +{ > + return pkey * PKEY_BITS_PER_PKEY; > +} pkey_bit_position(), perhaps? > +static inline pkey_reg_t reset_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return ~(bits << shift); > +} I'd prefer clear_pkey_flags() or maybe clear_pkey_bits(). "reset" can mean "reset to 0" or "reset to 1". Also, why the u32 here? Isn't an int more appropriate? > +static inline pkey_reg_t left_shift_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return (bits << shift); > +} > + > +static inline pkey_reg_t right_shift_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return (bits >> shift); > +} Some comments on these would be handy. Basically that this takes a per-key flags value and puts it at the right position so it can be shoved in the register. -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: dave.hansen@intel.com (Dave Hansen) Date: Fri, 16 Mar 2018 15:05:19 -0700 Subject: [PATCH v12 05/22] selftests/vm: generic function to handle shadow key register In-Reply-To: <1519264541-7621-6-git-send-email-linuxram@us.ibm.com> References: <1519264541-7621-1-git-send-email-linuxram@us.ibm.com> <1519264541-7621-6-git-send-email-linuxram@us.ibm.com> Message-ID: <92951c0a-0468-6d3c-efef-2d9da53fd10f@intel.com> Content-Type: text/plain; charset="UTF-8" Message-ID: <20180316220519.LwGqN19IO8m7QbeJi0ZiREFWKrMP-A0bEi3cD-Wyxwk@z> On 02/21/2018 05:55 PM, Ram Pai wrote: > +static inline u32 pkey_to_shift(int pkey) > +{ > + return pkey * PKEY_BITS_PER_PKEY; > +} pkey_bit_position(), perhaps? > +static inline pkey_reg_t reset_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return ~(bits << shift); > +} I'd prefer clear_pkey_flags() or maybe clear_pkey_bits(). "reset" can mean "reset to 0" or "reset to 1". Also, why the u32 here? Isn't an int more appropriate? > +static inline pkey_reg_t left_shift_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return (bits << shift); > +} > + > +static inline pkey_reg_t right_shift_bits(int pkey, pkey_reg_t bits) > +{ > + u32 shift = pkey_to_shift(pkey); > + > + return (bits >> shift); > +} Some comments on these would be handy. Basically that this takes a per-key flags value and puts it at the right position so it can be shoved in the register. -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html