From patchwork Tue Mar 6 15:50:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 144956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75BDDB6F9F for ; Wed, 7 Mar 2012 02:51:07 +1100 (EST) Received: from localhost ([::1]:45343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4wfI-0001HD-Jt for incoming@patchwork.ozlabs.org; Tue, 06 Mar 2012 10:51:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:38715) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4wf7-0001Gd-N1 for qemu-devel@nongnu.org; Tue, 06 Mar 2012 10:50:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4wek-0005Vc-5J for qemu-devel@nongnu.org; Tue, 06 Mar 2012 10:50:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31239) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4wej-0005VF-TT for qemu-devel@nongnu.org; Tue, 06 Mar 2012 10:50:30 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q26FoREk022356 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Mar 2012 10:50:27 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q26FoQT3001623; Tue, 6 Mar 2012 10:50:26 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 1667A250BAA; Tue, 6 Mar 2012 17:50:22 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org, Anthony Liguori Date: Tue, 6 Mar 2012 17:50:10 +0200 Message-Id: <1331049010-24312-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka Subject: [Qemu-devel] [PATCH] kvmvapic: align start address as well as size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The kvmvapic code remaps a section of ROM as RAM to allow the guest to maintain state there. It is careful to align the section size to a page boundary, to avoid creating subpages, but neglects to do the same for the start address. These leads to an assert later on when the memory core tries to create a page which is half RAM and half ROM. Fix by aligning the start address to a page boundary. This can be triggered by running qemu-system-x86_64 -enable-kvm -vga none. Signed-off-by: Avi Kivity Reviewed-by: Jan Kiszka Tested-by: Anthony Liguori --- hw/kvmvapic.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/kvmvapic.c b/hw/kvmvapic.c index 36ccfbc..e8bfeec 100644 --- a/hw/kvmvapic.c +++ b/hw/kvmvapic.c @@ -578,8 +578,10 @@ static void vapic_map_rom_writable(VAPICROMState *s) rom_size = ram[rom_paddr + 2] * ROM_BLOCK_SIZE; s->rom_size = rom_size; - /* We need to round up to avoid creating subpages + /* We need to round to avoid creating subpages * from which we cannot run code. */ + rom_size += rom_paddr & ~TARGET_PAGE_MASK; + rom_paddr &= TARGET_PAGE_MASK; rom_size = TARGET_PAGE_ALIGN(rom_size); memory_region_init_alias(&s->rom, "kvmvapic-rom", section.mr, rom_paddr,