xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mmcfg: Fix initalisation of variables in pci_mmcfg_nvidia_mcp55()
@ 2016-08-03  9:51 Andrew Cooper
  2016-08-03 10:24 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2016-08-03  9:51 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich

Shifting into the sign bit of an integer is undefined behaviour.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>

I was experimenting with -fsanitise=undefined and this bit failed to compile,
as the initialisation became a non-constant expression.
---
 xen/arch/x86/x86_64/mmconfig-shared.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/x86_64/mmconfig-shared.c b/xen/arch/x86/x86_64/mmconfig-shared.c
index 742bc18..a7592c6 100644
--- a/xen/arch/x86/x86_64/mmconfig-shared.c
+++ b/xen/arch/x86/x86_64/mmconfig-shared.c
@@ -182,10 +182,10 @@ static const char __init *pci_mmcfg_nvidia_mcp55(void)
     int bus, i;
 
     static const u32 extcfg_regnum      = 0x90;
-    static const u32 extcfg_enable_mask = 1<<31;
-    static const u32 extcfg_start_mask  = 0xff<<16;
+    static const u32 extcfg_enable_mask = 1u << 31;
+    static const u32 extcfg_start_mask  = 0xffu << 16;
     static const int extcfg_start_shift = 16;
-    static const u32 extcfg_size_mask   = 0x3<<28;
+    static const u32 extcfg_size_mask   = 3u << 28;
     static const int extcfg_size_shift  = 28;
     static const int extcfg_sizebus[]   = {0xff, 0x7f, 0x3f, 0x1f};
     static const u32 extcfg_base_mask[] = {0x7ff8, 0x7ffc, 0x7ffe, 0x7fff};
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mmcfg: Fix initalisation of variables in pci_mmcfg_nvidia_mcp55()
  2016-08-03  9:51 [PATCH] x86/mmcfg: Fix initalisation of variables in pci_mmcfg_nvidia_mcp55() Andrew Cooper
@ 2016-08-03 10:24 ` Jan Beulich
  2016-08-03 11:03   ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2016-08-03 10:24 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel

>>> On 03.08.16 at 11:51, <andrew.cooper3@citrix.com> wrote:
> --- a/xen/arch/x86/x86_64/mmconfig-shared.c
> +++ b/xen/arch/x86/x86_64/mmconfig-shared.c
> @@ -182,10 +182,10 @@ static const char __init *pci_mmcfg_nvidia_mcp55(void)
>      int bus, i;
>  
>      static const u32 extcfg_regnum      = 0x90;
> -    static const u32 extcfg_enable_mask = 1<<31;
> -    static const u32 extcfg_start_mask  = 0xff<<16;
> +    static const u32 extcfg_enable_mask = 1u << 31;

Aiui only this one change is really related to the patch subject; the
other two I suppose you just alter for consistency? Anyway,
Acked-by: Jan Beulich <jbeulich@suse.com>

> +    static const u32 extcfg_start_mask  = 0xffu << 16;
>      static const int extcfg_start_shift = 16;
> -    static const u32 extcfg_size_mask   = 0x3<<28;
> +    static const u32 extcfg_size_mask   = 3u << 28;
>      static const int extcfg_size_shift  = 28;
>      static const int extcfg_sizebus[]   = {0xff, 0x7f, 0x3f, 0x1f};
>      static const u32 extcfg_base_mask[] = {0x7ff8, 0x7ffc, 0x7ffe, 0x7fff};
> -- 
> 2.1.4




_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/mmcfg: Fix initalisation of variables in pci_mmcfg_nvidia_mcp55()
  2016-08-03 10:24 ` Jan Beulich
@ 2016-08-03 11:03   ` Andrew Cooper
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2016-08-03 11:03 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Xen-devel

On 03/08/16 11:24, Jan Beulich wrote:
>>>> On 03.08.16 at 11:51, <andrew.cooper3@citrix.com> wrote:
>> --- a/xen/arch/x86/x86_64/mmconfig-shared.c
>> +++ b/xen/arch/x86/x86_64/mmconfig-shared.c
>> @@ -182,10 +182,10 @@ static const char __init *pci_mmcfg_nvidia_mcp55(void)
>>      int bus, i;
>>  
>>      static const u32 extcfg_regnum      = 0x90;
>> -    static const u32 extcfg_enable_mask = 1<<31;
>> -    static const u32 extcfg_start_mask  = 0xff<<16;
>> +    static const u32 extcfg_enable_mask = 1u << 31;
> Aiui only this one change is really related to the patch subject; the
> other two I suppose you just alter for consistency? Anyway,
> Acked-by: Jan Beulich <jbeulich@suse.com>

Indeed.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-03 11:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03  9:51 [PATCH] x86/mmcfg: Fix initalisation of variables in pci_mmcfg_nvidia_mcp55() Andrew Cooper
2016-08-03 10:24 ` Jan Beulich
2016-08-03 11:03   ` Andrew Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).