qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-i386: Fix signedness of MSR_IA32_APICBASE_BASE
@ 2015-05-29 19:52 Eduardo Habkost
  2015-06-02 14:20 ` Igor Mammedov
  0 siblings, 1 reply; 2+ messages in thread
From: Eduardo Habkost @ 2015-05-29 19:52 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, zhugh.fnst, Igor Mammedov, Paolo Bonzini,
	Andreas Färber, Richard Henderson

Existing definition triggers the following when using clang
-fsanitize=undefined:

    hw/intc/apic_common.c:314:55: runtime error: left shift of 1048575 by 12
        places cannot be represented in type 'int'

Fix it so we won't try to shift a 1 to the sign bit of a signed integer.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target-i386/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 4ee12ca..26182bd 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -305,7 +305,7 @@
 #define MSR_IA32_APICBASE               0x1b
 #define MSR_IA32_APICBASE_BSP           (1<<8)
 #define MSR_IA32_APICBASE_ENABLE        (1<<11)
-#define MSR_IA32_APICBASE_BASE          (0xfffff<<12)
+#define MSR_IA32_APICBASE_BASE          (0xfffffU<<12)
 #define MSR_IA32_FEATURE_CONTROL        0x0000003a
 #define MSR_TSC_ADJUST                  0x0000003b
 #define MSR_IA32_TSCDEADLINE            0x6e0
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH] target-i386: Fix signedness of MSR_IA32_APICBASE_BASE
  2015-05-29 19:52 [Qemu-devel] [PATCH] target-i386: Fix signedness of MSR_IA32_APICBASE_BASE Eduardo Habkost
@ 2015-06-02 14:20 ` Igor Mammedov
  0 siblings, 0 replies; 2+ messages in thread
From: Igor Mammedov @ 2015-06-02 14:20 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, zhugh.fnst, qemu-devel, Paolo Bonzini,
	Andreas Färber, Richard Henderson

On Fri, 29 May 2015 16:52:34 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> Existing definition triggers the following when using clang
> -fsanitize=undefined:
> 
>     hw/intc/apic_common.c:314:55: runtime error: left shift of 1048575 by 12
>         places cannot be represented in type 'int'
> 
> Fix it so we won't try to shift a 1 to the sign bit of a signed integer.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  target-i386/cpu.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index 4ee12ca..26182bd 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -305,7 +305,7 @@
>  #define MSR_IA32_APICBASE               0x1b
>  #define MSR_IA32_APICBASE_BSP           (1<<8)
>  #define MSR_IA32_APICBASE_ENABLE        (1<<11)
> -#define MSR_IA32_APICBASE_BASE          (0xfffff<<12)
> +#define MSR_IA32_APICBASE_BASE          (0xfffffU<<12)
>  #define MSR_IA32_FEATURE_CONTROL        0x0000003a
>  #define MSR_TSC_ADJUST                  0x0000003b
>  #define MSR_IA32_TSCDEADLINE            0x6e0

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

end of thread, other threads:[~2015-06-02 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 19:52 [Qemu-devel] [PATCH] target-i386: Fix signedness of MSR_IA32_APICBASE_BASE Eduardo Habkost
2015-06-02 14:20 ` Igor Mammedov

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).