From: Aurelien Jarno <aurelien@aurel32.net>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] apic: Fix access to non-existent APIC
Date: Thu, 9 Apr 2009 00:58:44 +0200 [thread overview]
Message-ID: <20090408225844.GC23493@volta.aurel32.net> (raw)
In-Reply-To: <49DB8E4E.8010904@siemens.com>
On Tue, Apr 07, 2009 at 07:33:02PM +0200, Jan Kiszka wrote:
> When running with -M isapc, there is no env->apic_state. Fix
> cpu_get/set_apic_* helpers to handle this corner case gracefully.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> hw/apic.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
Thanks, applied.
> diff --git a/hw/apic.c b/hw/apic.c
> index 5a76498..d63d74b 100644
> --- a/hw/apic.c
> +++ b/hw/apic.c
> @@ -280,6 +280,8 @@ void cpu_set_apic_base(CPUState *env, uint64_t val)
> #ifdef DEBUG_APIC
> printf("cpu_set_apic_base: %016" PRIx64 "\n", val);
> #endif
> + if (!s)
> + return;
> s->apicbase = (val & 0xfffff000) |
> (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
> /* if disabled, cannot be enabled again */
> @@ -294,14 +296,17 @@ uint64_t cpu_get_apic_base(CPUState *env)
> {
> APICState *s = env->apic_state;
> #ifdef DEBUG_APIC
> - printf("cpu_get_apic_base: %016" PRIx64 "\n", (uint64_t)s->apicbase);
> + printf("cpu_get_apic_base: %016" PRIx64 "\n",
> + s ? (uint64_t)s->apicbase: 0);
> #endif
> - return s->apicbase;
> + return s ? s->apicbase : 0;
> }
>
> void cpu_set_apic_tpr(CPUX86State *env, uint8_t val)
> {
> APICState *s = env->apic_state;
> + if (!s)
> + return;
> s->tpr = (val & 0x0f) << 4;
> apic_update_irq(s);
> }
> @@ -309,7 +314,7 @@ void cpu_set_apic_tpr(CPUX86State *env, uint8_t val)
> uint8_t cpu_get_apic_tpr(CPUX86State *env)
> {
> APICState *s = env->apic_state;
> - return s->tpr >> 4;
> + return s ? s->tpr >> 4 : 0;
> }
>
> /* return -1 if no bit is set */
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
prev parent reply other threads:[~2009-04-08 22:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 17:33 [Qemu-devel] [PATCH] apic: Fix access to non-existent APIC Jan Kiszka
2009-04-08 22:58 ` Aurelien Jarno [this message]
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=20090408225844.GC23493@volta.aurel32.net \
--to=aurelien@aurel32.net \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
/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).