diff mbox

[v2,7/7] monitor: fix crash for platforms without a CPU 0

Message ID 1472661255-20160-8-git-send-email-clg@kaod.org
State New
Headers show

Commit Message

Cédric Le Goater Aug. 31, 2016, 4:34 p.m. UTC
On PowerNV, CPU ids start at 0x8 or 0x20, we don't have a CPU 0
anymore. So let's use the first_cpu index to initialize the monitor.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---

 So that you can dump the cpu list with the monitor :

	(qemu) info cpus
	* CPU #8: nip=0x0000000000000010 thread_id=7742
	  CPU #16: nip=0x0000000000000010 thread_id=7740
	  CPU #24: nip=0x0000000000000010 thread_id=7740
	  CPU #32: nip=0x0000000000000010 thread_id=7740
	  CPU #40: nip=0x0000000000000010 thread_id=7740
	  CPU #48: nip=0x0000000000000010 thread_id=7740
	  CPU #72: nip=0x0000000000000010 thread_id=7740
	  CPU #80: nip=0x0000000000000010 thread_id=7740
	  CPU #136: nip=0x0000000000000010 thread_id=7740
	  CPU #144: nip=0x0000000000000010 thread_id=7740
	  CPU #152: nip=0x0000000000000010 thread_id=7740
	  CPU #160: nip=0x0000000000000010 thread_id=7740
	  CPU #168: nip=0x0000000000000010 thread_id=7740
	  CPU #176: nip=0x0000000000000010 thread_id=7740
	  CPU #200: nip=0x0000000000000010 thread_id=7740
	  CPU #208: nip=0x0000000000000010 thread_id=7740

 monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Gibson Sept. 5, 2016, 4:27 a.m. UTC | #1
On Wed, Aug 31, 2016 at 06:34:15PM +0200, Cédric Le Goater wrote:
> On PowerNV, CPU ids start at 0x8 or 0x20, we don't have a CPU 0
> anymore. So let's use the first_cpu index to initialize the monitor.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

So we need a patch like this - amongst other fixes - in order to allow
unplug of cpu 0.  I'm not really sure whether to push it ahead now, or
gather it up with other no-cpu-0 fixes and send them as a batch.

> ---
> 
>  So that you can dump the cpu list with the monitor :
> 
> 	(qemu) info cpus
> 	* CPU #8: nip=0x0000000000000010 thread_id=7742
> 	  CPU #16: nip=0x0000000000000010 thread_id=7740
> 	  CPU #24: nip=0x0000000000000010 thread_id=7740
> 	  CPU #32: nip=0x0000000000000010 thread_id=7740
> 	  CPU #40: nip=0x0000000000000010 thread_id=7740
> 	  CPU #48: nip=0x0000000000000010 thread_id=7740
> 	  CPU #72: nip=0x0000000000000010 thread_id=7740
> 	  CPU #80: nip=0x0000000000000010 thread_id=7740
> 	  CPU #136: nip=0x0000000000000010 thread_id=7740
> 	  CPU #144: nip=0x0000000000000010 thread_id=7740
> 	  CPU #152: nip=0x0000000000000010 thread_id=7740
> 	  CPU #160: nip=0x0000000000000010 thread_id=7740
> 	  CPU #168: nip=0x0000000000000010 thread_id=7740
> 	  CPU #176: nip=0x0000000000000010 thread_id=7740
> 	  CPU #200: nip=0x0000000000000010 thread_id=7740
> 	  CPU #208: nip=0x0000000000000010 thread_id=7740
> 
>  monitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index e9009de09a6c..19b8ec14f40e 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1027,7 +1027,7 @@ int monitor_set_cpu(int cpu_index)
>  CPUState *mon_get_cpu(void)
>  {
>      if (!cur_mon->mon_cpu) {
> -        monitor_set_cpu(0);
> +        monitor_set_cpu(first_cpu->cpu_index);
>      }
>      cpu_synchronize_state(cur_mon->mon_cpu);
>      return cur_mon->mon_cpu;
Cédric Le Goater Sept. 6, 2016, 6:28 a.m. UTC | #2
On 09/05/2016 06:27 AM, David Gibson wrote:
> On Wed, Aug 31, 2016 at 06:34:15PM +0200, Cédric Le Goater wrote:
>> On PowerNV, CPU ids start at 0x8 or 0x20, we don't have a CPU 0
>> anymore. So let's use the first_cpu index to initialize the monitor.
>>
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> 
> So we need a patch like this - amongst other fixes - in order to allow
> unplug of cpu 0.  I'm not really sure whether to push it ahead now, or
> gather it up with other no-cpu-0 fixes and send them as a batch.

I think we could send it now as it removes an assumption on the cpu 
number. 

C. 


> 
>> ---
>>
>>  So that you can dump the cpu list with the monitor :
>>
>> 	(qemu) info cpus
>> 	* CPU #8: nip=0x0000000000000010 thread_id=7742
>> 	  CPU #16: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #24: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #32: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #40: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #48: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #72: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #80: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #136: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #144: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #152: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #160: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #168: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #176: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #200: nip=0x0000000000000010 thread_id=7740
>> 	  CPU #208: nip=0x0000000000000010 thread_id=7740
>>
>>  monitor.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/monitor.c b/monitor.c
>> index e9009de09a6c..19b8ec14f40e 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -1027,7 +1027,7 @@ int monitor_set_cpu(int cpu_index)
>>  CPUState *mon_get_cpu(void)
>>  {
>>      if (!cur_mon->mon_cpu) {
>> -        monitor_set_cpu(0);
>> +        monitor_set_cpu(first_cpu->cpu_index);
>>      }
>>      cpu_synchronize_state(cur_mon->mon_cpu);
>>      return cur_mon->mon_cpu;
>
David Gibson Sept. 7, 2016, 1:49 a.m. UTC | #3
On Tue, Sep 06, 2016 at 08:28:48AM +0200, Cédric Le Goater wrote:
> On 09/05/2016 06:27 AM, David Gibson wrote:
> > On Wed, Aug 31, 2016 at 06:34:15PM +0200, Cédric Le Goater wrote:
> >> On PowerNV, CPU ids start at 0x8 or 0x20, we don't have a CPU 0
> >> anymore. So let's use the first_cpu index to initialize the monitor.
> >>
> >> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> > 
> > So we need a patch like this - amongst other fixes - in order to allow
> > unplug of cpu 0.  I'm not really sure whether to push it ahead now, or
> > gather it up with other no-cpu-0 fixes and send them as a batch.
> 
> I think we could send it now as it removes an assumption on the cpu 
> number.

True enough.  I'll try to queue it once I've sorted out my first 2.8
pull request with the existing backlog.

> 
> C. 
> 
> 
> > 
> >> ---
> >>
> >>  So that you can dump the cpu list with the monitor :
> >>
> >> 	(qemu) info cpus
> >> 	* CPU #8: nip=0x0000000000000010 thread_id=7742
> >> 	  CPU #16: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #24: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #32: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #40: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #48: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #72: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #80: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #136: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #144: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #152: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #160: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #168: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #176: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #200: nip=0x0000000000000010 thread_id=7740
> >> 	  CPU #208: nip=0x0000000000000010 thread_id=7740
> >>
> >>  monitor.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/monitor.c b/monitor.c
> >> index e9009de09a6c..19b8ec14f40e 100644
> >> --- a/monitor.c
> >> +++ b/monitor.c
> >> @@ -1027,7 +1027,7 @@ int monitor_set_cpu(int cpu_index)
> >>  CPUState *mon_get_cpu(void)
> >>  {
> >>      if (!cur_mon->mon_cpu) {
> >> -        monitor_set_cpu(0);
> >> +        monitor_set_cpu(first_cpu->cpu_index);
> >>      }
> >>      cpu_synchronize_state(cur_mon->mon_cpu);
> >>      return cur_mon->mon_cpu;
> > 
>
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index e9009de09a6c..19b8ec14f40e 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1027,7 +1027,7 @@  int monitor_set_cpu(int cpu_index)
 CPUState *mon_get_cpu(void)
 {
     if (!cur_mon->mon_cpu) {
-        monitor_set_cpu(0);
+        monitor_set_cpu(first_cpu->cpu_index);
     }
     cpu_synchronize_state(cur_mon->mon_cpu);
     return cur_mon->mon_cpu;