From patchwork Fri Oct 16 08:49:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 531117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EDA4B140B0F for ; Fri, 16 Oct 2015 19:59:06 +1100 (AEDT) Received: from localhost ([::1]:51826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0qv-00011K-5C for incoming@patchwork.ozlabs.org; Fri, 16 Oct 2015 04:59:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0im-00044p-TN for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn0il-000766-P5 for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0il-00075y-In for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:39 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 3562B19F211; Fri, 16 Oct 2015 08:50:39 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-80.ams2.redhat.com [10.36.112.80]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9G8oCaZ010200; Fri, 16 Oct 2015 04:50:37 -0400 From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 16 Oct 2015 10:49:36 +0200 Message-Id: <1444985411-17803-15-git-send-email-pbonzini@redhat.com> In-Reply-To: <1444985411-17803-1-git-send-email-pbonzini@redhat.com> References: <1444985411-17803-1-git-send-email-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Alexey Kardashevskiy Subject: [Qemu-devel] [PULL 14/49] kvm-all: Align to qemu_real_host_page_size in kvm_set_phys_mem 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 From: Alexey Kardashevskiy As the comment in kvm_set_phys_mem() says, KVM works in page size chunks. However it uses hardcoded TARGET_PAGE_SIZE which is 4K on most platforms while actual host may use different page size, for example, PPC64 hosts use 64K system pages. This replaces static TARGET_PAGE_SIZE with run-time calculated qemu_real_host_page_size. Signed-off-by: Alexey Kardashevskiy Message-Id: <1444102257-17405-1-git-send-email-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- kvm-all.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 0be4615..6f04fbb 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -642,15 +642,15 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, /* kvm works in page size chunks, but the function may be called with sub-page size and unaligned start address. Pad the start address to next and truncate size to previous page boundary. */ - delta = (TARGET_PAGE_SIZE - (start_addr & ~TARGET_PAGE_MASK)); - delta &= ~TARGET_PAGE_MASK; + delta = qemu_real_host_page_size - (start_addr & ~qemu_real_host_page_mask); + delta &= ~qemu_real_host_page_mask; if (delta > size) { return; } start_addr += delta; size -= delta; - size &= TARGET_PAGE_MASK; - if (!size || (start_addr & ~TARGET_PAGE_MASK)) { + size &= qemu_real_host_page_mask; + if (!size || (start_addr & ~qemu_real_host_page_mask)) { return; }