From patchwork Wed Jan 29 12:00:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 23830 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D715F202FA for ; Wed, 29 Jan 2014 12:01:23 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf5612852iej.8 for ; Wed, 29 Jan 2014 04:01:23 -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=vmzEDcsMwm7vhVvFnjzuapv/9yc1w7LVjA6gTae9gEM=; b=Q4XztF5ssQ+3ofWMFzpkcd1bCdZg9PgNniFZwGK01LUqIikX5wG3G9It2gz1aKFdbH oqEQn6c/RhrVXTw8HLNMkBRwDYX75JVk9/yugsjPYUKAYqgssqwvD2Gs9/+t157/a9mM HKDRcHBdJMSmzTlTDLnlPNSN/4HNOBct4zDEEH7804w8DrEQ4B2kMk0hc1Wxe3DkZKSc Pc5HxVh40GczaBrUfng+Zhg5ZpjX4cooY4srrIxtSKypwpq9SIf4LPABuL7WIiTzyIqr J5oF4hJdoknnxzo4vqI6G2T3S8PGi0zszEFsJnn3iLgKcaa0Ypf5aY8MW5cC1V0zlR2T 3ktQ== X-Gm-Message-State: ALoCoQlWlPSFWDCCIOANcKOAvKpITcnSeDXWuBTy3a05aXoJUPK96cjR/3phzVBe5XywYzKZ01Z3 X-Received: by 10.42.250.196 with SMTP id mp4mr2355102icb.29.1390996883108; Wed, 29 Jan 2014 04:01:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls66025qgv.19.gmail; Wed, 29 Jan 2014 04:01:22 -0800 (PST) X-Received: by 10.220.103.141 with SMTP id k13mr833135vco.25.1390996882904; Wed, 29 Jan 2014 04:01:22 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id sm10si725714vec.43.2014.01.29.04.01.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 04:01:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 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.169; Received: by mail-ve0-f169.google.com with SMTP id oy12so1113284veb.14 for ; Wed, 29 Jan 2014 04:01:22 -0800 (PST) X-Received: by 10.220.88.204 with SMTP id b12mr6241218vcm.3.1390996882824; Wed, 29 Jan 2014 04:01:22 -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 u4csp106996vcz; Wed, 29 Jan 2014 04:01:22 -0800 (PST) X-Received: by 10.229.97.134 with SMTP id l6mr11135009qcn.11.1390996882228; Wed, 29 Jan 2014 04:01:22 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x4si1554258qad.108.2014.01.29.04.01.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 29 Jan 2014 04:01:22 -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]:41672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8TpZ-0006OP-QT for patch@linaro.org; Wed, 29 Jan 2014 07:01:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Tof-0005dY-B6 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 07:00:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ToZ-0002hF-40 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 07:00:25 -0500 Received: from smtp.citrix.com ([66.165.176.89]:30456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ToZ-0002h5-00 for qemu-devel@nongnu.org; Wed, 29 Jan 2014 07:00:19 -0500 X-IronPort-AV: E=Sophos;i="4.95,741,1384300800"; d="scan'208";a="97644780" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 29 Jan 2014 12:00:16 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.2.342.4; Wed, 29 Jan 2014 07:00:16 -0500 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1W8ToW-00007g-2L; Wed, 29 Jan 2014 12:00:16 +0000 Date: Wed, 29 Jan 2014 12:00:11 +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.89 Cc: Anthony Perard , George Dunlap , xen-devel@lists.xensource.com, qemu-devel@nongnu.org, Stefano Stabellini Subject: [Qemu-devel] [BUG] BSoD on Windows XP installation 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.169 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 Hi Paolo, we have been trying to fix a BSOD that would happen during the Windows XP installation, once every ten times on average. After many days of bisection, we found out that 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 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). The appended patch works around the issue by reverting to the old behaviour. What do you think is the right fix for this? Maybe we need to add a size parameter to qemu_get_ram_ptr? I should add that this problem is time sensitive because is a blocker for the Xen 4.4 release (Xen is in RC2 right now). Thanks for your feedback, Stefano diff --git a/exec.c b/exec.c index 667a718..15edb69 100644 --- a/exec.c +++ b/exec.c @@ -1948,10 +1948,15 @@ bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, hwaddr addr1; MemoryRegion *mr; bool error = false; + hwaddr page; while (len > 0) { l = len; mr = address_space_translate(as, addr, &addr1, &l, is_write); + page = addr & TARGET_PAGE_MASK; + l = (page + TARGET_PAGE_SIZE) - addr; + if (l > len) + l = len; if (is_write) { if (!memory_access_is_direct(mr, is_write)) { @@ -2057,11 +2062,16 @@ void cpu_physical_memory_write_rom(hwaddr addr, uint8_t *ptr; hwaddr addr1; MemoryRegion *mr; + hwaddr page; while (len > 0) { l = len; mr = address_space_translate(&address_space_memory, addr, &addr1, &l, true); + page = addr & TARGET_PAGE_MASK; + l = (page + TARGET_PAGE_SIZE) - addr; + if (l > len) + l = len; if (!(memory_region_is_ram(mr) || memory_region_is_romd(mr))) { @@ -2164,6 +2174,7 @@ void *address_space_map(AddressSpace *as, hwaddr l, xlat, base; MemoryRegion *mr, *this_mr; ram_addr_t raddr; + hwaddr page; if (len == 0) { return NULL; @@ -2171,6 +2182,10 @@ void *address_space_map(AddressSpace *as, l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); + page = addr & TARGET_PAGE_MASK; + l = (page + TARGET_PAGE_SIZE) - addr; + if (l > len) + l = len; if (!memory_access_is_direct(mr, is_write)) { if (bounce.buffer) { return NULL;