From: Jan Kiszka <jan.kiszka@siemens.com>
To: Kevin O'Connor <kevin@koconnor.net>, seabios <seabios@seabios.org>
Cc: Andrew Theurer <habanero@linux.vnet.ibm.com>,
Gleb Natapov <gleb@redhat.com>, ya su <suya94335@gmail.com>,
Alexander Graf <agraf@suse.de>,
qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] [PATCH] Probe HPET existence
Date: Mon, 29 Aug 2011 17:50:10 +0200 [thread overview]
Message-ID: <4E5BB532.4010106@siemens.com> (raw)
QEMU does not provide a HPET block if it was configured with -no-hpet,
other machines SeaBIOS runs on may lack a HPET as well. Perform basic
checks the ID register for a reasonable vendor ID and a clock period
within the valid range, do not build the HPET table if that fails.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
This allows to postpone the hpet_fw_cfg vs. ACPI discussion until we
have >1 HPET blocks and/or put them at non-standard addresses.
src/acpi.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/acpi.c b/src/acpi.c
index ea7b171..29160f4 100644
--- a/src/acpi.c
+++ b/src/acpi.c
@@ -158,6 +158,9 @@ struct acpi_20_hpet {
} PACKED;
#define ACPI_HPET_ADDRESS 0xFED00000UL
+#define HPET_ID 0x000
+#define HPET_PERIOD 0x004
+
/*
* SRAT (NUMA topology description) table
*/
@@ -464,7 +467,16 @@ build_ssdt(void)
static void*
build_hpet(void)
{
- struct acpi_20_hpet *hpet = malloc_high(sizeof(*hpet));
+ struct acpi_20_hpet *hpet;
+ const void *hpet_base = (void *)ACPI_HPET_ADDRESS;
+ u32 hpet_vendor = readl(hpet_base + HPET_ID) >> 16;
+ u32 hpet_period = readl(hpet_base + HPET_PERIOD);
+
+ if (hpet_vendor == 0 || hpet_vendor == 0xffff ||
+ hpet_period == 0 || hpet_period > 0x05F5E100)
+ return NULL;
+
+ hpet = malloc_high(sizeof(*hpet));
if (!hpet) {
warn_noalloc();
return NULL;
--
1.7.3.4
next reply other threads:[~2011-08-29 15:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 15:50 Jan Kiszka [this message]
2011-08-30 0:35 ` [Qemu-devel] [PATCH] Probe HPET existence Kevin O'Connor
2011-08-31 16:45 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E5BB532.4010106@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=habanero@linux.vnet.ibm.com \
--cc=kevin@koconnor.net \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
--cc=suya94335@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).