From patchwork Tue Aug 10 15:12:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 61397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 81CA2B6F0D for ; Wed, 11 Aug 2010 01:17:23 +1000 (EST) Received: from localhost ([127.0.0.1]:45158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiqZs-0000qt-Ie for incoming@patchwork.ozlabs.org; Tue, 10 Aug 2010 11:17:20 -0400 Received: from [140.186.70.92] (port=56604 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiqWC-0007W6-HL for qemu-devel@nongnu.org; Tue, 10 Aug 2010 11:13:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OiqWA-00011K-A2 for qemu-devel@nongnu.org; Tue, 10 Aug 2010 11:13:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8649) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OiqWA-00010s-3G for qemu-devel@nongnu.org; Tue, 10 Aug 2010 11:13:30 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7AFDROh024890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 Aug 2010 11:13:27 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7AFDRC8007466; Tue, 10 Aug 2010 11:13:27 -0400 Received: from amt.cnet (vpn-9-1.rdu.redhat.com [10.11.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o7AFDQo8032239; Tue, 10 Aug 2010 11:13:26 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 50F3C65603A; Tue, 10 Aug 2010 12:12:30 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o7AFCUYH004057; Tue, 10 Aug 2010 12:12:30 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Tue, 10 Aug 2010 12:12:06 -0300 Message-Id: <14542fea73f294b2a195a8e17c5a0dd15f60640e.1281453126.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gleb Natapov , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/2] kvm: remove guest triggerable abort() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gleb Natapov This abort() condition is easily triggerable by a guest if it configures pci bar with unaligned address that overlaps main memory. Signed-off-by: Gleb Natapov Signed-off-by: Marcelo Tosatti --- kvm-all.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 736c516..85f2e58 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -432,18 +432,10 @@ static void kvm_set_phys_mem(target_phys_addr_t start_addr, KVMSlot *mem, old; int err; - if (start_addr & ~TARGET_PAGE_MASK) { - if (flags >= IO_MEM_UNASSIGNED) { - if (!kvm_lookup_overlapping_slot(s, start_addr, - start_addr + size)) { - return; - } - fprintf(stderr, "Unaligned split of a KVM memory slot\n"); - } else { - fprintf(stderr, "Only page-aligned memory slots supported\n"); - } - abort(); - } + /* kvm works in page size chunks, but the function may be called + with sub-page size and unaligned start address. */ + size = TARGET_PAGE_ALIGN(size); + start_addr = TARGET_PAGE_ALIGN(start_addr); /* KVM does not support read-only slots */ phys_offset &= ~IO_MEM_ROM;