On 16.12.2022 03:25, Demi Marie Obenour wrote:
>> --- a/xen/arch/x86/include/asm/processor.h
>> +++ b/xen/arch/x86/include/asm/processor.h
>> @@ -100,6 +100,14 @@
>>
>> #ifndef __ASSEMBLY__
>>
>> +/* Convert from PAT/PCD/PWT embedded in PTE flags to actual cacheability
>> value */
>> +static inline unsigned int pte_flags_to_cacheability(unsigned int flags)
>> +{
>> + unsigned int pat_shift = ((flags & _PAGE_PAT) >> 2) |
>> + (flags & (_PAGE_PCD|_PAGE_PWT));
>
> This could also be written as
>
> unsigned int pat_shift = pte_flags_to_cacheattr(flags) << 3;
>
> which might be easiser to read.
Indeed. And then also be placed next to the other function (provided
we want this to be a globally visible helper in the first place).
But first of all Andrew's comment wants addressing - if the code
using this new helper is to be deleted, then the new helper doesn't
need getting into proper shape and place.
Jan