Received: from eggs.gnu.org ([2001:4830:134:3::10]:58009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhKXP-0008TM-RV for qemu-devel@nongnu.org; Mon, 05 May 2014 11:10:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhKXG-0007bj-FM for qemu-devel@nongnu.org; Mon, 05 May 2014 11:10:39 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:49535) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhKXG-0007bN-1h for qemu-devel@nongnu.org; Mon, 05 May 2014 11:10:30 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 May 2014 16:10:27 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3C71217D8059 for ; Mon, 5 May 2014 16:11:29 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s45FAOYY721256 for ; Mon, 5 May 2014 15:10:24 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s45FANdH023294 for ; Mon, 5 May 2014 09:10:24 -0600 From: Cornelia Huck Date: Mon, 5 May 2014 17:10:17 +0200 Message-Id: <1399302619-21944-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1399302619-21944-1-git-send-email-cornelia.huck@de.ibm.com> References: <1399302619-21944-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 1/3] s390x/helper: Fixed real-to-absolute address translation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, Jens Freimann , agraf@suse.de, Thomas Huth From: Thomas Huth The real-to-absolute address translation in mmu_translate() was missing the second part for translating the page at the prefix address back to the 0 page. And while we're at it, also moved the code into a separate helper function since this might come in handy for other parts of the code, too. Signed-off-by: Thomas Huth Reviewed-by: David Hildenbrand Signed-off-by: Jens Freimann Signed-off-by: Cornelia Huck --- target-s390x/helper.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/target-s390x/helper.c b/target-s390x/helper.c index aa628b8..ddf268e 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -170,6 +170,20 @@ static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr, trigger_pgm_exception(env, type, ilen); } +/** + * Translate real address to absolute (= physical) + * address by taking care of the prefix mapping. + */ +static target_ulong mmu_real2abs(CPUS390XState *env, target_ulong raddr) +{ + if (raddr < 0x2000) { + return raddr + env->psa; /* Map the lowcore. */ + } else if (raddr >= env->psa && raddr < env->psa + 0x2000) { + return raddr - env->psa; /* Map the 0 page. */ + } + return raddr; +} + static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr, uint64_t asc, uint64_t asce, int level, target_ulong *raddr, int *flags, int rw) @@ -363,9 +377,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc, out: /* Convert real address -> absolute address */ - if (*raddr < 0x2000) { - *raddr = *raddr + env->psa; - } + *raddr = mmu_real2abs(env, *raddr); if (*raddr <= ram_size) { sk = &env->storage_keys[*raddr / TARGET_PAGE_SIZE]; -- 1.7.9.5