Skip to contentSkip to conversation

bugfix: vm halt when in reset looping

PATCH Superseded hangaohuai 2 participants 3 messages Dec 14, 2016

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

hangaohuai

author
#0 lore raw

PATCH 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 | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/timer/mc146818rtc.c +8 -0
index da209d0..67d707d 100644
@@ -946,11 +946,19 @@ static Property mc146818rtc_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static void rtc_resetdev(DeviceState *d)
+{
+    RTCState *s = MC146818_RTC(d);
+
+    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
#1 lore raw
Quoted 10 lines · hangaohuai

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;

I think this would break S3 resume.

Paolo

Quoted 29 lines
---
 hw/timer/mc146818rtc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/timer/mc146818rtc.c +8 -0
index da209d0..67d707d 100644
@@ -946,11 +946,19 @@ static Property mc146818rtc_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static void rtc_resetdev(DeviceState *d)
+{
+    RTCState *s = MC146818_RTC(d);
+
+    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() */
author
#2 lore raw

Thanks for the review and proposals .
I will think over the suspend and resume of VM.

Quoted 10 lines · hangaohuai

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;

I think this would break S3 resume.

Paolo

Quoted 27 lines
---
 hw/timer/mc146818rtc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/timer/mc146818rtc.c index renamed from hw/timer/mc146818rtc.c +0 -0

da209d0..67d707d 100644

hw/timer/mc146818rtc.c +7 -0
@@ -946,11 +946,19 @@ static Property mc146818rtc_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static void rtc_resetdev(DeviceState *d) {
+    RTCState *s = MC146818_RTC(d);
+
+    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() */