From patchwork Thu Jan 27 11:01:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Rozenman X-Patchwork-Id: 80648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8DBE81007D1 for ; Thu, 27 Jan 2011 22:07:12 +1100 (EST) Received: from localhost ([127.0.0.1]:36836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiPgy-0000Sq-CN for incoming@patchwork.ozlabs.org; Thu, 27 Jan 2011 06:07:08 -0500 Received: from [140.186.70.92] (port=47640 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PiPbP-0007Ja-OE for qemu-devel@nongnu.org; Thu, 27 Jan 2011 06:01:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PiPbO-0001NQ-Nt for qemu-devel@nongnu.org; Thu, 27 Jan 2011 06:01:23 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:35867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PiPbO-0001NG-KK for qemu-devel@nongnu.org; Thu, 27 Jan 2011 06:01:22 -0500 Received: by iye19 with SMTP id 19so1410194iye.4 for ; Thu, 27 Jan 2011 03:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=RguH4XiH98yBgfRubmke1381quZs3ZE/SG0nFLAt/GQ=; b=d1WReUjiomnI67EjnX9k17b7lFVuhbFtfGoefL7+TlaLfVZWWHL2WxUyXo6moEli/z JT7TfaJxxomgvtaRYkTrMegJWlvNE7puxyajtU2isMmNnRermmqIoJmaINtiREv0ap7j xEfH9J33jGT8KYRba38Bz5JTrCcW3OL2juZ2E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=M1ZqAJ8b2am125+64Q/gzavf+pijlmuZu/eX8xMnF5PN1gHLrSMYukRXFTpq2OAjxW MPId4JM3eQKeqgGqFh1x+bZLOo8sbolvj3ZRCuyLphcF4lx91/HDZK4oPolIo72Gn3Ax wTVQ8lkoVdemVtBw3vH7KCrZ0QpzR/34+c3Iw= Received: by 10.42.179.194 with SMTP id br2mr1926626icb.339.1296126081728; Thu, 27 Jan 2011 03:01:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.108.7 with HTTP; Thu, 27 Jan 2011 03:01:01 -0800 (PST) From: Alex Rozenman Date: Thu, 27 Jan 2011 13:01:01 +0200 Message-ID: To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] use correct initial region_offset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi, I found a bug in phys_page_find_alloc function causing initial region_offset field to be set to incorrect initial value. Usually, the pages are re-assigned afterwards, so the bug has very small effect on regular QEMU users. We use "memory unassigned" callback and this bug causes invalid addresses there. A small patch is attached. I have ssh membership on savannah. Please approve and/or push. This is my first time when I am suggesting patches to QEMU; I also would like to add some fixes for ppc440/ppc440x6 cores. From 8935358ddf9bf5b80c8b8ac7014b650a519a3ebf Mon Sep 17 00:00:00 2001 From: Alex Rozenman Date: Thu, 27 Jan 2011 12:47:57 +0200 Subject: [PATCH] phys_page_find_alloc: use correct initial region_offset --- exec.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/exec.c b/exec.c index db9ff55..00667d7 100644 --- a/exec.c +++ b/exec.c @@ -416,6 +416,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) pd = *lp; if (pd == NULL) { int i; + int first_index = index & ~(L2_SIZE - 1); if (!alloc) { return NULL; @@ -425,7 +426,7 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) for (i = 0; i < L2_SIZE; i++) { pd[i].phys_offset = IO_MEM_UNASSIGNED; - pd[i].region_offset = (index + i) << TARGET_PAGE_BITS; + pd[i].region_offset = (first_index + i) << TARGET_PAGE_BITS; } } -- 1.7.0.4