From patchwork Wed Jul 23 20:09:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Schopp X-Patchwork-Id: 34176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B25032061E for ; Wed, 23 Jul 2014 20:10:18 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf11115257ieb.2 for ; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:user-agent :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=bfjEAK1pU0VDLgvsxfCOQnEJNWM3lKrc0ZSPPFoHzw0=; b=D5T6WKlDD0w48edsa1nzwCPf7WOCmtaqm+hMX1BsWqEiHWmx7zB/tK5oAr7Kqs58Gj TJ1/29Z2xBMq1FWfFKPGE4VVYjDa1PhEzmD0lvy1Ad2JJBL8WgmqVU9H66DstfBOILod LDwU9hNLX9CK7qeLC/reL50zLa7bdQknkqbM9RWbjFHT1k0z7RUaR6gj0s1UFwyfRV7v +GYqu1S8bVgW58ah5g4RS9tSpMebTnbRpIO+uMjTMjMEALj5OQwbvF2dUOLlVO4xpCxa iAGvtmuMlMhMUrO/Oh4wnZzMErZOJBe8vTx/UEfVwoHNMTE99IfH3my4j1RP5V/PHOc+ s88g== X-Gm-Message-State: ALoCoQnLALfim7p7EySeWuJZiCUGavbSjl0YL/7uyipVt/caqNYvCQ5VTLPxxFFBNH7+I6V+428K X-Received: by 10.182.28.136 with SMTP id b8mr1799888obh.19.1406146218219; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.194 with SMTP id 60ls469016qgf.7.gmail; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) X-Received: by 10.52.34.46 with SMTP id w14mr4694834vdi.64.1406146218121; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id th5si3439679vdb.39.2014.07.23.13.10.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 13:10:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so3151489vcb.41 for ; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr5916836vcb.48.1406146218006; Wed, 23 Jul 2014 13:10:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp309451vcb; Wed, 23 Jul 2014 13:10:17 -0700 (PDT) X-Received: by 10.224.129.68 with SMTP id n4mr6145732qas.66.1406146217640; Wed, 23 Jul 2014 13:10:17 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p18si6628705qga.38.2014.07.23.13.10.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Jul 2014 13:10:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:46749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA2rh-0007xI-5n for patch@linaro.org; Wed, 23 Jul 2014 16:10:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA2r4-0007Uh-3R for qemu-devel@nongnu.org; Wed, 23 Jul 2014 16:09:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XA2qw-0007V4-SF for qemu-devel@nongnu.org; Wed, 23 Jul 2014 16:09:38 -0400 Received: from mail-by2lp0240.outbound.protection.outlook.com ([207.46.163.240]:23075 helo=na01-by2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XA2qw-0007Uf-GN for qemu-devel@nongnu.org; Wed, 23 Jul 2014 16:09:30 -0400 Received: from BY1PR0201CA0004.namprd02.prod.outlook.com (25.160.191.142) by BN1PR02MB040.namprd02.prod.outlook.com (10.242.210.155) with Microsoft SMTP Server (TLS) id 15.0.990.7; Wed, 23 Jul 2014 20:09:25 +0000 Received: from BN1AFFO11FD038.protection.gbl (2a01:111:f400:7c10::123) by BY1PR0201CA0004.outlook.office365.com (2a01:111:e400:4814::14) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Wed, 23 Jul 2014 20:09:24 +0000 Received: from atltwp02.amd.com (165.204.84.222) by BN1AFFO11FD038.mail.protection.outlook.com (10.58.52.242) with Microsoft SMTP Server id 15.0.980.11 via Frontend Transport; Wed, 23 Jul 2014 20:09:24 +0000 X-WSS-ID: 0N96LBK-08-U0M-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 29751D16016; Wed, 23 Jul 2014 15:09:20 -0500 (CDT) Received: from SATLEXDAG06.amd.com (10.181.40.13) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.2.328.9; Wed, 23 Jul 2014 15:09:32 -0500 Received: from joelaarch64.amd.com (10.180.168.240) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server (TLS) id 14.2.328.9; Wed, 23 Jul 2014 16:09:22 -0400 From: Joel Schopp To: Date: Wed, 23 Jul 2014 15:09:25 -0500 Message-ID: <20140723200925.9787.75225.stgit@joelaarch64.amd.com> User-Agent: StGit/0.17.1-4-g4a0c1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(428002)(199002)(189002)(102836001)(4396001)(23676002)(101416001)(50986999)(83072002)(64706001)(92566001)(106466001)(47776003)(85852003)(81342001)(87936001)(99396002)(46102001)(20776003)(84676001)(105586002)(77096002)(95666004)(85306003)(54356999)(83506001)(80022001)(19580405001)(77982001)(107046002)(83322001)(92726001)(97736001)(76482001)(97746001)(81542001)(2351001)(21056001)(33646002)(68736004)(110136001)(103116003)(53416004)(31966008)(74502001)(44976005)(50466002)(19580395003)(79102001)(86362001)(229853001)(71626003); DIR:OUT; SFP:; SCL:1; SRVR:BN1PR02MB040; H:atltwp02.amd.com; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; MX:1; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 028166BF91 Received-SPF: None (: amd.com does not designate permitted sender hosts) X-OriginatorOrg: amd4.onmicrosoft.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 207.46.163.240 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH] arm64: 64K pages and > 1024MB guest 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: joel.schopp@amd.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 kvm_set_phys_mem doesn't work on arm64 with memory > 1GB. It exits with: kvm_set_phys_mem: error registering slot: Invalid argument An example of the failing address and size are start_addr == 0x90011000 and size=0xaffef000. As you can see both of these are 4K aligned, not 64K aligned. At 1024MB or smaller qemu only makes one call to kvm_set_user_memory_region, so the start_addr and size are aligned by accident and the bug doesn't happen. The following patch makes things work for me on an arm64 SOC. I also smoke tested the patch on an x86-64 box and qemu seemed to still run fine there with the patch applied. Cc: Peter Maydell Signed-off-by: Joel Schopp --- kvm-all.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kvm-all.c b/kvm-all.c index 1402f4f..1975862 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -618,14 +618,14 @@ static void kvm_set_phys_mem(MemoryRegionSection *section, bool add) /* kvm works in page size chunks, but the function may be called with sub-page size and unaligned start address. */ - delta = TARGET_PAGE_ALIGN(size) - size; + delta = HOST_PAGE_ALIGN(start_addr) - start_addr; if (delta > size) { return; } start_addr += delta; size -= delta; - size &= TARGET_PAGE_MASK; - if (!size || (start_addr & ~TARGET_PAGE_MASK)) { + size &= qemu_host_page_mask; + if (!size || (start_addr & ~qemu_host_page_mask)) { return; }