From patchwork Mon Dec 20 21:05:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 526087 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp4458101imb; Mon, 20 Dec 2021 13:18:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzs07FW2WOXAFnIc4xzMvbb6M2qbbBVEsrNCzvH5GfeoF5U+6ZXCePkiJlcm8X4BI77MBT X-Received: by 2002:a05:6638:411b:: with SMTP id ay27mr24476jab.211.1640035090981; Mon, 20 Dec 2021 13:18:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640035090; cv=none; d=google.com; s=arc-20160816; b=rlHl2I5oLer9Yy2Jn+TNMl5sPrq8EvO4BGVtxH7NqAHwH7ioJ25kbrEs6UvtaeDoCn tUz1hjBlmce0Wzo/2xqIZab1hZAYoTe/1UYR2JXY6Zm2X4so0W8wVRMe5OYkwiNbsKAs VUnHCzQzTiyIP5nRLIOoJTUntYa1A600bDudj0Eajnwdj1ywqCClQ0+/fmGfnIyzXaHI J++BKJsgzZYo7waAhXc0lqySQ0wRu/SacH/gWewAXRKBnqr7zfQlRTcwYioAnTEDGpjG AXMz1xgSB9HEwTf+Xkqh4oMyzVBTk8VZpUxoq1A/24CX89kuCKFLGdpiarAwri+u4sLH LfCw== 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 :dkim-signature; bh=RWV9WOum/EgcRXAB9OWJGs5V6nSAWvrKYW5XslI2s0c=; b=c8y8j8IDpEyUwG4lPdzOEB/HHccYWGSuH2Hu/4UqOJd5Wg3R/3573ojjExMoA2clwq YqTv7X5ud28hwRX+4GpVX4td7B7lQOz/fJGT5q3rQNG+9IMyr3nyCHwSOfPOrdfv0X5k E+Aq9jkz43Tz8GH3ATKSV1ouT0EJcyuaKql4/PY92ma06YK6VA1t4VYMIf8bk5rRve+C 8UCj5M8rO/j/HUaYtPyOQglMkwNF7uz/8fSzrLv/jbpLTAxmHNK4QADm8TfA8J3X8D3T W8bGXvMPpwuBvK0c7r/r/kupWiFsNyZWUrlZ0QuqNjEJC++pqSw8pilClXS1naE4WkJJ tkNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ui6yCzwN; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y3si16864160iov.37.2021.12.20.13.18.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Dec 2021 13:18:10 -0800 (PST) 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; dkim=fail header.i=@linaro.org header.s=google header.b=ui6yCzwN; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzQ2s-0000UA-Ef for patch@linaro.org; Mon, 20 Dec 2021 16:18:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzPqp-0000TK-2G for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:05:43 -0500 Received: from [2607:f8b0:4864:20::533] (port=47097 helo=mail-pg1-x533.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mzPqn-0005uk-II for qemu-devel@nongnu.org; Mon, 20 Dec 2021 16:05:42 -0500 Received: by mail-pg1-x533.google.com with SMTP id r138so10410388pgr.13 for ; Mon, 20 Dec 2021 13:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RWV9WOum/EgcRXAB9OWJGs5V6nSAWvrKYW5XslI2s0c=; b=ui6yCzwN5+lWeKDq3KNqxVURrgLoGvbrfAVYzpANY67V2pCQJkh+BzI7cvcMUtmplR q2KQ+8iK6ksxk6BrxIm8czevnqGvKijaJP1vtfSGyK+342JVP4OMtuogE+tq2REiosNV UmZrm2qJq03u6f4heHCeVclttwPQEB29JBJkUwtdA4dVA+RZzZ1yD8j1HCyIa2h+kX1i sH25DRvtRm/GweaiC3hXaZ1aSWE7qlSKvexHQcOq3ub3XMXIbSiB3n47uwTdzINffQDb X9x97eBS+uMUs1z72nn+fsU1mwzi0gyIvFjfB/z1Gtr7x0bmY7c68geupxKYwFM3+2Nc HJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RWV9WOum/EgcRXAB9OWJGs5V6nSAWvrKYW5XslI2s0c=; b=DPNfaqwILmg0fxlHamKmzwU0NugIit1KZ2DYfEwvUTWZ3C3kq2vs70jWuUbl9Qb0ZQ o66C80kjIaVqX8NnTwmJN11z/YHcGRRS1A9+XVc+uedId7gFBqhBik0jxjP+U9TjEmi+ d6oX7La3d68umMLmmMVvc3IP2DUhiR3jn97/WucqLRcst3GqPPhSsuDu81ULKNdT+AsZ DIp39co0C6ogMDFv30h7SiLkuQo5dankoKadCH7co9v6OugM7TO8G/dMMbvJdRVo6CZ7 TpmxxoQ58CYm5m5AHJeJY1tOXTb/m0y/V5XGQyRVnWU8orUAuX7lmDMubResev9g+b4I Hn9w== X-Gm-Message-State: AOAM530ONxIzln/l617uhM5LksbFobX74ruSPvIx9FAkeYzIeKfz7U+b FO+8LZUHbwP4yUcS91yS4WUyfdJAysmy2Q== X-Received: by 2002:a05:6a00:228b:b0:4bb:1111:65cb with SMTP id f11-20020a056a00228b00b004bb111165cbmr533780pfe.56.1640034340308; Mon, 20 Dec 2021 13:05:40 -0800 (PST) Received: from localhost.localdomain ([156.19.246.20]) by smtp.gmail.com with ESMTPSA id d13sm20091021pfu.213.2021.12.20.13.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 13:05:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 12/24] linux-user/microblaze: Use force_sig_fault Date: Mon, 20 Dec 2021 13:05:16 -0800 Message-Id: <20211220210529.150423-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211220210529.150423-1-richard.henderson@linaro.org> References: <20211220210529.150423-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::533 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Fill in the missing PC for SIGTRAP. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/microblaze/cpu_loop.c | 61 +++++++++++++------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c index a94467dd2d..263b68aea1 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -27,9 +27,8 @@ void cpu_loop(CPUMBState *env) { CPUState *cs = env_cpu(env); - int trapnr, ret; - target_siginfo_t info; - + int trapnr, ret, si_code; + while (1) { cpu_exec_start(cs); trapnr = cpu_exec(cs); @@ -38,8 +37,8 @@ void cpu_loop(CPUMBState *env) switch (trapnr) { case EXCP_INTERRUPT: - /* just indicate that signals should be handled asap */ - break; + /* just indicate that signals should be handled asap */ + break; case EXCP_SYSCALL: /* Return address is 4 bytes after the call. */ env->regs[14] += 4; @@ -67,6 +66,7 @@ void cpu_loop(CPUMBState *env) */ env->regs[14] = env->pc; break; + case EXCP_HW_EXCP: env->regs[17] = env->pc + 4; if (env->iflags & D_FLAG) { @@ -74,42 +74,31 @@ void cpu_loop(CPUMBState *env) env->pc -= 4; /* FIXME: if branch was immed, replay the imm as well. */ } - env->iflags &= ~(IMM_FLAG | D_FLAG); - switch (env->esr & 31) { - case ESR_EC_DIVZERO: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_FLTDIV; - info._sifields._sigfault._addr = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - case ESR_EC_FPU: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - if (env->fsr & FSR_IO) { - info.si_code = TARGET_FPE_FLTINV; - } - if (env->fsr & FSR_DZ) { - info.si_code = TARGET_FPE_FLTDIV; - } - info._sifields._sigfault._addr = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - default: - fprintf(stderr, "Unhandled hw-exception: 0x%x\n", - env->esr & ESR_EC_MASK); - cpu_dump_state(cs, stderr, 0); - exit(EXIT_FAILURE); - break; + case ESR_EC_DIVZERO: + si_code = TARGET_FPE_FLTDIV; + break; + case ESR_EC_FPU: + si_code = 0; + if (env->fsr & FSR_IO) { + si_code = TARGET_FPE_FLTINV; + } + if (env->fsr & FSR_DZ) { + si_code = TARGET_FPE_FLTDIV; + } + break; + default: + fprintf(stderr, "Unhandled hw-exception: 0x%x\n", + env->esr & ESR_EC_MASK); + cpu_dump_state(cs, stderr, 0); + exit(EXIT_FAILURE); } + force_sig_fault(TARGET_SIGFPE, si_code, env->pc); break; + case EXCP_DEBUG: - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs);