Apic creation should not depend on pci
PATCH v2 1/1 Apic creation should not depend on pci
It should depend on whether cpu has APIC.
hw/pc.c +2 -6
@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */ - env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env); }vmport_init ();
--
Gleb.
Quoted 9 lines · Gleb Natapov
It should depend on whether cpu has APIC.
Signed-off-by Gleb Natapov <[email protected]>hw/pc.c +0
-0
hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 881
Quoted 10 lines
hw/pc.c +1
-6@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */ - env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {
Obviously :), I'm fine with that change. Needs testing, though. What scenarios did you already check?
hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 884
Quoted 3 lines
hw/pc.c +1
-0apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env);
But this line silently reorders CPU and APIC reset handlers. If you did it intentionally (I vaguely recall it may have some benefit /wrt KVM synchronizing kernel and user space states), I would suggest pushing it as a separate patch.
Quoted 6 lines
hw/pc.c +0
-1}vmport_init (); --Gleb.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 15 lines · Jan Kiszka
Quoted 14 lines · Gleb Natapov
It should depend on whether cpu has APIC.
Signed-off-by Gleb Natapov <[email protected]>hw/pc.c +0
-2@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */
Quoted 9 lines
hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 881
Quoted 5 lines
hw/pc.c +1
-4- env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {Obviously :), I'm fine with that change. Needs testing, though. What scenarios did you already check?
:) Only standard runs. I don't have 486 smp guest around.
Quoted 8 lines
hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 884
Quoted 3 lines
hw/pc.c +1
-0apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env);But this line silently reorders CPU and APIC reset handlers. If you did it intentionally (I vaguely recall it may have some benefit /wrt KVM synchronizing kernel and user space states), I would suggest pushing it as a separate patch.
I don't know what this line is doing here. I'll remove it
--
Gleb.
Quoted 24 lines · Jan Kiszka
Quoted 9 lines · Gleb Natapov
It should depend on whether cpu has APIC.
Signed-off-by Gleb Natapov <[email protected]>hw/pc.c +0
-0hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 881
Quoted 10 lines
hw/pc.c +1
-6@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */ - env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {Obviously :), I'm fine with that change. Needs testing, though. What scenarios did you already check?
Quoted 9 lines
hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 884
Quoted 3 lines
hw/pc.c +1
-0apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env);But this line silently reorders CPU and APIC reset handlers. If you did it intentionally (I vaguely recall it may have some benefit /wrt KVM synchronizing kernel and user space states), I would suggest pushing it as a separate patch.
BTW relying on order of callback registration is not a good idea especially since we have "order" parameter now. On the other hand apic reset handler already resets cpu so if apic is present there is no need to register main_cpu_reset().
--
Gleb.
Quoted 27 lines · Gleb Natapov
Quoted 26 lines · Jan Kiszka
Quoted 9 lines · Gleb Natapov
It should depend on whether cpu has APIC.
Signed-off-by Gleb Natapov <[email protected]>hw/pc.c +0
-0hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 881
Quoted 10 lines
hw/pc.c +1
-6@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */ - env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {Obviously :), I'm fine with that change. Needs testing, though. What scenarios did you already check?
Quoted 3 lines
hw/pc.c +1
-0apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env);
Quoted 7 lines
Quoted 5 lines
But this line silently reorders CPU and APIC reset handlers. If you did it intentionally (I vaguely recall it may have some benefit /wrt KVM synchronizing kernel and user space states), I would suggest pushing it as a separate patch.
BTW relying on order of callback registration is not a good idea especially since we have "order" parameter now.
The order parameter is obsolete, I already posted a patch to revert this idea again (reminds me of posting an update as a new reset handler arrived in the meantime).
The system-wide assumed and applied order is that earlier instantiated devices will be reset first. That specifically makes sense if you think of bus/device relations.
Quoted 3 lines
On the other hand apic
reset handler already resets cpu so if apic is present there is no need to registermain_cpu_reset().
OK, this is a special case as the APIC reset triggers an init IPI and that resets the CPU, too. Then make this explicit, replace main_cpu_reset with cpu_reset (so that no one adds code to the former that is not run in the APIC case) and add some comment why.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 36 lines · Jan Kiszka
Quoted 27 lines · Gleb Natapov
Quoted 26 lines · Jan Kiszka
Quoted 9 lines · Gleb Natapov
It should depend on whether cpu has APIC.
Signed-off-by Gleb Natapov <[email protected]>hw/pc.c +0
-0hw/pc.c static void pc_init1(ram_addr_t ram_size, · line 881
Quoted 10 lines
hw/pc.c +1
-6@@ -878,14 +878,10 @@ static void pc_init1(ram_addr_t ram_size, }if (i !=0 ) env->halted =1 ; -if (smp_cpus >1 ) { -/* XXX: enable it in all cases */ - env->cpuid_features |=CPUID_APIC ; - } -qemu_register_reset (main_cpu_reset,0 , env); -if (pci_enabled) { +if ((env->cpuid_features &CPUID_APIC ) || smp_cpus >1 ) {Obviously :), I'm fine with that change. Needs testing, though. What scenarios did you already check?
Quoted 3 lines
hw/pc.c +1
-0apic_init (env); } +qemu_register_reset (main_cpu_reset,0 , env);Quoted 7 lines
Quoted 5 lines
But this line silently reorders CPU and APIC reset handlers. If you did it intentionally (I vaguely recall it may have some benefit /wrt KVM synchronizing kernel and user space states), I would suggest pushing it as a separate patch.
BTW relying on order of callback registration is not a good idea especially since we have "order" parameter now.
Quoted 8 lines
The order parameter is obsolete, I already posted a patch to revert this idea again (reminds me of posting an update as a new reset handler arrived in the meantime).
The system-wide assumed and applied order is that earlier instantiated devices will be reset first. That specifically makes sense if you think of bus/device relations.
Sounds fragile to me, but explicit order far from ideal too. Why should order matter anyway. Device reset callbacks should not rely on the state of other devices.
Quoted 8 lines
Quoted 3 lines
On the other hand apic
reset handler already resets cpu so if apic is present there is no need to registermain_cpu_reset().OK, this is a special case as the APIC reset triggers an init IPI and that resets the CPU, too. Then make this explicit, replace
main_cpu_resetwithcpu_reset(so that no one adds code to the former that is not run in the APIC case) and add some comment why.
Already doing it on top of this patch.
--
Gleb.