From patchwork Tue Aug 14 11:43:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 1319081 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 605B040210 for ; Tue, 14 Aug 2012 11:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753508Ab2HNLnU (ORCPT ); Tue, 14 Aug 2012 07:43:20 -0400 Received: from goliath.siemens.de ([192.35.17.28]:23926 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752080Ab2HNLnT (ORCPT ); Tue, 14 Aug 2012 07:43:19 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q7EBhDVf018776; Tue, 14 Aug 2012 13:43:13 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q7EBhCxX020230; Tue, 14 Aug 2012 13:43:12 +0200 Message-ID: <502A39D0.7080702@siemens.com> Date: Tue, 14 Aug 2012 13:43:12 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti CC: Markus Armbruster , qemu-devel , kvm Subject: [PATCH v2 uq/master] kvmvapic: Disable if there is insufficient memory References: <502A32BB.2000607@siemens.com> <87txw5itv9.fsf@blackfin.pond.sub.org> In-Reply-To: <87txw5itv9.fsf@blackfin.pond.sub.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org We need at least 1M of RAM to map the option ROM. Otherwise, we will corrupt host memory or even crash: $ qemu-system-x86_64 -nodefaults --enable-kvm -vnc :0 -m 640k Segmentation fault (core dumped) Reported-and-tested-by: Markus Armbruster Signed-off-by: Jan Kiszka --- hw/apic_common.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/apic_common.c b/hw/apic_common.c index 58e63b0..371f95d 100644 --- a/hw/apic_common.c +++ b/hw/apic_common.c @@ -299,7 +299,9 @@ static int apic_init_common(SysBusDevice *dev) sysbus_init_mmio(dev, &s->io_memory); - if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK) { + /* Note: We need at least 1M to map the VAPIC option ROM */ + if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK && + ram_size >= 1024 * 1024) { vapic = sysbus_create_simple("kvmvapic", -1, NULL); } s->vapic = vapic;