[PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*

Michal Orzel posted 2 patches 3 years, 9 months ago
[PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Posted by Michal Orzel 3 years, 9 months ago
Function unmap_common_complete (common/grant_table.c) defines and sets
a variable ld that is later on passed to a macro:
gnttab_host_mapping_get_page_type().
On Arm this macro does not make use of any arguments causing a compiler
to warn about unused-but-set variable (when -Wunused-but-set-variable
is enabled). Fix it by converting this macro to a static inline
helper and using the boolean return type.

While there, also convert macro gnttab_release_host_mappings.

Signed-off-by: Michal Orzel <michal.orzel@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
Changes since v1:
- mark parameters as const
---
 xen/arch/arm/include/asm/grant_table.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/include/asm/grant_table.h b/xen/arch/arm/include/asm/grant_table.h
index d31a4d6805..5ccaf6d51f 100644
--- a/xen/arch/arm/include/asm/grant_table.h
+++ b/xen/arch/arm/include/asm/grant_table.h
@@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
 #endif
 }
 
+static inline bool gnttab_host_mapping_get_page_type(const bool ro,
+                                                     const struct domain *ld,
+                                                     const struct domain *rd)
+{
+    return false;
+}
+
+static inline bool gnttab_release_host_mappings(const struct domain *d)
+{
+    return true;
+}
+
 int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                               unsigned int flags, unsigned int cache_flags);
-#define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
 int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                                unsigned long new_gpaddr, unsigned int flags);
-#define gnttab_release_host_mappings(domain) 1
 
 /*
  * The region used by Xen on the memory will never be mapped in DOM0
-- 
2.25.1
Re: [PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Posted by Jan Beulich 3 years, 9 months ago
On 06.05.2022 11:42, Michal Orzel wrote:
> Function unmap_common_complete (common/grant_table.c) defines and sets
> a variable ld that is later on passed to a macro:
> gnttab_host_mapping_get_page_type().
> On Arm this macro does not make use of any arguments causing a compiler
> to warn about unused-but-set variable (when -Wunused-but-set-variable
> is enabled). Fix it by converting this macro to a static inline
> helper and using the boolean return type.
> 
> While there, also convert macro gnttab_release_host_mappings.
> 
> Signed-off-by: Michal Orzel <michal.orzel@arm.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>

This R-b applies only ...

> --- a/xen/arch/arm/include/asm/grant_table.h
> +++ b/xen/arch/arm/include/asm/grant_table.h
> @@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
>  #endif
>  }
>  
> +static inline bool gnttab_host_mapping_get_page_type(const bool ro,

... with this const dropped again. As said elsewhere, while not
technically wrong we don't normally do so elsewhere, and this ends
up inconsistent with ...

> +                                                     const struct domain *ld,
> +                                                     const struct domain *rd)

... there being just a single const here.

Jan
Re: [PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Posted by Michal Orzel 3 years, 9 months ago
Hi Jan,

On 06.05.2022 12:03, Jan Beulich wrote:
> On 06.05.2022 11:42, Michal Orzel wrote:
>> Function unmap_common_complete (common/grant_table.c) defines and sets
>> a variable ld that is later on passed to a macro:
>> gnttab_host_mapping_get_page_type().
>> On Arm this macro does not make use of any arguments causing a compiler
>> to warn about unused-but-set variable (when -Wunused-but-set-variable
>> is enabled). Fix it by converting this macro to a static inline
>> helper and using the boolean return type.
>>
>> While there, also convert macro gnttab_release_host_mappings.
>>
>> Signed-off-by: Michal Orzel <michal.orzel@arm.com>
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> This R-b applies only ...
> 
>> --- a/xen/arch/arm/include/asm/grant_table.h
>> +++ b/xen/arch/arm/include/asm/grant_table.h
>> @@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
>>  #endif
>>  }
>>  
>> +static inline bool gnttab_host_mapping_get_page_type(const bool ro,
> 
> ... with this const dropped again. As said elsewhere, while not
> technically wrong we don't normally do so elsewhere, and this ends
> up inconsistent with ...
> 
>> +                                                     const struct domain *ld,
>> +                                                     const struct domain *rd)
> 
> ... there being just a single const here.
> 
> Jan
> 

Do you have any remarks related to the second patch in this series?
If yes, I will handle removal of const in the next version.
If not, Julien said in v1 that this can be handled on commit.

Cheers,
Michal
Re: [PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Posted by Jan Beulich 3 years, 8 months ago
On 10.05.2022 08:52, Michal Orzel wrote:
> Do you have any remarks related to the second patch in this series?

No, I have no further comments there.

Jan
Re: [PATCH v2 1/2] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Posted by Julien Grall 3 years, 9 months ago
Hi,

On 10/05/2022 07:52, Michal Orzel wrote:
> On 06.05.2022 12:03, Jan Beulich wrote:
>> On 06.05.2022 11:42, Michal Orzel wrote:
>>> Function unmap_common_complete (common/grant_table.c) defines and sets
>>> a variable ld that is later on passed to a macro:
>>> gnttab_host_mapping_get_page_type().
>>> On Arm this macro does not make use of any arguments causing a compiler
>>> to warn about unused-but-set variable (when -Wunused-but-set-variable
>>> is enabled). Fix it by converting this macro to a static inline
>>> helper and using the boolean return type.
>>>
>>> While there, also convert macro gnttab_release_host_mappings.
>>>
>>> Signed-off-by: Michal Orzel <michal.orzel@arm.com>
>>> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

>>
>> This R-b applies only ...
>>
>>> --- a/xen/arch/arm/include/asm/grant_table.h
>>> +++ b/xen/arch/arm/include/asm/grant_table.h
>>> @@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
>>>   #endif
>>>   }
>>>   
>>> +static inline bool gnttab_host_mapping_get_page_type(const bool ro,
>>
>> ... with this const dropped again. As said elsewhere, while not
>> technically wrong we don't normally do so elsewhere, and this ends
>> up inconsistent with ...
>>
>>> +                                                     const struct domain *ld,
>>> +                                                     const struct domain *rd)
>>
>> ... there being just a single const here.
>>
>> Jan
>>
> 
> Do you have any remarks related to the second patch in this series?

FYI, Jan is away this week.

> If yes, I will handle removal of const in the next version.
> If not, Julien said in v1 that this can be handled on commit.

I have committed this patch with the change discussed. I need a bit more 
time to review the second patch.

Cheers,

-- 
Julien Grall