From patchwork Fri Oct 1 17:11:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515089 Delivered-To: patch@linaro.org Received: by 2002:a02:606e:0:0:0:0:0 with SMTP id d46csp1021049jaf; Fri, 1 Oct 2021 10:43:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX2hLNTxAp60vlEzxmkcNK6cBfxuqstpJV3jvscj5SbsLHRbgmAdk+wIo0tDCxlVy+RNZP X-Received: by 2002:a05:6214:1342:: with SMTP id b2mr11919235qvw.16.1633110208891; Fri, 01 Oct 2021 10:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633110208; cv=none; d=google.com; s=arc-20160816; b=NIMgYryX33tugC8JgJ4pJs9JTCcOeY+KZjsXeKo/GsV43cRFz7S45Q1AmvXfiosoQH YkOnPKA+20we1cQmZMseuBHVpdvOjFHboGjEltq6I5zzYKuytf591e2NUxHUwtkp3/xs iK25bOT2DNbRqr12nOVbYCW6fW6YWxbclcPB/JzTFp0ptBIMDEI5bpm1ghybhVqr490r N1HKSo8r8FnjBw9+lLleyt2FXbO6ROh+nria/1jS5faiRJH4U990tPUs6VfmCpkV6rRy mP9pXauKERGobBM5Q3hYIIFr9F5R8PocTIyEVaNbDfJl3FwkMOTmZYcfx/N9VGzV7wSS /s6g== 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=h+WX/Xz3j7uTzh8f9NwZfFO9w7icTNNLSs9RiVXjf3k=; b=QOnDSsiaOykRygE4ABR5Z9VpuZYkxDqf0/BuT5gi8fSbc03BiTU3ZnP/pfMC9IrDgu xumgeouEIMGDUJQ8yq1EhPCpY4s6TmhseqY+cjtgJG6mnMBgo79SrbwyiuKIDZfj7DW6 Z295MIIfyJ4V+eGh8ANvocJIFfOda/eTAPZ+soXfncTxtbObY8L83CEswUh51AD7fD8T Cd6/xthJJ2AGahIUqq0lZ2wz8eQvyEaNdx3k8rrjHF1bRAEjKUsRTS/MxSyEsdGG9Sbl N/oVVm4NIQZAw3dfsGNYw7QJvm2UEsabOQUXQApj82UbXQH6ko/gmwefkG0OMpvBdYeP ntaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mCrnYTJn; 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 s15si5388947qtc.399.2021.10.01.10.43.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Oct 2021 10:43:28 -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; dkim=fail header.i=@linaro.org header.s=google header.b=mCrnYTJn; 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]:33968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWMZE-0001og-9X for patch@linaro.org; Fri, 01 Oct 2021 13:43:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWM5E-0005C8-1H for qemu-devel@nongnu.org; Fri, 01 Oct 2021 13:12:29 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:34808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWM5A-0005If-CK for qemu-devel@nongnu.org; Fri, 01 Oct 2021 13:12:27 -0400 Received: by mail-qt1-x835.google.com with SMTP id m26so9646193qtn.1 for ; Fri, 01 Oct 2021 10:12:23 -0700 (PDT) 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=h+WX/Xz3j7uTzh8f9NwZfFO9w7icTNNLSs9RiVXjf3k=; b=mCrnYTJnJbIbGzuxs5qDnO0t4J7n5Fu+Qhpm2DHKICihgqmI6wflxWRy8RtkQg40eY E5ZC8hEIUbbTCfnCh3aujUhfw5Vgf9gBybenKAwTc2H2C3Nm2FpodLkkPme+C/55yPUF PmIwSX0OI6w2W5H58XRYRnQ/sixHb28XQnAd2NgX0Bm+yf0AC3yLmjpMN3dl9R23NHom u28E+AGfGnJFeJsOYOuLnLDV3YTk1ZImviLjptMKDoJF2+RJfCSFA/WCAU6wK3armwYU WLa7tAQf+RZAJqH+DNOTAizAyV9NPhYQqn42Ap1usXn+c66PZDNkgB6cjzqZU8gHogAs hwnA== 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=h+WX/Xz3j7uTzh8f9NwZfFO9w7icTNNLSs9RiVXjf3k=; b=tQlTs4Lv1O3eiRf7pUHizf3h/Z8Gk2qt8BS4pti9C4qfHRwA87xSbvSsDP+XJVJ4fL /5Bgy4eiXwL595k2f0pQVLGLQyp0i/UmEEpoRe3UUY20GDEF2F3se1nvOXMCsmA48eO8 gBOSd04Wq6GCSn4TNTE9JR71n38Hx58SuwStDW26f3bC5pd5nBnOQuygmKUzFTSNhsYQ yPvKnXN0sMzTqnVKJ/ckJeUVTsZs5IQMCinbI9EySj+3An0rAgx35ng2Km1tp5yhoTns 4S2FQ3FnMcWNLbBivHdkhtCI+MM8R+l0/DuuFjlg+1htuNXgkQ9yPqbvEVg8z9Pa5jp8 Yz+A== X-Gm-Message-State: AOAM532/W/1e2lqgk/O/rc9Uhfa8YCSyGX9viIaXPGQWMT12LEyYyZsk FuiIoT7zS0Zca5wtT+ya0xVqOt6wLcUobA== X-Received: by 2002:ac8:7143:: with SMTP id h3mr14627375qtp.242.1633108343053; Fri, 01 Oct 2021 10:12:23 -0700 (PDT) Received: from localhost.localdomain (c-67-174-166-185.hsd1.ga.comcast.net. [67.174.166.185]) by smtp.gmail.com with ESMTPSA id y15sm3557250qko.78.2021.10.01.10.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 10:12:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 34/41] target/ppc: Implement ppc_cpu_record_sigsegv Date: Fri, 1 Oct 2021 13:11:44 -0400 Message-Id: <20211001171151.1739472-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211001171151.1739472-1-richard.henderson@linaro.org> References: <20211001171151.1739472-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x835.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-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: qemu-ppc@nongnu.org, alex.bennee@linaro.org, laurent@vivier.eu, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Record DAR, DSISR, and exception_index. That last means that we must exit to cpu_loop ourselves, instead of letting exception_index being overwritten. This is exactly what the user-mode ppc_cpu_tlb_fill does, so simply rename it as ppc_cpu_record_sigsegv. Cc: qemu-ppc@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 3 --- target/ppc/internal.h | 9 +++++++++ target/ppc/cpu_init.c | 6 ++++-- target/ppc/user_only_helper.c | 15 +++++++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) -- 2.25.1 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 01d3773bc7..60d1117845 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1278,9 +1278,6 @@ extern const VMStateDescription vmstate_ppc_cpu; /*****************************************************************************/ void ppc_translate_init(void); -bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); #if !defined(CONFIG_USER_ONLY) void ppc_store_sdr1(CPUPPCState *env, target_ulong value); diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 55284369f5..339974b7d8 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -283,5 +283,14 @@ static inline void pte_invalidate(target_ulong *pte0) #define PTE_PTEM_MASK 0x7FFFFFBF #define PTE_CHECK_MASK (TARGET_PAGE_MASK | 0x7B) +#ifdef CONFIG_USER_ONLY +void ppc_cpu_record_sigsegv(CPUState *cs, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); +#else +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); +#endif #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 6aad01d1d3..ec8da08f0b 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -9014,9 +9014,11 @@ static const struct SysemuCPUOps ppc_sysemu_ops = { static const struct TCGCPUOps ppc_tcg_ops = { .initialize = ppc_translate_init, - .tlb_fill = ppc_cpu_tlb_fill, -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + .record_sigsegv = ppc_cpu_record_sigsegv, +#else + .tlb_fill = ppc_cpu_tlb_fill, .cpu_exec_interrupt = ppc_cpu_exec_interrupt, .do_interrupt = ppc_cpu_do_interrupt, .cpu_exec_enter = ppc_cpu_exec_enter, diff --git a/target/ppc/user_only_helper.c b/target/ppc/user_only_helper.c index aa3f867596..7ff76f7a06 100644 --- a/target/ppc/user_only_helper.c +++ b/target/ppc/user_only_helper.c @@ -21,16 +21,23 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "internal.h" - -bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +void ppc_cpu_record_sigsegv(CPUState *cs, vaddr address, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; int exception, error_code; + /* + * Both DSISR and the "trap number" (exception vector offset, + * looked up from exception_index) are present in the linux-user + * signal frame. + * FIXME: we don't actually populate the trap number properly. + * It would be easiest to fill in an env->trap value now. + */ if (access_type == MMU_INST_FETCH) { exception = POWERPC_EXCP_ISI; error_code = 0x40000000;