Re: [RFC v2 27/32] x86/tdx: Exclude Shared bit from __PHYSICAL_MASK

From: Dave Hansen
Date: Thu May 20 2021 - 16:30:18 EST


On 5/20/21 11:48 AM, Kuppuswamy, Sathyanarayanan wrote:
>>>   +/* The highest bit of a guest physical address is the "sharing"
>>> bit */
>>> +phys_addr_t tdg_shared_mask(void)
>>> +{
>>> +    return 1ULL << (td_info.gpa_width - 1);
>>> +}
>>
>> Why not just inline this thing?  Functions don't get any smaller than
>> that.  Or does it not get used anywhere else?  Or are you concerned
>> about exporting td_info?
>
> We don't want to export td_info. It has more information additional to
> shared mask details. Any reason for suggesting to use inline?

My favorite reason is that it eliminates the need for three declarations:
1. An extern for the header
2. A stub for the header
3. The real function in the .c file.

An inline removes two places that might get out of sync in some way and
eliminates the need to check two implementation sites when grepping.

Not in this case, but in general, inlines also result in faster, more
compact code since the compiler has more visibility into what the
function does at its call sites.

Not wanting to export td_info _is_ a reasonable argument, though.