From patchwork Fri Jan 7 21:32:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 530501 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp720667imp; Fri, 7 Jan 2022 13:42:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWpCc6iww+PgU5Tli12tY5sim1XL9PfFUStkDNpAzd+IJNptCCsMma2okJ5ejRHDqulJw0 X-Received: by 2002:a05:6902:1243:: with SMTP id t3mr45996284ybu.49.1641591739660; Fri, 07 Jan 2022 13:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641591739; cv=none; d=google.com; s=arc-20160816; b=H2g7AHitPNP5VzNteGpEtC8lcKEvs3bcr/Dh1wTWVsCyaZ9EsXtO+VVs/0SxtpGAte keq0IKgHsuRERsGy9u2TK9cBYILLLH7SYNz3Tev6iB0UBc9AttIZfwhiYPUxoBOvLmoC 9uC1RrndAMi82Keovz54s83TdSQFNPWvelpcHFqtD5KwNTsv6E2dwhLKy/ZLyJxFQU7+ 7UVpZQrZLZmdGD8RIxikr2516Lgn4GXoUQhKBZW+lKozcDbfJ7fJ86JcQauVbuxc3osu yqC6WW5kzVMEe3nhXoSIT4d+Ufo5yJflu11cCzMJMxJSMZ/FHuf6EDkeYms4oNrvzMmY JX7w== 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=VQuAVj83D8N41Enr2c/2Fh+V+6HnjoMfetVUSJ6+wqw=; b=tQuQ201hPCQv/N5tq1Nm6NBkfu7btnM/YjlQqILqcRn5J5FW57H36N1053iUoDV2D2 V23qWux3UqzwAf8Wz34sE/rO9Bc8YKx1Ju6B+QbgFJM6SNp9g4j0nTwcTV4WpH0Swvzq NOfBSTudFzywd5d6b9o6agIOFZO1xGt3+n+sWPtvkLlxfJ04wXEa+W9/197+u0F1dhmN f8MyC4ArsFanR3NhAygIHUizY8BMWKpQSTPOB6cgTxP5HlCuD3LkKXDJeDcS/nFVXdyS R27qjuH5MGJPZbzHVOk4BiUb1OHPxI0mc9RmG+/bFxWEuYdVI3xXERsOcak836I24eX7 N93g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=HrZz7Lhm; 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 y3si4702818ybk.214.2022.01.07.13.42.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jan 2022 13:42:19 -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=HrZz7Lhm; 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]:55836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5x06-0000zO-Fb for patch@linaro.org; Fri, 07 Jan 2022 16:42:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5wr1-00059p-C8 for qemu-devel@nongnu.org; Fri, 07 Jan 2022 16:32:55 -0500 Received: from [2607:f8b0:4864:20::42b] (port=37565 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n5wqy-0007pJ-Qe for qemu-devel@nongnu.org; Fri, 07 Jan 2022 16:32:54 -0500 Received: by mail-pf1-x42b.google.com with SMTP id p37so6184028pfh.4 for ; Fri, 07 Jan 2022 13:32:52 -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=VQuAVj83D8N41Enr2c/2Fh+V+6HnjoMfetVUSJ6+wqw=; b=HrZz7LhmSSESR/al+1nE/tCJwsc5gH56GywVZ3Ctzog8Djx90F6nsM/cHEYfZMtNjs xJCz4LkrA749DGBQCcgmSNg93ll6YaORATCDla1RYNaf3lONByL6zpoID59gpxNI6oMV Km8KJLiyUcmJ7ZOKU9enthRQETbmI3t8w6UqC4W1sbaSW9nY1HKjh3OTziZH+UzNhuDa EDbCp0r8F0s8+VyrO4+/x/eEFHWviA4yTiJrFctx2gLwOVUKZQXHHfCuKeUFfgV1nmBa WEEuVBaMd+VL1M6UBDalTOOfMGC6AV9QWyPEOlRYzhm+Rzja7Dzcjv6axuHtwSAb68kx c98w== 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=VQuAVj83D8N41Enr2c/2Fh+V+6HnjoMfetVUSJ6+wqw=; b=jDKJCQTio8xLecnKLs47PkjBcBRya1fJjnl6s6eiPYkmvdRKI0DgM0iX42BxL0pNZI aEmHjCVYfnI4zvYa1jjxcXlgpTzmXEWeNrY+PXPms9XPJmrh2dfp4ADnn7TKVswWVyhQ Ib7NNH/FZiDKba1WxyorVD8gTOmAZc8xa0T4SzBX7nPKSgE8dDlDgakp8+aJzx9flknf zboQRI0kmc1PDl/WXVXdDMqlBl62NgLykS4y2O0nQMMqtK8+Q5kGDTX5gDbivpaOm2HY QzD9dYlh99PJWnIGPU5Wm6fLJTuuERwA4+pmlKx/ftfPQHF7eaa1zwPhpWLx6uPrscgV yjvQ== X-Gm-Message-State: AOAM532KAPQAqC2wUS/VA+6VdSite8kRBxHyWVsuIZ/9SagOm3um/HTp Fn7cofe0F5GyzjyVU9t6LG40e9agYXszHA== X-Received: by 2002:a63:87c3:: with SMTP id i186mr57808222pge.507.1641591171616; Fri, 07 Jan 2022 13:32:51 -0800 (PST) Received: from localhost.localdomain (174-21-75-75.tukw.qwest.net. [174.21.75.75]) by smtp.gmail.com with ESMTPSA id y11sm6633030pfi.80.2022.01.07.13.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 13:32:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 12/24] linux-user/microblaze: Use force_sig_fault Date: Fri, 7 Jan 2022 13:32:31 -0800 Message-Id: <20220107213243.212806-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220107213243.212806-1-richard.henderson@linaro.org> References: <20220107213243.212806-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42b (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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 ff1fb26c8b..08620d4e68 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);