* [PATCH] xen: Avoid left shifting into a sign bit
@ 2016-02-17 19:51 Andrew Cooper
2016-02-18 2:25 ` Wu, Feng
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2016-02-17 19:51 UTC (permalink / raw
To: Xen-devel
Cc: Kevin Tian, Feng Wu, Ian Campbell, Andrew Cooper, Tim Deegan,
Jan Beulich
Clang 3.8 notices, and objects because it is undefined behaviour.
"error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]"
Use unsigned constants rather than signed ones.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Tim Deegan <tim@xen.org>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Kevin Tian <kevin.tian@intel.com>
CC: Feng Wu <feng.wu@intel.com>
---
xen/common/page_alloc.c | 2 +-
xen/drivers/passthrough/vtd/x86/ats.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 624a266..7179d67 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1675,7 +1675,7 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
ASSERT(!in_irq());
if ( xenheap_bits && (memflags >> _MEMF_bits) > xenheap_bits )
- memflags &= ~MEMF_bits(~0);
+ memflags &= ~MEMF_bits(~0U);
if ( !(memflags >> _MEMF_bits) )
memflags |= MEMF_bits(xenheap_bits);
diff --git a/xen/drivers/passthrough/vtd/x86/ats.c b/xen/drivers/passthrough/vtd/x86/ats.c
index 7c797f6..334b9c1 100644
--- a/xen/drivers/passthrough/vtd/x86/ats.c
+++ b/xen/drivers/passthrough/vtd/x86/ats.c
@@ -133,7 +133,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
case DMA_TLB_GLOBAL_FLUSH:
/* invalidate all translations: sbit=1,bit_63=0,bit[62:12]=1 */
sbit = 1;
- addr = (~0 << PAGE_SHIFT_4K) & 0x7FFFFFFFFFFFFFFF;
+ addr = (~0UL << PAGE_SHIFT_4K) & 0x7FFFFFFFFFFFFFFF;
rc = qinval_device_iotlb(iommu, pdev->ats_queue_depth,
sid, sbit, addr);
break;
@@ -145,7 +145,7 @@ int dev_invalidate_iotlb(struct iommu *iommu, u16 did,
sbit = size_order ? 1 : 0;
/* clear lower bits */
- addr &= ~0 << PAGE_SHIFT_4K;
+ addr &= ~0UL << PAGE_SHIFT_4K;
/* if sbit == 1, zero out size_order bit and set lower bits to 1 */
if ( sbit )
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen: Avoid left shifting into a sign bit
2016-02-17 19:51 [PATCH] xen: Avoid left shifting into a sign bit Andrew Cooper
@ 2016-02-18 2:25 ` Wu, Feng
0 siblings, 0 replies; 2+ messages in thread
From: Wu, Feng @ 2016-02-18 2:25 UTC (permalink / raw
To: Andrew Cooper, Xen-devel
Cc: Wu, Feng, Tian, Kevin, Tim Deegan, Ian Campbell, Jan Beulich
> -----Original Message-----
> From: Andrew Cooper [mailto:andrew.cooper3@citrix.com]
> Sent: Thursday, February 18, 2016 3:52 AM
> To: Xen-devel <xen-devel@lists.xen.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>; Jan Beulich
> <JBeulich@suse.com>; Tim Deegan <tim@xen.org>; Ian Campbell
> <Ian.Campbell@citrix.com>; Tian, Kevin <kevin.tian@intel.com>; Wu, Feng
> <feng.wu@intel.com>
> Subject: [PATCH] xen: Avoid left shifting into a sign bit
>
> Clang 3.8 notices, and objects because it is undefined behaviour.
>
> "error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-
> value]"
>
> Use unsigned constants rather than signed ones.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Kevin Tian <kevin.tian@intel.com>
> CC: Feng Wu <feng.wu@intel.com>
> ---
> xen/common/page_alloc.c | 2 +-
> xen/drivers/passthrough/vtd/x86/ats.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
Acked-by: Feng Wu <feng.wu@intel.com> for the VT-d part.
Thanks,
Feng
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-18 2:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 19:51 [PATCH] xen: Avoid left shifting into a sign bit Andrew Cooper
2016-02-18 2:25 ` Wu, Feng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.