diff mbox

[5/8] target-i386: Set APIC ID using cpu_index on CONFIG_USER

Message ID 1418956884-24022-6-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Dec. 19, 2014, 2:41 a.m. UTC
The PC CPU initialization code already sets apic-id based on the CPU
topology, and CONFIG_USER doesn't need the topology-based APIC ID
calculation code.

Make CONFIG_USER set apic-id before realizing the CPU (just like PC
already does), so we can simplify x86_cpu_initfn later. As there is no
CPU topology configuration in CONFIG_USER, just use cpu_index as the
APIC ID.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 target-i386/cpu.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Paolo Bonzini Dec. 19, 2014, 11:22 a.m. UTC | #1
On 19/12/2014 03:41, Eduardo Habkost wrote:
> +    object_property_set_int(OBJECT(cpu), CPU(cpu)->cpu_index, "apic-id",
> +                            &error);
> +    if (error) {
> +        goto out;
> +    }
> +

Should this use &error_abort?

Paolo
Eduardo Habkost Dec. 19, 2014, 4:29 p.m. UTC | #2
On Fri, Dec 19, 2014 at 12:22:30PM +0100, Paolo Bonzini wrote:
> On 19/12/2014 03:41, Eduardo Habkost wrote:
> > +    object_property_set_int(OBJECT(cpu), CPU(cpu)->cpu_index, "apic-id",
> > +                            &error);
> > +    if (error) {
> > +        goto out;
> > +    }
> > +
> 
> Should this use &error_abort?

I normally use &error_abort only if there is no way to indicate errors
to the caller at all. In this case, we print the error message and
return NULL.

However, I was assuming that all callers of cpu_init() check for NULL
properly, and cpu_copy() at linux-user/main.c doesn't. As I don't want
to touch linux-user code or change the cpu_init() signature, I will use
&error_abort in the next version.
diff mbox

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index bb9525d..4b0e0a5 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2161,6 +2161,12 @@  CPUX86State *cpu_x86_init_user(const char *cpu_model)
         goto out;
     }
 
+    object_property_set_int(OBJECT(cpu), CPU(cpu)->cpu_index, "apic-id",
+                            &error);
+    if (error) {
+        goto out;
+    }
+
     object_property_set_bool(OBJECT(cpu), true, "realized", &error);
 
 out: