From patchwork Mon Jun 13 17:05:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 69906 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1649724qgf; Mon, 13 Jun 2016 10:19:48 -0700 (PDT) X-Received: by 10.140.155.131 with SMTP id b125mr15696141qhb.14.1465838388400; Mon, 13 Jun 2016 10:19:48 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h71si15785384qke.63.2016.06.13.10.19.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 13 Jun 2016 10:19:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:57973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVWd-0005M9-Uc for patch@linaro.org; Mon, 13 Jun 2016 13:19:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVJF-0001Za-GK for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:05:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCVJ9-0001ss-KQ for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:05:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVJ9-0001sk-C7 for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:05:51 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 06170C049E1D; Mon, 13 Jun 2016 17:05:51 +0000 (UTC) Received: from localhost (ovpn-112-61.ams2.redhat.com [10.36.112.61]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5DH5nFR017469; Mon, 13 Jun 2016 13:05:50 -0400 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Mon, 13 Jun 2016 18:05:26 +0100 Message-Id: <1465837535-30067-7-git-send-email-stefanha@redhat.com> In-Reply-To: <1465837535-30067-1-git-send-email-stefanha@redhat.com> References: <1465837535-30067-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 13 Jun 2016 17:05:51 +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 v3 06/15] target-i386: Move user-mode exception actions out of user-exec.c 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: Kevin Wolf , Peter Maydell , Fam Zheng , Jeff Cody , mreitz@redhat.com, jjherne@linux.vnet.ibm.com, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The exception_action() function in user-exec.c is just a call to cpu_loop_exit() for every target CPU except i386. Since this function is only called if the target's handle_mmu_fault() hook has indicated an MMU fault, and that hook is only called from the handle_cpu_signal() code path, we can simply move the x86-specific setup into that hook, which allows us to remove the TARGET_I386 ifdef from user-exec.c. Of the actions that were done by the call to raise_interrupt_err(): * cpu_svm_check_intercept_param() is a no-op in user mode * check_exception() is a no-op since double faults are impossible for user-mode * assignments to cs->exception_index and env->error_code are no-ops * assigning to env->exception_next_eip is unnecessary because it is not used unless env->exception_is_int is true * cpu_loop_exit_restore() is equivalent to cpu_loop_exit() since pc is 0 which leaves just setting env_>exception_is_int as the action that needs to be added to x86_cpu_handle_mmu_fault(). Signed-off-by: Peter Maydell Reviewed-by: Sergey Fedorov Acked-by: Eduardo Habkost Acked-by: Riku Voipio Message-id: 1463494687-25947-7-git-send-email-peter.maydell@linaro.org --- target-i386/helper.c | 2 ++ user-exec.c | 16 +--------------- 2 files changed, 3 insertions(+), 15 deletions(-) -- 2.5.5 diff --git a/target-i386/helper.c b/target-i386/helper.c index 889fdab..1c250b8 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -701,6 +701,8 @@ int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, env->error_code = (is_write << PG_ERROR_W_BIT); env->error_code |= PG_ERROR_U_MASK; cs->exception_index = EXCP0E_PAGE; + env->exception_is_int = 0; + env->exception_next_eip = -1; return 1; } diff --git a/user-exec.c b/user-exec.c index b9e7bec..50e95a6 100644 --- a/user-exec.c +++ b/user-exec.c @@ -40,18 +40,6 @@ //#define DEBUG_SIGNAL -static void exception_action(CPUState *cpu) -{ -#if defined(TARGET_I386) - X86CPU *x86_cpu = X86_CPU(cpu); - CPUX86State *env1 = &x86_cpu->env; - - raise_exception_err(env1, cpu->exception_index, env1->error_code); -#else - cpu_loop_exit(cpu); -#endif -} - /* exit the current TB from a signal handler. The host registers are restored in a state compatible with the CPU emulator */ @@ -120,10 +108,8 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, /* now we have a real cpu fault */ cpu_restore_state(cpu, pc); - /* we restore the process signal mask as the sigreturn should - do it (XXX: use sigsetjmp) */ sigprocmask(SIG_SETMASK, old_set, NULL); - exception_action(cpu); + cpu_loop_exit(cpu); /* never comes here */ return 1;