From patchwork Mon Jun 25 17:32:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 167182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0026FB6FB4 for ; Tue, 26 Jun 2012 03:33:00 +1000 (EST) Received: from localhost ([::1]:38856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjD9m-00070r-Ev for incoming@patchwork.ozlabs.org; Mon, 25 Jun 2012 13:32:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjD9f-00070d-Bu for qemu-devel@nongnu.org; Mon, 25 Jun 2012 13:32:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SjD9a-0004fI-H2 for qemu-devel@nongnu.org; Mon, 25 Jun 2012 13:32:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57699 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjD9a-0004f8-AZ for qemu-devel@nongnu.org; Mon, 25 Jun 2012 13:32:46 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 5BCD6A39D0; Mon, 25 Jun 2012 19:32:43 +0200 (CEST) From: Alexander Graf To: qemu-devel qemu-devel Date: Mon, 25 Jun 2012 19:32:39 +0200 Message-Id: <1340645559-5448-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Peter Maydell , Riku Voipio Subject: [Qemu-devel] [PATCH] linux-user: fix segmentation fault passing with g2h(x) != x 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When forwarding a segmentation fault into the guest process, we were passing the host's address directly into the guest process's signal descriptor. That obviously confused the guest process, since it didn't know what to make of the (usually 32-bit truncated) address. Passing in g2h(address) makes the guest process a lot happier. This fixes java running in arm-linux-user for me. Signed-off-by: Alexander Graf Reviewed-by: Peter Maydell --- user-exec.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/user-exec.c b/user-exec.c index 36d29b4..83d2d44 100644 --- a/user-exec.c +++ b/user-exec.c @@ -100,19 +100,20 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, /* Maybe we're still holding the TB fiddling lock? */ spin_unlock_safe(&tb_lock); - /* XXX: locking issue */ - if (is_write && h2g_valid(address) - && page_unprotect(h2g(address), pc, puc)) { - return 1; - } + if (h2g_valid(address)) { + /* XXX: locking issue */ + if (is_write && page_unprotect(h2g(address), pc, puc)) { + return 1; + } - /* see if it is an MMU fault */ - ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); - if (ret < 0) { - return 0; /* not an MMU fault */ - } - if (ret == 0) { - return 1; /* the MMU fault was handled without causing real CPU fault */ + /* see if it is an MMU fault */ + ret = cpu_handle_mmu_fault(env, h2g(address), is_write, MMU_USER_IDX); + if (ret < 0) { + return 0; /* not an MMU fault */ + } + if (ret == 0) { + return 1; /* the MMU fault was handled without causing real CPU fault */ + } } /* now we have a real cpu fault */ tb = tb_find_pc(pc);