From patchwork Mon Jul 30 16:04:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 174039 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 802A92C0087 for ; Tue, 31 Jul 2012 02:28:33 +1000 (EST) Received: from localhost ([::1]:55003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvsSn-0003Zg-Cw for incoming@patchwork.ozlabs.org; Mon, 30 Jul 2012 12:04:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvsS8-0001sL-MI for qemu-devel@nongnu.org; Mon, 30 Jul 2012 12:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SvsS4-0000XV-Dj for qemu-devel@nongnu.org; Mon, 30 Jul 2012 12:04:16 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:37543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvsS4-0000Wa-7U for qemu-devel@nongnu.org; Mon, 30 Jul 2012 12:04:12 -0400 Received: by mail-ee0-f45.google.com with SMTP id e53so1297961eek.4 for ; Mon, 30 Jul 2012 09:04:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=bdxYoTXVc7KwK04f3K6cxaTyd3cra0ERoHQvJyYtpXo=; b=G8ZMxHIhEGYfqAiRYz7DfZj7laoSv0YKp1YFhDB30ucKpmp13uCpcdrkkl1IVEmYtv HlJvGJOjPqm+aJ2cIf0wEm1pTIyAZWFDvRuyapa++YgHIPi9UJkvE8jID5vM0PEEXjXQ KmoCIv7E2MYj+A0eJairU1iBD/4r4NEaxz0ZwJCubpHqOlO3+j3TsxBiOfIxTv+lrtyd zF21f5EZc44/3FQ6wGv8yxlQ2ixWZnDHy/fdU+uGl6sCd4KsR7MnnHuryw8agBkvG/Yv f7GpxhJFv1ZDDyIQND5acx3xZtDYsMiQVQ9eVJi7rCrggVwsSqPirmIHRZVLsKPVhgSa KSMw== Received: by 10.14.225.68 with SMTP id y44mr4237671eep.5.1343664251842; Mon, 30 Jul 2012 09:04:11 -0700 (PDT) Received: from localhost.localdomain (blueswirl.broker.freenet6.net. [2001:5c0:1400:b::d5a3]) by mx.google.com with ESMTPS id k41sm6346971eep.13.2012.07.30.09.04.10 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jul 2012 09:04:11 -0700 (PDT) From: blauwirbel@gmail.com To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2012 16:04:34 +0000 Message-Id: <38b92c2c0c3a7fe7a6de1f09125a1154c2406677.1343664167.git.blauwirbel@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.45 Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 4/5] user: fix accidental AREG0 use 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 From: Blue Swirl Global register AREG0 was always assumed to be usable in user-exec.c, but this is incorrect for several targets. Fix with #ifdeffery and by using other variables. Signed-off-by: Blue Swirl --- user-exec.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/user-exec.c b/user-exec.c index b2a4261..7b93fc7 100644 --- a/user-exec.c +++ b/user-exec.c @@ -18,7 +18,9 @@ */ #include "config.h" #include "cpu.h" +#ifndef CONFIG_TCG_PASS_AREG0 #include "dyngen-exec.h" +#endif #include "disas.h" #include "tcg.h" @@ -58,9 +60,11 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc) struct sigcontext *uc = puc; #endif +#ifndef CONFIG_TCG_PASS_AREG0 env = env1; /* XXX: restore cpu registers saved in host registers */ +#endif if (puc) { /* XXX: use siglongjmp ? */ @@ -74,8 +78,8 @@ void cpu_resume_from_signal(CPUArchState *env1, void *puc) sigprocmask(SIG_SETMASK, &uc->sc_mask, NULL); #endif } - env->exception_index = -1; - longjmp(env->jmp_env, 1); + env1->exception_index = -1; + longjmp(env1->jmp_env, 1); } /* 'pc' is the host PC at which the exception was raised. 'address' is @@ -89,9 +93,11 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, TranslationBlock *tb; int ret; +#ifndef CONFIG_TCG_PASS_AREG0 if (cpu_single_env) { env = cpu_single_env; /* XXX: find a correct solution for multithread */ } +#endif #if defined(DEBUG_SIGNAL) qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", pc, address, is_write, *(unsigned long *)old_set); @@ -103,7 +109,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, } /* see if it is an MMU fault */ - ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); + ret = cpu_handle_mmu_fault(cpu_single_env, address, is_write, + MMU_USER_IDX); if (ret < 0) { return 0; /* not an MMU fault */ } @@ -115,13 +122,13 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, if (tb) { /* the PC is inside the translated code. It means that we have a virtual CPU fault */ - cpu_restore_state(tb, env, pc); + cpu_restore_state(tb, cpu_single_env, pc); } /* we restore the process signal mask as the sigreturn should do it (XXX: use sigsetjmp) */ sigprocmask(SIG_SETMASK, old_set, NULL); - exception_action(env); + exception_action(cpu_single_env); /* never comes here */ return 1;