diff mbox

[1/1] apic_common: improve readability of apic_reset_common

Message ID 1428414832-3104-1-git-send-email-den@openvz.org
State New
Headers show

Commit Message

Denis V. Lunev April 7, 2015, 1:53 p.m. UTC
Replace call of cpu_is_bsp(s->cpu) which really returns
    !!(s->apicbase & MSR_IA32_APICBASE_BSP)
with directly collected value. Due to this the tracepoint
  trace_cpu_get_apic_base((uint64_t)s->apicbase);
will not be hit anymore in apic_reset_common.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Andreas Färber <afaerber@suse.de>
CC: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/intc/apic_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Paolo Bonzini April 7, 2015, 2 p.m. UTC | #1
On 07/04/2015 15:53, Denis V. Lunev wrote:
> Replace call of cpu_is_bsp(s->cpu) which really returns
>     !!(s->apicbase & MSR_IA32_APICBASE_BSP)
> with directly collected value. Due to this the tracepoint
>   trace_cpu_get_apic_base((uint64_t)s->apicbase);
> will not be hit anymore in apic_reset_common.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Andreas Färber <afaerber@suse.de>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/intc/apic_common.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index 042e960..7a0c7e2 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -233,11 +233,10 @@ static void apic_reset_common(DeviceState *dev)
>  {
>      APICCommonState *s = APIC_COMMON(dev);
>      APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
> -    bool bsp;
> +    uint32_t bsp;
>  
> -    bsp = cpu_is_bsp(s->cpu);
> -    s->apicbase = APIC_DEFAULT_ADDRESS |
> -        (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
> +    bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
> +    s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
>  
>      s->vapic_paddr = 0;
>      info->vapic_base_update(s);
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Denis V. Lunev April 28, 2015, 5:38 a.m. UTC | #2
On 07/04/15 16:53, Denis V. Lunev wrote:
> Replace call of cpu_is_bsp(s->cpu) which really returns
>      !!(s->apicbase & MSR_IA32_APICBASE_BSP)
> with directly collected value. Due to this the tracepoint
>    trace_cpu_get_apic_base((uint64_t)s->apicbase);
> will not be hit anymore in apic_reset_common.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Andreas Färber <afaerber@suse.de>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   hw/intc/apic_common.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index 042e960..7a0c7e2 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -233,11 +233,10 @@ static void apic_reset_common(DeviceState *dev)
>   {
>       APICCommonState *s = APIC_COMMON(dev);
>       APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
> -    bool bsp;
> +    uint32_t bsp;
>   
> -    bsp = cpu_is_bsp(s->cpu);
> -    s->apicbase = APIC_DEFAULT_ADDRESS |
> -        (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
> +    bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
> +    s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
>   
>       s->vapic_paddr = 0;
>       info->vapic_base_update(s);
ping
Paolo Bonzini April 28, 2015, 9:49 a.m. UTC | #3
On 07/04/2015 15:53, Denis V. Lunev wrote:
> Replace call of cpu_is_bsp(s->cpu) which really returns
>     !!(s->apicbase & MSR_IA32_APICBASE_BSP)
> with directly collected value. Due to this the tracepoint
>   trace_cpu_get_apic_base((uint64_t)s->apicbase);
> will not be hit anymore in apic_reset_common.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Andreas Färber <afaerber@suse.de>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/intc/apic_common.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
> index 042e960..7a0c7e2 100644
> --- a/hw/intc/apic_common.c
> +++ b/hw/intc/apic_common.c
> @@ -233,11 +233,10 @@ static void apic_reset_common(DeviceState *dev)
>  {
>      APICCommonState *s = APIC_COMMON(dev);
>      APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
> -    bool bsp;
> +    uint32_t bsp;
>  
> -    bsp = cpu_is_bsp(s->cpu);
> -    s->apicbase = APIC_DEFAULT_ADDRESS |
> -        (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
> +    bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
> +    s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
>  
>      s->vapic_paddr = 0;
>      info->vapic_base_update(s);
> 

Applied, thanks.

Paolo
Andreas Färber April 28, 2015, 12:03 p.m. UTC | #4
Am 07.04.2015 um 15:53 schrieb Denis V. Lunev:
> Replace call of cpu_is_bsp(s->cpu) which really returns
>     !!(s->apicbase & MSR_IA32_APICBASE_BSP)
> with directly collected value. Due to this the tracepoint
>   trace_cpu_get_apic_base((uint64_t)s->apicbase);
> will not be hit anymore in apic_reset_common.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Andreas Färber <afaerber@suse.de>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/intc/apic_common.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks,
Andreas
diff mbox

Patch

diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
index 042e960..7a0c7e2 100644
--- a/hw/intc/apic_common.c
+++ b/hw/intc/apic_common.c
@@ -233,11 +233,10 @@  static void apic_reset_common(DeviceState *dev)
 {
     APICCommonState *s = APIC_COMMON(dev);
     APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
-    bool bsp;
+    uint32_t bsp;
 
-    bsp = cpu_is_bsp(s->cpu);
-    s->apicbase = APIC_DEFAULT_ADDRESS |
-        (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE;
+    bsp = s->apicbase & MSR_IA32_APICBASE_BSP;
+    s->apicbase = APIC_DEFAULT_ADDRESS | bsp | MSR_IA32_APICBASE_ENABLE;
 
     s->vapic_paddr = 0;
     info->vapic_base_update(s);