Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lrgh5-0000FK-HL for qemu-devel@nongnu.org; Wed, 08 Apr 2009 18:56:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lrgh2-0000E0-Kx for qemu-devel@nongnu.org; Wed, 08 Apr 2009 18:56:29 -0400 Received: from [199.232.76.173] (port=53222 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lrgh2-0000Dn-4k for qemu-devel@nongnu.org; Wed, 08 Apr 2009 18:56:28 -0400 Received: from savannah.gnu.org ([199.232.41.3]:36120 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lrgh1-00028W-NY for qemu-devel@nongnu.org; Wed, 08 Apr 2009 18:56:27 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lrgh1-0005SV-50 for qemu-devel@nongnu.org; Wed, 08 Apr 2009 22:56:27 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lrgh0-0005SR-VY for qemu-devel@nongnu.org; Wed, 08 Apr 2009 22:56:27 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Wed, 08 Apr 2009 22:56:26 +0000 Subject: [Qemu-devel] [7048] apic: Fix access to non-existent APIC Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7048 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7048 Author: aurel32 Date: 2009-04-08 22:56:26 +0000 (Wed, 08 Apr 2009) Log Message: ----------- apic: Fix access to non-existent APIC 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 Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/hw/apic.c Modified: trunk/hw/apic.c =================================================================== --- trunk/hw/apic.c 2009-04-08 22:56:19 UTC (rev 7047) +++ trunk/hw/apic.c 2009-04-08 22:56:26 UTC (rev 7048) @@ -280,6 +280,8 @@ #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 @@ { 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 @@ 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 */