Skip to contentSkip to conversation

apic_common: improve readability of apic_reset_common

PATCH Applied Denis V. Lunev 3 participants 5 messages Apr 7, 2015 – Apr 28, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 apic_common: improve readability of apic_reset_common

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.

CC Andreas Färber <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/intc/apic_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/intc/apic_common.c +3 -4
index 042e960..7a0c7e2 100644
@@ -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);
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · 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.

CC Andreas Färber <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/intc/apic_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/intc/apic_common.c +0 -1
index 042e960..7a0c7e2 100644
@@ -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;

hw/intc/apic_common.c static void apic_reset_common(DeviceState *dev) · line 242

Quoted 10 lines
hw/intc/apic_common.c +3 -3
+    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);
#2 lore raw
In reply to Denis V. Lunev
Quoted 22 lines · 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.

CC Andreas Färber <[email protected]>
CC Paolo Bonzini <[email protected]>
---
  hw/intc/apic_common.c | 7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
hw/intc/apic_common.c +0 -1
index 042e960..7a0c7e2 100644
@@ -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;

hw/intc/apic_common.c static void apic_reset_common(DeviceState *dev) · line 242

Quoted 10 lines
hw/intc/apic_common.c +3 -3
+    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

#3 lore raw
In reply to Denis V. Lunev
Quoted 23 lines · 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.

CC Andreas Färber <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/intc/apic_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/intc/apic_common.c +0 -1
index 042e960..7a0c7e2 100644
@@ -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;

hw/intc/apic_common.c static void apic_reset_common(DeviceState *dev) · line 242

Quoted 10 lines
hw/intc/apic_common.c +3 -3
+    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

Reviewed-by on v1 1/1
#4 lore raw
In reply to Denis V. Lunev

Am 07.04.2015 um 15:53 schrieb Denis V. Lunev:

Quoted 6 lines

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.

Quoted 6 lines
CC Andreas Färber <[email protected]>
CC Paolo Bonzini <[email protected]>
---
 hw/intc/apic_common.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Thanks,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)