Received: from eggs.gnu.org ([2001:4830:134:3::10]:48581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhxMQ-0005HM-OZ for qemu-devel@nongnu.org; Wed, 07 May 2014 04:38:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhxMI-0008Kg-CN for qemu-devel@nongnu.org; Wed, 07 May 2014 04:37:54 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:56602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhxMI-0008K1-4L for qemu-devel@nongnu.org; Wed, 07 May 2014 04:37:46 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 May 2014 09:37:45 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 82F642190041 for ; Wed, 7 May 2014 09:37:33 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s478bfGF59900122 for ; Wed, 7 May 2014 08:37:41 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s478bcO9023519 for ; Wed, 7 May 2014 02:37:41 -0600 From: Cornelia Huck Date: Wed, 7 May 2014 10:37:30 +0200 Message-Id: <1399451852-12122-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1399451852-12122-1-git-send-email-cornelia.huck@de.ibm.com> References: <1399451852-12122-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org, Thomas Huth , agraf@suse.de, borntraeger@de.ibm.com, Jens Freimann , aliguori@amazon.com, Cornelia Huck 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 Reviewed-by: Alexander Graf 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