From patchwork Fri Sep 24 13:56:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 514576 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1501824jao; Fri, 24 Sep 2021 07:03:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw53rETNIIt6Z0/qf8rogaQX0gBkXvS1xHyBNYJjN4xkYKz8GNNPV9Skal2szalAhdMAKRr X-Received: by 2002:a05:620a:c4d:: with SMTP id u13mr10636074qki.411.1632492210444; Fri, 24 Sep 2021 07:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632492210; cv=none; d=google.com; s=arc-20160816; b=KKAesvMScOidyG8PCofA0GBkroLcdzv6fm7b5jB9RueT0QxWSGLrjQvNLot1d61xt6 6y15CXQqL6u1IGpHzyHwfj+sSJu9iN2HvoM2Wib02TS2MaYUELTo58dxpnQbqPiNFtL5 kLJKdScz3mr8pCKXnzisKh3LCdRPm8hdurRFnN+UmeRA23luHfApSgbOBGo8dUEcgthX NoPBBI/QepEJD9mj8w3zVu6pnwhxU06Z6F0em2GEtHU6wgXmZPBmfWVh6WaUqMcfUWgd daYeqFUhPqO80T6aSjQcFPmNrf2Fa+N8qy+T8rWIAJqShK4jGOK61hRG+/LkJjKJ25vb xBsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=p+YIg+ohRLXbSiWgTXYClEhedxqEhBHgb/zCnqhBh80=; b=qUf26Ew/Cu+I9wcDaZQlaUYAKXeRtFr5QPcXmmv7zgCrshSQF5ISu/w00w+Swh0wX0 pJdx+/ktpCBy09+qkdJf2a+kqgyVl+cU1EHE9DcFG5HJA8fXdKIhDOCdYH8j17lsew07 DMwo+4Jf8RVX8jty4aYxCyGm90GePcmCwMoz2Ixeg+IiVbD0S7qT/IZN3oBY+1i279IU v4C9r0T0AeJelDJLFCEgFqepoGiZDoWw0yvzUNrmrddjJRznnDVRJIGsz/j4/vOy8s75 1o5XtlqQ5I+jtuyaDCJ5X8FuYTO7UesIumzDJQDCj3zSebSK5SflO8YlRTuhhRyQ4Otg oftg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iy14si6552679qvb.213.2021.09.24.07.03.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 07:03:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:39852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTlnV-00054r-T1 for patch@linaro.org; Fri, 24 Sep 2021 10:03:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgu-00032i-KM for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:59141) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTlgs-0005AF-5R for qemu-devel@nongnu.org; Fri, 24 Sep 2021 09:56:40 -0400 Received: from quad ([82.142.21.142]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N3bGP-1muGu01dop-010c3Y; Fri, 24 Sep 2021 15:56:35 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 6/7] linux-user/arm: Use force_sig_fault() Date: Fri, 24 Sep 2021 15:56:30 +0200 Message-Id: <20210924135631.2067582-7-laurent@vivier.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210924135631.2067582-1-laurent@vivier.eu> References: <20210924135631.2067582-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:GR3BsFG5L32UWDfi68Eb/l0ifBT1ItetpTC46iNdBYsV5jx+Jee 1nm3TfPWBMjNPfjChpHxjcTz+vCA4a+RpvzFRnwItOHSAPi39hRepSq549WvlsK34h3i/5Y TTNBWUJIEj306mH+QdRNRivMfykFKRLiKNLbRmWrw2bUorP6MIeCJIRPqRC/ZjTt04JoF45 lW1bWUcsNmzT69OeCMRUQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:DJQyKOes5TI=:faTkQ5QLfVg0DQJSUAajCm P+wrEh1GoxAGqFYED1CPQSgj6gT8QZd53r3t+q0V7VI5d6TtRf6YfQW5xbtaPx/ZhTHFKHe/Y ms0P4dkecvvWL1k2JQL3U4XH/58oYbg3eDjFc/wuNKH4j2Z2gwtRZymZ8Hgxy0KprlvNbiolX 4MhlqYikDqgq3Gb4sZSPp3Tjj6OqAbJ8RMzWmB8X/o02cnc9YTiphwad2v5ACuyylGtsjgpQd BPqwEoevY4NcdpvCX2l4nm/JAaN50ZYXy1bUCNbr1edPWWwtZNfK3OAW4X5tlQbaE9aS6rLj9 w6jbORUqkYQng7ICsC5BjU9ynAjT73GkqfwlNeN548bOej7MgffV6m/2NR05pl50Hz+HAUeza xi57A468AFEupY7GTC+vAS7xBgu7i2EK2xCjggkiEQnkoypGH3LkRG4Jy5NV6ClptMjv/WdYW KNyLcMt/8ohhjAbH3CNbDXA/i/aPqxVSCNrUDfP5RobgXx6Vp4qRftCGWRxeJH5vMR4NysNEm 9Lej9JmFYrictpDBCt2SGcD7wbahELDzPnj2zfvEg4LKtrdNfeN+SO61AiXRn7dTonJhcu8bT ndnLkLzkM8SFp8H+lZNYiWNcG2Pt/X2HBkSsuuN4Ihmi5xLvwYXsBgopKqCCu1OKu6lYqtDfg kXmqKOZkTBzMYLuDjKCIs+k/5HsoElu/Ty4tRI7Z03BhGSOw0YSrOEmBSE/ynIH173K2vzj5a piun5XUBWldG/OOMviWCzTlRxGoAMeZ0M4Dp3g== Received-SPF: none client-ip=212.227.17.24; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20210813131809.28655-7-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/arm/cpu_loop.c | 53 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) -- 2.31.1 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index fb78a1aab308..ae09adcb9501 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -94,7 +94,6 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env) { uint64_t oldval, newval, val; uint32_t addr, cpsr; - target_siginfo_t info; /* Based on the 32 bit code in do_kernel_trap */ @@ -143,12 +142,9 @@ segv: end_exclusive(); /* We get the PC of the entry address - which is as good as anything, on a real kernel what you get depends on which mode it uses. */ - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->exception.vaddress; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); } /* Handle a jump to the kernel code page. */ @@ -286,8 +282,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs = env_cpu(env); int trapnr; unsigned int n, insn; - target_siginfo_t info; - uint32_t addr; abi_ulong ret; for(;;) { @@ -322,11 +316,8 @@ void cpu_loop(CPUARMState *env) break; } - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, + env->regs[15]); } break; case EXCP_SWI: @@ -394,18 +385,14 @@ void cpu_loop(CPUARMState *env) * Otherwise SIGILL. This includes any SWI with * immediate not originally 0x9fxxxx, because * of the earlier XOR. + * Like the real kernel, we report the addr of the + * SWI in the siginfo si_addr but leave the PC + * pointing at the insn after the SWI. */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLTRP; - info._sifields._sigfault._addr = env->regs[15]; - if (env->thumb) { - info._sifields._sigfault._addr -= 2; - } else { - info._sifields._sigfault._addr -= 4; - } - queue_signal(env, info.si_signo, - QEMU_SI_FAULT, &info); + abi_ulong faultaddr = env->regs[15]; + faultaddr -= env->thumb ? 2 : 4; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + faultaddr); } break; } @@ -436,24 +423,14 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr = env->exception.vaddress; - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + /* XXX: check env->error_code */ + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: excp_debug: - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[15]); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env))