Re: [Xen-devel] [PATCH] libx86: Fix 32bit stubdom build of x86_cpuid_policy_fill_native()

2018-11-13 Thread Roger Pau Monné
On Tue, Nov 13, 2018 at 11:59:15AM +, Andrew Cooper wrote:
> With -m32, GCC generates a warning for _t ==  long, which is the
> typecheck hidden inside the min() macro.
> 
> Switch to using explicitly typed versions instead.
> 
> Signed-off-by: Andrew Cooper 

Reviewed-by: Roger Pau Monné 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libx86: Fix 32bit stubdom build of x86_cpuid_policy_fill_native()

2018-11-13 Thread Wei Liu
On Tue, Nov 13, 2018 at 11:59:15AM +, Andrew Cooper wrote:
> With -m32, GCC generates a warning for _t ==  long, which is the
> typecheck hidden inside the min() macro.
> 
> Switch to using explicitly typed versions instead.
> 
> Signed-off-by: Andrew Cooper 

Reviewed-by: Wei Liu 

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libx86: Fix 32bit stubdom build of x86_cpuid_policy_fill_native()

2018-11-13 Thread Jan Beulich
>>> On 13.11.18 at 12:59,  wrote:
> --- a/xen/lib/x86/cpuid.c
> +++ b/xen/lib/x86/cpuid.c
> @@ -7,8 +7,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
>  unsigned int i;
>  
>  cpuid_leaf(0, >basic.raw[0]);
> -for ( i = 1; i < min(ARRAY_SIZE(p->basic.raw),
> - p->basic.max_leaf + 1ul); ++i )
> +for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->basic.raw),
> +   p->basic.max_leaf); ++i )

I dislike the (hidden) casting resulting from the uses of min_t() /
max_t(), so in a case like this I'd have preferred to replace 1ul
by sizeof(char) or some such. But I expect you wouldn't like this,
so either way
Acked-by: Jan Beulich 

Jan



___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH] libx86: Fix 32bit stubdom build of x86_cpuid_policy_fill_native()

2018-11-13 Thread Andrew Cooper
With -m32, GCC generates a warning for _t ==  long, which is the
typecheck hidden inside the min() macro.

Switch to using explicitly typed versions instead.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
---
 xen/lib/x86/cpuid.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index f09d8d5..5a3159b 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -7,8 +7,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
 unsigned int i;
 
 cpuid_leaf(0, >basic.raw[0]);
-for ( i = 1; i < min(ARRAY_SIZE(p->basic.raw),
- p->basic.max_leaf + 1ul); ++i )
+for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->basic.raw),
+   p->basic.max_leaf); ++i )
 {
 switch ( i )
 {
@@ -52,8 +52,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
 {
 cpuid_count_leaf(7, 0, >feat.raw[0]);
 
-for ( i = 1; i < min(ARRAY_SIZE(p->feat.raw),
- p->feat.max_subleaf + 1ul); ++i )
+for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->feat.raw),
+   p->feat.max_subleaf); ++i )
 cpuid_count_leaf(7, i, >feat.raw[i]);
 }
 
@@ -96,7 +96,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
 xstates  = ((uint64_t)(p->xstate.xcr0_high | p->xstate.xss_high) << 
32);
 xstates |=(p->xstate.xcr0_low  | p->xstate.xss_low);
 
-for ( i = 2; i < min(63ul, ARRAY_SIZE(p->xstate.raw)); ++i )
+for ( i = 2; i < min_t(unsigned int, 63,
+   ARRAY_SIZE(p->xstate.raw)); ++i )
 {
 if ( xstates & (1ul << i) )
 cpuid_count_leaf(0xd, i, >xstate.raw[i]);
@@ -105,8 +106,8 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
 
 /* Extended leaves. */
 cpuid_leaf(0x8000, >extd.raw[0]);
-for ( i = 1; i < min(ARRAY_SIZE(p->extd.raw),
- p->extd.max_leaf + 1 - 0x8000ul); ++i )
+for ( i = 1; i < min_t(unsigned int, ARRAY_SIZE(p->extd.raw),
+   p->extd.max_leaf + 1 - 0x8000); ++i )
 cpuid_leaf(0x8000 + i, >extd.raw[i]);
 }
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel