aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2020-05-07 13:53:26 +0200
committerGerd Hoffmann <kraxel@redhat.com>2020-05-15 13:33:17 +0200
commit51c6fc699e5a42343ff1f2884f67fee1ae12eac8 (patch)
tree60b23738f6b4679576a5416f55f4dd81365f791a
parentfffac0fa089cf51437a692b546d0bdc0a92da7f9 (diff)
downloadseabios-51c6fc699e5a42343ff1f2884f67fee1ae12eac8.tar.gz
qemu: check rtc presence before reading cpu count from cmos
Read month register which should never have a value larger than 12. In case the read returns 0xff assume the rtc isn't there. Don't try to read the cpu count from cmos without rtc. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
-rw-r--r--src/fw/paravirt.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c
index 3465f97e..e76fa65d 100644
--- a/src/fw/paravirt.c
+++ b/src/fw/paravirt.c
@@ -447,6 +447,11 @@ qemu_get_romfile_key(struct romfile_s *file)
return qfile->select;
}
+static int rtc_present(void)
+{
+ return rtc_read(CMOS_RTC_MONTH) != 0xff;
+}
+
u16
qemu_get_present_cpus_count(void)
{
@@ -454,9 +459,11 @@ qemu_get_present_cpus_count(void)
if (qemu_cfg_enabled()) {
qemu_cfg_read_entry(&smp_count, QEMU_CFG_NB_CPUS, sizeof(smp_count));
}
- u16 cmos_cpu_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
- if (smp_count < cmos_cpu_count) {
- smp_count = cmos_cpu_count;
+ if (rtc_present()) {
+ u16 cmos_cpu_count = rtc_read(CMOS_BIOS_SMP_COUNT) + 1;
+ if (smp_count < cmos_cpu_count) {
+ smp_count = cmos_cpu_count;
+ }
}
return smp_count;
}