From patchwork Thu Jan 30 12:46:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 23921 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f199.google.com (mail-yk0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3042D202B2 for ; Thu, 30 Jan 2014 12:46:52 +0000 (UTC) Received: by mail-yk0-f199.google.com with SMTP id 142sf16551258ykq.2 for ; Thu, 30 Jan 2014 04:46:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to: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; bh=oDTRFwynIG+JF5gLmyQGxaT0oCuj1yHyRj6EggQyQV0=; b=cOnN0uugbp8s86r+G0WzYeP9PKgqdSBG5Prbes0uPK0gVkUM1hJOfFo0LNAvzBp4Yv AOsLVwEMf9pF/WAyhmouIXsGvAiBwxFBAT6UPx2yEwN6a+WnLsAfj3P+YXY+MHuLxyQI QSIgioBXh8kJb/+utbnAH8NuadzzxyTNsBBaz/slsLly8CaIPSRp/yPK0X0n4KFVe93r zgYAIqSeRvG3GouW0jcbxr5eGWXGL0EsFgrP5lxu4M+v8zIkM6cXgv6QKlZlS9LiQu4F cQS1AFBOVD92CZZn5lDBTxECgYVCnkqKmbe7GmwkrbmcQyzU2E1h8Iy+iNCsOfw8JnAK ITYA== X-Gm-Message-State: ALoCoQn2nzuXGRn5pYvxOyDMxAQoIDIjHJkXNtTNaMehjYG+33xbJUOCQomVqu5VO12+OZkw3SUe X-Received: by 10.58.43.132 with SMTP id w4mr5071753vel.20.1391086011204; Thu, 30 Jan 2014 04:46:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.102 with SMTP id f93ls562629qga.75.gmail; Thu, 30 Jan 2014 04:46:51 -0800 (PST) X-Received: by 10.221.26.10 with SMTP id rk10mr11764245vcb.0.1391086011066; Thu, 30 Jan 2014 04:46:51 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id si7si2021480vdc.24.2014.01.30.04.46.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 04:46:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so2166688veb.27 for ; Thu, 30 Jan 2014 04:46:51 -0800 (PST) X-Received: by 10.220.58.202 with SMTP id i10mr6557954vch.23.1391086010983; Thu, 30 Jan 2014 04:46:50 -0800 (PST) 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.220.174.196 with SMTP id u4csp9628vcz; Thu, 30 Jan 2014 04:46:50 -0800 (PST) X-Received: by 10.140.22.232 with SMTP id 95mr20050740qgn.82.1391086010568; Thu, 30 Jan 2014 04:46:50 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id v8si4366589qab.49.2014.01.30.04.46.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 04:46:50 -0800 (PST) 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]:48326 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8r18-0000cr-7n for patch@linaro.org; Thu, 30 Jan 2014 07:46:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8r0b-0000Dv-OA for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:46:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8r0X-0002F2-12 for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:46:17 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:38412) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8r0W-0002Es-TA for qemu-devel@nongnu.org; Thu, 30 Jan 2014 07:46:12 -0500 X-IronPort-AV: E=Sophos;i="4.95,749,1384300800"; d="scan'208";a="96104410" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 30 Jan 2014 12:46:11 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.2.342.4; Thu, 30 Jan 2014 07:46:10 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W8r0U-0004nO-Mi; Thu, 30 Jan 2014 12:46:10 +0000 Date: Thu, 30 Jan 2014 12:46:05 +0000 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Paolo Bonzini Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Cc: Anthony PERARD , george.dunlap@eu.citrix.com, xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [PATCH] address_space_translate: do not cross page boundaries 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: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 The following commit: commit 149f54b53b7666a3facd45e86eece60ce7d3b114 Author: Paolo Bonzini Date: Fri May 24 12:59:37 2013 +0200 memory: add address_space_translate breaks Xen support in QEMU, in particular the Xen mapcache. The effect is that one Windows XP installation out of ten would end up with BSOD. The reason is that after this commit l in address_space_rw can span a page boundary, however qemu_get_ram_ptr still calls xen_map_cache asking to map a single page (if block->offset == 0). Fix the issue by reverting to the previous behaviour: do not return a length from address_space_translate_internal that can span a page boundary. Also in address_space_translate do not ignore the length returned by address_space_translate_internal. This patch should be backported to QEMU 1.6.x. Signed-off-by: Stefano Stabellini Signed-off-by: Anthony Perard --- exec.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 667a718..f3797b7 100644 --- a/exec.c +++ b/exec.c @@ -251,7 +251,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x hwaddr *plen, bool resolve_subpage) { MemoryRegionSection *section; - Int128 diff; + Int128 diff, diff_page; section = address_space_lookup_region(d, addr, resolve_subpage); /* Compute offset within MemoryRegionSection */ @@ -260,7 +260,9 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x /* Compute offset within MemoryRegion */ *xlat = addr + section->offset_within_region; + diff_page = int128_make64(((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - addr); diff = int128_sub(section->mr->size, int128_make64(addr)); + diff = int128_min(diff, diff_page); *plen = int128_get64(int128_min(diff, int128_make64(*plen))); return section; } @@ -275,7 +277,7 @@ MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, hwaddr len = *plen; for (;;) { - section = address_space_translate_internal(as->dispatch, addr, &addr, plen, true); + section = address_space_translate_internal(as->dispatch, addr, &addr, &len, true); mr = section->mr; if (!mr->iommu_ops) {