bugfix: vm halt when in reset looping
PATCH v3 1/1 bugfix: vm halt when in reset looping
reset mc146818rtc device when RESET event happens.
Fix the problem:
1. Guest boot the second cpu, set CMOS_RESET_CODE 0x0a to protect selfboot;
2. VM being reset by others, hmp_system_reset;
3. seabios resume check the CMOS_RESET_CODE, if 0x0a, jump to the BDA
resume execution by jump via 40h:0067h;
4. Guest halt;
--- hw/timer/mc146818rtc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/timer/mc146818rtc.c +11 -0
@@ -946,11 +946,22 @@ static Property mc146818rtc_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void rtc_resetdev (DeviceState *d) +{ +RTCState *s =MC146818_RTC (d); + +/* Reason: VM do suspend self will set 0xfe +* Only handle the VM boot case */ +if (s->cmos_data[0x0f ] ==0x0a ) + s->cmos_data[0x0f ] =0x00 ; +} +static void rtc_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = rtc_realizefn; + dc->reset = rtc_resetdev; dc->vmsd = &vmstate_rtc; dc->props = mc146818rtc_properties;/* Reason: needs to be wired up by rtc_init() */
Signature · 1 line
1.8.3.1
Quoted 21 lines · hangaohuai
reset mc146818rtc device when RESET event happens.
Fix the problem:
1. Guest boot the second cpu, setCMOS_RESET_CODE0x0ato protect selfboot;
2. VM being reset by others,hmp_system_reset;
3. seabios resume check theCMOS_RESET_CODE, if0x0a, jump to the BDAresume execution by jump via 40h:0067h;4. Guest halt;
Signed-off-by hangaohuai <[email protected]>--- hw/timer/mc146818rtc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)hw/timer/mc146818rtc.c +0
-0@@ -946,11 +946,22 @@ static Property mc146818rtc_properties[] = { DEFINE_PROP_END_OF_LIST(), };
hw/timer/mc146818rtc.c static Property mc146818rtc_properties[] = { · line 957
Quoted 10 lines
hw/timer/mc146818rtc.c +9
-0+static void rtc_resetdev (DeviceState *d) +{ +RTCState *s =MC146818_RTC (d); + +/* Reason: VM do suspend self will set 0xfe +* Only handle the VM boot case */ +if (s->cmos_data[0x0f ] ==0x0a ) + s->cmos_data[0x0f ] =0x00 ; +}
Let's just do it for all values other than 0xfe. Also, please run checkpatch.pl on your patch.
Paolo
Quoted 10 lines
hw/timer/mc146818rtc.c +1
-0static void rtc_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); dc->realize = rtc_realizefn; + dc->reset = rtc_resetdev; dc->vmsd = &vmstate_rtc; dc->props = mc146818rtc_properties;/* Reason: needs to be wired up by rtc_init() */