From patchwork Thu Jan 30 14:25:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 23930 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 132EE20341 for ; Thu, 30 Jan 2014 14:27:05 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id f11sf6827061qae.7 for ; Thu, 30 Jan 2014 06:27:05 -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:from:to:date:message-id:in-reply-to :references: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=2kFWghilAJHHQcfALBepTC4xPPHz1tfbeXxRtzfHLUw=; b=TxH2h/1QEetZUHS1EwyHD65hj2J1ooQQHim9Lifdtb4eJLv3QE8nW1YBaozxUtED9/ MBlkfFZmCj5MPQQCRNNIAvbQekoLALbcH6VxwQ26dsC/q5Zz9BEfVvKdeDCp/YlmOOpK F9PqPEEa1vfCjbeNFGmjSdnR59SnuAC/V4D8KfwpWIs5YL4XquWyBTGUk1qjyEcgGWMc YrYFl/Y640TpjT/A4kziMav/AOLeF9lr67V8otU5VcMInzYIyfHG3LW8PcwOvoIPexRI OXzHpBdtaQCKB9fQB95P/rn3LhQkZb8TpuGdRQio5Q6g73pIMUkOKgJZEcB6PBCF4EsO YHyg== X-Gm-Message-State: ALoCoQn/nmec4xbnvzxnMjjqnkpEGIvnA64UnumPG13dazj5AsxfoeD+bSG5Ts5hnZdkOcafIDJR X-Received: by 10.224.47.129 with SMTP id n1mr5446191qaf.4.1391092025307; Thu, 30 Jan 2014 06:27:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.137 with SMTP id l9ls577855qgf.40.gmail; Thu, 30 Jan 2014 06:27:05 -0800 (PST) X-Received: by 10.52.181.199 with SMTP id dy7mr79143vdc.43.1391092025157; Thu, 30 Jan 2014 06:27:05 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id go5si2131313vec.33.2014.01.30.06.27.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:27:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ks9so2069649vcb.25 for ; Thu, 30 Jan 2014 06:27:05 -0800 (PST) X-Received: by 10.52.181.33 with SMTP id dt1mr10197773vdc.21.1391092025028; Thu, 30 Jan 2014 06:27:05 -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 u4csp16661vcz; Thu, 30 Jan 2014 06:27:04 -0800 (PST) X-Received: by 10.229.7.133 with SMTP id d5mr22172070qcd.10.1391092024399; Thu, 30 Jan 2014 06:27:04 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f67si4600498qgf.146.2014.01.30.06.27.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 06:27:04 -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]:50260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8sa8-0000xz-0q for patch@linaro.org; Thu, 30 Jan 2014 09:27:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8sYp-0007uU-1N for qemu-devel@nongnu.org; Thu, 30 Jan 2014 09:25:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8sYk-000527-K5 for qemu-devel@nongnu.org; Thu, 30 Jan 2014 09:25:42 -0500 Received: from smtp02.citrix.com ([66.165.176.63]:33889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8sYk-000522-FT; Thu, 30 Jan 2014 09:25:38 -0500 X-IronPort-AV: E=Sophos;i="4.95,750,1384300800"; d="scan'208";a="96138351" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 30 Jan 2014 14:25:37 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Thu, 30 Jan 2014 09:25:36 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W8sYZ-0006LU-14; Thu, 30 Jan 2014 14:25:27 +0000 From: Stefano Stabellini To: Date: Thu, 30 Jan 2014 14:25:21 +0000 Message-ID: <1391091921-7306-1-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: 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: xen-devel@lists.xensource.com, Stefano Stabellini , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Anthony Perard , pbonzini@redhat.com Subject: [Qemu-devel] [PULL 1/1] 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.220.180 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 From: Stefano Stabellini 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 Tested-by: Paolo Bonzini Acked-by: Paolo Bonzini Cc: qemu-stable@nongnu.org --- exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 2435d9e..9ad0a4b 100644 --- a/exec.c +++ b/exec.c @@ -325,7 +325,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 */ @@ -334,7 +334,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; } @@ -349,7 +351,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) {