From patchwork Wed Sep 21 17:06:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 9343971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C37BD601C2 for ; Wed, 21 Sep 2016 17:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE092A77D for ; Wed, 21 Sep 2016 17:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC6292A783; Wed, 21 Sep 2016 17:10:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F9962A77D for ; Wed, 21 Sep 2016 17:10:05 +0000 (UTC) Received: from localhost ([::1]:45425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bml24-000704-EL for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Sep 2016 13:10:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmkyh-0004bR-KH for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:06:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmkyc-0006IB-JS for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:06:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmkyc-0006Hm-Do for qemu-devel@nongnu.org; Wed, 21 Sep 2016 13:06:30 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9BE4FC05A2A3; Wed, 21 Sep 2016 17:06:29 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-30.ams2.redhat.com [10.36.112.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8LH6Qeo021892; Wed, 21 Sep 2016 13:06:27 -0400 From: Laurent Vivier To: rth@twiddle.net Date: Wed, 21 Sep 2016 19:06:13 +0200 Message-Id: <1474477573-6386-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 21 Sep 2016 17:06:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] exec: fix tlb_vaddr_to_host() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , afaerber@suse.de, aurelien@aurel32.net, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When used in linux-user mode, tlb_vaddr_to_host(..., addr, ...)) should return "g2h(addr)", but instead it returns "g2h(vaddr)". As "vaddr" is "typedef uint64_t", the result of "g2h(vaddr)" is "((void *)((unsigned long)(target_ulong)(uint64_t) + guest_base))". This bug has been found trying to run "ls" with qemu-ppc. Fixes: "c9f82d0 ppc: Speed up dcbz" Reported-by: Andreas Färber Signed-off-by: Laurent Vivier Reviewed-by: Aurelien Jarno --- include/exec/cpu_ldst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index b573df5..6eb5fe8 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -401,7 +401,7 @@ static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr, int access_type, int mmu_idx) { #if defined(CONFIG_USER_ONLY) - return g2h(vaddr); + return g2h(addr); #else int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];