From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851505279477.10483808210347; Tue, 2 Nov 2021 04:11:45 -0700 (PDT) Received: from localhost ([::1]:54382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrhg-0001VZ-2D for importer@patchew.org; Tue, 02 Nov 2021 07:11:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdp-0003Zy-Fs for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:45 -0400 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]:40653) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdn-0000r1-32 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:45 -0400 Received: by mail-qv1-xf2c.google.com with SMTP id b11so9632152qvm.7 for ; Tue, 02 Nov 2021 04:07:42 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:41 -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=IKLMeO+3mWomlul9GD0bgra/twuVZxh+Vxqn0acqDpE=; b=fdxqpc5SsTQqvN2m0uzkLW3aQ8kneUC7Qy2HbZre6aPCr0TiLcgPespn9CitWKh5id kALWIB5NoUze4eBVbC66CaC1UI6xECSSaYIlKPl8OG1zCEnBV3j6Aa++cfH6CNb4uRI2 9YZ5H5ttByc8c8E51xkzOPRX0RA9eigl9533q9HRpioAPvNQ8XG9hJ04v3piHvsHaG9z YSokPctQn4GGBNP4q6jgyBWKwFP5dk0n4Fms3QyKo0tvborV4GrGXXbTblVQ1f6SCDBk nOF8A0ddIt2LcVuYktvhT3tiNZdVAcMR2kxHCVwdFQJMwHUPl3mZR9J337i8nGR8Fbq3 dDUA== 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=IKLMeO+3mWomlul9GD0bgra/twuVZxh+Vxqn0acqDpE=; b=bYSjfOlcKFCrWTaQhgHmdw9fGtle0KZt11s6fVBtX3ZG5EI5K4L3tgECkRNYeZRNUy ubdjQFBjROgip0OfYNzq8LGOYcJvZ91jWKLP9G+IwX+rr3lNmJ4JkLEch3eCbRc5Sjwu NsVOWxagAVVb0VkWJcu+CJX9Ba7UC9C5eI367F43jtd2M7ReRponEdPVO1G8vqePa3mm brBIocFCB8ZDt/UC6QJXEQpRGRgds4g8H/WMp7E0e47HHLhn+IMZd6xIe36SkzIc6FCR dHywfT7Je8zGDvVABqT4LzxH+K07kzCrZznz5fRLVed2PlO9kodPnTd6lXzVebstY2cw suWg== X-Gm-Message-State: AOAM530E5DhOkE+i4xOqyW4R4KF+2rAXpM65s/KLq1PiVzdqisqLqnk0 nXi+S4AGbUGK/tx9S0xH1XfQXe3hmmwWGQ== X-Google-Smtp-Source: ABdhPJzmLiXLZxRR3OXreqaLzDspxiFwvx8UQWKoNLiwymWkgE4HaeZw9kJT/XFPJdOXqhMF6Oq4Sw== X-Received: by 2002:a05:6214:400e:: with SMTP id kd14mr12582204qvb.66.1635851261924; Tue, 02 Nov 2021 04:07:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/60] accel/tcg: Split out adjust_signal_pc Date: Tue, 2 Nov 2021 07:06:41 -0400 Message-Id: <20211102110740.215699-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635851505967100001 Split out a function to adjust the raw signal pc into a value that could be passed to cpu_restore_state. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- v2: Adjust pc in place; return MMUAccessType. --- include/exec/exec-all.h | 10 ++++++++++ accel/tcg/user-exec.c | 41 +++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 9d5987ba04..e54f8e5d65 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -663,6 +663,16 @@ static inline tb_page_addr_t get_page_addr_code_hostp(= CPUArchState *env, return addr; } =20 +/** + * adjust_signal_pc: + * @pc: raw pc from the host signal ucontext_t. + * @is_write: host memory operation was write, or read-modify-write. + * + * Alter @pc as required for unwinding. Return the type of the + * guest memory access -- host reads may be for guest execution. + */ +MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); + /** * cpu_signal_handler * @signum: host signal number diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index e6bb29b42d..c02d509ec6 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -57,18 +57,11 @@ static void QEMU_NORETURN cpu_exit_tb_from_sighandler(C= PUState *cpu, cpu_loop_exit_noexc(cpu); } =20 -/* 'pc' is the host PC at which the exception was raised. 'address' is - the effective address of the memory exception. 'is_write' is 1 if a - write caused the exception and otherwise 0'. 'old_set' is the - signal set which should be restored */ -static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, - int is_write, sigset_t *old_set) +/* + * Adjust the pc to pass to cpu_restore_state; return the memop type. + */ +MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write) { - CPUState *cpu =3D current_cpu; - CPUClass *cc; - unsigned long address =3D (unsigned long)info->si_addr; - MMUAccessType access_type =3D is_write ? MMU_DATA_STORE : MMU_DATA_LOA= D; - switch (helper_retaddr) { default: /* @@ -77,7 +70,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo= _t *info, * pointer into the generated code that will unwind to the * correct guest pc. */ - pc =3D helper_retaddr; + *pc =3D helper_retaddr; break; =20 case 0: @@ -97,7 +90,7 @@ static inline int handle_cpu_signal(uintptr_t pc, siginfo= _t *info, * Therefore, adjust to compensate for what will be done later * by cpu_restore_state_from_tb. */ - pc +=3D GETPC_ADJ; + *pc +=3D GETPC_ADJ; break; =20 case 1: @@ -113,12 +106,28 @@ static inline int handle_cpu_signal(uintptr_t pc, sig= info_t *info, * * Like tb_gen_code, release the memory lock before cpu_loop_exit. */ - pc =3D 0; - access_type =3D MMU_INST_FETCH; mmap_unlock(); - break; + *pc =3D 0; + return MMU_INST_FETCH; } =20 + return is_write ? MMU_DATA_STORE : MMU_DATA_LOAD; +} + +/* + * 'pc' is the host PC at which the exception was raised. + * 'address' is the effective address of the memory exception. + * 'is_write' is 1 if a write caused the exception and otherwise 0. + * 'old_set' is the signal set which should be restored. + */ +static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, + int is_write, sigset_t *old_set) +{ + CPUState *cpu =3D current_cpu; + CPUClass *cc; + unsigned long address =3D (unsigned long)info->si_addr; + MMUAccessType access_type =3D adjust_signal_pc(&pc, is_write); + /* For synchronous signals we expect to be coming from the vCPU * thread (so current_cpu should be valid) and either from running * code or during translation which can fault as we cross pages. --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635851706; cv=none; d=zohomail.com; s=zohoarc; b=dkPcFmS6VkFcd+0Ksm3pATx5ZZj7omnuLZJNGFr5aNX9CLjsSQ4YBABXR7TtDSnDXGmGgPYpjFoK7jBo+jVu3FClNd3rsw5qHPg7AufnZI08fKcUqLQOOR6I+NtbCfq7WL8KFTpEU2GeZrIi1axkqK1yHxDEMmRRPcQgwfKuZCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635851706; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xXlHj7GOOQFwxbMfswRsUIWuGeJ1kP2ehgRt9eaYqEQ=; b=kAY79JUpSbtPWhs36dcBX6tprw0XowyrgfKxjHWiyo23lKmtyraQ9t1w/2JPPAs3pG2kQ8qV8jF6nDYgeJsEeiG0KakOaXtI1+59gILo4H7R96OMnH0yzaJUYY8tEOjiOLXF3IV/sdmTjd+Cpbb3TvfK4A1zl2j+uPV6Bbk2fMU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851706746731.345738756901; Tue, 2 Nov 2021 04:15:06 -0700 (PDT) Received: from localhost ([::1]:34626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrkv-0007Fx-Ma for importer@patchew.org; Tue, 02 Nov 2021 07:15:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdq-0003cT-EQ for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:37851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdn-0000r4-JD for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: by mail-qt1-x830.google.com with SMTP id o12so7699372qtv.4 for ; Tue, 02 Nov 2021 04:07:43 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:42 -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=xXlHj7GOOQFwxbMfswRsUIWuGeJ1kP2ehgRt9eaYqEQ=; b=Zwak4UEpGoYhHgJS7JDogOfAPDX/1uZJPB2zXNpLBV0sOZlwZxntcLrZylOK5Dqtcn fTxuoKDq1bEQTPc5O9aLAW4Dax6io5DwGHFLA28dGnWEvn90CueEtrQXBJtEm6cuIzgK AN6akTQCE/QsDHkPx2cAhk+0sMf/Vg2+yavPSwSAFOE2nbGSxTEpDCntZKzcgzQ/z/vQ OcvR3egHagFDrIa7WHwJx2TY2ZBJzHOo/qeVXyGRPM3Aunuee6yJEBeRbpT58TxhinFN 5bC9nb/My+8fd6qG0w8XGCdXNgcSwsSF5rXGFRvrGbsZW45fcOxj9kfj7A5uef/ygav2 yHgg== 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=xXlHj7GOOQFwxbMfswRsUIWuGeJ1kP2ehgRt9eaYqEQ=; b=rY4RDsLaoJ7rBKlKIMZSVn+vI6fSVjMj+aiG8q1sXXF1qO1sSBZkpjbC1mh9lkp2GE wxlp9T+T2s4k2D5GbSsLNkFRZ1wWtzQXglFHf9/Sp7PStkGtgHKvahN6A2VCJeC5fEtd HSl+eDg6GnUII/pg3Z9BqO6ENk+C9owQdyYSplOgCwusXwpoXlmHUXhGwvC5NglxWNVa eT4n3l46LmPrUezGilyVT12t2rCcBIsKKOQl2lwKGKuLZAnN2IHjJBg1MYILbvUHCIlG TqRdMOagbGb/QKPIkUdB0r/gYw6dLVwN2pybfVXITT+aKLedplGrIUg2MZ2+u6wwtVM+ gtJA== X-Gm-Message-State: AOAM5303WnUGnb1chaS4Ws4mAQJO8iZGDplogaB45ws1B+ac9R1dbIef xN35vkMEg99K1cCoun09fEXuzr4bKpMtEA== X-Google-Smtp-Source: ABdhPJy9TXmX3l55LtDILzutQK4YZWZsFeCq0HW3gr5KsMUJDHf7DLuVVUgzFY999JT5gp2HwDScSg== X-Received: by 2002:ac8:5f51:: with SMTP id y17mr325652qta.154.1635851262482; Tue, 02 Nov 2021 04:07:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/60] accel/tcg: Move clear_helper_retaddr to cpu loop Date: Tue, 2 Nov 2021 07:06:42 -0400 Message-Id: <20211102110740.215699-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635851707927100002 Content-Type: text/plain; charset="utf-8" Currently there are only two places that require we reset this value before exiting to the main loop, but that will change. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 3 ++- accel/tcg/user-exec.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index c9764c1325..bba4672632 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -462,6 +462,7 @@ void cpu_exec_step_atomic(CPUState *cpu) * memory. */ #ifndef CONFIG_SOFTMMU + clear_helper_retaddr(); tcg_debug_assert(!have_mmap_lock()); #endif if (qemu_mutex_iothread_locked()) { @@ -471,7 +472,6 @@ void cpu_exec_step_atomic(CPUState *cpu) qemu_plugin_disable_mem_helpers(cpu); } =20 - /* * As we start the exclusive region before codegen we must still * be in the region if we longjump out of either the codegen or @@ -916,6 +916,7 @@ int cpu_exec(CPUState *cpu) #endif =20 #ifndef CONFIG_SOFTMMU + clear_helper_retaddr(); tcg_debug_assert(!have_mmap_lock()); #endif if (qemu_mutex_iothread_locked()) { diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index c02d509ec6..3f3e793b7b 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -175,7 +175,6 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, * currently executing TB was modified and must be exited * immediately. Clear helper_retaddr for next execution. */ - clear_helper_retaddr(); cpu_exit_tb_from_sighandler(cpu, old_set); /* NORETURN */ =20 @@ -193,7 +192,6 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, * an exception. Undo signal and retaddr state prior to longjmp. */ sigprocmask(SIG_SETMASK, old_set, NULL); - clear_helper_retaddr(); =20 cc =3D CPU_GET_CLASS(cpu); cc->tcg_ops->tlb_fill(cpu, address, 0, access_type, --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852067594143.1456637640331; Tue, 2 Nov 2021 04:21:07 -0700 (PDT) Received: from localhost ([::1]:50278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrqk-00012Q-85 for importer@patchew.org; Tue, 02 Nov 2021 07:21:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdq-0003eJ-Ta for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:35365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdo-0000rB-0S for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: by mail-qt1-x835.google.com with SMTP id n2so18482462qta.2 for ; Tue, 02 Nov 2021 04:07:43 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:42 -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=shTlPwSm/VaKjDDgx3jqfEVE3VVxFJ7ui9L4q5qHESI=; b=rrOPzkRAbEbIhstLJhHVEz1EefNEBeszVBUyML71IR03hKlYFfVh5eNxo8qlgylg30 Q3gzRiBss58E5iENjaX1ryIln/e5xHC0MZ3kKDRH/Iu4lYUwn49n/CKda+BMY+sNkQ/Z eTX1vquUt0x7qLhymX6MDacizi8S1rJssJLoDfNYKoYxf66caQuE5wIIVUvEKieLfKAd bAdVA+A3JfT07BidvIn5RT9LQmxgMbJlWLP3UfHxM8VnnsH+RkoEwkaSVTec13t8eChp L/zH8j4JysdJHoIrNuJj1zyD0wWm1OuV+0apTESzagmTFEgSySlL57gybmlVqOkMCcmM Q8vQ== 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=shTlPwSm/VaKjDDgx3jqfEVE3VVxFJ7ui9L4q5qHESI=; b=KtmDo8y9OVlJdezSNECOHxJIxWEvPwlipp8YZ3VSlZsn0bSK5VMFPQOeDKr4Nw9Vz8 dYQaPKosBcY9XkYR7vVHe2ma6mxEfzuQZUdnPJ94WEYRTX1uRwcMsYYTXHRg0PXiE3m6 FsE0daxnmEzKCLiRuStLNj7Rx+zGPXUBQ7XyTidoE9N+TR+vu8cAJvJqiHE8+erXFaiK af6XMn8oBt7p588WQU/w6kPRM5cie/YfRPtTQ9dOIGjvoTBy0+vEnxAnIo6T0MVv3qhM sT0oUv9s7S4nOPJsFCyPzU5wUFXTM26HtkDuC4zIOEDxFUNmTHCQdYctMPiMnKsa4Ret hv4Q== X-Gm-Message-State: AOAM531kxs0I1LLpA4bdnBlQ2+BXy4HmIlsRqmOysMptXvvL+JUMT/Gg frkzofMwWnz6RPLh9rFAUS3/OfWtcr3bCA== X-Google-Smtp-Source: ABdhPJxUpr1MrDfYIK7ceilQY28s7ruTZAgqwye79D5wSMtATu8Y1XXtiu6Ed35XthjX0Q/JfUAomA== X-Received: by 2002:ac8:7f84:: with SMTP id z4mr20917416qtj.81.1635851263048; Tue, 02 Nov 2021 04:07:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/60] accel/tcg: Split out handle_sigsegv_accerr_write Date: Tue, 2 Nov 2021 07:06:43 -0400 Message-Id: <20211102110740.215699-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852068528100001 This is the major portion of handle_cpu_signal which is specific to tcg, handling the page protections for the translations. Most of the rest will migrate to linux-user/ shortly. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- v2: Pass guest address to handle_sigsegv_accerr_write. --- include/exec/exec-all.h | 12 +++++ accel/tcg/user-exec.c | 101 ++++++++++++++++++++++++---------------- 2 files changed, 72 insertions(+), 41 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e54f8e5d65..5f94d799aa 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -673,6 +673,18 @@ static inline tb_page_addr_t get_page_addr_code_hostp(= CPUArchState *env, */ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); =20 +/** + * handle_sigsegv_accerr_write: + * @cpu: the cpu context + * @old_set: the sigset_t from the signal ucontext_t + * @host_pc: the host pc, adjusted for the signal + * @host_addr: the host address of the fault + * + * Return true if the write fault has been handled, and should be re-tried. + */ +bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, + uintptr_t host_pc, abi_ptr guest_addr); + /** * cpu_signal_handler * @signum: host signal number diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 3f3e793b7b..b83f8d12f4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -114,6 +114,52 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_= write) return is_write ? MMU_DATA_STORE : MMU_DATA_LOAD; } =20 +/** + * handle_sigsegv_accerr_write: + * @cpu: the cpu context + * @old_set: the sigset_t from the signal ucontext_t + * @host_pc: the host pc, adjusted for the signal + * @guest_addr: the guest address of the fault + * + * Return true if the write fault has been handled, and should be re-tried. + * + * Note that it is important that we don't call page_unprotect() unless + * this is really a "write to nonwriteable page" fault, because + * page_unprotect() assumes that if it is called for an access to + * a page that's writeable this means we had two threads racing and + * another thread got there first and already made the page writeable; + * so we will retry the access. If we were to call page_unprotect() + * for some other kind of fault that should really be passed to the + * guest, we'd end up in an infinite loop of retrying the faulting access. + */ +bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, + uintptr_t host_pc, abi_ptr guest_addr) +{ + switch (page_unprotect(guest_addr, host_pc)) { + case 0: + /* + * Fault not caused by a page marked unwritable to protect + * cached translations, must be the guest binary's problem. + */ + return false; + case 1: + /* + * Fault caused by protection of cached translation; TBs + * invalidated, so resume execution. + */ + return true; + case 2: + /* + * Fault caused by protection of cached translation, and the + * currently executing TB was modified and must be exited immediat= ely. + */ + cpu_exit_tb_from_sighandler(cpu, old_set); + /* NORETURN */ + default: + g_assert_not_reached(); + } +} + /* * 'pc' is the host PC at which the exception was raised. * 'address' is the effective address of the memory exception. @@ -125,8 +171,9 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, { CPUState *cpu =3D current_cpu; CPUClass *cc; - unsigned long address =3D (unsigned long)info->si_addr; + unsigned long host_addr =3D (unsigned long)info->si_addr; MMUAccessType access_type =3D adjust_signal_pc(&pc, is_write); + abi_ptr guest_addr; =20 /* For synchronous signals we expect to be coming from the vCPU * thread (so current_cpu should be valid) and either from running @@ -143,49 +190,21 @@ static inline int handle_cpu_signal(uintptr_t pc, sig= info_t *info, =20 #if defined(DEBUG_SIGNAL) printf("qemu: SIGSEGV pc=3D0x%08lx address=3D%08lx w=3D%d oldset=3D0x%= 08lx\n", - pc, address, is_write, *(unsigned long *)old_set); + pc, host_addr, is_write, *(unsigned long *)old_set); #endif - /* XXX: locking issue */ - /* Note that it is important that we don't call page_unprotect() unless - * this is really a "write to nonwriteable page" fault, because - * page_unprotect() assumes that if it is called for an access to - * a page that's writeable this means we had two threads racing and - * another thread got there first and already made the page writeable; - * so we will retry the access. If we were to call page_unprotect() - * for some other kind of fault that should really be passed to the - * guest, we'd end up in an infinite loop of retrying the faulting - * access. - */ - if (is_write && info->si_signo =3D=3D SIGSEGV && info->si_code =3D=3D = SEGV_ACCERR && - h2g_valid(address)) { - switch (page_unprotect(h2g(address), pc)) { - case 0: - /* Fault not caused by a page marked unwritable to protect - * cached translations, must be the guest binary's problem. - */ - break; - case 1: - /* Fault caused by protection of cached translation; TBs - * invalidated, so resume execution. Retain helper_retaddr - * for a possible second fault. - */ - return 1; - case 2: - /* Fault caused by protection of cached translation, and the - * currently executing TB was modified and must be exited - * immediately. Clear helper_retaddr for next execution. - */ - cpu_exit_tb_from_sighandler(cpu, old_set); - /* NORETURN */ - - default: - g_assert_not_reached(); - } - } =20 /* Convert forcefully to guest address space, invalid addresses are still valid segv ones */ - address =3D h2g_nocheck(address); + guest_addr =3D h2g_nocheck(host_addr); + + /* XXX: locking issue */ + if (is_write && + info->si_signo =3D=3D SIGSEGV && + info->si_code =3D=3D SEGV_ACCERR && + h2g_valid(host_addr) && + handle_sigsegv_accerr_write(cpu, old_set, pc, guest_addr)) { + return 1; + } =20 /* * There is no way the target can handle this other than raising @@ -194,7 +213,7 @@ static inline int handle_cpu_signal(uintptr_t pc, sigin= fo_t *info, sigprocmask(SIG_SETMASK, old_set, NULL); =20 cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops->tlb_fill(cpu, address, 0, access_type, + cc->tcg_ops->tlb_fill(cpu, guest_addr, 0, access_type, MMU_USER_IDX, false, pc); g_assert_not_reached(); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635851850; cv=none; d=zohomail.com; s=zohoarc; b=Q5s7qATyyJVqSa6o0N3LLDtkU2jAUKsavbpWRFf7f2AgdHsirhon4Pu7UAPrWTURermERYomyPrKGLhL8aT1uFSl5YNS5C6jPsA4ppGebmjyC3cv6rBzuKJXPmSg5OqAMHruazcOyj/TTHcG98cCxMOyg8d82yllA9SSCvzKhbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635851850; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jNnLCcJOHvXqFRNx4ivHlyFLW3vo/pqpN29drgRbLjE=; b=CKqoxElXA1IJQ4VX2UvKuF8d4aBRatmnoqPoayuJtGWRrnJjqEUGC405Uia/RQvqa7BGt9oP67YPq/9t9PXc07SqOZoDbXwhPTO5+l25nL7U5QAYX9w+6Pt5+IzQnzmXhyGFr9TK1KSv9W4AJhDeXM59QX2mKhQZ1oJ0izs6aNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851850961815.0925322703476; Tue, 2 Nov 2021 04:17:30 -0700 (PDT) Received: from localhost ([::1]:41712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrnF-0003jP-Um for importer@patchew.org; Tue, 02 Nov 2021 07:17:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdq-0003cO-Ce for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:35366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdo-0000rF-GC for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:46 -0400 Received: by mail-qt1-x836.google.com with SMTP id n2so18482472qta.2 for ; Tue, 02 Nov 2021 04:07:44 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:43 -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=jNnLCcJOHvXqFRNx4ivHlyFLW3vo/pqpN29drgRbLjE=; b=yvYzfsniw4jwUycH+nacUZQFPP59LTxmD+vlvlqksRp4fc5zGcJycMIfSBrRBRGYBf DvpQ1o084lcDDJr+yjy+vf4LNcJyyzuRyLbsTjXjUG/k8DuLT8h5W56hFqKu9SrhMKWc KrCc7gHbJ5X5VwNJdzH5d2LFfPcu5k3uemdlUDKc7RXoopPjAWZZssefL5yBtYuTL76E 1DYwanUxxNziJbbQzhQSY+znyJ9RNjxaSEWIzoJhDpqYp+QiN30/WewjOlwsqIIpQjF8 f+umoF34ktXgcA8exYLIoUiWs99RImEALqoiakg3qjPjcnnvS9kofU5vU+oJ0qcww5sI /Flw== 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=jNnLCcJOHvXqFRNx4ivHlyFLW3vo/pqpN29drgRbLjE=; b=IcxAH2mgDBTvFqYuYP8BS3tcvOZP0H83rvUUQPvI1HKVPx8UkJW8UJ4V110WRQLkhx Xb9Wu3MiuoTiA94wJ/DOAP6w1QyCPIM4o2V+Ss7DphjQxNwx6CbQw9qUrdFCa6xBbPzj BO7Vc8QqoxG4VrQ9rNOgtJxo7uRrUNnhfGj/Z4+Fozy0KzUMcvIXE66TWSEuGUurno8q A8/TGbWrIELqwauuuhx4FedyICvleWnFCeuzNFj048e72XOp5P43bkr1IHHaGDXqQU1Q GZWn3vxILND3U/7qJJajGXNqrrKTEr+aUHAw8Tjc/ziwsvH+OldSyXnB9g5PlJAK0KWU NxSQ== X-Gm-Message-State: AOAM5316/1hHyFwdW6h4nDIoEKGDalpJK4h/5n5Gb1ht8RV+ZUGx9ZFv YTw1u9DymVoYLTNyLBeDOypRgHrVI7D3LA== X-Google-Smtp-Source: ABdhPJyK3xFxmK+VluKwFDHKQDI4LM/EwHEh3vO+tDjrF9gKh/GtHtoCeL5RiAtya9O8C9t3rpHHgw== X-Received: by 2002:a05:622a:3:: with SMTP id x3mr5103195qtw.133.1635851263624; Tue, 02 Nov 2021 04:07:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/60] accel/tcg: Fold cpu_exit_tb_from_sighandler into caller Date: Tue, 2 Nov 2021 07:06:44 -0400 Message-Id: <20211102110740.215699-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x836.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635851851394100001 Content-Type: text/plain; charset="utf-8" Remove the comment about siglongjmp. We do use sigsetjmp in the main cpu loop, but we do not save the signal mask as most exits from the cpu loop do not require them. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index b83f8d12f4..b1183aa4b3 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -46,17 +46,6 @@ __thread uintptr_t helper_retaddr; =20 //#define DEBUG_SIGNAL =20 -/* exit the current TB from a signal handler. The host registers are - restored in a state compatible with the CPU emulator - */ -static void QEMU_NORETURN cpu_exit_tb_from_sighandler(CPUState *cpu, - sigset_t *old_set) -{ - /* XXX: use siglongjmp ? */ - sigprocmask(SIG_SETMASK, old_set, NULL); - cpu_loop_exit_noexc(cpu); -} - /* * Adjust the pc to pass to cpu_restore_state; return the memop type. */ @@ -153,7 +142,8 @@ bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_= t *old_set, * Fault caused by protection of cached translation, and the * currently executing TB was modified and must be exited immediat= ely. */ - cpu_exit_tb_from_sighandler(cpu, old_set); + sigprocmask(SIG_SETMASK, old_set, NULL); + cpu_loop_exit_noexc(cpu); /* NORETURN */ default: g_assert_not_reached(); --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852313430188.11009401138529; Tue, 2 Nov 2021 04:25:13 -0700 (PDT) Received: from localhost ([::1]:33290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrui-0000LZ-Ep for importer@patchew.org; Tue, 02 Nov 2021 07:25:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0003hR-Ow for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:49 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:39471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdq-0000rT-7g for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:48 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id k29so13012856qve.6 for ; Tue, 02 Nov 2021 04:07:44 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:44 -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=dyOAbtDEe2hsdPtG2fphhVCPp8pp4Epcy5WbMT+mT+o=; b=ubnsuYS/0j6S4B/eh3xJJe+kVKMcVaVdJcMnzHcKn3mAno3LsHxaFOtAUPOTLgkYl1 szZY4WXHuWoOE4o4aKALcxSUuOv+s0Q6JWRjqR94snLA3d0QOPzJlTNv7qTTiPXK1gBe d7HG3xDLpiGNRVfb14XSPv92WALIdlQ29lZQQoBwHvMkyu1BXldonvEjPDnQ4ReBfU1Y TsY4IE46+aIyRRZTx1rr9i2BAecXtRCDj+XkDYOVG1Od4t/RqOF70DGwNXYI7/SUunMo mCapZhof3aH+I+KxSXqPZKTRXwPKZIVhV2V6xlTXxU/jvZCJEcsWNp+1jvRW4jhRhPHR PWnQ== 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=dyOAbtDEe2hsdPtG2fphhVCPp8pp4Epcy5WbMT+mT+o=; b=Er4QnjPLaKPmx0+DwKyv7ZGpuOyLPOLwbYDtZGTNJkA29iHC45z+3+gA9bsbng5KWM J2xRs4+s/olOjtg1LvGNW8PXy0coT01lNUT3NjzS9JKORoUXHo96RIQmNH8zHTvfWRJq FVlciBzDdtTj7is4DW6idrnYqdLGt0lDTJZuPxwzCucpu8YXjMwy0r+WyLA/xNjROXtK H7zz/gmRZhQxqhZu43qKa+xGYHW2RZYtuf18n74dmR2Qn8+ztQIr+Cu42i7kwiUSdGQJ 5fEfztjqfgRHTcvPOAiFlz84TdO/A2EjgSZWoscY4wwMm2cm/Eni5K+OqU4XUoiOaToS bWuw== X-Gm-Message-State: AOAM532lnfiO22FHZ4ZhRqrUMInmlzv6eeRRIJ/tmSg3qSmgcZ24PT3E vwSsldiVf7SvqTFtbvVJ3JsK5cHeVZe4vA== X-Google-Smtp-Source: ABdhPJzUXNHckFdxxtL4nBRM+gog3BqQqDNs8k25qEcB/+pdo/Ndb8I35KkUH6tTogJLpPAOXxh3yA== X-Received: by 2002:a0c:9c0f:: with SMTP id v15mr34742043qve.8.1635851264274; Tue, 02 Nov 2021 04:07:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/60] configure: Merge riscv32 and riscv64 host architectures Date: Tue, 2 Nov 2021 07:06:45 -0400 Message-Id: <20211102110740.215699-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2a; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852314884100001 The existing code for safe-syscall.inc.S will compile without change for riscv32 and riscv64. We may also drop the meson.build stanza that merges them for tcg/. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- configure | 8 ++------ meson.build | 4 +--- linux-user/host/{riscv64 =3D> riscv}/hostdep.h | 4 ++-- linux-user/host/riscv32/hostdep.h | 11 ----------- linux-user/host/{riscv64 =3D> riscv}/safe-syscall.inc.S | 0 5 files changed, 5 insertions(+), 22 deletions(-) rename linux-user/host/{riscv64 =3D> riscv}/hostdep.h (94%) delete mode 100644 linux-user/host/riscv32/hostdep.h rename linux-user/host/{riscv64 =3D> riscv}/safe-syscall.inc.S (100%) diff --git a/configure b/configure index 039467c04b..d57ad58342 100755 --- a/configure +++ b/configure @@ -570,11 +570,7 @@ elif check_define __s390__ ; then cpu=3D"s390" fi elif check_define __riscv ; then - if check_define _LP64 ; then - cpu=3D"riscv64" - else - cpu=3D"riscv32" - fi + cpu=3D"riscv" elif check_define __arm__ ; then cpu=3D"arm" elif check_define __aarch64__ ; then @@ -587,7 +583,7 @@ ARCH=3D # Normalise host CPU name and set ARCH. # Note that this case should only have supported host CPUs, not guests. case "$cpu" in - ppc|ppc64|s390x|sparc64|x32|riscv32|riscv64) + ppc|ppc64|s390x|sparc64|x32|riscv) ;; ppc64le) ARCH=3D"ppc64" diff --git a/meson.build b/meson.build index 2c5b53cbe2..90e3e85f20 100644 --- a/meson.build +++ b/meson.build @@ -55,7 +55,7 @@ have_block =3D have_system or have_tools python =3D import('python').find_installation() =20 supported_oses =3D ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', '= sunos', 'linux'] -supported_cpus =3D ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', = 'x86_64', +supported_cpus =3D ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64', 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64'] =20 cpu =3D host_machine.cpu_family() @@ -351,8 +351,6 @@ if not get_option('tcg').disabled() tcg_arch =3D 'i386' elif config_host['ARCH'] =3D=3D 'ppc64' tcg_arch =3D 'ppc' - elif config_host['ARCH'] in ['riscv32', 'riscv64'] - tcg_arch =3D 'riscv' endif add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tc= g_arch, language: ['c', 'cpp', 'objc']) diff --git a/linux-user/host/riscv64/hostdep.h b/linux-user/host/riscv/host= dep.h similarity index 94% rename from linux-user/host/riscv64/hostdep.h rename to linux-user/host/riscv/hostdep.h index 865f0fb9ff..2ba07456ae 100644 --- a/linux-user/host/riscv64/hostdep.h +++ b/linux-user/host/riscv/hostdep.h @@ -5,8 +5,8 @@ * See the COPYING file in the top-level directory. */ =20 -#ifndef RISCV64_HOSTDEP_H -#define RISCV64_HOSTDEP_H +#ifndef RISCV_HOSTDEP_H +#define RISCV_HOSTDEP_H =20 /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL diff --git a/linux-user/host/riscv32/hostdep.h b/linux-user/host/riscv32/ho= stdep.h deleted file mode 100644 index adf9edbf2d..0000000000 --- a/linux-user/host/riscv32/hostdep.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * hostdep.h : things which are dependent on the host architecture - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#ifndef RISCV32_HOSTDEP_H -#define RISCV32_HOSTDEP_H - -#endif diff --git a/linux-user/host/riscv64/safe-syscall.inc.S b/linux-user/host/r= iscv/safe-syscall.inc.S similarity index 100% rename from linux-user/host/riscv64/safe-syscall.inc.S rename to linux-user/host/riscv/safe-syscall.inc.S --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16358519181881015.2618774104791; Tue, 2 Nov 2021 04:18:38 -0700 (PDT) Received: from localhost ([::1]:43616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhroL-0004zq-4w for importer@patchew.org; Tue, 02 Nov 2021 07:18:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0003hY-Rd for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:49 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:44732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdp-0000rp-UA for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:49 -0400 Received: by mail-qt1-x82b.google.com with SMTP id j1so11231100qtq.11 for ; Tue, 02 Nov 2021 04:07:45 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:44 -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=A9mkVrBs8KkxTXk1PYgQKfRHS5p1nm/1r22NtGvkuhs=; b=wiznCEa6FEQ9ZzmKRZ8OU/XJBBDk9CZAybAsDn8IJiGtJWff0Q1ZNPZFUk6Ttl9UGP aRkLuyFSPqPmd1x5d4mNouT51IHTRGbZpl9Q2ZHcnkG0yPaOUgvP8Wr7AdI2wpRK5sKd oiQvH0P42dCZ2TDyZYLZkD6wzWgJxmd5v8R71xrx72lqSzJwdIOSbYk4cLzvtwnxJEmc a7MmUHtmXC33ZiSm+Z7J5Ziy9eOoWQyAAWgZOd6tlgxfnkn5M0VSGVVh0b0iB3JmZ/Vd 7/nmw+WBY9hSN2436yT5oBzwMPZCSD26+YigMbK3z1Ini0JDXuz5ag6xFdZ4LWBCazh9 ping== 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=A9mkVrBs8KkxTXk1PYgQKfRHS5p1nm/1r22NtGvkuhs=; b=65KAWMf0/K9FXGDgo+ixRFi3maELmjOq4itgOiOgwZxd+OAVp/2Div+bLHUr7bIHa8 7ib7j0RDFnTkK5nf5bdRPbHwGYv7v4nDdoh+cxatUb9NL/S/FrOPxdoMFGeVf8A7uey1 0/LpCr7/eHTSIQjgOq128cFVJA/SRKtwtETfuyidATG+fx7iA2hAf+oJ2+b0QizNlgpT FIhZKLKC+QvbjPVPswQ09t4bHN40+H9qFFLC9ldaQxBPhuML2ApOGgR95qn71S5NNCh1 34FIwWuqJ+fsQ1YsTNxpHRrkkn51M8wdvYCEMrDzO0x0OMqHP1/WaCKdDShdiDJY391z 3S7w== X-Gm-Message-State: AOAM5301KoYRY+U2sINhr0Ym2EF9/aNHMCvRVM9q6/mVgdM1li2zmXj6 RMfdsz8379iRmsTG1UVSvbkuZBflESLcSA== X-Google-Smtp-Source: ABdhPJzdPs5Diy6hgx+MNdRT5Wp9mtftM1Ere3nH5dytirnUV0Cr/OqnrUonBS1rHfNzpiPow4q8Rg== X-Received: by 2002:ac8:5a4b:: with SMTP id o11mr38088517qta.59.1635851264925; Tue, 02 Nov 2021 04:07:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/60] linux-user: Reorg handling for SIGSEGV Date: Tue, 2 Nov 2021 07:06:46 -0400 Message-Id: <20211102110740.215699-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635851918662100001 Add stub host-signal.h for all linux-user hosts. Add new code replacing cpu_signal_handler. Full migration will happen one host at a time. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Alistair Francis Signed-off-by: Richard Henderson --- linux-user/host/aarch64/host-signal.h | 1 + linux-user/host/arm/host-signal.h | 1 + linux-user/host/i386/host-signal.h | 1 + linux-user/host/mips/host-signal.h | 1 + linux-user/host/ppc/host-signal.h | 1 + linux-user/host/ppc64/host-signal.h | 1 + linux-user/host/riscv/host-signal.h | 1 + linux-user/host/s390/host-signal.h | 1 + linux-user/host/s390x/host-signal.h | 1 + linux-user/host/sparc/host-signal.h | 1 + linux-user/host/sparc64/host-signal.h | 1 + linux-user/host/x32/host-signal.h | 1 + linux-user/host/x86_64/host-signal.h | 1 + linux-user/signal.c | 109 ++++++++++++++++++++++---- 14 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 linux-user/host/aarch64/host-signal.h create mode 100644 linux-user/host/arm/host-signal.h create mode 100644 linux-user/host/i386/host-signal.h create mode 100644 linux-user/host/mips/host-signal.h create mode 100644 linux-user/host/ppc/host-signal.h create mode 100644 linux-user/host/ppc64/host-signal.h create mode 100644 linux-user/host/riscv/host-signal.h create mode 100644 linux-user/host/s390/host-signal.h create mode 100644 linux-user/host/s390x/host-signal.h create mode 100644 linux-user/host/sparc/host-signal.h create mode 100644 linux-user/host/sparc64/host-signal.h create mode 100644 linux-user/host/x32/host-signal.h create mode 100644 linux-user/host/x86_64/host-signal.h diff --git a/linux-user/host/aarch64/host-signal.h b/linux-user/host/aarch6= 4/host-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/aarch64/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/arm/host-signal.h b/linux-user/host/arm/host-s= ignal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/arm/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/i386/host-signal.h b/linux-user/host/i386/host= -signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/i386/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/mips/host-signal.h b/linux-user/host/mips/host= -signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/mips/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-s= ignal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/ppc/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/ppc64/host-signal.h b/linux-user/host/ppc64/ho= st-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/ppc64/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/ho= st-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/riscv/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host= -signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/s390/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/s390x/host-signal.h b/linux-user/host/s390x/ho= st-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/s390x/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/ho= st-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/sparc/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/sparc64/host-signal.h b/linux-user/host/sparc6= 4/host-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/sparc64/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/x32/host-signal.h b/linux-user/host/x32/host-s= ignal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/x32/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/host/x86_64/host-signal.h b/linux-user/host/x86_64/= host-signal.h new file mode 100644 index 0000000000..f4b4d65031 --- /dev/null +++ b/linux-user/host/x86_64/host-signal.h @@ -0,0 +1 @@ +#define HOST_SIGNAL_PLACEHOLDER diff --git a/linux-user/signal.c b/linux-user/signal.c index 14d8fdfde1..6900acb122 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "qemu/bitops.h" #include "exec/gdbstub.h" +#include "hw/core/tcg-cpu-ops.h" =20 #include #include @@ -29,6 +30,7 @@ #include "loader.h" #include "trace.h" #include "signal-common.h" +#include "host-signal.h" =20 static struct target_sigaction sigact_table[TARGET_NSIG]; =20 @@ -769,41 +771,116 @@ static inline void rewind_if_in_safe_syscall(void *p= uc) } #endif =20 -static void host_signal_handler(int host_signum, siginfo_t *info, - void *puc) +static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { CPUArchState *env =3D thread_cpu->env_ptr; CPUState *cpu =3D env_cpu(env); TaskState *ts =3D cpu->opaque; - - int sig; target_siginfo_t tinfo; ucontext_t *uc =3D puc; struct emulated_sigtable *k; + int guest_sig; =20 +#ifdef HOST_SIGNAL_PLACEHOLDER /* the CPU emulator uses some host signals to detect exceptions, we forward to it some signals */ - if ((host_signum =3D=3D SIGSEGV || host_signum =3D=3D SIGBUS) + if ((host_sig =3D=3D SIGSEGV || host_sig =3D=3D SIGBUS) && info->si_code > 0) { - if (cpu_signal_handler(host_signum, info, puc)) + if (cpu_signal_handler(host_sig, info, puc)) { return; + } } +#else + uintptr_t pc =3D 0; + bool sync_sig =3D false; + + /* + * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special + * handling wrt signal blocking and unwinding. + */ + if ((host_sig =3D=3D SIGSEGV || host_sig =3D=3D SIGBUS) && info->si_co= de > 0) { + MMUAccessType access_type; + uintptr_t host_addr; + abi_ptr guest_addr; + bool is_write; + + host_addr =3D (uintptr_t)info->si_addr; + + /* + * Convert forcefully to guest address space: addresses outside + * reserved_va are still valid to report via SEGV_MAPERR. + */ + guest_addr =3D h2g_nocheck(host_addr); + + pc =3D host_signal_pc(uc); + is_write =3D host_signal_write(info, uc); + access_type =3D adjust_signal_pc(&pc, is_write); + + if (host_sig =3D=3D SIGSEGV) { + const struct TCGCPUOps *tcg_ops; + + if (info->si_code =3D=3D SEGV_ACCERR && h2g_valid(host_addr)) { + /* If this was a write to a TB protected page, restart. */ + if (is_write && + handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask, + pc, guest_addr)) { + return; + } + + /* + * With reserved_va, the whole address space is PROT_NONE, + * which means that we may get ACCERR when we want MAPERR. + */ + if (page_get_flags(guest_addr) & PAGE_VALID) { + /* maperr =3D false; */ + } else { + info->si_code =3D SEGV_MAPERR; + } + } + + sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + + tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; + tcg_ops->tlb_fill(cpu, guest_addr, 0, access_type, + MMU_USER_IDX, false, pc); + g_assert_not_reached(); + } else { + sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + } + + sync_sig =3D true; + } +#endif =20 /* get target signal number */ - sig =3D host_to_target_signal(host_signum); - if (sig < 1 || sig > TARGET_NSIG) + guest_sig =3D host_to_target_signal(host_sig); + if (guest_sig < 1 || guest_sig > TARGET_NSIG) { return; - trace_user_host_signal(env, host_signum, sig); + } + trace_user_host_signal(env, host_sig, guest_sig); + + host_to_target_siginfo_noswap(&tinfo, info); + k =3D &ts->sigtab[guest_sig - 1]; + k->info =3D tinfo; + k->pending =3D guest_sig; + ts->signal_pending =3D 1; + +#ifndef HOST_SIGNAL_PLACEHOLDER + /* + * For synchronous signals, unwind the cpu state to the faulting + * insn and then exit back to the main loop so that the signal + * is delivered immediately. + */ + if (sync_sig) { + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, pc); + } +#endif =20 rewind_if_in_safe_syscall(puc); =20 - host_to_target_siginfo_noswap(&tinfo, info); - k =3D &ts->sigtab[sig - 1]; - k->info =3D tinfo; - k->pending =3D sig; - ts->signal_pending =3D 1; - - /* Block host signals until target signal handler entered. We + /* + * Block host signals until target signal handler entered. We * can't block SIGSEGV or SIGBUS while we're executing guest * code in case the guest code provokes one in the window between * now and it getting out to the main loop. Signals will be --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852074; cv=none; d=zohomail.com; s=zohoarc; b=SuD85S9veDp1+YlThI4kUOnKAI3j3HvJtRciM5kM5JyJUDxS3rBOiouPCZtC4RXzozYLDqBGB1KAWG64GUndCc/nz+CfcuM+XAdevJ812LjGwi2sOtVGtYqRXtgCYkZXX+NEclJCIGL4QIjtp31f+oWG1vkWX6LYR5xKEVXE0Qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852074; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RSgMMIuxwm2GRlSM3OSJ89oURZNxoJr58EWEVCgv90k=; b=iEMiuAq9hPodj8lxQt6GDoikhjVKNQzYC19SgKA1WpWOSuUMiPSWLduDTK1QMT7Ca53jrDBQSpVdolcWTvpo8fumzA24/48LY4XyjK6Cc/EbcVn3GToPZsbjQABXob3+1Mp9TXMxEpdYHCFZgeXohpIieY415Mps2/UiemQLlNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852074000157.91726132246947; Tue, 2 Nov 2021 04:21:14 -0700 (PDT) Received: from localhost ([::1]:51042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrqq-0001Xr-OC for importer@patchew.org; Tue, 02 Nov 2021 07:21:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jg-Qj for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]:46676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdq-0000ry-OC for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:53 -0400 Received: by mail-qv1-xf36.google.com with SMTP id g25so12008974qvf.13 for ; Tue, 02 Nov 2021 04:07:46 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:45 -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=RSgMMIuxwm2GRlSM3OSJ89oURZNxoJr58EWEVCgv90k=; b=dyTIrLB+JjoNSzMd66ccGjk52JUY3AoIoCl90a71D7b59nDQxn9KeA48RfTC53ZEw+ /cP4+qKSvGRhZCJAzkMNa3turKwpnFH1kscVELkmvzcyHNugr2O+NHWhj2qs4pKIDpF0 thytWbRpWrTeQsOIdaZ6We7z8ydeI+dHz06ZhNXqyqqDGHU26L7nzzhc27e9/CzupSEH GoT8lLbR1eVwppaLZgj4ydJnc8rgfOqow6YGCc4baFqxeX5VganPuuLX3pNOVbHkdunX EPHS6MBhdcFWsRxBZ5reFJaC/+hghbrZXCWZQQgBanywF0YgwteqluLz7VydCYnqOxtn Rh6A== 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=RSgMMIuxwm2GRlSM3OSJ89oURZNxoJr58EWEVCgv90k=; b=Gp+oUqVANi46MFcmTtFqHJJKF4ATmbqqwYU+/J0HYuh1tXnA+BZhLDAMCHtW8L1T8H Mjg6tS0MnhuTfzOUAJEhTk/d7RjHHSZ9HtFJ/TTNY1hK/gW2sMKJmmR/1M2C2OqV9hX7 Sf2eywhjyIcm06xQN+UFyNcXgJ+0kfcpzyRcAKD4wLwCwXKZrNSsSruHaxv+m5rW8UYO DQCWAvPavaKG6hLjTXGTB1W7rDEHcmNHb4IJVLyvCWRMZLgZSEXrKdLoUltWm0A0ZYdk Jg3RDLDP7nKSyAOxmjsJZ3iYOe1PtdtEgRTGe612lMYmRGjmX6RgigLEsXL0qfl4o8HB ONLw== X-Gm-Message-State: AOAM530RafpdQeFis/8aE+IORq13WEzGvTwwfCv4qwT43fN42AkoJg3O mnQzu7dWgCCQguxUe1ntQ0zyxzZB1jHG6g== X-Google-Smtp-Source: ABdhPJwkSNUbeNdn9KSP2fSOEXDjStqRyOhgz4PrX8vpQZKNyDgbmy4G/NsD0xQSDxW7wyp0Sn4U/w== X-Received: by 2002:a05:6214:4107:: with SMTP id kc7mr14868977qvb.12.1635851265691; Tue, 02 Nov 2021 04:07:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/60] linux-user/host/x86: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:47 -0400 Message-Id: <20211102110740.215699-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf36.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852075161100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- linux-user/host/i386/host-signal.h | 26 ++++- linux-user/host/x32/host-signal.h | 2 +- linux-user/host/x86_64/host-signal.h | 25 ++++- accel/tcg/user-exec.c | 136 +-------------------------- 4 files changed, 51 insertions(+), 138 deletions(-) diff --git a/linux-user/host/i386/host-signal.h b/linux-user/host/i386/host= -signal.h index f4b4d65031..4c8eef99ce 100644 --- a/linux-user/host/i386/host-signal.h +++ b/linux-user/host/i386/host-signal.h @@ -1 +1,25 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef I386_HOST_SIGNAL_H +#define I386_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.gregs[REG_EIP]; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe + && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); +} + +#endif diff --git a/linux-user/host/x32/host-signal.h b/linux-user/host/x32/host-s= ignal.h index f4b4d65031..26800591d3 100644 --- a/linux-user/host/x32/host-signal.h +++ b/linux-user/host/x32/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../x86_64/host-signal.h" diff --git a/linux-user/host/x86_64/host-signal.h b/linux-user/host/x86_64/= host-signal.h index f4b4d65031..883d2fcf65 100644 --- a/linux-user/host/x86_64/host-signal.h +++ b/linux-user/host/x86_64/host-signal.h @@ -1 +1,24 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (C) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef X86_64_HOST_SIGNAL_H +#define X86_64_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.gregs[REG_RIP]; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe + && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index b1183aa4b3..b121e6c2e9 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -29,19 +29,6 @@ #include "trace/trace-root.h" #include "internal.h" =20 -#undef EAX -#undef ECX -#undef EDX -#undef EBX -#undef ESP -#undef EBP -#undef ESI -#undef EDI -#undef EIP -#ifdef __linux__ -#include -#endif - __thread uintptr_t helper_retaddr; =20 //#define DEBUG_SIGNAL @@ -266,123 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong ad= dr, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__i386__) - -#if defined(__NetBSD__) -#include -#include - -#define EIP_sig(context) ((context)->uc_mcontext.__gregs[_REG_EIP]) -#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) -#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR]) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#elif defined(__FreeBSD__) || defined(__DragonFly__) -#include -#include - -#define EIP_sig(context) (*((unsigned long *)&(context)->uc_mcontext.mc_e= ip)) -#define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) -#define ERROR_sig(context) ((context)->uc_mcontext.mc_err) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#elif defined(__OpenBSD__) -#include -#define EIP_sig(context) ((context)->sc_eip) -#define TRAP_sig(context) ((context)->sc_trapno) -#define ERROR_sig(context) ((context)->sc_err) -#define MASK_sig(context) ((context)->sc_mask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#else -#define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) -#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) -#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP 0xe -#endif - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) - ucontext_t *uc =3D puc; -#elif defined(__OpenBSD__) - struct sigcontext *uc =3D puc; -#else - ucontext_t *uc =3D puc; -#endif - unsigned long pc; - int trapno; - -#ifndef REG_EIP -/* for glibc 2.1 */ -#define REG_EIP EIP -#define REG_ERR ERR -#define REG_TRAPNO TRAPNO -#endif - pc =3D EIP_sig(uc); - trapno =3D TRAP_sig(uc); - return handle_cpu_signal(pc, info, - trapno =3D=3D PAGE_FAULT_TRAP ? - (ERROR_sig(uc) >> 1) & 1 : 0, - &MASK_sig(uc)); -} - -#elif defined(__x86_64__) - -#ifdef __NetBSD__ -#include -#define PC_sig(context) _UC_MACHINE_PC(context) -#define TRAP_sig(context) ((context)->uc_mcontext.__gregs[_REG_TRAPNO]) -#define ERROR_sig(context) ((context)->uc_mcontext.__gregs[_REG_ERR]) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#elif defined(__OpenBSD__) -#include -#define PC_sig(context) ((context)->sc_rip) -#define TRAP_sig(context) ((context)->sc_trapno) -#define ERROR_sig(context) ((context)->sc_err) -#define MASK_sig(context) ((context)->sc_mask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#elif defined(__FreeBSD__) || defined(__DragonFly__) -#include -#include - -#define PC_sig(context) (*((unsigned long *)&(context)->uc_mcontext.mc_ri= p)) -#define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) -#define ERROR_sig(context) ((context)->uc_mcontext.mc_err) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP T_PAGEFLT -#else -#define PC_sig(context) ((context)->uc_mcontext.gregs[REG_RIP]) -#define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) -#define ERROR_sig(context) ((context)->uc_mcontext.gregs[REG_ERR]) -#define MASK_sig(context) ((context)->uc_sigmask) -#define PAGE_FAULT_TRAP 0xe -#endif - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - unsigned long pc; -#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) - ucontext_t *uc =3D puc; -#elif defined(__OpenBSD__) - struct sigcontext *uc =3D puc; -#else - ucontext_t *uc =3D puc; -#endif - - pc =3D PC_sig(uc); - return handle_cpu_signal(pc, info, - TRAP_sig(uc) =3D=3D PAGE_FAULT_TRAP ? - (ERROR_sig(uc) >> 1) & 1 : 0, - &MASK_sig(uc)); -} - -#elif defined(_ARCH_PPC) +#if defined(_ARCH_PPC) =20 /*********************************************************************** * signal context platform-specific definitions @@ -893,11 +764,6 @@ int cpu_signal_handler(int host_signum, void *pinfo, =20 return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); } - -#else - -#error host CPU specific signal handler needed - #endif =20 /* The softmmu versions of these helpers are in cputlb.c. */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852287; cv=none; d=zohomail.com; s=zohoarc; b=DvY3wE+AllmgzLK1dO8YRZk2/MhXfwkFcAicDkeeq8TYlU/Zt1ZuMIbWMe8pmg+9il+hiWHOR0VJg1pPLzZHgfUgRbfOPHDwffuOkUvsG80/mELR85txj3YTLRBqQT3Fh9ow33wpOs20BObSuprbdzr17eeqxSUDFTWy7g3acG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852287; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8/7KXVD3zq87x6TOe7PU4RK3OGzoSoejAMrm7z+tUkk=; b=SSoQME83Ag2Qg5Ak9+B0Q/vi4A5aOuDHMQ9tKE22+DoH3cWwQd/WWBGBISJ0Iy6LkipKj76yXHDwJPSYlKgh49iSMQSDM+HRpOwnmxR1hdkV3MN7tUzWh5DCdMQUmAgXGSgFJgGejrT3LIEAiZBFNc7p2I044cS6SDFqO1DhOEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852287935777.0013009455073; Tue, 2 Nov 2021 04:24:47 -0700 (PDT) Received: from localhost ([::1]:59436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhruI-0007N7-VK for importer@patchew.org; Tue, 02 Nov 2021 07:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jd-QH for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:45038) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdr-0000sF-8p for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:53 -0400 Received: by mail-qk1-x736.google.com with SMTP id bj20so7951719qkb.11 for ; Tue, 02 Nov 2021 04:07:46 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:46 -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=8/7KXVD3zq87x6TOe7PU4RK3OGzoSoejAMrm7z+tUkk=; b=aEJ791NdOwLJ3MBpD57UXs5LdjWjmtoREtOAI6CCNAe1YYkzZZy+v1+UIjt+X7pIro IIpFEjL0M2srSnjn+zO5f5JcVBbfHefDOuluox5Ihnuww9XG9GupeGULwPlPSMoMTwJ8 oH3zIa3jIRF+KH1BDQSq8diajZjYEmA2+ThdL8813beVAOFmDvqEb3kSnKlewWwXs7gF QUh8XsPGWUdkrAmDK0jJ8tpAha9F3GBQO9H+JtiEtDWOs88XSDp5/PvYEkempvLKEBGM U7Ch05dyDtfMy8bWaIzvnARnLYH6Tuvvg7yZQi0N5iRrZiB9+kszlT38Ef/k5k1Rh5j8 6yog== 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=8/7KXVD3zq87x6TOe7PU4RK3OGzoSoejAMrm7z+tUkk=; b=2ZDSHfyTFjTtuV6jUskCFpS1p6wFi+hPlPb+B1xXxEqRumuEvfZv0eQr/ya/oZxCQP QU3kPoQdLaTZrVaTvx2o4mHaberBO29M9xv3Muf4w2LKk1qx63bGGzubNDFBNQKJ4rUS FJJiHRUK9jFTPdEVdfL7QvCuCMf4lifJ233Nag8shFvOwxwzgB1eaqAXL+tt+VSR/F+/ QI8synRvzC+mBvWbKm8nRv/D4yOeAVlYb6UdkpGBajVYEtk3GtHG88/GTlAgOnsmEIo6 QNjt9sStnbOmUiWDqs4eVcLzjsA2W1rQ5oLBcAPYsC8TxIw+jEDH56evXIZ8mB8TY9V1 1ZGA== X-Gm-Message-State: AOAM530BLcYONRYwxNxPPqCUBPcMZVQQwFPEcAEDydY77Lub2GXSCABu dy019tIRmse5VImSV3Rk4kC08xk4Uxn/vA== X-Google-Smtp-Source: ABdhPJz63HdGoVgPYpkiD3ftEZYl0dAKDa61Xjtu3gwHNz2yzLMjPAfDEDNQo8TTbo93XnPTohVqGA== X-Received: by 2002:a05:620a:2910:: with SMTP id m16mr11515492qkp.389.1635851266289; Tue, 02 Nov 2021 04:07:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/60] linux-user/host/ppc: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:48 -0400 Message-Id: <20211102110740.215699-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x736.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852288250100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- linux-user/host/ppc/host-signal.h | 26 +++++++++- linux-user/host/ppc64/host-signal.h | 2 +- accel/tcg/user-exec.c | 79 +---------------------------- 3 files changed, 27 insertions(+), 80 deletions(-) diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-s= ignal.h index f4b4d65031..a491c413dc 100644 --- a/linux-user/host/ppc/host-signal.h +++ b/linux-user/host/ppc/host-signal.h @@ -1 +1,25 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef PPC_HOST_SIGNAL_H +#define PPC_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.regs->nip; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + return uc->uc_mcontext.regs->trap !=3D 0x400 + && (uc->uc_mcontext.regs->dsisr & 0x02000000); +} + +#endif diff --git a/linux-user/host/ppc64/host-signal.h b/linux-user/host/ppc64/ho= st-signal.h index f4b4d65031..a353c22a90 100644 --- a/linux-user/host/ppc64/host-signal.h +++ b/linux-user/host/ppc64/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../ppc/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index b121e6c2e9..5a0a65fa46 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,84 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(_ARCH_PPC) - -/*********************************************************************** - * signal context platform-specific definitions - * From Wine - */ -#ifdef linux -/* All Registers access - only for local access */ -#define REG_sig(reg_name, context) \ - ((context)->uc_mcontext.regs->reg_name) -/* Gpr Registers access */ -#define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], conte= xt) -/* Program counter */ -#define IAR_sig(context) REG_sig(nip, context) -/* Machine State Register (Supervisor) */ -#define MSR_sig(context) REG_sig(msr, context) -/* Count register */ -#define CTR_sig(context) REG_sig(ctr, context) -/* User's integer exception register */ -#define XER_sig(context) REG_sig(xer, context) -/* Link register */ -#define LR_sig(context) REG_sig(link, context) -/* Condition register */ -#define CR_sig(context) REG_sig(ccr, context) - -/* Float Registers access */ -#define FLOAT_sig(reg_num, context) \ - (((double *)((char *)((context)->uc_mcontext.regs + 48 * 4)))[reg_num]) -#define FPSCR_sig(context) \ - (*(int *)((char *)((context)->uc_mcontext.regs + (48 + 32 * 2) * 4))) -/* Exception Registers access */ -#define DAR_sig(context) REG_sig(dar, context) -#define DSISR_sig(context) REG_sig(dsisr, context) -#define TRAP_sig(context) REG_sig(trap, context) -#endif /* linux */ - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#include -#define IAR_sig(context) ((context)->uc_mcontext.mc_srr0) -#define MSR_sig(context) ((context)->uc_mcontext.mc_srr1) -#define CTR_sig(context) ((context)->uc_mcontext.mc_ctr) -#define XER_sig(context) ((context)->uc_mcontext.mc_xer) -#define LR_sig(context) ((context)->uc_mcontext.mc_lr) -#define CR_sig(context) ((context)->uc_mcontext.mc_cr) -/* Exception Registers access */ -#define DAR_sig(context) ((context)->uc_mcontext.mc_dar) -#define DSISR_sig(context) ((context)->uc_mcontext.mc_dsisr) -#define TRAP_sig(context) ((context)->uc_mcontext.mc_exc) -#endif /* __FreeBSD__|| __FreeBSD_kernel__ */ - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - ucontext_t *uc =3D puc; -#else - ucontext_t *uc =3D puc; -#endif - unsigned long pc; - int is_write; - - pc =3D IAR_sig(uc); - is_write =3D 0; -#if 0 - /* ppc 4xx case */ - if (DSISR_sig(uc) & 0x00800000) { - is_write =3D 1; - } -#else - if (TRAP_sig(uc) !=3D 0x400 && (DSISR_sig(uc) & 0x02000000)) { - is_write =3D 1; - } -#endif - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__alpha__) +#if defined(__alpha__) =20 int cpu_signal_handler(int host_signum, void *pinfo, void *puc) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852573; cv=none; d=zohomail.com; s=zohoarc; b=TU/5pg+FscLwqawZBq9/AnUzFJ7CsKZn3qd2Be1mk7tAW4JBJ94bdNJltibs0kP03SJTi9045+yl92EidJ1jTWPyLHfQrTmbBXrezvI220sgEgxo7iCxKOuh3GW1evtRyIAiVrXoKcIsSjagHAdP4MSNtYStz5diHHBRdaQgxhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852573; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xi5Xc/by+fXO9rb16n3Qpt44Vj6KLnw5qZ8SYUB9TCU=; b=N3SyHxQgH9g7sq+Doq5rx7Wuyy4L4Rmh8m9ysMJe077jmhI3Y6zjyAgcjn75zsYxG3rxQjBwt6F65VJ2m7/dGsd1ZIElfef8+0ZA7lI//39h5oboFrFzfzfkoWRa1/9SZhxJHjYXwrWnh0OeHJbz4hKLLCdouVIvJJQChO1P3hU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852573435354.73615073090946; Tue, 2 Nov 2021 04:29:33 -0700 (PDT) Received: from localhost ([::1]:48070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhryu-00029M-Fh for importer@patchew.org; Tue, 02 Nov 2021 07:29:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jj-RY for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:47025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrds-0000sO-7G for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:54 -0400 Received: by mail-qt1-x82b.google.com with SMTP id s1so17057747qta.13 for ; Tue, 02 Nov 2021 04:07:47 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:46 -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=Xi5Xc/by+fXO9rb16n3Qpt44Vj6KLnw5qZ8SYUB9TCU=; b=QQrtI7EZahGS/Rso0AXET1VU/SFI5k/kagepGctStPT7hJWf/c0IEO+sF3H3B422oK wcfGvOcHI3tnd1MqOt18Mf/aLT2165PY1ufbWKH8eFiCZY6BHG16W2q564/Xwsrt9gTw ZMiFkvmWK9Vu86RQXGDvNT52qHADPhT3uATl4OElOwZKsOb8S2TvPybPN586d+aC9Ohy LpqaE1YgKI4BCjQQpF4X2oAD38gAwoS/g/IDRtY2a2usMM5uCptF9c/Wtf/NRXqkJhJS AzSMBwNV+rXPZS4OjGho5tOkj2wpDtTJU6mYZaC3sFN8Obh8PV0/OMvxZucNSqIsVJci Jr0w== 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=Xi5Xc/by+fXO9rb16n3Qpt44Vj6KLnw5qZ8SYUB9TCU=; b=F0X90bK2XvkGeMTGWOa4JlFXmDOn2ufSUpRkqBxxcE+6MfRBstbLvrdfPJj5PaQbyD ki+9xDOqkDjvj0UHiTF0IM1QRnairGsvmamKIogcLNd+oK9URvTVsi3UQ5Csn2XQtiQM stsYg+z24arX3AAAmPywcCvJkvsTG8DhRz7hSiW6FBCXdXy0J/ucXv2tWLH3hn4TwNd8 NF8a1IMGW+FqnN570LPjgrLEnPWNTbCzbdeF5qilX5D6IaOngnV+xbuIw6KwQjYhzD4v FHAY6sy119/GWb/NQZ95VTJgG2rbLTO0aUlnYAr9QnseH2xS/0hJM6qLWnQttvR1gAzh +DbA== X-Gm-Message-State: AOAM533XVPcKg2bn+wH+e+IGKpmjJrzGWaMc6kv0YCoY2m0z+C2of77+ EJ7JrTaWYRDbPBaCyvncB8s5Ro3o1Gds0g== X-Google-Smtp-Source: ABdhPJwTWPWL9tJu6IurrL9IzAHO840X2s6bRry/5RgIrzFCn+08WyJabxiYVUb0J+eMl5IxmYnBJA== X-Received: by 2002:a05:622a:1aaa:: with SMTP id s42mr27799400qtc.376.1635851266962; Tue, 02 Nov 2021 04:07:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/60] linux-user/host/alpha: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:49 -0400 Message-Id: <20211102110740.215699-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852574079100001 Split host_signal_pc and host_signal_write out of user-exec.c. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/host/alpha/host-signal.h | 42 +++++++++++++++++++++++++++++ accel/tcg/user-exec.c | 31 +-------------------- 2 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 linux-user/host/alpha/host-signal.h diff --git a/linux-user/host/alpha/host-signal.h b/linux-user/host/alpha/ho= st-signal.h new file mode 100644 index 0000000000..e080be412f --- /dev/null +++ b/linux-user/host/alpha/host-signal.h @@ -0,0 +1,42 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef ALPHA_HOST_SIGNAL_H +#define ALPHA_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.sc_pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint32_t *pc =3D (uint32_t *)host_signal_pc(uc); + uint32_t insn =3D *pc; + + /* XXX: need kernel patch to get write flag faster */ + switch (insn >> 26) { + case 0x0d: /* stw */ + case 0x0e: /* stb */ + case 0x0f: /* stq_u */ + case 0x24: /* stf */ + case 0x25: /* stg */ + case 0x26: /* sts */ + case 0x27: /* stt */ + case 0x2c: /* stl */ + case 0x2d: /* stq */ + case 0x2e: /* stl_c */ + case 0x2f: /* stq_c */ + return true; + } + return false; +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 5a0a65fa46..e9b6eb696f 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,36 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__alpha__) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - uint32_t *pc =3D uc->uc_mcontext.sc_pc; - uint32_t insn =3D *pc; - int is_write =3D 0; - - /* XXX: need kernel patch to get write flag faster */ - switch (insn >> 26) { - case 0x0d: /* stw */ - case 0x0e: /* stb */ - case 0x0f: /* stq_u */ - case 0x24: /* stf */ - case 0x25: /* stg */ - case 0x26: /* sts */ - case 0x27: /* stt */ - case 0x2c: /* stl */ - case 0x2d: /* stq */ - case 0x2e: /* stl_c */ - case 0x2f: /* stq_c */ - is_write =3D 1; - } - - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} -#elif defined(__sparc__) +#if defined(__sparc__) =20 int cpu_signal_handler(int host_signum, void *pinfo, void *puc) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852303; cv=none; d=zohomail.com; s=zohoarc; b=Yu7JHPPj/UGVRsjOCb1o7Lg4wJ2Xou8Gxe91OtU7H7Kh1x+XSANRBI9aBHye1t4W4CPvt6QIrbeJE5FAcAfNEPhH9Wf1N7sPmE8QM5+qEltMJum4M2aIzAmvgoXkHkf0FCUIECm4Atq2k5RQvsrusMtFtnltkOWhvBmtFULwhYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852303; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=G0fWsTacooPk07Wvp7sSPStT5clQlQCTGduwntq+qzUybogiTyDZ9+ePDcXfnCqjGT4xUlmnYrasINX66POLkP4PrVVP7+YPMvQ2+VEtzuGFmqzy/GZszqgudmls/dNrAXgMXn3JGEZne1r0KPFFyLjuT7t6+cnot67Vs3G5AJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852303690954.937251255133; Tue, 2 Nov 2021 04:25:03 -0700 (PDT) Received: from localhost ([::1]:60922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhruY-0008OI-Mh for importer@patchew.org; Tue, 02 Nov 2021 07:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jf-R2 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:33462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0000sU-E9 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:53 -0400 Received: by mail-qk1-x730.google.com with SMTP id p4so988131qkk.0 for ; Tue, 02 Nov 2021 04:07:48 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:47 -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=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=yv8JHmYlFTvDXhygfBtED2Mbmufs2dOzX9Y1X9++1qoLODRNGvHjaZRf+TclBtwuKo oWh+u9hNUjzWZZNtPT3nwRbY7THvJYYPJQSxgNjVvx71hkr2oJPhpWcPfe4QJuM/iNEJ deXwVzlObhBPrky0vmRsoMdbj6iEuKk7cLfIk73FSBH3z83PtbvWf8ehVSRoIh+n22Cy l6ls2nlD9qemtlDw7n7HIKLEzoDSQJ9if9cZUZKr9tYJCZh+NfIw0xXLRZnl8n1CFDCq LmPoBfIXd7c5hIDHFepzyt9Fs0bjuxxdfGqHT8Xew5yn7gSdrVpsGx4/lAuqay6QP/4A BTEQ== 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=09EXkfsXIChlE/LXOeHg30UK63IRh0uoWnU1yPu4O3s=; b=Bi+oWTJwPj/H3fDZ5XW/NB2hIhbhwhndmKzjj5G49vOJY1fXhe897meLnaN6I/sf1j KEcIjVfsTHnhEB1Jcc1OIp8nWxIzubHhVtKaW1N+o7PLtq90D8Z3+v3ecXaJg1QgFJfY xi5LtqVOcrHOzcmZP/QDrx5BrXhuJ8LfuLUrawl6V5tOpbyqWdlDdoT1aiOPQLlRrzIf IF2ZC+iVXtsLrX9zRxKJBMynr8ATciwrzguE82RlS1IYlqFpSJ1VQT/8qebnkX1SciDF njgfhTVncjysR0KJl2XTPQymYxlxZEGIblxKp5SJgsE2Nv9kTPvoN+38NgLHQE9G0HLV e0Bg== X-Gm-Message-State: AOAM530ukHYMLc42OEQwhd+XoDK6QfNJf2Se41lXFrcRUDgQGsDqDmgf MKzLQV8vjgrLzHVYgLqVMRLfP/aPN58EQA== X-Google-Smtp-Source: ABdhPJxK2bpuryNu4XxpjMchI+ae96fXA6UXk7rJqosUnDZAW1kz7uWTC5A58T/P89E/4sn7ECAC7w== X-Received: by 2002:a37:2e03:: with SMTP id u3mr28505172qkh.313.1635851267555; Tue, 02 Nov 2021 04:07:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/60] linux-user/host/sparc: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:50 -0400 Message-Id: <20211102110740.215699-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852306044100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Drop the Solaris code as completely unused. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- linux-user/host/sparc/host-signal.h | 55 +++++++++++++++++++++++- linux-user/host/sparc64/host-signal.h | 2 +- accel/tcg/user-exec.c | 62 +-------------------------- 3 files changed, 56 insertions(+), 63 deletions(-) diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/ho= st-signal.h index f4b4d65031..5e71d33f8e 100644 --- a/linux-user/host/sparc/host-signal.h +++ b/linux-user/host/sparc/host-signal.h @@ -1 +1,54 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef SPARC_HOST_SIGNAL_H +#define SPARC_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ +#ifdef __arch64__ + return uc->uc_mcontext.mc_gregs[MC_PC]; +#else + return uc->uc_mcontext.gregs[REG_PC]; +#endif +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); + + if ((insn >> 30) =3D=3D 3) { + switch ((insn >> 19) & 0x3f) { + case 0x05: /* stb */ + case 0x15: /* stba */ + case 0x06: /* sth */ + case 0x16: /* stha */ + case 0x04: /* st */ + case 0x14: /* sta */ + case 0x07: /* std */ + case 0x17: /* stda */ + case 0x0e: /* stx */ + case 0x1e: /* stxa */ + case 0x24: /* stf */ + case 0x34: /* stfa */ + case 0x27: /* stdf */ + case 0x37: /* stdfa */ + case 0x26: /* stqf */ + case 0x36: /* stqfa */ + case 0x25: /* stfsr */ + case 0x3c: /* casa */ + case 0x3e: /* casxa */ + return true; + } + } + return false; +} + +#endif diff --git a/linux-user/host/sparc64/host-signal.h b/linux-user/host/sparc6= 4/host-signal.h index f4b4d65031..1191fe2d40 100644 --- a/linux-user/host/sparc64/host-signal.h +++ b/linux-user/host/sparc64/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../sparc/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index e9b6eb696f..694eff7f04 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,67 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__sparc__) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - int is_write; - uint32_t insn; -#if !defined(__arch64__) || defined(CONFIG_SOLARIS) - uint32_t *regs =3D (uint32_t *)(info + 1); - void *sigmask =3D (regs + 20); - /* XXX: is there a standard glibc define ? */ - unsigned long pc =3D regs[1]; -#else -#ifdef __linux__ - struct sigcontext *sc =3D puc; - unsigned long pc =3D sc->sigc_regs.tpc; - void *sigmask =3D (void *)sc->sigc_mask; -#elif defined(__OpenBSD__) - struct sigcontext *uc =3D puc; - unsigned long pc =3D uc->sc_pc; - void *sigmask =3D (void *)(long)uc->sc_mask; -#elif defined(__NetBSD__) - ucontext_t *uc =3D puc; - unsigned long pc =3D _UC_MACHINE_PC(uc); - void *sigmask =3D (void *)&uc->uc_sigmask; -#endif -#endif - - /* XXX: need kernel patch to get write flag faster */ - is_write =3D 0; - insn =3D *(uint32_t *)pc; - if ((insn >> 30) =3D=3D 3) { - switch ((insn >> 19) & 0x3f) { - case 0x05: /* stb */ - case 0x15: /* stba */ - case 0x06: /* sth */ - case 0x16: /* stha */ - case 0x04: /* st */ - case 0x14: /* sta */ - case 0x07: /* std */ - case 0x17: /* stda */ - case 0x0e: /* stx */ - case 0x1e: /* stxa */ - case 0x24: /* stf */ - case 0x34: /* stfa */ - case 0x27: /* stdf */ - case 0x37: /* stdfa */ - case 0x26: /* stqf */ - case 0x36: /* stqfa */ - case 0x25: /* stfsr */ - case 0x3c: /* casa */ - case 0x3e: /* casxa */ - is_write =3D 1; - break; - } - } - return handle_cpu_signal(pc, info, is_write, sigmask); -} - -#elif defined(__arm__) +#if defined(__arm__) =20 #if defined(__NetBSD__) #include --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163585244196917.689083331464758; Tue, 2 Nov 2021 04:27:21 -0700 (PDT) Received: from localhost ([::1]:39574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrwm-0004id-W8 for importer@patchew.org; Tue, 02 Nov 2021 07:27:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003jl-Su for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qv1-xf36.google.com ([2607:f8b0:4864:20::f36]:33450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0000sZ-Ey for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:54 -0400 Received: by mail-qv1-xf36.google.com with SMTP id bu11so5128062qvb.0 for ; Tue, 02 Nov 2021 04:07:48 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:47 -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=4j+5GOHH9i6aEZjBZv3rJ6b7IG39UFn9wARHFg8XAtc=; b=uVdB7wPNC2/n/viuGOTnyjvgF1i+kQibUiH0lptoDohSfThKCei0qKZ/PXV2I8gLHF hzOWjZXOsh55lwilvs29SkXXP65xXH7syY21fsUTOIBnJrH50wkSdXC3yTJxaEDHzy+8 J5Z0fm85ZplR6/oq4JBSMrOxens4+HSO12GJEdyMsVTO41dZLYPyLRmOAo5M+Sz4GHeD y5/7KhosiGcCisnjibeO19vi+vXFqbLkozvU/JsM9mxstwJG3e0oF2k7LcDlG/mwtvNM 0ZBsnUTpeRFJrZCVc4Ojbl85hIs+VUtzjw/a59fpTx4k596NHJpekOUbSXv/we8Fzj2T Kh5A== 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=4j+5GOHH9i6aEZjBZv3rJ6b7IG39UFn9wARHFg8XAtc=; b=7lnUCS328kvObHH6QXoY5Fogi9JyzENnSIYGtFwUJbsjveaWuS2968gmA85B5vj9D6 mAQUpBJh/ra7Eij6BslzKgXpNYD1r4lLSKNjktEfOK8MzimmIBo6G7IeR1aPKj1nRIXQ uw1/mEg5oqx6OZjuOJSZDDAJVsroAaiYGibfiuUkG+Vhw7unfsXJRU58/nIYBjlz8DgF t9NQtSx2Y9uDqo4QbMyHRrBVp35uMELGJS951ug6nZ6XYjVqAlth9njn1vkbSA6xN1QJ zo+h2oZQRi8JlTmaBa8jdk81qWrBMDjXPXAvmSVQ3ksBdEZ8U4yGvTCTy3A2qf5nroPr SekA== X-Gm-Message-State: AOAM533HqSWS1DtbjjGMKGWGPdA5vv+z24pfui6KYzBNMyDTbSWjdkBF MN9guuD5LaV3/dk1tBI/EGPBdKyL6VG9rw== X-Google-Smtp-Source: ABdhPJybiKzPZKppCkbf9LZclSG60aXTgTkRZQp4xxo9FbxtzmO18gXl+qFFDPR8Nsn7txbudLNwAQ== X-Received: by 2002:a05:6214:27e1:: with SMTP id jt1mr35320302qvb.62.1635851268144; Tue, 02 Nov 2021 04:07:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/60] linux-user/host/arm: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:51 -0400 Message-Id: <20211102110740.215699-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f36; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf36.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852442245100001 Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/host/arm/host-signal.h | 31 ++++++++++++++++++++- accel/tcg/user-exec.c | 45 +------------------------------ 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/linux-user/host/arm/host-signal.h b/linux-user/host/arm/host-s= ignal.h index f4b4d65031..efb165c0c5 100644 --- a/linux-user/host/arm/host-signal.h +++ b/linux-user/host/arm/host-signal.h @@ -1 +1,30 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef ARM_HOST_SIGNAL_H +#define ARM_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.arm_pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + /* + * In the FSR, bit 11 is WnR, assuming a v6 or + * later processor. On v5 we will always report + * this as a read, which will fail later. + */ + uint32_t fsr =3D uc->uc_mcontext.error_code; + return extract32(fsr, 11, 1); +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 694eff7f04..fabc8855a9 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,50 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__arm__) - -#if defined(__NetBSD__) -#include -#include -#endif - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; -#if defined(__NetBSD__) - ucontext_t *uc =3D puc; - siginfo_t *si =3D pinfo; -#else - ucontext_t *uc =3D puc; -#endif - unsigned long pc; - uint32_t fsr; - int is_write; - -#if defined(__NetBSD__) - pc =3D uc->uc_mcontext.__gregs[_REG_R15]; -#elif defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ =3D=3D 2 && __GLI= BC_MINOR__ <=3D 3)) - pc =3D uc->uc_mcontext.gregs[R15]; -#else - pc =3D uc->uc_mcontext.arm_pc; -#endif - -#ifdef __NetBSD__ - fsr =3D si->si_trap; -#else - fsr =3D uc->uc_mcontext.error_code; -#endif - /* - * In the FSR, bit 11 is WnR, assuming a v6 or - * later processor. On v5 we will always report - * this as a read, which will fail later. - */ - is_write =3D extract32(fsr, 11, 1); - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__aarch64__) +#if defined(__aarch64__) =20 #if defined(__NetBSD__) =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852456; cv=none; d=zohomail.com; s=zohoarc; b=C7Ayxgmtp0mbPiYRyXuxWBkIEAxASchLXFMgAY6TP8ouUDrB9mkqjTsuoM9JcVIeca5O+HknraaO9GMoK/EgT2uVcojWHecFYLcCS9zbvEeLNdqfdO0feMpmun5LCgl8+UR+/tORLv5P1TZUlMWjLzKxABs5gilBVOFs+t0pxO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852456; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FKF5pmiX/o7unekmxiUMsGTx/xn7CVdGNA9mcaJJAdI=; b=IQ6PoSbaOSFRvozufA9j234a5TL+Yvp9Ldz5lEGYad7AnQJxwGiW7i0ePIJJMiVk7LaJtT0v1n7z55y8plNKCfH8qXTigr3Hgh/UldSOxsRueo5cMq0fs8lRQNnzFokq7VuyM7p3DUEjNcKs9MrUOScwuTzhTADPgA4neOD4E+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852456147930.9356784497257; Tue, 2 Nov 2021 04:27:36 -0700 (PDT) Received: from localhost ([::1]:40992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrx1-0005h6-4w for importer@patchew.org; Tue, 02 Nov 2021 07:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0003je-Qf for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:42549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdt-0000sh-Nc for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:54 -0400 Received: by mail-qt1-x82b.google.com with SMTP id v22so828099qtk.9 for ; Tue, 02 Nov 2021 04:07:49 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:48 -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=FKF5pmiX/o7unekmxiUMsGTx/xn7CVdGNA9mcaJJAdI=; b=fJYaGTfWKRoKshDBkdO7LuC6mxMyaIBSyJn3ip1eM9u6QlKUtITGJrow+EpbsqwAWF +oyZg5jjAk+NcAToWjnN02ZECyNDaA+JBnjE9hpX/LSmtV64zQHtfBLNSt4PwcF0PSM9 HCvhl9plKAZVo+T5TWZui6Vm1NoI6NgLTrwkMw2YubyWcx1VFi+q7RoVuHL+sPrlwAw1 nZrgsZW2HZQXgAN1LYyXRGPtsQP4ANhWgc2wXa8d01PMBOmCQWZuBP6BOuyjgtpaTBBl z/QbHmpj0sfoKs88WOzRrpiUStAF1fZpfKSer8gI3mt6ybJC4gGvb93aeGcE7vFdBYsC kVqw== 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=FKF5pmiX/o7unekmxiUMsGTx/xn7CVdGNA9mcaJJAdI=; b=f2O0IjtmYZgfayU9cVkrfgZx0868kAQV3laFFqVUBr9cHx8B5KlHq/IcmwKZ+NkWQq /dwL2ymyhL9QcaKwtOTgaxqZS81FhPZ3nNswDi++rq2tab0BJIuvakrvlAu7L5FZ6XrE 6N8k3tPM52i7X+/RkW112UdTvAtwa7zKcVLfmSeSje9ho9jaN2KHSJtU9PPoExrecUoc /3Oq5pI4FAp6e1SPAd94sbOqHCsQNOKOGaGAW5gMGf3r3nb7uh8omnZhooHodSkO/jzI JodsLross8ahm29Qy5gzPWK1g7YTI5vH9x+tqrOMDLqJE+Ixubo3TBkjSAckxoVQdQRN 6e6g== X-Gm-Message-State: AOAM530VxFUckx8mMDDIIm1Ulj2Jz/1M4P6jyLBx6hE0breQkQvjJaYV cyWEQ0vTssCopoh20S6ZO80Ua457NN1H0g== X-Google-Smtp-Source: ABdhPJxGGQgngz+bYOhJn1qipR6BhE6m8lkO+ACv0HO7+4341C3ttBPWgpLc1Rz4mJweSDYRcJo8hA== X-Received: by 2002:a05:622a:c3:: with SMTP id p3mr37708175qtw.161.1635851268819; Tue, 02 Nov 2021 04:07:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/60] linux-user/host/aarch64: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:52 -0400 Message-Id: <20211102110740.215699-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852458153100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Drop the *BSD code, to be re-created under bsd-user/ later. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- linux-user/host/aarch64/host-signal.h | 75 ++++++++++++++++++++- accel/tcg/user-exec.c | 94 +-------------------------- 2 files changed, 75 insertions(+), 94 deletions(-) diff --git a/linux-user/host/aarch64/host-signal.h b/linux-user/host/aarch6= 4/host-signal.h index f4b4d65031..0c0b08383a 100644 --- a/linux-user/host/aarch64/host-signal.h +++ b/linux-user/host/aarch64/host-signal.h @@ -1 +1,74 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef AARCH64_HOST_SIGNAL_H +#define AARCH64_HOST_SIGNAL_H + +/* Pre-3.16 kernel headers don't have these, so provide fallback definitio= ns */ +#ifndef ESR_MAGIC +#define ESR_MAGIC 0x45535201 +struct esr_context { + struct _aarch64_ctx head; + uint64_t esr; +}; +#endif + +static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc) +{ + return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved; +} + +static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr) +{ + return (struct _aarch64_ctx *)((char *)hdr + hdr->size); +} + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + struct _aarch64_ctx *hdr; + uint32_t insn; + + /* Find the esr_context, which has the WnR bit in it */ + for (hdr =3D first_ctx(uc); hdr->magic; hdr =3D next_ctx(hdr)) { + if (hdr->magic =3D=3D ESR_MAGIC) { + struct esr_context const *ec =3D (struct esr_context const *)h= dr; + uint64_t esr =3D ec->esr; + + /* For data aborts ESR.EC is 0b10010x: then bit 6 is the WnR b= it */ + return extract32(esr, 27, 5) =3D=3D 0x12 && extract32(esr, 6, = 1) =3D=3D 1; + } + } + + /* + * Fall back to parsing instructions; will only be needed + * for really ancient (pre-3.16) kernels. + */ + insn =3D *(uint32_t *)host_signal_pc(uc); + + return (insn & 0xbfff0000) =3D=3D 0x0c000000 /* C3.3.1 */ + || (insn & 0xbfe00000) =3D=3D 0x0c800000 /* C3.3.2 */ + || (insn & 0xbfdf0000) =3D=3D 0x0d000000 /* C3.3.3 */ + || (insn & 0xbfc00000) =3D=3D 0x0d800000 /* C3.3.4 */ + || (insn & 0x3f400000) =3D=3D 0x08000000 /* C3.3.6 */ + || (insn & 0x3bc00000) =3D=3D 0x39000000 /* C3.3.13 */ + || (insn & 0x3fc00000) =3D=3D 0x3d800000 /* ... 128bit */ + /* Ignore bits 10, 11 & 21, controlling indexing. */ + || (insn & 0x3bc00000) =3D=3D 0x38000000 /* C3.3.8-12 */ + || (insn & 0x3fe00000) =3D=3D 0x3c800000 /* ... 128bit */ + /* Ignore bits 23 & 24, controlling indexing. */ + || (insn & 0x3a400000) =3D=3D 0x28000000; /* C3.3.7,14-16 */ +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index fabc8855a9..5cdbfab35b 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,99 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__aarch64__) - -#if defined(__NetBSD__) - -#include -#include - -int cpu_signal_handler(int host_signum, void *pinfo, void *puc) -{ - ucontext_t *uc =3D puc; - siginfo_t *si =3D pinfo; - unsigned long pc; - int is_write; - uint32_t esr; - - pc =3D uc->uc_mcontext.__gregs[_REG_PC]; - esr =3D si->si_trap; - - /* - * siginfo_t::si_trap is the ESR value, for data aborts ESR.EC - * is 0b10010x: then bit 6 is the WnR bit - */ - is_write =3D extract32(esr, 27, 5) =3D=3D 0x12 && extract32(esr, 6, 1)= =3D=3D 1; - return handle_cpu_signal(pc, si, is_write, &uc->uc_sigmask); -} - -#else - -#ifndef ESR_MAGIC -/* Pre-3.16 kernel headers don't have these, so provide fallback definitio= ns */ -#define ESR_MAGIC 0x45535201 -struct esr_context { - struct _aarch64_ctx head; - uint64_t esr; -}; -#endif - -static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc) -{ - return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved; -} - -static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr) -{ - return (struct _aarch64_ctx *)((char *)hdr + hdr->size); -} - -int cpu_signal_handler(int host_signum, void *pinfo, void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - uintptr_t pc =3D uc->uc_mcontext.pc; - bool is_write; - struct _aarch64_ctx *hdr; - struct esr_context const *esrctx =3D NULL; - - /* Find the esr_context, which has the WnR bit in it */ - for (hdr =3D first_ctx(uc); hdr->magic; hdr =3D next_ctx(hdr)) { - if (hdr->magic =3D=3D ESR_MAGIC) { - esrctx =3D (struct esr_context const *)hdr; - break; - } - } - - if (esrctx) { - /* For data aborts ESR.EC is 0b10010x: then bit 6 is the WnR bit */ - uint64_t esr =3D esrctx->esr; - is_write =3D extract32(esr, 27, 5) =3D=3D 0x12 && extract32(esr, 6= , 1) =3D=3D 1; - } else { - /* - * Fall back to parsing instructions; will only be needed - * for really ancient (pre-3.16) kernels. - */ - uint32_t insn =3D *(uint32_t *)pc; - - is_write =3D ((insn & 0xbfff0000) =3D=3D 0x0c000000 /* C3.3.1 */ - || (insn & 0xbfe00000) =3D=3D 0x0c800000 /* C3.3.2 */ - || (insn & 0xbfdf0000) =3D=3D 0x0d000000 /* C3.3.3 */ - || (insn & 0xbfc00000) =3D=3D 0x0d800000 /* C3.3.4 */ - || (insn & 0x3f400000) =3D=3D 0x08000000 /* C3.3.6 */ - || (insn & 0x3bc00000) =3D=3D 0x39000000 /* C3.3.13 = */ - || (insn & 0x3fc00000) =3D=3D 0x3d800000 /* ... 128b= it */ - /* Ignore bits 10, 11 & 21, controlling indexing. */ - || (insn & 0x3bc00000) =3D=3D 0x38000000 /* C3.3.8-1= 2 */ - || (insn & 0x3fe00000) =3D=3D 0x3c800000 /* ... 128b= it */ - /* Ignore bits 23 & 24, controlling indexing. */ - || (insn & 0x3a400000) =3D=3D 0x28000000); /* C3.3.7,1= 4-16 */ - } - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} -#endif - -#elif defined(__s390__) +#if defined(__s390__) =20 int cpu_signal_handler(int host_signum, void *pinfo, void *puc) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852461; cv=none; d=zohomail.com; s=zohoarc; b=XkoEWfadahFbn3m1BtsrRsS7tc6kDg4GKRUBkQjlZBoHUF+OCk3I/Lz/2t4/STP3o1Q02y1Jhph0AEnlHHioS6TCyJyO2yiMQEFG/l3J+F2OirpY6t/s1g8R5kjetcFK0KjHgD85Aw+rNOHBSUJ2JYdlkStuQOOei9woEiYtsAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852461; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iCPpn5LVQcjFIXnJdO6By+zwqZwVsISAIj+ezxFmWpI=; b=JkFiXCz7I5K7crUwM/HUzA3s10UVB1k6o9c7TDIMqVV+1O7MnvbblOTnQtAyCpc6hXgUiuY5nj26H4JDYUXHA4ojjLj5NHJrs5rzf1Wi7UXvrj6mRR/Uug+Vqq1UYpuyG7cb2+iz5tbuleWJ/tBlgQnS5ax5uOxiFaIIKoVDU1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852461613816.3036270799463; Tue, 2 Nov 2021 04:27:41 -0700 (PDT) Received: from localhost ([::1]:41514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrx6-00065q-Ly for importer@patchew.org; Tue, 02 Nov 2021 07:27:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhre3-0003kD-MR for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:01 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:38633) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0000tU-GR for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:57 -0400 Received: by mail-qk1-x72c.google.com with SMTP id bi29so19207500qkb.5 for ; Tue, 02 Nov 2021 04:07:49 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:49 -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=iCPpn5LVQcjFIXnJdO6By+zwqZwVsISAIj+ezxFmWpI=; b=IuNexV1bmUfejmZfUziZJFSjEUMiFx3BPKrxJ+nb0xk17JFAKy2xhTPtwjCOuWbkro OhN/6otscNa6tH26NVJjFqGxZRIM/Ke48cLX9hKtBimiGJaBL2WQAPkoejoREiotJMYi sA9iBQBXe40qHlYurdmYGne6CXu6BTbmQawGSWkf8A7bGRW0rQ99zs5YaqvjBDRLEFve lztbeG77MvUNRI8bAnnrnUYBHsDtwx2CgUcfLH7CNbG9M7I3ovPoBbWFJgaYVVis9+S4 Ew81rFAAr0fCiQT9UacXccNV0WhPCrujkVxJJosaw06CKQOvdWKW82qD7jP5wY0bP/L3 Y8KQ== 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=iCPpn5LVQcjFIXnJdO6By+zwqZwVsISAIj+ezxFmWpI=; b=tz2FAtOa0nvI98RzPOln0NahJy4pYFfH1ZJ79FwBzpGcgZHX1wp5vTirqOjvphSPjx Dfzb4XidsYac8oXQ4W9x17Jm+DcKS3NSkjmgGYQHf5i0dD7sBLPpUWVc1l+6xFfdh0xn VbJX+qWBkVthAyXBhNzM7eljuMo5FJjoQgBDpl+gg6p9qBdcjaSKaXVI1g1UyCusF3s0 3YCRbx0jwbz66EoK4DWULr2I4HO9lwn3TwUj56gE0SHNjbMC2WSUYqbcFSvKqECpGIMz tpqV9II4+T2XHgsPhfPqVICutD/QAyF7r/9vjZuCQXnbz7sV7+0t+nmh0tqMxs/63t48 pEKw== X-Gm-Message-State: AOAM5300XyhHn+53rdFY1Lq34p9SvgSGfFu3DarMfMqIiJ4UVRUAxPFZ RJH98utXZGSqxIWuNI0HncRzoA1T4wPSQA== X-Google-Smtp-Source: ABdhPJzKSREyqamnYsAR3ZIKROkJw6ge6vREvgZooSAh8j99Nzlffe+Nz6SftPAbojDUPaH9qIIBoQ== X-Received: by 2002:a05:620a:4589:: with SMTP id bp9mr14864366qkb.274.1635851269428; Tue, 02 Nov 2021 04:07:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/60] linux-user/host/s390: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:53 -0400 Message-Id: <20211102110740.215699-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852462726100001 Split host_signal_pc and host_signal_write out of user-exec.c. Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/host/s390/host-signal.h | 94 ++++++++++++++++++++++++++++- linux-user/host/s390x/host-signal.h | 2 +- accel/tcg/user-exec.c | 88 +-------------------------- 3 files changed, 95 insertions(+), 89 deletions(-) diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host= -signal.h index f4b4d65031..26990e4893 100644 --- a/linux-user/host/s390/host-signal.h +++ b/linux-user/host/s390/host-signal.h @@ -1 +1,93 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef S390_HOST_SIGNAL_H +#define S390_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.psw.addr; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint16_t *pinsn =3D (uint16_t *)host_signal_pc(uc); + + /* + * ??? On linux, the non-rt signal handler has 4 (!) arguments instead + * of the normal 2 arguments. The 4th argument contains the "Translat= ion- + * Exception Identification for DAT Exceptions" from the hardware (aka + * "int_parm_long"), which does in fact contain the is_write value. + * The rt signal handler, as far as I can tell, does not give this val= ue + * at all. Not that we could get to it from here even if it were. + * So fall back to parsing instructions. Treat read-modify-write ones= as + * writes, which is not fully correct, but for tracking self-modifying= code + * this is better than treating them as reads. Checking si_addr page = flags + * might be a viable improvement, albeit a racy one. + */ + /* ??? This is not even close to complete. */ + switch (pinsn[0] >> 8) { + case 0x50: /* ST */ + case 0x42: /* STC */ + case 0x40: /* STH */ + case 0xba: /* CS */ + case 0xbb: /* CDS */ + return true; + case 0xc4: /* RIL format insns */ + switch (pinsn[0] & 0xf) { + case 0xf: /* STRL */ + case 0xb: /* STGRL */ + case 0x7: /* STHRL */ + return true; + } + break; + case 0xc8: /* SSF format insns */ + switch (pinsn[0] & 0xf) { + case 0x2: /* CSST */ + return true; + } + break; + case 0xe3: /* RXY format insns */ + switch (pinsn[2] & 0xff) { + case 0x50: /* STY */ + case 0x24: /* STG */ + case 0x72: /* STCY */ + case 0x70: /* STHY */ + case 0x8e: /* STPQ */ + case 0x3f: /* STRVH */ + case 0x3e: /* STRV */ + case 0x2f: /* STRVG */ + return true; + } + break; + case 0xeb: /* RSY format insns */ + switch (pinsn[2] & 0xff) { + case 0x14: /* CSY */ + case 0x30: /* CSG */ + case 0x31: /* CDSY */ + case 0x3e: /* CDSG */ + case 0xe4: /* LANG */ + case 0xe6: /* LAOG */ + case 0xe7: /* LAXG */ + case 0xe8: /* LAAG */ + case 0xea: /* LAALG */ + case 0xf4: /* LAN */ + case 0xf6: /* LAO */ + case 0xf7: /* LAX */ + case 0xfa: /* LAAL */ + case 0xf8: /* LAA */ + return true; + } + break; + } + return false; +} + +#endif diff --git a/linux-user/host/s390x/host-signal.h b/linux-user/host/s390x/ho= st-signal.h index f4b4d65031..0e83f9358d 100644 --- a/linux-user/host/s390x/host-signal.h +++ b/linux-user/host/s390x/host-signal.h @@ -1 +1 @@ -#define HOST_SIGNAL_PLACEHOLDER +#include "../s390/host-signal.h" diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 5cdbfab35b..f18f3b2a5c 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,93 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__s390__) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - unsigned long pc; - uint16_t *pinsn; - int is_write =3D 0; - - pc =3D uc->uc_mcontext.psw.addr; - - /* - * ??? On linux, the non-rt signal handler has 4 (!) arguments instead - * of the normal 2 arguments. The 4th argument contains the "Translat= ion- - * Exception Identification for DAT Exceptions" from the hardware (aka - * "int_parm_long"), which does in fact contain the is_write value. - * The rt signal handler, as far as I can tell, does not give this val= ue - * at all. Not that we could get to it from here even if it were. - * So fall back to parsing instructions. Treat read-modify-write ones= as - * writes, which is not fully correct, but for tracking self-modifying= code - * this is better than treating them as reads. Checking si_addr page = flags - * might be a viable improvement, albeit a racy one. - */ - /* ??? This is not even close to complete. */ - pinsn =3D (uint16_t *)pc; - switch (pinsn[0] >> 8) { - case 0x50: /* ST */ - case 0x42: /* STC */ - case 0x40: /* STH */ - case 0xba: /* CS */ - case 0xbb: /* CDS */ - is_write =3D 1; - break; - case 0xc4: /* RIL format insns */ - switch (pinsn[0] & 0xf) { - case 0xf: /* STRL */ - case 0xb: /* STGRL */ - case 0x7: /* STHRL */ - is_write =3D 1; - } - break; - case 0xc8: /* SSF format insns */ - switch (pinsn[0] & 0xf) { - case 0x2: /* CSST */ - is_write =3D 1; - } - break; - case 0xe3: /* RXY format insns */ - switch (pinsn[2] & 0xff) { - case 0x50: /* STY */ - case 0x24: /* STG */ - case 0x72: /* STCY */ - case 0x70: /* STHY */ - case 0x8e: /* STPQ */ - case 0x3f: /* STRVH */ - case 0x3e: /* STRV */ - case 0x2f: /* STRVG */ - is_write =3D 1; - } - break; - case 0xeb: /* RSY format insns */ - switch (pinsn[2] & 0xff) { - case 0x14: /* CSY */ - case 0x30: /* CSG */ - case 0x31: /* CDSY */ - case 0x3e: /* CDSG */ - case 0xe4: /* LANG */ - case 0xe6: /* LAOG */ - case 0xe7: /* LAXG */ - case 0xe8: /* LAAG */ - case 0xea: /* LAALG */ - case 0xf4: /* LAN */ - case 0xf6: /* LAO */ - case 0xf7: /* LAX */ - case 0xfa: /* LAAL */ - case 0xf8: /* LAA */ - is_write =3D 1; - } - break; - } - - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__mips__) +#if defined(__mips__) =20 #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding" --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854321281197.92492722898749; Tue, 2 Nov 2021 04:58:41 -0700 (PDT) Received: from localhost ([::1]:39898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsR6-0004Ez-92 for importer@patchew.org; Tue, 02 Nov 2021 07:58:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreK-00043d-41 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:16 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:39453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreF-0000uD-DW for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: by mail-qt1-x82f.google.com with SMTP id t40so18450285qtc.6 for ; Tue, 02 Nov 2021 04:07:50 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:49 -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=DSOjZQ0mpw8Fmix6YmRPzs+3MA5kVCOMFIAxxXd1b/Y=; b=w33iOpoLEf67g/duwRKYls4tg/pix2TAuINwaqfWGQBSluRZ1ZCBl9Ni7JKMNFcudp DAQ+ebnegt7xHkQJvHcUJpapr9Ed8WWJ4rnyUFeplKHKGf74qpZBbkx3s8VJImqvBoal HQ35ZCZt52/wGgGFxfy04NdUzZJz4rcn/vgsLQhsyK3RZev0Zp5jqIkXs0lppqJUsnO3 G/7JIoJA0f/DztCiyY3o7jTGtpPSdb1IuX9jqgj4g0NcGyRtDavF5j+E0QGpfW9qcld3 7aCNdWg9QyUZzqT4GF5fS+03uAaTu7f4O1Cx3KPXnd9hlAebqotzXik9WEECHVObQGI8 C87w== 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=DSOjZQ0mpw8Fmix6YmRPzs+3MA5kVCOMFIAxxXd1b/Y=; b=Fy5uo5gsSzmFHeb55GEqMSfT9K0qqX6b2NES5RCFTXIwxr/LsWsRB8j3a59k3HQcGB Jotg4qzdCFyMcb36k+ILgd+UeGIPL3VFNtGCGP++5Ahr0XGHRV/KdCsbcckAl3aGdErE 042R5GPMuAFxDHVQ59P0vUTsPO8psPJsHjyrpfwhH7gCdWo593HujAQPkM3peP7RExGO mcreC39+10tXmbADXiDCrLvjgGNDtNXnODe9IxFWHL884C/c4aZ/Zuufl6wRWZzNEPaE KQyTbjzujyes0U3bwd+bOwYBelwyf7d3/Hn1DumE9iJQ0pLalI4/aWfjTTV7VfQPpyTn lrog== X-Gm-Message-State: AOAM532ncxX3hqkW0F9kKJIX4HCDaEjoezPPOwxII4hkSDt+eyCXU87R byF4GlIQ9/TKlFpSXg57ptUwXhUk7jBqNw== X-Google-Smtp-Source: ABdhPJwsN2+oVMcCOnro5GiYXWVT7iqNSwBAE69dEo+fk+lVr0vxH/xMEfQg8jvZzyDGAjH4a+Xfew== X-Received: by 2002:a05:622a:14ce:: with SMTP id u14mr34474787qtx.141.1635851270048; Tue, 02 Nov 2021 04:07:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/60] linux-user/host/mips: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:54 -0400 Message-Id: <20211102110740.215699-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854323845100001 Split host_signal_pc and host_signal_write out of user-exec.c. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/host/mips/host-signal.h | 63 +++++++++++++++++++++++++++++- accel/tcg/user-exec.c | 52 +----------------------- 2 files changed, 63 insertions(+), 52 deletions(-) diff --git a/linux-user/host/mips/host-signal.h b/linux-user/host/mips/host= -signal.h index f4b4d65031..ef341f7c20 100644 --- a/linux-user/host/mips/host-signal.h +++ b/linux-user/host/mips/host-signal.h @@ -1 +1,62 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef MIPS_HOST_SIGNAL_H +#define MIPS_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.pc; +} + +#if defined(__misp16) || defined(__mips_micromips) +#error "Unsupported encoding" +#endif + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); + + /* Detect all store instructions at program counter. */ + switch ((insn >> 26) & 077) { + case 050: /* SB */ + case 051: /* SH */ + case 052: /* SWL */ + case 053: /* SW */ + case 054: /* SDL */ + case 055: /* SDR */ + case 056: /* SWR */ + case 070: /* SC */ + case 071: /* SWC1 */ + case 074: /* SCD */ + case 075: /* SDC1 */ + case 077: /* SD */ +#if !defined(__mips_isa_rev) || __mips_isa_rev < 6 + case 072: /* SWC2 */ + case 076: /* SDC2 */ +#endif + return true; + case 023: /* COP1X */ + /* + * Required in all versions of MIPS64 since + * MIPS64r1 and subsequent versions of MIPS32r2. + */ + switch (insn & 077) { + case 010: /* SWXC1 */ + case 011: /* SDXC1 */ + case 015: /* SUXC1 */ + return true; + } + break; + } + return false; +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index f18f3b2a5c..44c83acba5 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -253,57 +253,7 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__mips__) - -#if defined(__misp16) || defined(__mips_micromips) -#error "Unsupported encoding" -#endif - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - uintptr_t pc =3D uc->uc_mcontext.pc; - uint32_t insn =3D *(uint32_t *)pc; - int is_write =3D 0; - - /* Detect all store instructions at program counter. */ - switch((insn >> 26) & 077) { - case 050: /* SB */ - case 051: /* SH */ - case 052: /* SWL */ - case 053: /* SW */ - case 054: /* SDL */ - case 055: /* SDR */ - case 056: /* SWR */ - case 070: /* SC */ - case 071: /* SWC1 */ - case 074: /* SCD */ - case 075: /* SDC1 */ - case 077: /* SD */ -#if !defined(__mips_isa_rev) || __mips_isa_rev < 6 - case 072: /* SWC2 */ - case 076: /* SDC2 */ -#endif - is_write =3D 1; - break; - case 023: /* COP1X */ - /* Required in all versions of MIPS64 since - MIPS64r1 and subsequent versions of MIPS32r2. */ - switch (insn & 077) { - case 010: /* SWXC1 */ - case 011: /* SDXC1 */ - case 015: /* SUXC1 */ - is_write =3D 1; - } - break; - } - - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} - -#elif defined(__riscv) +#if defined(__riscv) =20 int cpu_signal_handler(int host_signum, void *pinfo, void *puc) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851633807412.81194646571635; Tue, 2 Nov 2021 04:13:53 -0700 (PDT) Received: from localhost ([::1]:59010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrjk-0004c5-Ia for importer@patchew.org; Tue, 02 Nov 2021 07:13:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhre3-0003kB-Kr for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:01 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:45785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdx-0000uH-5c for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:56 -0400 Received: by mail-qt1-x830.google.com with SMTP id r2so17167958qtw.12 for ; Tue, 02 Nov 2021 04:07:51 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:50 -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=nso+AlCV/s0wqCbT6fU5+I4rw6sZu+GDtrLSeOTW3Gg=; b=l3DPIXJYayE1PsikeaA0ecsAA8UAbKdyyQWvxbh2JnCxk2DeDTimnjReUg9jlQzLxw nMvSYdXqKd7iSWLROfYx38yX3YtXAxpvtz9eYWEivLU6EbunYRYsV32I2qi7Kpnfx7Gr EG2JArD8AmtJG54JEdfj4NwfzAG4ShRYj+yc1UaNfAl3lyUHPuSAD++d4N4NPnyTdAIA YiKUc0NsvRaJwBh8NgrSoZxtZNuLxPlAFe+Y3bRWYn1hnSDxuke0x6qWnuywhdU7fM3j YzvCy8XeuGue16H2cEY3murbmhd4VSfV06/tsrUyr+/xP6HPCbx/lI1Dak9yDVrPk9AD ugeA== 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=nso+AlCV/s0wqCbT6fU5+I4rw6sZu+GDtrLSeOTW3Gg=; b=w/W0qQf0ZzdJjPxFmki9PL3H88Zd5GIzK8OYtuZnwEB1m8aMwzzRPpoJ+JnEXHy63Z JZnSCLs3R9jgi8x8H16/8Y5YtEiOLnS1i1npgv0uLFgtyDXeZyfAftyg9R/pAczCvaC6 G9+SyqsdYk8aplhjEUIcGpDgqFwYTjWvOjse75Ne7kNo7SzBGjZga12CdpVUz2YcLvGq euIYwDaE6C5iVERhdglBKOspXJEP1mD2qprws0CtVI090MTDLd6hB5bMpM44vj2y3Y/l 8WVNTvHvx13jkQq/kJW1uWqolTNKC4bVGPvVctdmgd7W4Y2vNWh5HoYj/azD+j4hfdQT JM3w== X-Gm-Message-State: AOAM53378hqsFPXOoScnJZDgKcRF1YfCVvSPuuOae2qIS3m6LvqrxWnJ hrLOxaKejwo/uqP7632zibB8LZ8QpUeDjw== X-Google-Smtp-Source: ABdhPJzk2l1W5SemUadnGSwO1vqOw8xIXZq4kVo82bEfGAZd2uNv4QQIqPT1UeE19ssOAmPTSwH9kw== X-Received: by 2002:a05:622a:1716:: with SMTP id h22mr16410369qtk.224.1635851270626; Tue, 02 Nov 2021 04:07:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/60] linux-user/host/riscv: Populate host_signal.h Date: Tue, 2 Nov 2021 07:06:55 -0400 Message-Id: <20211102110740.215699-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635851635983100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Reviewed-by: Warner Losh Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- linux-user/host/riscv/host-signal.h | 86 +++++++++++++++++- accel/tcg/user-exec.c | 134 ---------------------------- 2 files changed, 85 insertions(+), 135 deletions(-) diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/ho= st-signal.h index f4b4d65031..df145b1527 100644 --- a/linux-user/host/riscv/host-signal.h +++ b/linux-user/host/riscv/host-signal.h @@ -1 +1,85 @@ -#define HOST_SIGNAL_PLACEHOLDER +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef RISCV_HOST_SIGNAL_H +#define RISCV_HOST_SIGNAL_H + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.__gregs[REG_PC]; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); + + /* + * Detect store by reading the instruction at the program + * counter. Note: we currently only generate 32-bit + * instructions so we thus only detect 32-bit stores + */ + switch (((insn >> 0) & 0b11)) { + case 3: + switch (((insn >> 2) & 0b11111)) { + case 8: + switch (((insn >> 12) & 0b111)) { + case 0: /* sb */ + case 1: /* sh */ + case 2: /* sw */ + case 3: /* sd */ + case 4: /* sq */ + return true; + default: + break; + } + break; + case 9: + switch (((insn >> 12) & 0b111)) { + case 2: /* fsw */ + case 3: /* fsd */ + case 4: /* fsq */ + return true; + default: + break; + } + break; + default: + break; + } + } + + /* Check for compressed instructions */ + switch (((insn >> 13) & 0b111)) { + case 7: + switch (insn & 0b11) { + case 0: /*c.sd */ + case 2: /* c.sdsp */ + return true; + default: + break; + } + break; + case 6: + switch (insn & 0b11) { + case 0: /* c.sw */ + case 3: /* c.swsp */ + return true; + default: + break; + } + break; + default: + break; + } + + return false; +} + +#endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 44c83acba5..a0cba61e83 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -137,64 +137,6 @@ bool handle_sigsegv_accerr_write(CPUState *cpu, sigset= _t *old_set, } } =20 -/* - * 'pc' is the host PC at which the exception was raised. - * 'address' is the effective address of the memory exception. - * 'is_write' is 1 if a write caused the exception and otherwise 0. - * 'old_set' is the signal set which should be restored. - */ -static inline int handle_cpu_signal(uintptr_t pc, siginfo_t *info, - int is_write, sigset_t *old_set) -{ - CPUState *cpu =3D current_cpu; - CPUClass *cc; - unsigned long host_addr =3D (unsigned long)info->si_addr; - MMUAccessType access_type =3D adjust_signal_pc(&pc, is_write); - abi_ptr guest_addr; - - /* For synchronous signals we expect to be coming from the vCPU - * thread (so current_cpu should be valid) and either from running - * code or during translation which can fault as we cross pages. - * - * If neither is true then something has gone wrong and we should - * abort rather than try and restart the vCPU execution. - */ - if (!cpu || !cpu->running) { - printf("qemu:%s received signal outside vCPU context @ pc=3D0x%" - PRIxPTR "\n", __func__, pc); - abort(); - } - -#if defined(DEBUG_SIGNAL) - printf("qemu: SIGSEGV pc=3D0x%08lx address=3D%08lx w=3D%d oldset=3D0x%= 08lx\n", - pc, host_addr, is_write, *(unsigned long *)old_set); -#endif - - /* Convert forcefully to guest address space, invalid addresses - are still valid segv ones */ - guest_addr =3D h2g_nocheck(host_addr); - - /* XXX: locking issue */ - if (is_write && - info->si_signo =3D=3D SIGSEGV && - info->si_code =3D=3D SEGV_ACCERR && - h2g_valid(host_addr) && - handle_sigsegv_accerr_write(cpu, old_set, pc, guest_addr)) { - return 1; - } - - /* - * There is no way the target can handle this other than raising - * an exception. Undo signal and retaddr state prior to longjmp. - */ - sigprocmask(SIG_SETMASK, old_set, NULL); - - cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops->tlb_fill(cpu, guest_addr, 0, access_type, - MMU_USER_IDX, false, pc); - g_assert_not_reached(); -} - static int probe_access_internal(CPUArchState *env, target_ulong addr, int fault_size, MMUAccessType access_type, bool nonfault, uintptr_t ra) @@ -253,82 +195,6 @@ void *probe_access(CPUArchState *env, target_ulong add= r, int size, return size ? g2h(env_cpu(env), addr) : NULL; } =20 -#if defined(__riscv) - -int cpu_signal_handler(int host_signum, void *pinfo, - void *puc) -{ - siginfo_t *info =3D pinfo; - ucontext_t *uc =3D puc; - greg_t pc =3D uc->uc_mcontext.__gregs[REG_PC]; - uint32_t insn =3D *(uint32_t *)pc; - int is_write =3D 0; - - /* Detect store by reading the instruction at the program - counter. Note: we currently only generate 32-bit - instructions so we thus only detect 32-bit stores */ - switch (((insn >> 0) & 0b11)) { - case 3: - switch (((insn >> 2) & 0b11111)) { - case 8: - switch (((insn >> 12) & 0b111)) { - case 0: /* sb */ - case 1: /* sh */ - case 2: /* sw */ - case 3: /* sd */ - case 4: /* sq */ - is_write =3D 1; - break; - default: - break; - } - break; - case 9: - switch (((insn >> 12) & 0b111)) { - case 2: /* fsw */ - case 3: /* fsd */ - case 4: /* fsq */ - is_write =3D 1; - break; - default: - break; - } - break; - default: - break; - } - } - - /* Check for compressed instructions */ - switch (((insn >> 13) & 0b111)) { - case 7: - switch (insn & 0b11) { - case 0: /*c.sd */ - case 2: /* c.sdsp */ - is_write =3D 1; - break; - default: - break; - } - break; - case 6: - switch (insn & 0b11) { - case 0: /* c.sw */ - case 3: /* c.swsp */ - is_write =3D 1; - break; - default: - break; - } - break; - default: - break; - } - - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); -} -#endif - /* The softmmu versions of these helpers are in cputlb.c. */ =20 /* --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852739945886.3929853847122; Tue, 2 Nov 2021 04:32:19 -0700 (PDT) Received: from localhost ([::1]:58372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs1a-0000oW-VT for importer@patchew.org; Tue, 02 Nov 2021 07:32:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreG-0003rz-7Z for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:12 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:45787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre7-0000uL-Mi for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: by mail-qt1-x832.google.com with SMTP id r2so17167972qtw.12 for ; Tue, 02 Nov 2021 04:07:51 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:50 -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=gSr02Sd1ztBN32tTKGrZscSunLegESBnCl09IIG3Qgg=; b=VJ2ke1kzAkaxTS6xs2wraGABWordnhsqftp9GzImfyUYZN4tTTSfOf1XcZps4TKSWq PhMkNy9o1u9Ghhx2Fqkx+Msn9J0nh9sApO83ftl/wmvhPfLELB9mTVH6tjVOxxIRwGw8 4SzDmuq3VWvUAd2hlMwFQ/COcG6J07YLcgpMkeG1tP10VQCvLJn4rc5wu93hwcaAIijZ 6fblbHbE2S0dqOX2crCZ73rQR3vNu3abaQ7qeQh1GbpZNbqN1zO/4Rr+hdPdKo1dv57a NRCfVp19rJvQW4AJRwKZZ5v8+7a28pcbk9iXnMNeTkZdzPb3abH4L0VX3GBaAsm+jgvI S5bA== 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=gSr02Sd1ztBN32tTKGrZscSunLegESBnCl09IIG3Qgg=; b=p0Wnd85U2TatbVqf1fwaHp8Ood0Ut/jvdNZZ41mUhsd1oabN6L32hRUnlE/2qyuOkB h8WZ8rhxZ3fG/S/Ln7SYUEaa+mHp2BrHq8VOVls0TOgwIOhfvn6sYL99gHZctfs/Hjov do4WxedB+gX5ujm82f/vmSriQ2wIws3o1rsJyewfSAQx7/R0NUI2QLC6JcbwCWtrW53M n9qKn7BD7NZ38h3UD7JsV9cw+TR2VnHFECC2J3M5zwwL0Oo3moQrubbOrmTppVjcRJCh NlHmBfR6Tb1vSrgsCTQkzcoT9aPDvn5UkBypeBWv21/J0XAXN4Gyy6kqnXPYSbLdoTS0 O/oA== X-Gm-Message-State: AOAM531MdGRLYc85JBzWk34HPx5/JbE88jo1NKW5mf57zgJiJsaIOgXa Y830U2AWOU/IjtbpsWITbGx9l1YLcs6A5Q== X-Google-Smtp-Source: ABdhPJyrDRoK5DkUAhcei9ESdmItjl3ibww2MkFut4UBA8tOnDKAYtnWv9I8G4aAP/nEZG+HNOM6Jw== X-Received: by 2002:a05:622a:1301:: with SMTP id v1mr12236710qtk.119.1635851271204; Tue, 02 Nov 2021 04:07:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/60] target/arm: Fixup comment re handle_cpu_signal Date: Tue, 2 Nov 2021 07:06:56 -0400 Message-Id: <20211102110740.215699-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852741000100001 The named function no longer exists. Refer to host_signal_handler instead. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/sve_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index dab5f1d1cd..07be55b7e1 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -6118,7 +6118,7 @@ DO_LDN_2(4, dd, MO_64) * linux-user/ in its get_user/put_user macros. * * TODO: Construct some helpers, written in assembly, that interact with - * handle_cpu_signal to produce memory ops which can properly report errors + * host_signal_handler to produce memory ops which can properly report err= ors * without racing. */ =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852586; cv=none; d=zohomail.com; s=zohoarc; b=IiHHKP0fgYs/FtCk5ux1K+gbKhcZ7IJK4WPMUdTbDRQcJZ60goqM00yQgdq2/3T4jgTTcjyroGf86wQ3d8mxu/bnm0HMl7BH/pAJYRFdJT4XTPAEFbZTfCs4xkm7+tzPXMqQZUF2br5RB0dZELG0wR9wpTMg4cpM4l6byBAjIFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852586; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aVqSiCZ8VIDZCZNfC7lcfLdqkY20k4N+WRPXdiuKsNc=; b=JWdl2u6ycTNh5pegfjyJOLtNdWHWlO3Sm6j1sexb/FmS4YfTG5YkYwrvNU3tPwGaKJa2W/LOYMYyPXt9uj5WvXoGpGrnOPFizuTnpFYEFfcy3JDhNOeVi8j5t6HoX/4DwNRIoKzMV8F0fLaPpufh39hMDXkSIQ+YFJKuhQ/3gAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852586646312.0370345581305; Tue, 2 Nov 2021 04:29:46 -0700 (PDT) Received: from localhost ([::1]:49356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrz7-00030L-EC for importer@patchew.org; Tue, 02 Nov 2021 07:29:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhre3-0003kC-LE for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:01 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:44738) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdx-0000ub-SL for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:57 -0400 Received: by mail-qt1-x831.google.com with SMTP id j1so11231364qtq.11 for ; Tue, 02 Nov 2021 04:07:52 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:51 -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=aVqSiCZ8VIDZCZNfC7lcfLdqkY20k4N+WRPXdiuKsNc=; b=vwCWarHqA2Ijem+Zxi+VVu0pdgqTICc/pHNWdL1rnd9qDyUvnF5wDJUIMSLj249RW/ DnWXAnmnPTeu6BfLBQJoRARIYZv5enPNKVFpPMlcoNxoCqh1xAwiuoiIJQW6Tt6WpWfC S9a3pXvFdEC00R9wIKmUdto6pM2fhMYrtJQRJuJF33+BUUUIdxc4uMydVM53n6JHQoil QLYrwCKTgjMnRhXLHCpnsw+ZzGkgeZ0LVwYYzOAgiwuYp6vqtyAE/ELKolcT7uhfAMZ9 3Yv6RkXn4ZftpEWW8vW6k1AIAexqOACNBPK3JiQY0hLUZrr4DWf5Y6+T82fCOXR62UcO exWA== 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=aVqSiCZ8VIDZCZNfC7lcfLdqkY20k4N+WRPXdiuKsNc=; b=AMPd/tIDGCqSy8gDl92BrKzPN2d3+gDYzL9MCvoxbqBTm1qjjAiBom6GGDZtWZD9Ps MjB42hKPTMr/b28KVt4/uRiJz3u4mlCl0nxLRIxBIUMDJOoptU5fAa45nTKk2aetkHCe yhSZKTUz9d2u+jLrvGHYpqTxqPO7OqznlqhSLStPKg9zzxif498W1SgxtOHUIqbkx7W1 CTJEBgIEwSqr06V/F9+Ei8sDMA83htIHlYHgqiCmIB/GEM1dLgem0vhadZOTpWP1x4KG 33x8jgJlRe/6pGBh7BPWnh27HKgR/bcPGEHQ1Zn8y2dk6prpQ7x0gx3aHAT2rGin16Pg zdPQ== X-Gm-Message-State: AOAM532efNAXhsHnPw3RmlfRBgopoiqU9Z6ZiPggCq0N7pW/UsBn3uJF TlQCFxA2cszr2ZWHbpKMwFE/uB9EBkfQ3Q== X-Google-Smtp-Source: ABdhPJxTpVHDPiskai7Vq1TYA3CmF+F2pMrA2KzHpBlhcJo8Yib4OBSQnhsnWcu5oALsblmLi6opXw== X-Received: by 2002:ac8:588d:: with SMTP id t13mr37586638qta.179.1635851271731; Tue, 02 Nov 2021 04:07:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 17/60] linux-user/host/riscv: Improve host_signal_write Date: Tue, 2 Nov 2021 07:06:57 -0400 Message-Id: <20211102110740.215699-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::831; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x831.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852587199100001 Content-Type: text/plain; charset="utf-8" Do not read 4 bytes before we determine the size of the insn. Simplify triple switches in favor of checking major opcodes. Include the missing cases of compact fsd and fsdsp. Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- linux-user/host/riscv/host-signal.h | 83 ++++++++++------------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/ho= st-signal.h index df145b1527..3b168cb58b 100644 --- a/linux-user/host/riscv/host-signal.h +++ b/linux-user/host/riscv/host-signal.h @@ -18,65 +18,38 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) =20 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { - uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); - /* - * Detect store by reading the instruction at the program - * counter. Note: we currently only generate 32-bit - * instructions so we thus only detect 32-bit stores + * Detect store by reading the instruction at the program counter. + * Do not read more than 16 bits, because we have not yet determined + * the size of the instruction. */ - switch (((insn >> 0) & 0b11)) { - case 3: - switch (((insn >> 2) & 0b11111)) { - case 8: - switch (((insn >> 12) & 0b111)) { - case 0: /* sb */ - case 1: /* sh */ - case 2: /* sw */ - case 3: /* sd */ - case 4: /* sq */ - return true; - default: - break; - } - break; - case 9: - switch (((insn >> 12) & 0b111)) { - case 2: /* fsw */ - case 3: /* fsd */ - case 4: /* fsq */ - return true; - default: - break; - } - break; - default: - break; - } + const uint16_t *pinsn =3D (const uint16_t *)host_signal_pc(uc); + uint16_t insn =3D pinsn[0]; + + /* 16-bit instructions */ + switch (insn & 0xe003) { + case 0xa000: /* c.fsd */ + case 0xc000: /* c.sw */ + case 0xe000: /* c.sd (rv64) / c.fsw (rv32) */ + case 0xa002: /* c.fsdsp */ + case 0xc002: /* c.swsp */ + case 0xe002: /* c.sdsp (rv64) / c.fswsp (rv32) */ + return true; } =20 - /* Check for compressed instructions */ - switch (((insn >> 13) & 0b111)) { - case 7: - switch (insn & 0b11) { - case 0: /*c.sd */ - case 2: /* c.sdsp */ - return true; - default: - break; - } - break; - case 6: - switch (insn & 0b11) { - case 0: /* c.sw */ - case 3: /* c.swsp */ - return true; - default: - break; - } - break; - default: - break; + /* 32-bit instructions, major opcodes */ + switch (insn & 0x7f) { + case 0x23: /* store */ + case 0x27: /* store-fp */ + return true; + case 0x2f: /* amo */ + /* + * The AMO function code is in bits 25-31, unread as yet. + * The AMO functions are LR (read), SC (write), and the + * rest are all read-modify-write. + */ + insn =3D pinsn[1]; + return (insn >> 11) !=3D 2; /* LR */ } =20 return false; --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852857; cv=none; d=zohomail.com; s=zohoarc; b=j225SPTrUgzEwBNQerh4WGpq+gcDfU6N7sr92ldcGkP0AhmAIeWUimI7bO4jIxiftxlFPzQ65C22K/UoaH09EzGSK4wqNQ6S0MzBq0wxIKSZq/uqBey0jqOFKUj+rCmrM/HEGODJEVbfuWYuEWmcc4GJyIzsUyW6l+NP2QRAb5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852857; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BEoOYfyvrRlliP3CVpcV5+AEGq6qhapGY3bb4mVGTHg=; b=hmVmWA3kbcnH/b3PPZ+XXUPiIobkzzHB4ycaO8TV9cFqJOtLLFnUKeuJMAMR394ZVN566QJ5r9GxrKWJtD/9I3ej3GnOIGY8vjXZMZbzBcGCf4o/+J9LGCEfPuooYZI9B9MAc1GZciOJE9kjcJNaYcbWu+09qAoBMqvqqgKewEk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852857176541.2137894186754; Tue, 2 Nov 2021 04:34:17 -0700 (PDT) Received: from localhost ([::1]:36874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs3U-0005EA-62 for importer@patchew.org; Tue, 02 Nov 2021 07:34:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreB-0003nX-Pk for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:07 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:33501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre0-0000uh-FR for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: by mail-qt1-x82f.google.com with SMTP id h16so14036787qtk.0 for ; Tue, 02 Nov 2021 04:07:52 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:52 -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=BEoOYfyvrRlliP3CVpcV5+AEGq6qhapGY3bb4mVGTHg=; b=FFU5BWwwGn+SsA3IB4vNCzUdtUYaH0vC37mTtTDE7fKYg7Vj85GKmaC3li9IdC82Iu zZpTwehtziNiC3M204qllouO0Rfs7/7siHsSLO14Sh0p45VA/D3nIHx/q7btNxYCs6Yv V2eEHVsCtvqu/Doepmp7+/92IwwnicaIruWv/IHd7V1XSalkLvFqZjaD3Wre3snw6BfT jOCLmY6H2ZH0ZT8zpS8fFaqgRuz6y8ZM8Tryq2crHjJ4+3qr5URf17uAT/2zAoQGlNZn /G3XIKV5cjaG9s0lY6cNE/dHfri2P5i8HbLH0UcnPNwcNLKo6LLwyl/7Ajdnv5a8WxaE NOhg== 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=BEoOYfyvrRlliP3CVpcV5+AEGq6qhapGY3bb4mVGTHg=; b=s0T5oViLYV0DbRZUjha9FQNoOEi/BO83E2Z1ntcrVxKNIaNusrLmp0VrQUOUis2bUb 80jegQf04EqYBe0PBI3S1j/xqHeIvTqoOG23D0iBHwMBRy80oETSOoLid76CTbPrw9vm x1U54RZUc2qA5H5TNTaZmx7RX3ufma+xj90qG16VpNiBv2ARqEfsSkxZ/JCECcWNpNcP SQmBuoc30DPTXZfw5W93MqNMxVzInCpya/KneJ1Zxy/kllNbU1oPiSqpfIDzRoaaL4mv QWCFdok9smkeL1ANMQrO1D5zcRnTl3zLULzNoDo0Txy+wvuxTtFuo8SaNCMC4Mn+aU+s vopw== X-Gm-Message-State: AOAM530ATzwjk0iUGH7yHWD8Ep8MBwRvo1r/xwBvHafoMGxulXSlkE5H BCH3yK1w++8O7Rfllvj000M1IYWdtCaw7Q== X-Google-Smtp-Source: ABdhPJzqxYeWXxlrQlMvtg/Yia39lDCqTxGKfiZ9jgJhbrCBTaBiFYWwbCTMQ9uG7MaUnvS1hXwqXQ== X-Received: by 2002:a05:622a:346:: with SMTP id r6mr37424173qtw.0.1635851272330; Tue, 02 Nov 2021 04:07:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/60] linux-user/signal: Drop HOST_SIGNAL_PLACEHOLDER Date: Tue, 2 Nov 2021 07:06:58 -0400 Message-Id: <20211102110740.215699-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852857623100003 Now that all of the linux-user hosts have been converted to host-signal.h, drop the compatibility code. Reviewed by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 12 ------------ linux-user/signal.c | 14 -------------- 2 files changed, 26 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 5f94d799aa..5dd663c153 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -685,18 +685,6 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_= write); bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, uintptr_t host_pc, abi_ptr guest_addr); =20 -/** - * cpu_signal_handler - * @signum: host signal number - * @pinfo: host siginfo_t - * @puc: host ucontext_t - * - * To be called from the SIGBUS and SIGSEGV signal handler to inform the - * virtual cpu of exceptions. Returns true if the signal was handled by - * the virtual CPU. - */ -int cpu_signal_handler(int signum, void *pinfo, void *puc); - #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} diff --git a/linux-user/signal.c b/linux-user/signal.c index 6900acb122..b816678ba5 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -780,17 +780,6 @@ static void host_signal_handler(int host_sig, siginfo_= t *info, void *puc) ucontext_t *uc =3D puc; struct emulated_sigtable *k; int guest_sig; - -#ifdef HOST_SIGNAL_PLACEHOLDER - /* the CPU emulator uses some host signals to detect exceptions, - we forward to it some signals */ - if ((host_sig =3D=3D SIGSEGV || host_sig =3D=3D SIGBUS) - && info->si_code > 0) { - if (cpu_signal_handler(host_sig, info, puc)) { - return; - } - } -#else uintptr_t pc =3D 0; bool sync_sig =3D false; =20 @@ -850,7 +839,6 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) =20 sync_sig =3D true; } -#endif =20 /* get target signal number */ guest_sig =3D host_to_target_signal(host_sig); @@ -865,7 +853,6 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) k->pending =3D guest_sig; ts->signal_pending =3D 1; =20 -#ifndef HOST_SIGNAL_PLACEHOLDER /* * For synchronous signals, unwind the cpu state to the faulting * insn and then exit back to the main loop so that the signal @@ -875,7 +862,6 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) cpu->exception_index =3D EXCP_INTERRUPT; cpu_loop_exit_restore(cpu, pc); } -#endif =20 rewind_if_in_safe_syscall(puc); =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635851431; cv=none; d=zohomail.com; s=zohoarc; b=jMwV0JoF5R11fUq27K2eNE+iAOil5qwMxWzb1xLVgGIiCujThpJFbOj4tkUVUljJ510Uy6RcU+kI8kykI9+HsvYUHXTOA0Mq+90Q2j14/8ZkH3nO0jQHuIrNCiICGXe/mA4r0jgNiyIDSBEFihM2lM5DuFpuOVuRpiWVXQob8As= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635851431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p8GaNWW3vnRejpH0QBiQY2hh87QfB4bhIFphc+bCE2U=; b=NEvWlAyLHzndZkXbEByiNYYuhnT0SDHNug+OJ2t2+89ckbWvZX5E5SF4RUlP4l6WqQErLt8B9cEyanLcnYeSSZ7aB4xd9zAm6ldOfHc74dqyVEHpjbYz7maC7WR2Eivai0Scwq0yetaD0jFVRAseqOFhb9cQKmD4Hz3gbjjka54= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851431175143.24195020836953; Tue, 2 Nov 2021 04:10:31 -0700 (PDT) Received: from localhost ([::1]:50354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrgU-0007C9-4g for importer@patchew.org; Tue, 02 Nov 2021 07:10:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreB-0003nW-QK for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:09 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:38521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0000ul-IX for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: by mail-qt1-x833.google.com with SMTP id h4so17862350qth.5 for ; Tue, 02 Nov 2021 04:07:53 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:52 -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=p8GaNWW3vnRejpH0QBiQY2hh87QfB4bhIFphc+bCE2U=; b=ndx+nxGalQGcx8gHIpf2cIhBhNdI6xfbGIUmrVsQcDzUHYzmvh/tkR72RWjIzni/Z6 GVElS6F93n9qABUq7aeF6B25hAgM2paxRbdDEHuz8YfhJuHF+f/5ulBsMmXnMMUuzwXt IoiV02rTxend6uO0+8NUmsMj9xkDR03EsSz1lUhXAjkR31Q0hWqRckLey3uyOZ9el+9H wZ0zFL+tXi86iGXYtLIO4dZ92xTKk1HUGJH74rgXlwdR6LoKanXxuv3Gd5pCxbFtN1FY HD1JChHVRsMOHO6F8t9Kydt06VJxbpu336/oykXBUos9bc1Toa4mK1ugzXTECpATjq9B fKrw== 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=p8GaNWW3vnRejpH0QBiQY2hh87QfB4bhIFphc+bCE2U=; b=LfEaVHjbzd3N7HAREdO3VuTW/y6IbEadh8ekfPtTVhQfFk7CCgMllxSerpSp+d2HWu aI2HTfNW4mLkezo8TKiQPzUpVuFHMSfFA+SwOPfHLJbktcBEBxyciKuEDT8c3fhGWU7u D8ltprh1BDfzxCmzxkvI52Iu7A+0ML5o75C/b/IUdx6F6CcdA0fH99gAJvg5X6oXcknQ 7Xo+AT4Xsp17Wp9MdBzC3VSoMoJGEQUHSd3jwoMaaHrRMZ4uUks6DjUdzbCJbGiMcRtp 44qm1H1gBCETmhPs8xuaP/Nbb3qxIjzOfqHRTO9E8JIxaA01B4L0N9B+6rPXPKqvHlF1 VDAQ== X-Gm-Message-State: AOAM531ujBYT3FYz060rOQCjMyw2eqpgLluloRTlKW/rsUlvHsVNeNe3 FATajBitFvS2d2LsqQvoZEzXbjsTw/3pUg== X-Google-Smtp-Source: ABdhPJyErmMcWZfB8WqoUtjtTWWgZMS9JiTWZqZCq6r4lcZEay1JosDD9m0d6LVqrWgV0Ofd+bThrg== X-Received: by 2002:ac8:5dc6:: with SMTP id e6mr37116541qtx.174.1635851272809; Tue, 02 Nov 2021 04:07:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/60] hw/core: Add TCGCPUOps.record_sigsegv Date: Tue, 2 Nov 2021 07:06:59 -0400 Message-Id: <20211102110740.215699-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635851431843100001 Add a new user-only interface for updating cpu state before raising a signal. This will replace tlb_fill for user-only and should result in less boilerplate for each guest. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 6cbe17f2e6..41718b695b 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -111,6 +111,32 @@ struct TCGCPUOps { */ bool (*io_recompile_replay_branch)(CPUState *cpu, const TranslationBlock *tb); +#else + /** + * record_sigsegv: + * @cpu: cpu context + * @addr: faulting guest address + * @access_type: access was read/write/execute + * @maperr: true for invalid page, false for permission fault + * @ra: host pc for unwinding + * + * We are about to raise SIGSEGV with si_code set for @maperr, + * and si_addr set for @addr. Record anything further needed + * for the signal ucontext_t. + * + * If the emulated kernel does not provide anything to the signal + * handler with anything besides the user context registers, and + * the siginfo_t, then this hook need do nothing and may be omitted. + * Otherwise, record the data and return; the caller will raise + * the signal, unwind the cpu state, and return to the main loop. + * + * If it is simpler to re-use the sysemu tlb_fill code, @ra is provided + * so that a "normal" cpu exception can be raised. In this case, + * the signal must be raised by the architecture cpu_loop. + */ + void (*record_sigsegv)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852710; cv=none; d=zohomail.com; s=zohoarc; b=A9bRf1ZEwm2TcmLe8xW75z+a5BC9ZmkeT7QMplvdmnmaCpptHSJ4z3cBTAbpBKiRgP8seEvfn9yNG0ulksDlfRoEao3eVrDsUUCdJepc3y83gWfOiD9TuOcxURCdpQJq8CLElubg68giS1oURXsfjghhNHgrovbpR2+he9CLr7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852710; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h74jAt7hxYWJ8vb//ZptaTN1DfaIP6MJ1JsKHfl8Ic0=; b=J1ylMtBJw/UZWin355LB6vBnMDAPHnVN6ZRYKTqFDKyqFhHKr0vmAIb3Ko7F80y7jo/GXPzs0q9EXzWv4obmfHk/Sj5mFBeANzK0q3lvaVcmtrWnCDIMXqtAJVR+TYblL2c5V3KT8F6clATQjBN/RFbJz9hUTiTDPo9OD2M9Wvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852710474899.2275852793332; Tue, 2 Nov 2021 04:31:50 -0700 (PDT) Received: from localhost ([::1]:56458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs16-0007vF-5w for importer@patchew.org; Tue, 02 Nov 2021 07:31:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreB-0003nV-OD for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:07 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:38639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0000uv-Hn for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: by mail-qk1-x732.google.com with SMTP id bi29so19207636qkb.5 for ; Tue, 02 Nov 2021 04:07:53 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:53 -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=h74jAt7hxYWJ8vb//ZptaTN1DfaIP6MJ1JsKHfl8Ic0=; b=BZWt8kLBePsFpxw8g79nSKzp6BLk5ZhJztL5mVP3ZGLkJwLRWyRFU8gfgtBEeOts4L w+thPrkljJd/mi6sVVMXKFoZ6OZv/yX/PLoepkfxEerX2+c8vPq7wwigK4TBjNYzKraI bK0vqucqAqi9wVW63DGACU+lpJyfgq/d1vTzE1ArhLA9s/KJiJnOS5O3TddJy5AAtzEq OuZdsFpb6gjxdxbK+EJ0Pmscug26nNZ96NGLGky9Y5JzE32zNJv8K/vXsjC8mWV6N/tQ 9OnmbhHVskd4PYBEpV7lS0VrRENGxxMRzTuVkGU6lfOKcMV8rVH1wrBX0GeI4yKF5A1j FCfg== 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=h74jAt7hxYWJ8vb//ZptaTN1DfaIP6MJ1JsKHfl8Ic0=; b=AosfJlDKtGSRnzkncgIFPCmg8w8I0mKoHMQCFLEXY67hIdCSOrGxM8G2gYjDSFBgGk Mhv/Cv3aYOG06csyBIQVu6IvXTSgUrIJcW8KbnHeu7Ol1o0EpmxF6H9mdxlzgg0v/RYV lQ+gckeECLADo1edv/5glpnYEQmeTayyXPWIYuJYQRP6T/7ynCjKB5qZnxVjR94PcTtt jRIIya/rxc92+s2s6aj9nLSQ321HKrh+HrhlTEyHs6IrlOKtfUsmhEb211AoZA2OjgtU a3fLLjjnJQXsfySWRYvnEThxhC1pTkbyhk0SxCMrSMeraQFdnc8NjZCDPn9Ov533p6fm OlvQ== X-Gm-Message-State: AOAM531WmHI+NpciZ9C79qJ3CJKAreU3C5NL7riNLzCLm5XKXUQJQuXA gMXIcsMRddaxFvBwlV/6d4zJEzoVrEMywg== X-Google-Smtp-Source: ABdhPJwvbopvusDaafZ0PO6Ob5BeEiFE+qG5EfxdtvAM3n5lqblV7WtJaAQGq4+vVyeHcsgEfgYtbg== X-Received: by 2002:a05:620a:2808:: with SMTP id f8mr6816341qkp.434.1635851273327; Tue, 02 Nov 2021 04:07:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/60] linux-user: Add cpu_loop_exit_sigsegv Date: Tue, 2 Nov 2021 07:07:00 -0400 Message-Id: <20211102110740.215699-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852711275100001 This is a new interface to be provided by the os emulator for raising SIGSEGV on fault. Use the new record_sigsegv target hook. Reviewed by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 15 +++++++++++++++ accel/tcg/user-exec.c | 33 ++++++++++++++++++--------------- linux-user/signal.c | 30 ++++++++++++++++++++++-------- 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 5dd663c153..f74578500c 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -685,6 +685,21 @@ MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_= write); bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, uintptr_t host_pc, abi_ptr guest_addr); =20 +/** + * cpu_loop_exit_sigsegv: + * @cpu: the cpu context + * @addr: the guest address of the fault + * @access_type: access was read/write/execute + * @maperr: true for invalid page, false for permission fault + * @ra: host pc for unwinding + * + * Use the TCGCPUOps hook to record cpu state, do guest operating system + * specific things to raise SIGSEGV, and jump to the main cpu loop. + */ +void QEMU_NORETURN cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); + #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index a0cba61e83..c4f69908e9 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -141,35 +141,38 @@ static int probe_access_internal(CPUArchState *env, t= arget_ulong addr, int fault_size, MMUAccessType access_type, bool nonfault, uintptr_t ra) { - int flags; + int acc_flag; + bool maperr; =20 switch (access_type) { case MMU_DATA_STORE: - flags =3D PAGE_WRITE; + acc_flag =3D PAGE_WRITE_ORG; break; case MMU_DATA_LOAD: - flags =3D PAGE_READ; + acc_flag =3D PAGE_READ; break; case MMU_INST_FETCH: - flags =3D PAGE_EXEC; + acc_flag =3D PAGE_EXEC; break; default: g_assert_not_reached(); } =20 - if (!guest_addr_valid_untagged(addr) || - page_check_range(addr, 1, flags) < 0) { - if (nonfault) { - return TLB_INVALID_MASK; - } else { - CPUState *cpu =3D env_cpu(env); - CPUClass *cc =3D CPU_GET_CLASS(cpu); - cc->tcg_ops->tlb_fill(cpu, addr, fault_size, access_type, - MMU_USER_IDX, false, ra); - g_assert_not_reached(); + if (guest_addr_valid_untagged(addr)) { + int page_flags =3D page_get_flags(addr); + if (page_flags & acc_flag) { + return 0; /* success */ } + maperr =3D !(page_flags & PAGE_VALID); + } else { + maperr =3D true; } - return 0; + + if (nonfault) { + return TLB_INVALID_MASK; + } + + cpu_loop_exit_sigsegv(env_cpu(env), addr, access_type, maperr, ra); } =20 int probe_access_flags(CPUArchState *env, target_ulong addr, diff --git a/linux-user/signal.c b/linux-user/signal.c index b816678ba5..135983747d 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -688,9 +688,27 @@ void force_sigsegv(int oldsig) } force_sig(TARGET_SIGSEGV); } - #endif =20 +void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, bool maperr, uintptr= _t ra) +{ + const struct TCGCPUOps *tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; + + if (tcg_ops->record_sigsegv) { + tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); + } else if (tcg_ops->tlb_fill) { + tcg_ops->tlb_fill(cpu, addr, 0, access_type, MMU_USER_IDX, false, = ra); + g_assert_not_reached(); + } + + force_sig_fault(TARGET_SIGSEGV, + maperr ? TARGET_SEGV_MAPERR : TARGET_SEGV_ACCERR, + addr); + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, ra); +} + /* abort execution with signal */ static void QEMU_NORETURN dump_core_and_abort(int target_sig) { @@ -806,7 +824,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) access_type =3D adjust_signal_pc(&pc, is_write); =20 if (host_sig =3D=3D SIGSEGV) { - const struct TCGCPUOps *tcg_ops; + bool maperr =3D true; =20 if (info->si_code =3D=3D SEGV_ACCERR && h2g_valid(host_addr)) { /* If this was a write to a TB protected page, restart. */ @@ -821,18 +839,14 @@ static void host_signal_handler(int host_sig, siginfo= _t *info, void *puc) * which means that we may get ACCERR when we want MAPERR. */ if (page_get_flags(guest_addr) & PAGE_VALID) { - /* maperr =3D false; */ + maperr =3D false; } else { info->si_code =3D SEGV_MAPERR; } } =20 sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); - - tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; - tcg_ops->tlb_fill(cpu, guest_addr, 0, access_type, - MMU_USER_IDX, false, pc); - g_assert_not_reached(); + cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc= ); } else { sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852595; cv=none; d=zohomail.com; s=zohoarc; b=XG0oJA6RxS7sNYWBBqhc6H6Ao/7S/ckKr8Q6vt9dRPRS1sUHfLgCriplRZBFkWAMyoE2aWN9spakW+7kvZn29N8uM5jgHkTsn6RSSOQdcar1pUurRRoW63+Ubp1C0MmsuzN+MRkQz4i5xqhCfVFcx23BHZ7iIAUpk/LRXo0WMTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852595; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AEaCX227BZE+QCVidN+9WkHpAoM/8sOPsRQn51mlr6o=; b=YXT3kR0eJAxNHb1YJGOAntpk79EXzb/4yqnB7olfV3iyDtIoEcwv/Pa7A2rpdXZlGZwl4ewjy7+GQMmHc6SZmO05VCXU0lZAx9rnVlEASieqt5+aKLwhYfEfe8whcZ8H3787q56xvuYbohOM7ckAy7JUXp3EKK1SumBz71lgnsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852595028697.1334479622469; Tue, 2 Nov 2021 04:29:55 -0700 (PDT) Received: from localhost ([::1]:49854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrzG-0003LA-0I for importer@patchew.org; Tue, 02 Nov 2021 07:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreE-0003pA-HS for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:38524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0000v2-IL for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: by mail-qt1-x836.google.com with SMTP id h4so17862384qth.5 for ; Tue, 02 Nov 2021 04:07:54 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:53 -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=AEaCX227BZE+QCVidN+9WkHpAoM/8sOPsRQn51mlr6o=; b=WvXhDJWnJVF4K6aZgPWES/CZO3QZ8CXgtc/S+xSycLa3aoVvwXlrDtqdXXeARFVe9A 9vklVeOPmC/SxEQGP69NladvRtlsEI93fxWFhmWNdh276NCqJriDHlYf4OrjV8XeSVjy tDNsHU65Dfjn3EkUKhclg8vF+Kgx84l1oqRPL4fIOUq4P86JnrBJ3FTgyYgMiZnKUYxd Dy+BmdAmJ7b+QtWw+/ynvhXcn3wXG93p+TztJGVXdeW98Vau1lP5fZgDydY5Jpnp7otf YiIvY2WICop7wSH/q2RAKxAuqZ5sGzvUzFEdofgzHzEQTzkSE/rVMhBa+kSqEsjMKnVw pSEQ== 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=AEaCX227BZE+QCVidN+9WkHpAoM/8sOPsRQn51mlr6o=; b=c7aHHLNYLifJM+wD+QMzGOet1ZU/eGGeCmM/fc4Kpk+HUuK4TAsOvYhkKapPFp01oi 5nd3XUsCP4eNriK6dJW7HnM7dxF2+LqOjd8BP8MukQyCPGwkkINyYkJhagjfOOHTJqb5 JQrVCe4uPkp15mNb3LavCKMUaIZOnNYBar1o6tVc0UlXjjPnC6bauI90YQzCscZzNnfl oGpYAKwaCUrWSWEQB1mNXZDKdE3ts2ZMtawafH1h+e0Lt4NQDmdoPW5SDwPvXJmHua+g MiWyqHB2JL/FGmnGV19XrYraeMJHUGp3ZT4r1K7xzuylE0pfSmNnoCYnzcz5CfxMaRfU huCQ== X-Gm-Message-State: AOAM532JImxXN7cuFKHCH7uYjJu0J68+fWcff3VYNrdN7+gnyp5wl3Uf ACjO5XBK4xZRnfbKwkf/KSWtKJwsNfYnVQ== X-Google-Smtp-Source: ABdhPJyJzxP8+Q34RDcENnAabP1X5R4JPlHWqimw6u5fnL0GzF/z18acaSdziClDEtAX4iL4Rv1XUw== X-Received: by 2002:a05:622a:1904:: with SMTP id w4mr18073532qtc.257.1635851273874; Tue, 02 Nov 2021 04:07:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 21/60] target/alpha: Implement alpha_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:01 -0400 Message-Id: <20211102110740.215699-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x836.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852596201100001 Record trap_arg{0,1,2} for the linux-user signal frame. Fill in the stores to trap_arg{1,2} that were missing from the previous user-only alpha_cpu_tlb_fill function. Use maperr to simplify computation of trap_arg1. Remove the code for EXCP_MMFAULT from cpu_loop, as that part is now handled by cpu_loop_exit_sigsegv. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/alpha/cpu.h | 13 +++++++++---- linux-user/alpha/cpu_loop.c | 8 -------- target/alpha/cpu.c | 6 ++++-- target/alpha/helper.c | 39 ++++++++++++++++++++++++++++++++----- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 772828cc26..d49cc36d07 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -439,9 +439,6 @@ void alpha_translate_init(void); #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU =20 void alpha_cpu_list(void); -bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int); void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t); =20 @@ -449,7 +446,15 @@ uint64_t cpu_alpha_load_fpcr (CPUAlphaState *env); void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val); uint64_t cpu_alpha_load_gr(CPUAlphaState *env, unsigned reg); void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val); -#ifndef CONFIG_USER_ONLY + +#ifdef CONFIG_USER_ONLY +void alpha_cpu_record_sigsegv(CPUState *cs, vaddr address, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr); +#else +bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index 1b00a81385..4cc8e0a55c 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -54,14 +54,6 @@ void cpu_loop(CPUAlphaState *env) fprintf(stderr, "External interrupt. Exit\n"); exit(EXIT_FAILURE); break; - case EXCP_MMFAULT: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info.si_code =3D (page_get_flags(env->trap_arg0) & PAGE_VALID - ? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR); - info._sifields._sigfault._addr =3D env->trap_arg0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_UNALIGN: info.si_signo =3D TARGET_SIGBUS; info.si_errno =3D 0; diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 93e16a2ffb..69f32c3078 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -218,9 +218,11 @@ static const struct SysemuCPUOps alpha_sysemu_ops =3D { =20 static const struct TCGCPUOps alpha_tcg_ops =3D { .initialize =3D alpha_translate_init, - .tlb_fill =3D alpha_cpu_tlb_fill, =20 -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D alpha_cpu_record_sigsegv, +#else + .tlb_fill =3D alpha_cpu_tlb_fill, .cpu_exec_interrupt =3D alpha_cpu_exec_interrupt, .do_interrupt =3D alpha_cpu_do_interrupt, .do_transaction_failed =3D alpha_cpu_do_transaction_failed, diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 81550d9e2f..b7e7f73b15 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -120,15 +120,44 @@ void cpu_alpha_store_gr(CPUAlphaState *env, unsigned = reg, uint64_t val) } =20 #if defined(CONFIG_USER_ONLY) -bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +void alpha_cpu_record_sigsegv(CPUState *cs, vaddr address, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr) { AlphaCPU *cpu =3D ALPHA_CPU(cs); + target_ulong mmcsr, cause; =20 - cs->exception_index =3D EXCP_MMFAULT; + /* Assuming !maperr, infer the missing protection. */ + switch (access_type) { + case MMU_DATA_LOAD: + mmcsr =3D MM_K_FOR; + cause =3D 0; + break; + case MMU_DATA_STORE: + mmcsr =3D MM_K_FOW; + cause =3D 1; + break; + case MMU_INST_FETCH: + mmcsr =3D MM_K_FOE; + cause =3D -1; + break; + default: + g_assert_not_reached(); + } + if (maperr) { + if (address < BIT_ULL(TARGET_VIRT_ADDR_SPACE_BITS - 1)) { + /* Userspace address, therefore page not mapped. */ + mmcsr =3D MM_K_TNV; + } else { + /* Kernel or invalid address. */ + mmcsr =3D MM_K_ACV; + } + } + + /* Record the arguments that PALcode would give to the kernel. */ cpu->env.trap_arg0 =3D address; - cpu_loop_exit_restore(cs, retaddr); + cpu->env.trap_arg1 =3D mmcsr; + cpu->env.trap_arg2 =3D cause; } #else /* Returns the OSF/1 entMM failure indication, or -1 on success. */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635851807237578.5459430542157; Tue, 2 Nov 2021 04:16:47 -0700 (PDT) Received: from localhost ([::1]:39446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrmY-0002Dj-3n for importer@patchew.org; Tue, 02 Nov 2021 07:16:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreE-0003pB-HC for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:10 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:36414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrdz-0000v6-Hz for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:07:59 -0400 Received: by mail-qt1-x836.google.com with SMTP id h14so17662662qtb.3 for ; Tue, 02 Nov 2021 04:07:54 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:54 -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=fofFGJJJzbXM7L3Ibz3JhPAmpo8LElJ1YWB6iIwHWsU=; b=T1aQLka/Z4qsgfQcDhmJWZA+a8r2wa48hUR3iOXD0iCkVcKOk5xMMcqP4nYC+rRBV+ sLTYZgv//gkfwYndZ07hqTdlxt5Q/75C+R3HUzhy4L2zFVx3bKWkTVU5liJVYp7EhAo3 d4rkf5gv0DTL3QnBymRCyYbjsDs4TtmFYf9Q8uHSCGovNHx5OjTXNfCW0K40gsDmtkXd lD8qYkOwRalBxJsA9W7JFcP0v7AAZGqDkO+ukULfnrezPJEwgJDs0gh+yNX1bvjkNIKH WZhuYwzEtNqchTM9p0HYHK/ySBU6W/cKD6QSVCyUthHuHaGdU0CmlOxeBuunkvRWpj7L Tbwg== 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=fofFGJJJzbXM7L3Ibz3JhPAmpo8LElJ1YWB6iIwHWsU=; b=oivBjY/GHLFcMDPP++5XG2SyF0bYOpVHs5CuZ6PQgNH/bSRruC3n+QjqlXqqRJoPET teqAaKkqMNCLZnu95BhlqiKc9W7vxmHUBD1huMaju/gFGXJFw2DAJmJbq+5D6X+pe4Ye ++f/V0rr0c1eHhlVEC1x8XGHWtcloBSYHs1Ha6cuakjJICkzhY5BcTo28MHxtKmWQEoJ 1CocHsWZixTxtfyGL26vvqoa+yQhDi+ROUE5wqyY2/rzgjCK+VLqBmGMnwEZOcsqEEmJ y2QMXseZ3/YaQzYaQeUU6+gy30KpuFJXFSEOZ7uH8SntEguo5cEm9cyoWZNzlP+CClpr Uulw== X-Gm-Message-State: AOAM531XGbk3SrucDgDtCOncngQQ9Ucxvpndk0XdNVJAnPlcj3SsjeC/ QMS8LaoA42Rsh27wMGKs0DOM+D33/4onMw== X-Google-Smtp-Source: ABdhPJy8NqDKgcOZ+8T9lJrxQJYLRYBlsLbw8lVtjP5IkRvw4c2zgRVqmvqEjoB1KqMnb2xvTfJrfg== X-Received: by 2002:ac8:7d92:: with SMTP id c18mr7686746qtd.324.1635851274479; Tue, 02 Nov 2021 04:07:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/60] target/arm: Use cpu_loop_exit_sigsegv for mte tag lookup Date: Tue, 2 Nov 2021 07:07:02 -0400 Message-Id: <20211102110740.215699-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x836.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635851807781100001 Use the new os interface for raising the exception, rather than calling arm_cpu_tlb_fill directly. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/arm/mte_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c index 724175210b..e09b7e46a2 100644 --- a/target/arm/mte_helper.c +++ b/target/arm/mte_helper.c @@ -84,10 +84,8 @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int= ptr_mmu_idx, uintptr_t index; =20 if (!(flags & (ptr_access =3D=3D MMU_DATA_STORE ? PAGE_WRITE_ORG : PAG= E_READ))) { - /* SIGSEGV */ - arm_cpu_tlb_fill(env_cpu(env), ptr, ptr_size, ptr_access, - ptr_mmu_idx, false, ra); - g_assert_not_reached(); + cpu_loop_exit_sigsegv(env_cpu(env), ptr, ptr_access, + !(flags & PAGE_VALID), ra); } =20 /* Require both MAP_ANON and PROT_MTE for the page. */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852729790129.65007403790105; Tue, 2 Nov 2021 04:32:09 -0700 (PDT) Received: from localhost ([::1]:57784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs1Q-0000O0-OZ for importer@patchew.org; Tue, 02 Nov 2021 07:32:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreE-0003p8-Dw for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:10 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:35365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre1-0000vG-De for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:00 -0400 Received: by mail-qk1-x72d.google.com with SMTP id az8so8035235qkb.2 for ; Tue, 02 Nov 2021 04:07:55 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:54 -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=GxgKUblSc/AuTdeTrCoYEJS946D/KatMQ8ilg/nMD3U=; b=WUrOCNn0Fx8p9K2qnWZBibRuOakp5G4qvXPzOV1zMD688l/Ab5LA2oa+LW5QIDxGC/ mPwkuHDBEfKAEpXTzA6h1uPepGaK0qQ1rIzX5nMzgvfNxPEr99xQCZBCUcvOc6mWWYgb xm2IQSa08xmgStfgcdyt3nMYmtyVHNxnkA6gRCU7dHbCqE83WYigbL9AynGDM9uLTOBo kF3zrJIdjOuxRq7cW/6wI/0lO50cRvuIJ+YUGhPPNJu+0vV/Y0yhes/jRvLjRdt8gGYS XZChZi7Rh/B1UhzvyYOPyqtlq5kc/k9lMA/vwixW0qU/rh6ORG6jx7qDwCN4Feh9aW+Z Ho0A== 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=GxgKUblSc/AuTdeTrCoYEJS946D/KatMQ8ilg/nMD3U=; b=IYzQOguO9H4ZONGVApP3HYVuJsByIZ8rfJpsOMCnjwLywDMaMmrAUcMJ9RMRHdCiYE zO3ty8geSbON5ikoFxzxRzU2zG9II9VUVCbH48VZTwuiDxLGiKFxAUqWMsx2OD+LcEih IcZ1piY3uxXVGAEzyPJgpWesYBzBUj5xAdQU530LhRbrR7kONtzOTAaphoOAcBjjdO/o Zr13KFhe1E/gxaoIh5IV722W5sBxZQTjIHOqpL26ZMpSsp2rj4o9q98mW6Mwdb7ZpYwp 8OE6JY0q9RRI90/EW8Xn4dH5KHf95X79Ic29d+J+K/sTQ3jYzndsA/IRlEtlKYwaz7FV QWRA== X-Gm-Message-State: AOAM531Pye0Z0bxB6bH7qipOBhyqXE9hDZ2gJDHESCgBpQips16HFh8n F5+6zn3qomXV3GwQQp+g45nejhMx59rUkg== X-Google-Smtp-Source: ABdhPJwqAH/JVEzkdwIJDwS9BqByijqk8BTil4TIWxO3y0kRK6IHYbYNLK65/48zoT9YTPuc3X/D4Q== X-Received: by 2002:a05:620a:29c8:: with SMTP id s8mr11398713qkp.250.1635851275098; Tue, 02 Nov 2021 04:07:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/60] target/arm: Implement arm_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:03 -0400 Message-Id: <20211102110740.215699-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852731213100001 Content-Type: text/plain; charset="utf-8" Because of the complexity of setting ESR, continue to use arm_deliver_fault. This means we cannot remove the code within cpu_loop that decodes EXCP_DATA_ABORT and EXCP_PREFETCH_ABORT. But using the new hook means that we don't have to do the page_get_flags check manually, and we'll be able to restrict the tlb_fill hook to sysemu later. Reviewed-by: Warner Losh Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 6 ++++++ target/arm/cpu.c | 6 ++++-- target/arm/cpu_tcg.c | 6 ++++-- target/arm/tlb_helper.c | 36 +++++++++++++++++++----------------- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 3612107ab2..5a7aaf0f51 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -544,9 +544,15 @@ static inline bool arm_extabort_type(MemTxResult resul= t) return result !=3D MEMTX_DECODE_ERROR; } =20 +#ifdef CONFIG_USER_ONLY +void arm_cpu_record_sigsegv(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); +#else bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +#endif =20 static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx) { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 641a8c2d3d..7a18a58ca0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2031,10 +2031,12 @@ static const struct SysemuCPUOps arm_sysemu_ops =3D= { static const struct TCGCPUOps arm_tcg_ops =3D { .initialize =3D arm_translate_init, .synchronize_from_tb =3D arm_cpu_synchronize_from_tb, - .tlb_fill =3D arm_cpu_tlb_fill, .debug_excp_handler =3D arm_debug_excp_handler, =20 -#if !defined(CONFIG_USER_ONLY) +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D arm_cpu_record_sigsegv, +#else + .tlb_fill =3D arm_cpu_tlb_fill, .cpu_exec_interrupt =3D arm_cpu_exec_interrupt, .do_interrupt =3D arm_cpu_do_interrupt, .do_transaction_failed =3D arm_cpu_do_transaction_failed, diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 0d5adccf1a..7b3bea2fbb 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -898,10 +898,12 @@ static void pxa270c5_initfn(Object *obj) static const struct TCGCPUOps arm_v7m_tcg_ops =3D { .initialize =3D arm_translate_init, .synchronize_from_tb =3D arm_cpu_synchronize_from_tb, - .tlb_fill =3D arm_cpu_tlb_fill, .debug_excp_handler =3D arm_debug_excp_handler, =20 -#if !defined(CONFIG_USER_ONLY) +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D arm_cpu_record_sigsegv, +#else + .tlb_fill =3D arm_cpu_tlb_fill, .cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt, .do_interrupt =3D arm_v7m_cpu_do_interrupt, .do_transaction_failed =3D arm_cpu_do_transaction_failed, diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index 3107f9823e..dc5860180f 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -147,28 +147,12 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwad= dr physaddr, arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); } =20 -#endif /* !defined(CONFIG_USER_ONLY) */ - bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) { ARMCPU *cpu =3D ARM_CPU(cs); ARMMMUFaultInfo fi =3D {}; - -#ifdef CONFIG_USER_ONLY - int flags =3D page_get_flags(useronly_clean_ptr(address)); - if (flags & PAGE_VALID) { - fi.type =3D ARMFault_Permission; - } else { - fi.type =3D ARMFault_Translation; - } - fi.level =3D 3; - - /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr, true); - arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); -#else hwaddr phys_addr; target_ulong page_size; int prot, ret; @@ -210,5 +194,23 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int= size, cpu_restore_state(cs, retaddr, true); arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); } -#endif } +#else +void arm_cpu_record_sigsegv(CPUState *cs, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra) +{ + ARMMMUFaultInfo fi =3D { + .type =3D maperr ? ARMFault_Translation : ARMFault_Permission, + .level =3D 3, + }; + ARMCPU *cpu =3D ARM_CPU(cs); + + /* + * We report both ESR and FAR to signal handlers. + * For now, it's easiest to deliver the fault normally. + */ + cpu_restore_state(cs, ra, true); + arm_deliver_fault(cpu, addr, access_type, MMU_USER_IDX, &fi); +} +#endif /* !defined(CONFIG_USER_ONLY) */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853055; cv=none; d=zohomail.com; s=zohoarc; b=bSMiBgG3w0dQkzxDziWw87EP9r3wkwN5jFHQcT/f/v4m3VCI4f10bNKo6T3gPRpUDI9x8m7qd2FZZAJYRMQ4wEyLZzD0BtvzZpra20ZK3i+HyvHs/hqKP2JBe7hiNiOCeoJcpcQhuq9oep9buxcCOFO5jWM6M+c0rcBtL/qqEBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853055; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LvK67GkX13tDj2L9Y8ql/Gd7bbn2JZgBQ3dF7lXKOxQ=; b=F+2bZhNQ0fZn+CWsArm8hV4gzmragPl5K5OlePLgnpo8K2zYvMqQXPbRs4Syi4Gg7Z1j45jbeMJ7BTJaQFtR97+Q8FJmelzk1Rrx3zIAC3VALfEomqBO/6apO7Venmr5+1mrwR7WdS52xIZt5mHqHUq0wUygemJMm+ATLVTmj9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853055289457.3289089811451; Tue, 2 Nov 2021 04:37:35 -0700 (PDT) Received: from localhost ([::1]:47146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs6g-0003f5-Cd for importer@patchew.org; Tue, 02 Nov 2021 07:37:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreL-00044k-3k for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:23 -0400 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:36559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreF-0000vq-Eb for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:16 -0400 Received: by mail-qk1-x731.google.com with SMTP id i9so18687388qki.3 for ; Tue, 02 Nov 2021 04:07:56 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:55 -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=LvK67GkX13tDj2L9Y8ql/Gd7bbn2JZgBQ3dF7lXKOxQ=; b=gBpQ1oV8q/Q3dM/FYthNAV8jBglSIh6QLVTeeb5sSRQifJmVXZuiXmw6GpFs1I6h2Y F9BxRgViHB+cF6t53Vk2c2Z1QiB+KR73y1nlxogRuws1nYByCyBj9RxsonXnwYKEowWk VgalnV9xfVVUOPS4mw+/hXWy9t7IOWLj8LaED80cfw1aXcqhYtg1/RSjkvigCJR/NvvC 29SRYFThH2QBkqr6UZAjuvJsigojilwE0NVTxZeGM0tdXKYrt8whcBenBMv9KbWo4d5M mwLwajmhyYlZQoQrg9tMMaXSTvo/3v+G07l5tgRJyakoduyrX2GRQpZjfLh+jZf04BbF 5Kcw== 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=LvK67GkX13tDj2L9Y8ql/Gd7bbn2JZgBQ3dF7lXKOxQ=; b=stU5rfbXbC9WDgszwHSAtYGMExXMew2zDP6MgLmY1TUlC5/Q7PJjhEcSiSdX9hSodK AqP/F5fQiFrBEnURGA5Dqq4n+Pr0pbO3QgNNxZ4/5cu2eTKWx1lwMk5yn35rNlR74sy4 HlJ6HVegl8yApCJoSY0ADAyWryvrnGnkozfghWEMnBDao1Is4G1rddH99W3jZ6Ur3DEX 93zJF7QYMbz+d1IaMlcVonBknqZMnkNE36e/wJ6TEaWp64CBYi7HPC1edlrmG4bT7p6K p/rYvx68M1XsoPuI7DFQKbPSEnyeOgUqlNR6KPMMqJrbe8if7//6Xl9TgutybT3gaFBa AJ0w== X-Gm-Message-State: AOAM531bnneoMrS0M6Ibz8ld/Px36TIar7mjYuYI0awvnkMQtsQBwyJe 7ejycLZ4gBb4gpTzkYNM3+y2RW1oXTzjjw== X-Google-Smtp-Source: ABdhPJxg+WSQyoHM8P6JA3GYqqa2l4DlsX7tDaylTG23YXFzWAUJ1szitmFnpOGEjXkZkiDANX5aXg== X-Received: by 2002:a05:620a:4008:: with SMTP id h8mr21744249qko.253.1635851275678; Tue, 02 Nov 2021 04:07:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/60] target/cris: Make cris_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:04 -0400 Message-Id: <20211102110740.215699-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x731.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853056730100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for cris linux-user. Remove the code from cpu_loop that handled the unnamed 0xaa exception. This makes all of the code in helper.c sysemu only, so remove the ifdefs and move the file to cris_softmmu_ss. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/cris/cpu.h | 8 ++++---- linux-user/cris/cpu_loop.c | 10 ---------- target/cris/cpu.c | 4 ++-- target/cris/helper.c | 18 ------------------ target/cris/meson.build | 7 +++++-- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/target/cris/cpu.h b/target/cris/cpu.h index 6603565f83..b445b194ea 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -189,6 +189,10 @@ extern const VMStateDescription vmstate_cris_cpu; void cris_cpu_do_interrupt(CPUState *cpu); void crisv10_cpu_do_interrupt(CPUState *cpu); bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req); + +bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #endif =20 void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags); @@ -251,10 +255,6 @@ static inline int cpu_mmu_index (CPUCRISState *env, bo= ol ifetch) return !!(env->pregs[PR_CCS] & U_FLAG); } =20 -bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); - /* Support function regs. */ #define SFR_RW_GC_CFG 0][0 #define SFR_RW_MM_CFG env->pregs[PR_SRS]][0 diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index b9085619c4..0d5d268609 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -37,16 +37,6 @@ void cpu_loop(CPUCRISState *env) process_queued_cpu_work(cs); =20 switch (trapnr) { - case 0xaa: - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->pregs[PR_EDA]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; diff --git a/target/cris/cpu.c b/target/cris/cpu.c index c2e7483f5b..ed6c781342 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -205,9 +205,9 @@ static const struct SysemuCPUOps cris_sysemu_ops =3D { =20 static const struct TCGCPUOps crisv10_tcg_ops =3D { .initialize =3D cris_initialize_crisv10_tcg, - .tlb_fill =3D cris_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D cris_cpu_tlb_fill, .cpu_exec_interrupt =3D cris_cpu_exec_interrupt, .do_interrupt =3D crisv10_cpu_do_interrupt, #endif /* !CONFIG_USER_ONLY */ @@ -215,9 +215,9 @@ static const struct TCGCPUOps crisv10_tcg_ops =3D { =20 static const struct TCGCPUOps crisv32_tcg_ops =3D { .initialize =3D cris_initialize_tcg, - .tlb_fill =3D cris_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D cris_cpu_tlb_fill, .cpu_exec_interrupt =3D cris_cpu_exec_interrupt, .do_interrupt =3D cris_cpu_do_interrupt, #endif /* !CONFIG_USER_ONLY */ diff --git a/target/cris/helper.c b/target/cris/helper.c index 36926faf32..a0d6ecdcd3 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -39,22 +39,6 @@ #define D_LOG(...) do { } while (0) #endif =20 -#if defined(CONFIG_USER_ONLY) - -bool cris_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - CRISCPU *cpu =3D CRIS_CPU(cs); - - cs->exception_index =3D 0xaa; - cpu->env.pregs[PR_EDA] =3D address; - cpu_loop_exit_restore(cs, retaddr); -} - -#else /* !CONFIG_USER_ONLY */ - - static void cris_shift_ccs(CPUCRISState *env) { uint32_t ccs; @@ -304,5 +288,3 @@ bool cris_cpu_exec_interrupt(CPUState *cs, int interrup= t_request) =20 return ret; } - -#endif /* !CONFIG_USER_ONLY */ diff --git a/target/cris/meson.build b/target/cris/meson.build index 67c3793c85..c1e326d950 100644 --- a/target/cris/meson.build +++ b/target/cris/meson.build @@ -2,13 +2,16 @@ cris_ss =3D ss.source_set() cris_ss.add(files( 'cpu.c', 'gdbstub.c', - 'helper.c', 'op_helper.c', 'translate.c', )) =20 cris_softmmu_ss =3D ss.source_set() -cris_softmmu_ss.add(files('mmu.c', 'machine.c')) +cris_softmmu_ss.add(files( + 'helper.c', + 'machine.c', + 'mmu.c', +)) =20 target_arch +=3D {'cris': cris_ss} target_softmmu_arch +=3D {'cris': cris_softmmu_ss} --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853020; cv=none; d=zohomail.com; s=zohoarc; b=SaN1c1cFkb9zcSMiE77vudIW7OiwiurF/OHlroS4r67K4K2q7uZlKA6fu6yBJg8TDvfJvQ3mWqBq7jB7/m+e2iUvga0KMbRQ9izdMxWBcNMF9WeqsDwrJlZW4JLrONseq8P+FDc/0i9wTcM4WNkK6QO7IcbY7tahbf3hfEV+OWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853020; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z8ecs4LTwGjkTaIMjFwaDU18rjRNxTTeFlYdhpfOXR8=; b=OuWDbLANRhuK6VjJpEWo2n45eRJN9itIGWOnWL2ab3GFIP4e9+DYcFoQaGbKGlCiQ1IRQ+HTI/Twgtuayy3AfPPu4ufxniJhGAYaObjtzegWxyTP06zmDD+01V4e9mQosu9fgYbKjiI8TRFHWsmdXt3keChWLPWNz86yZUN1B5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853020114152.4226145216528; Tue, 2 Nov 2021 04:37:00 -0700 (PDT) Received: from localhost ([::1]:45610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs66-0002dW-Vf for importer@patchew.org; Tue, 02 Nov 2021 07:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreF-0003qV-OT for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:33458) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre3-0000vx-Co for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:10 -0400 Received: by mail-qk1-x72b.google.com with SMTP id p4so988464qkk.0 for ; Tue, 02 Nov 2021 04:07:56 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:55 -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=z8ecs4LTwGjkTaIMjFwaDU18rjRNxTTeFlYdhpfOXR8=; b=EkH9Ppp+yQ8tag6+63FM9tSuH5jfpvAVfiRSrzTx6AHmgLyAXYgVGBwxX0j9Xv5Q/q rM3XB4YGQyKerRRWCkv1H7xdMTFdGLr5yLydvBJ6gxHWYxrc9ccmcZ1qCp2yZ1IKLMKV zP+whDPKUq9gKzLjRFBZOfclj5EUrOu+WRaun4SXZ18wz8442S0xQw/grhsbWgCwYYZT TYnjC4oT8IDcqtkvt7/Vkj3bJxEQKhgR34U3SrROGgTDYPY76f0TvTgPT/Lzs+TYadLZ VC2g5/VDJTiG3NFh0KyZSjJXGNZy6UsEGntuQ2X+0trgSgTBKJItaqQjtD1F6A+RTwT1 CTOQ== 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=z8ecs4LTwGjkTaIMjFwaDU18rjRNxTTeFlYdhpfOXR8=; b=jr7ithavWhWAufqeE7yWfAPMJc9VKteFRdwYn5Ilrg271HP/Qq9Ngvlh2Vy4fSA0wd 2LqgZKdtoxRuvnSTSdgbGBABvX6R65QjK0I7txgukWjtaSOOfwLpXz81iLIqi2IJHD2X fzfjtzaaagcDc9oVZujie9pM0gAd7fH6vLCtE3WmbWtPBJfynPIB7rqugchDnN6BE9Nx pkVTef2pyH9XFkurwJlmJYC77rvaeLaEYVID/Z+YaeZYJx2u0h2wdKKOKUotNbvuIxMe a9lz7t6wfH8rIuBwSqUgiOsbvvwAnJowRWFexg/wNhJ6trgs92by4u6tgnvRsycZPXsD rRwA== X-Gm-Message-State: AOAM532uY/d1GDtNBC985HCsWvQa3Q+l8loQKWJxH+mVuztIfbNdomtT kvUpzHvtbsxCPyYPxqQ+A4j/1AAx9MvZug== X-Google-Smtp-Source: ABdhPJxE3kF5cm7EPZBH/8wNwcrRURYS5GNngLmX0TvaoIlQ8DSVnvrxou8ES2tddq+M7lnD9BGYoA== X-Received: by 2002:a05:620a:4586:: with SMTP id bp6mr7149658qkb.470.1635851276207; Tue, 02 Nov 2021 04:07:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/60] target/hexagon: Remove hexagon_cpu_tlb_fill Date: Tue, 2 Nov 2021 07:07:05 -0400 Message-Id: <20211102110740.215699-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Taylor Simpson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853021389100001 Content-Type: text/plain; charset="utf-8" The fallback code in cpu_loop_exit_sigsegv is sufficient for hexagon linux-user. Remove the code from cpu_loop that raises SIGSEGV. Reviewed-by: Taylor Simpson Signed-off-by: Richard Henderson --- linux-user/hexagon/cpu_loop.c | 24 +----------------------- target/hexagon/cpu.c | 23 ----------------------- 2 files changed, 1 insertion(+), 46 deletions(-) diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c index bee2a9e4ea..6b24cbaba9 100644 --- a/linux-user/hexagon/cpu_loop.c +++ b/linux-user/hexagon/cpu_loop.c @@ -28,8 +28,7 @@ void cpu_loop(CPUHexagonState *env) { CPUState *cs =3D env_cpu(env); - int trapnr, signum, sigcode; - target_ulong sigaddr; + int trapnr; target_ulong syscallnum; target_ulong ret; =20 @@ -39,10 +38,6 @@ void cpu_loop(CPUHexagonState *env) cpu_exec_end(cs); process_queued_cpu_work(cs); =20 - signum =3D 0; - sigcode =3D 0; - sigaddr =3D 0; - switch (trapnr) { case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ @@ -65,12 +60,6 @@ void cpu_loop(CPUHexagonState *env) env->gpr[0] =3D ret; } break; - case HEX_EXCP_FETCH_NO_UPAGE: - case HEX_EXCP_PRIV_NO_UREAD: - case HEX_EXCP_PRIV_NO_UWRITE: - signum =3D TARGET_SIGSEGV; - sigcode =3D TARGET_SEGV_MAPERR; - break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; @@ -79,17 +68,6 @@ void cpu_loop(CPUHexagonState *env) trapnr); exit(EXIT_FAILURE); } - - if (signum) { - target_siginfo_t info =3D { - .si_signo =3D signum, - .si_errno =3D 0, - .si_code =3D sigcode, - ._sifields._sigfault._addr =3D sigaddr - }; - queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); - } - process_pending_signals(env); } } diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 3338365c16..160a46a3d5 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -245,34 +245,11 @@ static void hexagon_cpu_init(Object *obj) qdev_property_add_static(DEVICE(obj), &hexagon_lldb_stack_adjust_prope= rty); } =20 -static bool hexagon_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ -#ifdef CONFIG_USER_ONLY - switch (access_type) { - case MMU_INST_FETCH: - cs->exception_index =3D HEX_EXCP_FETCH_NO_UPAGE; - break; - case MMU_DATA_LOAD: - cs->exception_index =3D HEX_EXCP_PRIV_NO_UREAD; - break; - case MMU_DATA_STORE: - cs->exception_index =3D HEX_EXCP_PRIV_NO_UWRITE; - break; - } - cpu_loop_exit_restore(cs, retaddr); -#else -#error System mode not implemented for Hexagon -#endif -} - #include "hw/core/tcg-cpu-ops.h" =20 static const struct TCGCPUOps hexagon_tcg_ops =3D { .initialize =3D hexagon_translate_init, .synchronize_from_tb =3D hexagon_cpu_synchronize_from_tb, - .tlb_fill =3D hexagon_tlb_fill, }; =20 static void hexagon_cpu_class_init(ObjectClass *c, void *data) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853430; cv=none; d=zohomail.com; s=zohoarc; b=RsQKyH52Rc4CHyOmFEqSAB1yp+h52dgWWc4USD6dLNG3xAhnnkTyLr5JFSUPER1XNGQ/T67mN88v/Wzbzy1VCQWaf/05nsQGehM9k99NI5L5U1TaqNk5XWTejf4lDBNcVjbBF7+JCtyzfRrQBtvHLF6z+lPAX862rr+fTcSgaB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853430; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=StWIwDrqZSFeqnqFg+3hcLpPKjUfEIhsbr06iPdg0Gc=; b=aPXUA3J2/JpuMmbNw/yQaFFaDAdPCvEyEi0Zr3pfCEs/V+m/GnMinJOeyRVsI9heu657+5Oolc6js/svFXm0SQ7htKCTt8ifihon4nSQ1dLaWJuwDuJT2tLbIO2IAUdWEcWvBYZQ+wWGi7eN9C65l+HVYyBjYxgNCBIDXsoo8pA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853430373354.75737880225574; Tue, 2 Nov 2021 04:43:50 -0700 (PDT) Received: from localhost ([::1]:54160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsCj-0000AT-5g for importer@patchew.org; Tue, 02 Nov 2021 07:43:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreF-0003qe-Om for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:36407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre3-0000w1-CU for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:10 -0400 Received: by mail-qt1-x82e.google.com with SMTP id h14so17662790qtb.3 for ; Tue, 02 Nov 2021 04:07:57 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:56 -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=StWIwDrqZSFeqnqFg+3hcLpPKjUfEIhsbr06iPdg0Gc=; b=DlbdVejiussjWNpJ32pJ5I3owF8tmWrUSHRbJgX3Z7MvJWdVSJ9kojPxIu+4g1K0GN InPQHmtrMnVZRSm9y385A0y4SNnxjzZgS0K1ocUUErYxfXChTpz07cG2/j8UvE/NyYzA YU0xj16daS7pWbhHwsREMO9vmgxU3tK4nH0/SO84imb0HuRWLv1446VYBw0bVOG0xWkg 8xTsvGK5FQXem7jo91mx23bCkv1uH2LUi8NwNeK1Udm6pwrcTe7GhUeYsaS//5LofiKn PVaGBCKKb8Vy+CGzeoLPCd3TKtanayohqwCWg/RGCmS7Yn4wJs29f29D9o8UqJZiuSZz ED7g== 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=StWIwDrqZSFeqnqFg+3hcLpPKjUfEIhsbr06iPdg0Gc=; b=G8PBCVcsufxbp4IVQ754q3rjJFVqsWo93j5Uxv+KgjA3jR41aww/Gni/eIAdauGM33 1DGcx51g2aQUN5BK4/UfF9MjZYSwh0vxsyHF2whMRDsH0hCgHYndf5u5YpgUKcIJQu3Z XHeEupoT51qKmIs2twOfiHaDC+qiZgAFiMlkWhca1a9PKNUfacp4fgTeSSgOwEYyuoPd LW8PqTp8D4xx49ZcScUN8Pnjt9IqrFXinGYT+grqb9qGNH0O/kZilI3Z7LLDdEa0VOv5 5tltLzlJda8LxVjHEJ9k+ubAUzeeESet8T2knd997Kng42O+AE6Z6UVXli1KzCTS+AMV mqDw== X-Gm-Message-State: AOAM532nP3W4SAcCMCDJwZYCk0+UxhfPklBon7mlk9FSsoF33sDGAmwi EufdFB3iDLpGPoNHpsoEkJ5+ogmZ7BlttQ== X-Google-Smtp-Source: ABdhPJw/9pfHsY6GiaqxuSSe9pss+1BlSTzW2QpDjAL5c3gl+d+9VMg5HBCQT04QLS/fTh7UqIoBdw== X-Received: by 2002:a05:622a:30f:: with SMTP id q15mr6725530qtw.316.1635851276727; Tue, 02 Nov 2021 04:07:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/60] target/hppa: Make hppa_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:06 -0400 Message-Id: <20211102110740.215699-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82e.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853433244100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for hppa linux-user. Remove the code from cpu_loop that raised SIGSEGV. This makes all of the code in mem_helper.c sysemu only, so remove the ifdefs and move the file to hppa_softmmu_ss. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 2 +- linux-user/hppa/cpu_loop.c | 16 ---------------- target/hppa/cpu.c | 2 +- target/hppa/mem_helper.c | 15 --------------- target/hppa/meson.build | 6 ++++-- 5 files changed, 6 insertions(+), 35 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index d3cb7a279f..294fd7297f 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -323,10 +323,10 @@ hwaddr hppa_cpu_get_phys_page_debug(CPUState *cs, vad= dr addr); int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void hppa_cpu_dump_state(CPUState *cs, FILE *f, int); +#ifndef CONFIG_USER_ONLY bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); -#ifndef CONFIG_USER_ONLY void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx, diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 81607a9b27..e0a62deeb9 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -144,22 +144,6 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_f =3D env->gr[31]; env->iaoq_b =3D env->gr[31] + 4; break; - case EXCP_ITLB_MISS: - case EXCP_DTLB_MISS: - case EXCP_NA_ITLB_MISS: - case EXCP_NA_DTLB_MISS: - case EXCP_IMP: - case EXCP_DMP: - case EXCP_DMB: - case EXCP_PAGE_REF: - case EXCP_DMAR: - case EXCP_DMPI: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info.si_code =3D TARGET_SEGV_ACCERR; - info._sifields._sigfault._addr =3D env->cr[CR_IOR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_UNALIGN: info.si_signo =3D TARGET_SIGBUS; info.si_errno =3D 0; diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 89cba9d7a2..23eb254228 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -145,9 +145,9 @@ static const struct SysemuCPUOps hppa_sysemu_ops =3D { static const struct TCGCPUOps hppa_tcg_ops =3D { .initialize =3D hppa_translate_init, .synchronize_from_tb =3D hppa_cpu_synchronize_from_tb, - .tlb_fill =3D hppa_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D hppa_cpu_tlb_fill, .cpu_exec_interrupt =3D hppa_cpu_exec_interrupt, .do_interrupt =3D hppa_cpu_do_interrupt, .do_unaligned_access =3D hppa_cpu_do_unaligned_access, diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index afc5b56c3e..bf07445cd1 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -24,20 +24,6 @@ #include "hw/core/cpu.h" #include "trace.h" =20 -#ifdef CONFIG_USER_ONLY -bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - HPPACPU *cpu =3D HPPA_CPU(cs); - - /* ??? Test between data page fault and data memory protection trap, - which would affect si_code. */ - cs->exception_index =3D EXCP_DMP; - cpu->env.cr[CR_IOR] =3D address; - cpu_loop_exit_restore(cs, retaddr); -} -#else static hppa_tlb_entry *hppa_find_tlb(CPUHPPAState *env, vaddr addr) { int i; @@ -392,4 +378,3 @@ int hppa_artype_for_page(CPUHPPAState *env, target_ulon= g vaddr) hppa_tlb_entry *ent =3D hppa_find_tlb(env, vaddr); return ent ? ent->ar_type : -1; } -#endif /* CONFIG_USER_ONLY */ diff --git a/target/hppa/meson.build b/target/hppa/meson.build index 8a7ff82efc..021e42a2d0 100644 --- a/target/hppa/meson.build +++ b/target/hppa/meson.build @@ -7,13 +7,15 @@ hppa_ss.add(files( 'gdbstub.c', 'helper.c', 'int_helper.c', - 'mem_helper.c', 'op_helper.c', 'translate.c', )) =20 hppa_softmmu_ss =3D ss.source_set() -hppa_softmmu_ss.add(files('machine.c')) +hppa_softmmu_ss.add(files( + 'machine.c', + 'mem_helper.c', +)) =20 target_arch +=3D {'hppa': hppa_ss} target_softmmu_arch +=3D {'hppa': hppa_softmmu_ss} --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852071; cv=none; d=zohomail.com; s=zohoarc; b=NGX7tnC6ozGFsTtDvHS6TWGFrtWuxk+35tgRdlq597wAz7jUCWb6Mw/KWAjRh9Xz8i6/GLeqVsLjCnhffnMmk34Ol6fBLSGZN1lTin9lNG72Besc5JhDGmyvMUT4z7AyE24Lc5mSw7ChQikqTyDGzVB4FwkktpsZCsDyi6HWejo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852071; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bcv7+vrfVWDaxhREKP7oW3QycojCjuZf0xWMtNuZYi8=; b=hsg0Tv7nrNluiF3SrDIVZV9wl2mTMsHbl2Nj/ivcUAxbEL+NXsKTEAotqcmReBuMztUo5/2andCkYgASKwz/YiBeCflSvirKAyXfNsNR0tKq88TreJji6i5DUDT3MyVQk8Tw9tb/9CSUxf08KQR9p0wIW6dUXlxjTJyeR2svQu0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852071910114.74179374020252; Tue, 2 Nov 2021 04:21:11 -0700 (PDT) Received: from localhost ([::1]:50722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrqo-0001KC-Ch for importer@patchew.org; Tue, 02 Nov 2021 07:21:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreG-0003s9-AJ for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:12 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:39504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre3-0000w8-CV for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: by mail-qk1-x72e.google.com with SMTP id bk22so12482348qkb.6 for ; Tue, 02 Nov 2021 04:07:57 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:56 -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=Bcv7+vrfVWDaxhREKP7oW3QycojCjuZf0xWMtNuZYi8=; b=VhhMXEt1F5UycjB4r+Cd4HQkr9225pO6eL8qvN1PrQ1fRduWHTeixFvbw80x6V6EcB D6YH8zxwipI0BZ32mXEH/LSJrM97hxUgYaYJbHapdDM4fo8lxEeIfX/Um4ZavhD73TpO o1iSgx5lcveP8hL48A1GCMwz6XG3lK0q52PFb7XRr4LvWQLxDlEzbRarUVnOH8Kffoyu F0pS/BUqVn70pWfNhq1CN2XbGhsIWNauMemv3/eQMzbB7yQNC8M0hbuVeA1fOllIjZpI W5z/mED/nXrdCr4Gm+5d9IsKcgQ3RCGscA/AtRD4+myR4Lgz7b0sxwZQyITGhM8xhHcN vG6g== 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=Bcv7+vrfVWDaxhREKP7oW3QycojCjuZf0xWMtNuZYi8=; b=5OSVVfn/QBLxVnYfDP5+SXtm6+sUBM0vZNf2iMI947x750XUMEUbw4QCQWUFYfZeq9 hJkuxFrV8LaXqY4DWEJNblz/L6xX8drlBWFNMg4iWwpYXCveS5LRiohMWVaDJmSwD+7H oQ/A+2aTEpMgFvt+zaX+osXhQlWLr1OiqeFJ+JZxxjL4iGMeLmSAqL1yPNTYJROERmEp yDuS5Q98lrQGXxpxRA6IWP0p01dTUa74dRA60FMy9yqnWrh4nPxnN2HVxyS2agDR0MLE pL86q3ynx2cVVVxlh45LAZYXHNOua0UYK6JUI8sOgxU6lvmbxlm54//1tZ+bLbc8vWnV a0Bw== X-Gm-Message-State: AOAM531iwAa3/kvB3UPaarkEwmhczOX/jVqdhjYMcQ4AJDDMdIp0Os8E 9Ewht3c+FRuuafjSS/Ex4OFVxYrbSBasgw== X-Google-Smtp-Source: ABdhPJx5JSMT29cxrN5Ouh/62xtCYp95gTC7LNk08LH7gVltwQvWwuF9T9K1aBNByy1q5uNO/6Ipxg== X-Received: by 2002:a37:6c83:: with SMTP id h125mr27783636qkc.486.1635851277219; Tue, 02 Nov 2021 04:07:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/60] target/i386: Implement x86_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:07 -0400 Message-Id: <20211102110740.215699-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72e.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852073024100001 Record cr2, error_code, and exception_index. That last means that we must exit to cpu_loop ourselves, instead of letting exception_index being overwritten. Use the maperr parameter to properly set PG_ERROR_P_MASK. Reviewed by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/i386/tcg/helper-tcg.h | 6 ++++++ target/i386/tcg/tcg-cpu.c | 3 ++- target/i386/tcg/user/excp_helper.c | 23 +++++++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/target/i386/tcg/helper-tcg.h b/target/i386/tcg/helper-tcg.h index 60ca09e95e..0a4401e917 100644 --- a/target/i386/tcg/helper-tcg.h +++ b/target/i386/tcg/helper-tcg.h @@ -43,9 +43,15 @@ bool x86_cpu_exec_interrupt(CPUState *cpu, int int_req); #endif =20 /* helper.c */ +#ifdef CONFIG_USER_ONLY +void x86_cpu_record_sigsegv(CPUState *cs, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); +#else bool x86_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +#endif =20 void breakpoint_handler(CPUState *cs); =20 diff --git a/target/i386/tcg/tcg-cpu.c b/target/i386/tcg/tcg-cpu.c index 3ecfae34cb..6fdfdf9598 100644 --- a/target/i386/tcg/tcg-cpu.c +++ b/target/i386/tcg/tcg-cpu.c @@ -72,10 +72,11 @@ static const struct TCGCPUOps x86_tcg_ops =3D { .synchronize_from_tb =3D x86_cpu_synchronize_from_tb, .cpu_exec_enter =3D x86_cpu_exec_enter, .cpu_exec_exit =3D x86_cpu_exec_exit, - .tlb_fill =3D x86_cpu_tlb_fill, #ifdef CONFIG_USER_ONLY .fake_user_interrupt =3D x86_cpu_do_interrupt, + .record_sigsegv =3D x86_cpu_record_sigsegv, #else + .tlb_fill =3D x86_cpu_tlb_fill, .do_interrupt =3D x86_cpu_do_interrupt, .cpu_exec_interrupt =3D x86_cpu_exec_interrupt, .debug_excp_handler =3D breakpoint_handler, diff --git a/target/i386/tcg/user/excp_helper.c b/target/i386/tcg/user/excp= _helper.c index a89b5228fd..cd507e2a1b 100644 --- a/target/i386/tcg/user/excp_helper.c +++ b/target/i386/tcg/user/excp_helper.c @@ -22,18 +22,29 @@ #include "exec/exec-all.h" #include "tcg/helper-tcg.h" =20 -bool x86_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +void x86_cpu_record_sigsegv(CPUState *cs, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; =20 + /* + * The error_code that hw reports as part of the exception frame + * is copied to linux sigcontext.err. The exception_index is + * copied to linux sigcontext.trapno. Short of inventing a new + * place to store the trapno, we cannot let our caller raise the + * signal and set exception_index to EXCP_INTERRUPT. + */ env->cr[2] =3D addr; - env->error_code =3D (access_type =3D=3D MMU_DATA_STORE) << PG_ERROR_W_= BIT; - env->error_code |=3D PG_ERROR_U_MASK; + env->error_code =3D ((access_type =3D=3D MMU_DATA_STORE) << PG_ERROR_W= _BIT) + | (maperr ? 0 : PG_ERROR_P_MASK) + | PG_ERROR_U_MASK; cs->exception_index =3D EXCP0E_PAGE; + + /* Disable do_interrupt_user. */ env->exception_is_int =3D 0; env->exception_next_eip =3D -1; - cpu_loop_exit_restore(cs, retaddr); + + cpu_loop_exit_restore(cs, ra); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852906; cv=none; d=zohomail.com; s=zohoarc; b=LaIpnf0Ex/3U79snfNUiOqx4DdSo4wTkE0tEWA2EkytqFsYq5Wcl6deqIQMObKejhmmfMCfZu7xtsLuhoNNTY1MxhrcvaU4jotu6dpjS3K2KoofRmiuw9Y6PU+Nb5Hxe91JZOcTvDXCXrncEUynlRFtdbCJc2O18e34DQx//wG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/utnMsLyouv7LilvnHYZPxrZ8zRoC/jZ7xS1qGJE894=; b=feRQV+HZTOmw7KeJEdi2tYZyQp8yJ0EQSYhiYpB2vpgWoM3lp3D0wJK39Bv/vpDHBZ0dDkREZXGF8q+PyU1nE8/m0l1AxEy4ROQVCpFjvnzdQq5/WM/wwi50LKRBg6fmxsP2vrSKIecyQhr8y/LqRUSLjtQmh0vInR01nJSXmaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852906588212.51254906641213; Tue, 2 Nov 2021 04:35:06 -0700 (PDT) Received: from localhost ([::1]:38424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs4H-0006GR-FG for importer@patchew.org; Tue, 02 Nov 2021 07:35:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreG-0003sF-AY for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:12 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:43668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhre4-0000wH-0L for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:11 -0400 Received: by mail-qt1-x82a.google.com with SMTP id 8so979931qty.10 for ; Tue, 02 Nov 2021 04:07:58 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:57 -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=/utnMsLyouv7LilvnHYZPxrZ8zRoC/jZ7xS1qGJE894=; b=RCZurs00E5PwKyfhSnL8+fW1JhT86YuTvroVJgzPnEYoehIGQQ1V01+WATT6Co3lvj GSpL8EMqcT9PzLojgK70nunfrLRox/kZXPwjrA3SelgKNiVsYxtg2mXukrGquBjd4JkQ vHDkwyUcdo+uqLVkWbPHao375zjtrb/QdAxeilk7Ybawt14URouiy3dU/AhcYqw9cn8f bCBhl8KKJ4X9wMBHUqIlH6ayVBucwjHPuh/Dnm1V9HxN2OmhjQD27oNsmsY1QRNOa3bm p1bLyyudwOcMWTVbw2fnBuOq8pD0fF8v9rgNDKBC9W/WOtimmtGGBJR6+bCbWMaQ8r+6 wCIg== 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=/utnMsLyouv7LilvnHYZPxrZ8zRoC/jZ7xS1qGJE894=; b=ONtSAwv9ZzltUf7LYz3LiAwJHfmZJMeOAHlpFy8qwsieEO+boKDERATQavQpXkgM9e nbmhygcT1NqlRDaGy6+wlXmf+2D5QwjYYDqLaWXnOKfWl27pH1K5BB3pyMiOmA6iaF1K 7z/HvNEYsYmJi/OcS3tsxEpERDof/6erkmKL/ipo+SFsW1y5qjgIv3grVbNE0QRRuAm6 3ez5fyb1YiHw1PdEoCD41M0hv+FiICPHSUKKoc2FBY2EfAeKrtGFsvqT9/0KQI4fvj2Y UcaUxdp4DN+97Ig5EEuGyuEdZRl6bGjHHiWTV6ukKen5FccPEzDgcaRgSyKZ+vQkh8bl EAUQ== X-Gm-Message-State: AOAM530DUiW9I8g5TltaGn9s7EbteplRuxpbqjJ8xsFq2sF9QB+taG4Z chVHxYKlVEE+2aJXL2tQ6GoAjSaabP5+JQ== X-Google-Smtp-Source: ABdhPJwlZIoWNkwcXMIskYyyzX5zgt9XBa/BBRtWTfhYemytKPGiMntvo7nRe+pG5ueP0tSgPWXTLg== X-Received: by 2002:ac8:5dd4:: with SMTP id e20mr12156632qtx.8.1635851277951; Tue, 02 Nov 2021 04:07:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 28/60] target/m68k: Make m68k_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:08 -0400 Message-Id: <20211102110740.215699-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852907106100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for m68k linux-user. Remove the code from cpu_loop that handled EXCP_ACCESS. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/m68k/cpu_loop.c | 10 ---------- target/m68k/cpu.c | 2 +- target/m68k/helper.c | 6 +----- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index ebf32be78f..790bd558c3 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -90,16 +90,6 @@ void cpu_loop(CPUM68KState *env) case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; - case EXCP_ACCESS: - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->mmu.ar; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; case EXCP_DEBUG: info.si_signo =3D TARGET_SIGTRAP; info.si_errno =3D 0; diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 66d22d1189..c7aeb7da9c 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -515,9 +515,9 @@ static const struct SysemuCPUOps m68k_sysemu_ops =3D { =20 static const struct TCGCPUOps m68k_tcg_ops =3D { .initialize =3D m68k_tcg_init, - .tlb_fill =3D m68k_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D m68k_cpu_tlb_fill, .cpu_exec_interrupt =3D m68k_cpu_exec_interrupt, .do_interrupt =3D m68k_cpu_do_interrupt, .do_transaction_failed =3D m68k_cpu_transaction_failed, diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 137a3e1a3d..5728e48585 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -978,16 +978,12 @@ void m68k_set_irq_level(M68kCPU *cpu, int level, uint= 8_t vector) } } =20 -#endif - bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType qemu_access_type, int mmu_idx, bool probe, uintptr_t retaddr) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; - -#ifndef CONFIG_USER_ONLY hwaddr physical; int prot; int access_type; @@ -1051,12 +1047,12 @@ bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address,= int size, if (!(access_type & ACCESS_STORE)) { env->mmu.ssw |=3D M68K_RW_040; } -#endif =20 cs->exception_index =3D EXCP_ACCESS; env->mmu.ar =3D address; cpu_loop_exit_restore(cs, retaddr); } +#endif /* !CONFIG_USER_ONLY */ =20 uint32_t HELPER(bitrev)(uint32_t x) { --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852910901740.7406383055393; Tue, 2 Nov 2021 04:35:10 -0700 (PDT) Received: from localhost ([::1]:38706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs4L-0006Rj-KD for importer@patchew.org; Tue, 02 Nov 2021 07:35:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreJ-00042g-F9 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:45636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000wM-7H for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: by mail-qk1-x72c.google.com with SMTP id n15so5719852qkp.12 for ; Tue, 02 Nov 2021 04:07:58 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:58 -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=Wm8ynGMh6kJsv+mBV6l6SdFFT71ClM8AMZtK4AOJ7uE=; b=ucLC/rW27YL59WvVDAQ8zlrSheapRx3yaCFnBoWQhysaLQWvNSlgIFEJ1JJNSUUj9n DXi2Yj+r5yMb5TcKogKFLvFxqNgTxtGJmfvmr+rCiPKALWy6i4N06bSkmTljJ0kCfo6Z MBegi6OTJTqONsK/OUdi8COoR3+Ssc+l2ASzeiATIwJ88VC/b2K3QWsbxlDzlU2UW9Y7 jZl4ZiLtSJMYi2s42OryclKgYgjt5sSq3MhmLLvDu0v35KeiJZphykEuQRs7LlhDCz5f oTCZTFY00FOiIXCq8KWzc3IrC5Euk33890N7lB7Fejs6VhvVyGnp6E9VVnsMSbnY8jiu Aisg== 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=Wm8ynGMh6kJsv+mBV6l6SdFFT71ClM8AMZtK4AOJ7uE=; b=RmWDhMlKK732/sdqG3ymjNw+HMRSVMSfDeoX9trvPFJR8qfYpBVb3l9aDi7aQ9L5P0 E6vyYBJkM7IN0zPePeLxGd1JoZWXiAJewrS3r1ZNeQVqOIuQStzIOWvdiyouQLPocT8q BbaRjH6a1bYCnAEF3O0wWfWP6K6w7+RLzQ2CCXP4bB/qyT6aFT6n5jR6hwuSiuSQjZgN 28WFP6LaddYJXGzFn356z2c/JoPJ0rvKTFgBUCdM3Q1b5i551Vu/bAxbuNe0INTHDgR/ t7MVE7YUOwms53u072bd/ECPc/3+sZ03dr+angPk0JWRCARLKl+lpudFdINXwd4F05O/ mi1g== X-Gm-Message-State: AOAM532hmXTNTe0ulknJnAdD30QpMObp2u3pBrgyOKUNl9p8Ttjp6ppw spTGE9vojAGm+vQedmWkIrcH+x35AqfroQ== X-Google-Smtp-Source: ABdhPJzNIarwgcPdjrTpQwoUfVi3gfNqVHT8oX4PY5kH4MQCOfBWsbX6Qk1/dP7Y+PF9WfXTxpr13Q== X-Received: by 2002:a05:620a:414a:: with SMTP id k10mr12266267qko.309.1635851278583; Tue, 02 Nov 2021 04:07:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/60] target/microblaze: Make mb_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:09 -0400 Message-Id: <20211102110740.215699-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852911614100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for microblaze linux-user. Remove the code from cpu_loop that handled the unnamed 0xaa exception. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/cpu.h | 8 ++++---- linux-user/microblaze/cpu_loop.c | 10 ---------- target/microblaze/cpu.c | 2 +- target/microblaze/helper.c | 13 +------------ 4 files changed, 6 insertions(+), 27 deletions(-) diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index b7a848bbae..e9cd0b88de 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -394,10 +394,6 @@ void mb_tcg_init(void); #define MMU_USER_IDX 2 /* See NB_MMU_MODES further up the file. */ =20 -bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); - typedef CPUMBState CPUArchState; typedef MicroBlazeCPU ArchCPU; =20 @@ -415,6 +411,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *en= v, target_ulong *pc, } =20 #if !defined(CONFIG_USER_ONLY) +bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs, diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_l= oop.c index 52222eb93f..a94467dd2d 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -37,16 +37,6 @@ void cpu_loop(CPUMBState *env) process_queued_cpu_work(cs); =20 switch (trapnr) { - case 0xaa: - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 15db277925..b9c888b87e 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -365,9 +365,9 @@ static const struct SysemuCPUOps mb_sysemu_ops =3D { static const struct TCGCPUOps mb_tcg_ops =3D { .initialize =3D mb_tcg_init, .synchronize_from_tb =3D mb_cpu_synchronize_from_tb, - .tlb_fill =3D mb_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D mb_cpu_tlb_fill, .cpu_exec_interrupt =3D mb_cpu_exec_interrupt, .do_interrupt =3D mb_cpu_do_interrupt, .do_transaction_failed =3D mb_cpu_transaction_failed, diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index dd2aecd1d5..a607fe68e5 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -24,18 +24,7 @@ #include "qemu/host-utils.h" #include "exec/log.h" =20 -#if defined(CONFIG_USER_ONLY) - -bool mb_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - cs->exception_index =3D 0xaa; - cpu_loop_exit_restore(cs, retaddr); -} - -#else /* !CONFIG_USER_ONLY */ - +#ifndef CONFIG_USER_ONLY static bool mb_cpu_access_is_secure(MicroBlazeCPU *cpu, MMUAccessType access_type) { --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853775378751.2292479540843; Tue, 2 Nov 2021 04:49:35 -0700 (PDT) Received: from localhost ([::1]:34270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsIH-0005zB-DD for importer@patchew.org; Tue, 02 Nov 2021 07:49:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreG-0003tz-N4 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:12 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:45637) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreC-0000we-9H for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:12 -0400 Received: by mail-qk1-x72d.google.com with SMTP id n15so5719869qkp.12 for ; Tue, 02 Nov 2021 04:07:59 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:58 -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=ap2DHedkoq+uxK6WhzWLDOfP9mxx1Wp6apyTQWx8z3U=; b=krxifhDrneb2LmvZHQJOlaSCv/JZc+266S6RNLjiY45l8zBUt4sNb9SXvFuGPv2ogg pmvNHH25pz97FIcdrMC8NWsr8i4Kru/GCiC+g7lc7iRquJ76vmsCQaaOkkYSIaLfF3mA WZcYipA1QLd9r41le2sc5Hm+PGwlv3PWJE3e9i3fnEUZUtQ2Y7jT4EJP7Jjqs4jhy23G J393JRJ34K3b3Ttm8L/g7z5+Co3MwxARbyGO38m2UWsJQEPlItAvCmq6NapANfCtrtyw 11hkgbMcBx9Awzr0HrEmY8vSVRoEAqS2zDgeklqANHU4pRCwjO1e++z1Gde+EjZDaYWw 7j4g== 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=ap2DHedkoq+uxK6WhzWLDOfP9mxx1Wp6apyTQWx8z3U=; b=1tp+Gaf0H4i6Ma8j4dNoxL8VJnegRc9WxBcLcThenQZQczRkG2oGEn6qqkA6mR8piB TTtrxN0I5snEznkmQPKNaAnpBUqC1Eu1en/a7aO1Vn/DHs4gwld5hBrIw1pkT5dbC3VW 6fXydp14bkjjIYm4eQq1qm67pEavAlpPdjcBkcXk2Uz7OzB7KPPOqAaYrEO6Gdn/6PUR 3XJYZojT/+qvwBEcLWGirtE65gjeDrwAIPizaQlw9HhoHXRrxpHkfE3SVvwjyxezMitl yiMAHa6ebQo5iEK9/uw3AX6UmPGY7opC+mNB6RA7+2SCU5ou6Ki1sNeJvn+56po1ERUW XwfA== X-Gm-Message-State: AOAM533GsqG6IIdh1qQu4XlY23aMWLWPF3wPXCs46wuy9GMfGndypMxG 1jkDvcpWLsip+n2ZwbYmQ/r5uf8T5YWzeQ== X-Google-Smtp-Source: ABdhPJyv1BmRqFxhq0F8hu8oy0ECWHbar5dDVMEruRt/S8UX0eDxIIFQ7AQqKwgQGEncu4ZRWRrbhw== X-Received: by 2002:a05:620a:2a0f:: with SMTP id o15mr12998619qkp.444.1635851279194; Tue, 02 Nov 2021 04:07:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/60] target/mips: Make mips_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:10 -0400 Message-Id: <20211102110740.215699-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635853777339100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for mips linux-user. This means we can remove tcg/user/tlb_helper.c entirely. Remove the code from cpu_loop that raised SIGSEGV. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/mips/tcg/tcg-internal.h | 7 ++-- linux-user/mips/cpu_loop.c | 11 ------ target/mips/cpu.c | 2 +- target/mips/tcg/user/tlb_helper.c | 59 ------------------------------- target/mips/tcg/meson.build | 3 -- target/mips/tcg/user/meson.build | 3 -- 6 files changed, 5 insertions(+), 80 deletions(-) delete mode 100644 target/mips/tcg/user/tlb_helper.c delete mode 100644 target/mips/tcg/user/meson.build diff --git a/target/mips/tcg/tcg-internal.h b/target/mips/tcg/tcg-internal.h index bad3deb611..466768aec4 100644 --- a/target/mips/tcg/tcg-internal.h +++ b/target/mips/tcg/tcg-internal.h @@ -18,9 +18,6 @@ void mips_tcg_init(void); =20 void mips_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb= ); -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); void mips_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) QEMU_NORETURN; @@ -60,6 +57,10 @@ void mips_cpu_do_transaction_failed(CPUState *cs, hwaddr= physaddr, MemTxResult response, uintptr_t retadd= r); void cpu_mips_tlb_flush(CPUMIPSState *env); =20 +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + #endif /* !CONFIG_USER_ONLY */ =20 #endif diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index cb03fb066b..b735c99a24 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -158,17 +158,6 @@ done_syscall: } env->active_tc.gpr[2] =3D ret; break; - case EXCP_TLBL: - case EXCP_TLBS: - case EXCP_AdEL: - case EXCP_AdES: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->CP0_BadVAddr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_CpU: case EXCP_RI: info.si_signo =3D TARGET_SIGILL; diff --git a/target/mips/cpu.c b/target/mips/cpu.c index 00e0c55d0e..4aae23934b 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -539,9 +539,9 @@ static const struct SysemuCPUOps mips_sysemu_ops =3D { static const struct TCGCPUOps mips_tcg_ops =3D { .initialize =3D mips_tcg_init, .synchronize_from_tb =3D mips_cpu_synchronize_from_tb, - .tlb_fill =3D mips_cpu_tlb_fill, =20 #if !defined(CONFIG_USER_ONLY) + .tlb_fill =3D mips_cpu_tlb_fill, .cpu_exec_interrupt =3D mips_cpu_exec_interrupt, .do_interrupt =3D mips_cpu_do_interrupt, .do_transaction_failed =3D mips_cpu_do_transaction_failed, diff --git a/target/mips/tcg/user/tlb_helper.c b/target/mips/tcg/user/tlb_h= elper.c deleted file mode 100644 index 210c6d529e..0000000000 --- a/target/mips/tcg/user/tlb_helper.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIPS TLB (Translation lookaside buffer) helpers. - * - * Copyright (c) 2004-2005 Jocelyn Mayer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#include "qemu/osdep.h" - -#include "cpu.h" -#include "exec/exec-all.h" -#include "internal.h" - -static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, - MMUAccessType access_type) -{ - CPUState *cs =3D env_cpu(env); - - env->error_code =3D 0; - if (access_type =3D=3D MMU_INST_FETCH) { - env->error_code |=3D EXCP_INST_NOTAVAIL; - } - - /* Reference to kernel address from user mode or supervisor mode */ - /* Reference to supervisor address from user mode */ - if (access_type =3D=3D MMU_DATA_STORE) { - cs->exception_index =3D EXCP_AdES; - } else { - cs->exception_index =3D EXCP_AdEL; - } - - /* Raise exception */ - if (!(env->hflags & MIPS_HFLAG_DM)) { - env->CP0_BadVAddr =3D address; - } -} - -bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - MIPSCPU *cpu =3D MIPS_CPU(cs); - CPUMIPSState *env =3D &cpu->env; - - /* data access */ - raise_mmu_exception(env, address, access_type); - do_raise_exception_err(env, cs->exception_index, env->error_code, reta= ddr); -} diff --git a/target/mips/tcg/meson.build b/target/mips/tcg/meson.build index 8f6f7508b6..98003779ae 100644 --- a/target/mips/tcg/meson.build +++ b/target/mips/tcg/meson.build @@ -28,9 +28,6 @@ mips_ss.add(when: 'TARGET_MIPS64', if_true: files( 'mxu_translate.c', )) =20 -if have_user - subdir('user') -endif if have_system subdir('sysemu') endif diff --git a/target/mips/tcg/user/meson.build b/target/mips/tcg/user/meson.= build deleted file mode 100644 index 79badcd321..0000000000 --- a/target/mips/tcg/user/meson.build +++ /dev/null @@ -1,3 +0,0 @@ -mips_user_ss.add(files( - 'tlb_helper.c', -)) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854075; cv=none; d=zohomail.com; s=zohoarc; b=AWkKyHP3EthkY6ifgpuPDiTAa/fBmsXMC32/WfWC7yaHQESEU53tYV/ellvfPiZChdgr/tUuZ+lyY2M61mmpjWq27FndQEKHJXEfXQ4No8l+skr477VAqGOYwX6zMvoU/McXdcaVUK0Q6nCEjfUW4OYl7hmEdc0IV92AA/ehewc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zhmoQq400LN3ckB+F14vIMLu76bali80G5XXiJl040k=; b=c9kg9sNzs3lzSq87aZCzP6yoFSA6Idh++6sISZxtIL4WesY0sQo+QJJVYpEOoV/Bcp504aQC22nf5QNzcC81xFSgeaorrhc51QSXrYT3SaMlN6FKE8Yp9qYVvWLn5MJ/+MpEo/s+cEBaUmlRRX/SuhGgx/EdLoisjOgussY7dLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163585407571515.746694368274802; Tue, 2 Nov 2021 04:54:35 -0700 (PDT) Received: from localhost ([::1]:51220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsN8-0000sw-PF for importer@patchew.org; Tue, 02 Nov 2021 07:54:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreI-0003zs-1W for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:14 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:34316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000wo-5V for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:13 -0400 Received: by mail-qk1-x72a.google.com with SMTP id bq14so7748215qkb.1 for ; Tue, 02 Nov 2021 04:08:00 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:07:59 -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=zhmoQq400LN3ckB+F14vIMLu76bali80G5XXiJl040k=; b=s7z92tkrpD5ANgAjV7xHrKJzN/K/FoYKYHN7E4lZ+D1NIaWRGjQ5pjvzpe69ObJZAE q5RwsOpV2waT/rOqhPEbAbNKQlqCRqNhOIiwVc6kdViOXMdHnwgwoMC4AZ9W5cgdDJhO oKMvkWY9uDQIktTLRq5326MAIVYrmdVGQwb/CXtMgL6S0wOxcBc7KqpihJjP6MLAZ7uF j4+mDCcTuT7IixIeKMlZeGRP95DneoOppEpt6ne9Bn/ItzS5uxb+KwPlQZMNcHmbunbs 0Jl48Ad61v1cQk7ZRqAEAZZSYmduZwW/NCq4lU49GR+zgA0kbPOpbeh2BApAdL/6OhrA bpFw== 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=zhmoQq400LN3ckB+F14vIMLu76bali80G5XXiJl040k=; b=4mcQhs3c58b/cI/wZyQap+U4efND6qATmOW14fMjb3ScpMEV5PQUEXeO3QXTZhv0Lc VwpPqcKUhxy1MGKUdxunoLszBLE/DaDgQg33fynUEH7AAIYQXLU5vTU6H154GRZhS9Ez CRQUdRPeY+9o3h0TCY6e0A7IUwqSHuTj6y3//cDXOpzt1ms+v0S1imCLZD+aQtnfbaT0 q/8eycJAdPirBrxcir9VID6z+5Vur3ZC8KjEMVCKyUlmEYBG4IkLKxFdPwzrWonob9lU /CtWjBbHBUmHOs4ixolRkdfsfDv9jlnsKtZjDwx9G4uxLTUK2QgZ+lLN8eXK0e0pTH6Q 6Lvw== X-Gm-Message-State: AOAM533u3NHmSFdzHtS+WvRhsoq1BmZV5wtrx84Y3bFuRwxX4K9jl2LL 9qxH21cCNQ3xfgIGuzT+SnigGqT96ibcoA== X-Google-Smtp-Source: ABdhPJzNgBem2uvTVztCAXMZkuoQYdtacQNI06VWOICMzFcVz8bymdrLvkyPDSrj3QSMnmo6VDsLmg== X-Received: by 2002:a05:620a:430a:: with SMTP id u10mr28923554qko.53.1635851279857; Tue, 02 Nov 2021 04:07:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 31/60] target/nios2: Implement nios2_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:11 -0400 Message-Id: <20211102110740.215699-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854077835100001 Because the linux-user kuser page handling is currently implemented by detecting magic addresses in the unnamed 0xaa trap, we cannot simply remove nios2_cpu_tlb_fill and rely on the fallback code. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/nios2/cpu.h | 6 ++++++ target/nios2/cpu.c | 6 ++++-- target/nios2/helper.c | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index a80587338a..1a69ed7a49 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -218,9 +218,15 @@ static inline int cpu_mmu_index(CPUNios2State *env, bo= ol ifetch) MMU_SUPERVISOR_IDX; } =20 +#ifdef CONFIG_USER_ONLY +void nios2_cpu_record_sigsegv(CPUState *cpu, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); +#else bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +#endif =20 static inline int cpu_interrupts_enabled(CPUNios2State *env) { diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 58ecd27d75..4cade61e93 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -216,9 +216,11 @@ static const struct SysemuCPUOps nios2_sysemu_ops =3D { =20 static const struct TCGCPUOps nios2_tcg_ops =3D { .initialize =3D nios2_tcg_init, - .tlb_fill =3D nios2_cpu_tlb_fill, =20 -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D nios2_cpu_record_sigsegv, +#else + .tlb_fill =3D nios2_cpu_tlb_fill, .cpu_exec_interrupt =3D nios2_cpu_exec_interrupt, .do_interrupt =3D nios2_cpu_do_interrupt, .do_unaligned_access =3D nios2_cpu_do_unaligned_access, diff --git a/target/nios2/helper.c b/target/nios2/helper.c index 53be8398e9..e5c98650e1 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -38,10 +38,11 @@ void nios2_cpu_do_interrupt(CPUState *cs) env->regs[R_EA] =3D env->regs[R_PC] + 4; } =20 -bool nios2_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +void nios2_cpu_record_sigsegv(CPUState *cs, vaddr addr, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr) { + /* FIXME: Disentangle kuser page from linux-user sigsegv handling. */ cs->exception_index =3D 0xaa; cpu_loop_exit_restore(cs, retaddr); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854221; cv=none; d=zohomail.com; s=zohoarc; b=BJjtGQpJbBQV+RSvvprdCsHpP1z3tftjPNZJfkeeWP5dT87DwS/ID/2dHPv9a8WF4jBNau2S7x/J6o9iA9h0/qzw6vNGa433KlZz9wE7Z1luabm5D36stSMC1BFxID9lBpPqST6QDy41Ny4lVp+U4ZfVaCDiFpJ8vskwQNMm2Ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mXI5pLklfarH8j3WhgGW5xn4dLCOLkkDAfhYzkOpzbo=; b=fyBj+gaHz54m4zDgHoUGasvcw7ymmkbmNPz+YeMNOpLHeUQECj1/+NXkz+k9VW4Sa76YFLDbyX1kCdSNU4O3fBJmz7sjY6DC4JpUtSOnTiqYXWLXWBsXbMeOfU1epagaQsA7UhMWftNmJ7k06YC+pCYzshX3J+vcqnK0OPT83Uw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854221358797.7671126865075; Tue, 2 Nov 2021 04:57:01 -0700 (PDT) Received: from localhost ([::1]:59614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsPU-0006oJ-9U for importer@patchew.org; Tue, 02 Nov 2021 07:57:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreJ-00042t-Ky for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:38522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000wu-7K for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: by mail-qt1-x833.google.com with SMTP id h4so17862632qth.5 for ; Tue, 02 Nov 2021 04:08:00 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:00 -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=mXI5pLklfarH8j3WhgGW5xn4dLCOLkkDAfhYzkOpzbo=; b=pnWkhqvB+yiHYoayc0XTVOtqrb/Zj7wlE0pU/F/+hcJJYdDFIQelrGO2yH2GLCrmJP u8CdzMabCW2SgUSoJHsZEOUVl+LjOoPJagAqVn/RafyJtN1/Y8cAxs8yXnuUY7nJ2F2E f0EQocLINTK1OtcoorMSQQ0/OO3pNtpVCAk6E2anMX8gybPd1CPH8GPoEti6gqSTiTZw /K6aOxMwfd5j450oK6DXLEZ6bqlfIjQYnAzxkiotMujFyJNQlrMdFVLCQBfT8xpwvfCr l4dsbBi9OELYeaJKOMIWUUCKnPIzvDJwv8eYnAdcxlt8HnypJhBuXAk2s3v/KxzwSAWO PUeA== 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=mXI5pLklfarH8j3WhgGW5xn4dLCOLkkDAfhYzkOpzbo=; b=iO/eBdXlip+VgoP6jL3uHXSFKW1vWodIEJL6IMz35aoNvtpm0u9nCodCNCKvbTWgES YhNUfPnVJpoDf+NiQpm4dNTLIoo996hfsod7FooDHVNXmWIavVm6Y3T+0jnnK2UIHLLm kPxk3J/9XgZo85hRfcswERtiq4ipjOZV7GY7coVobVv7sf8zfncXMWGjH9mh18DBnSbb Oh3Wcneizjm6h/bmRDBAN7/RQvrJkLQZWvmqCemGlgxzEjfXT1qvbVI+JllXXxyK2mHt j8Avg+2jYVZfvFHj5DaZS03yNPJHgr1c+xch45/tMt+Y0iN4f3TNlrSaWC6uS7EoQy9R lvFA== X-Gm-Message-State: AOAM530Z71Fu1wbEGBVVOF16PAGSdB+W3RUsUyaq0CvTckQDDtVm/ZlP qACM5vV6jm23rFfJzw21wspJPy0ljpHpCA== X-Google-Smtp-Source: ABdhPJx3t3Vk740y0qck+fmHEf0wrP5gPk8o+sc4k0sh7yuuoBLGhg23bq4ARzptPnVjU4ngzRmY9g== X-Received: by 2002:ac8:5f51:: with SMTP id y17mr327607qta.154.1635851280521; Tue, 02 Nov 2021 04:08:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 32/60] linux-user/openrisc: Abort for EXCP_RANGE, EXCP_FPE Date: Tue, 2 Nov 2021 07:07:12 -0400 Message-Id: <20211102110740.215699-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854222636100003 QEMU does not allow the system control bits for either exception to be enabled in linux-user, therefore both exceptions are dead code. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/openrisc/cpu_loop.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c index f6360db47c..10b7147f68 100644 --- a/linux-user/openrisc/cpu_loop.c +++ b/linux-user/openrisc/cpu_loop.c @@ -56,7 +56,6 @@ void cpu_loop(CPUOpenRISCState *env) break; case EXCP_DPF: case EXCP_IPF: - case EXCP_RANGE: info.si_signo =3D TARGET_SIGSEGV; info.si_errno =3D 0; info.si_code =3D TARGET_SEGV_MAPERR; @@ -77,13 +76,6 @@ void cpu_loop(CPUOpenRISCState *env) info._sifields._sigfault._addr =3D env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; - case EXCP_FPE: - info.si_signo =3D TARGET_SIGFPE; - info.si_errno =3D 0; - info.si_code =3D 0; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_INTERRUPT: /* We processed the pending cpu work above. */ break; @@ -96,6 +88,15 @@ void cpu_loop(CPUOpenRISCState *env) case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; + case EXCP_RANGE: + /* Requires SR.OVE set, which linux-user won't do. */ + cpu_abort(cs, "Unexpected RANGE exception"); + case EXCP_FPE: + /* + * Requires FPSCR.FPEE set. Writes to FPSCR from usermode not + * yet enabled in kernel ABI, so linux-user does not either. + */ + cpu_abort(cs, "Unexpected FPE exception"); default: g_assert_not_reached(); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852837; cv=none; d=zohomail.com; s=zohoarc; b=DSl778VkXOXoSoAF1uO4mvBt0n/5u+fQLqM3/L9u8FFQ2oS5nRBtYXUE98oUbpazKi7+d/zmb4nBBtGV2idMIsiabMcZwqhxxhMmWJhc0bHy9lZC8KOeV0ulcVHzm2ylTVIEIYZXfvpRZ197S7SS0bBCmtHVOgvKs5S6KgeBGYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852837; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pnbVDz2F7bl2MnMZvXAf7/LYYOvOlpdsDMsaNKSumSw=; b=WHiWAHQH8AudTOmuBLVaq658aNesq54thyTJOda3RMnZ13QEQQti+H3QC6fBAqEBACNKy36z0Xo5Bs7k4Jo8FTPqtSo2875IQ29Y/tqStVT9hNWV4gAKE8jVU5b+7ZYnZ31juj40AEwPBmhxJKaM3Q9HsQ83XcZ2hZRAzwXSraQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163585283740229.452386068820033; Tue, 2 Nov 2021 04:33:57 -0700 (PDT) Received: from localhost ([::1]:36246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs3A-0004oD-3k for importer@patchew.org; Tue, 02 Nov 2021 07:33:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreM-00044y-8h for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:23 -0400 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]:35613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreF-0000wy-Fa for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:18 -0400 Received: by mail-qv1-xf2c.google.com with SMTP id u25so13036248qve.2 for ; Tue, 02 Nov 2021 04:08:01 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:00 -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=pnbVDz2F7bl2MnMZvXAf7/LYYOvOlpdsDMsaNKSumSw=; b=gzCYzORViM2sFtaz04+I7cfzoOC6ky9SmBRjIjDJFp3S653I2oe0AEfYD5FzJb9uUO BBMQ1ecQFqNfmBg2C8GqWCmDghStgo8hENurmVn2Kd6kT6altUzwOb99G/2UE83OvEIO BrfwMA1l+VMC1jBktUEJgb5fGkvd5321BRVPLwuA7pScvhYtNMzVgcQngV65sT0Ax14C DIs3T4OnflYpLU2CZoD3tRPZ5uselL3kykUKj4lH5WUtA/3oaRiNfN2P2qjMfKKWX5xe calGBSdNtruLveP7NUUZgEr+AM/lNVI5ZcCbEXqVMu6GN5Y5NIf3DS5L/X06c++sxy2y /VFg== 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=pnbVDz2F7bl2MnMZvXAf7/LYYOvOlpdsDMsaNKSumSw=; b=mqfGAX88B3XxHNpT9INCRHB+fnWA5VNHFheqYphQleeBJlZgR0a2JcDiF+WYFBC9+c 27I6UF7dFa9pJlDuu9uZhZsCbpPpaK8baRrUcxbetOeCbF07goLTHawPs4cH27i2GNUD rSKfeUrlUAJevHsbBDrMp3Epb+cIrFYliawZ2X/osdm/Opgof8mV3Z565D9nHV8bFJrE C8C4s0V2nzbn/gaCyqr8LHX23RhUZ/gA+XPZY0E5PudzwRJm30i5WfZQQpGdbM75ztEa SekhXJVQtt9IVHzGcEZqtt73bwrewf11spD3ztU9h47WdqDgfX4j7M0+COOzrk8MEAU/ 7irA== X-Gm-Message-State: AOAM533mV3kHD2pWLlv7t0TqWw2J+FQtekWwk1Ec1hM7KaQrhf9x49Uk FQGt4E8t0llHAqg9qHuM3/pyqdgbQrX5dA== X-Google-Smtp-Source: ABdhPJyHOdIj1BK+/bT6X2YZjV0tMMb3+dUJz3zVLxXAH2w0HtAV9f5QOX17VzYiprhDSGy0b1OlsQ== X-Received: by 2002:a05:6214:29eb:: with SMTP id jv11mr35067397qvb.9.1635851281044; Tue, 02 Nov 2021 04:08:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 33/60] target/openrisc: Make openrisc_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:13 -0400 Message-Id: <20211102110740.215699-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2c; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852839283100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for openrisc linux-user. This makes all of the code in mmu.c sysemu only, so remove the ifdefs and move the file to openrisc_softmmu_ss. Remove the code from cpu_loop that handled EXCP_DPF. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 7 ++++--- linux-user/openrisc/cpu_loop.c | 8 -------- target/openrisc/cpu.c | 2 +- target/openrisc/mmu.c | 9 --------- target/openrisc/meson.build | 2 +- 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 187a4a114e..ee069b080c 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -317,14 +317,15 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu= , vaddr addr); int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg= ); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void openrisc_translate_init(void); -bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); int print_insn_or1k(bfd_vma addr, disassemble_info *info); =20 #define cpu_list cpu_openrisc_list =20 #ifndef CONFIG_USER_ONLY +bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + extern const VMStateDescription vmstate_openrisc_cpu; =20 void openrisc_cpu_do_interrupt(CPUState *cpu); diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c index 10b7147f68..3cfdbbf037 100644 --- a/linux-user/openrisc/cpu_loop.c +++ b/linux-user/openrisc/cpu_loop.c @@ -54,14 +54,6 @@ void cpu_loop(CPUOpenRISCState *env) cpu_set_gpr(env, 11, ret); } break; - case EXCP_DPF: - case EXCP_IPF: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_ALIGN: info.si_signo =3D TARGET_SIGBUS; info.si_errno =3D 0; diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 27cb04152f..dfbafc5236 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -186,9 +186,9 @@ static const struct SysemuCPUOps openrisc_sysemu_ops = =3D { =20 static const struct TCGCPUOps openrisc_tcg_ops =3D { .initialize =3D openrisc_translate_init, - .tlb_fill =3D openrisc_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D openrisc_cpu_tlb_fill, .cpu_exec_interrupt =3D openrisc_cpu_exec_interrupt, .do_interrupt =3D openrisc_cpu_do_interrupt, #endif /* !CONFIG_USER_ONLY */ diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 94df8c7bef..e561ef245b 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -23,11 +23,8 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "qemu/host-utils.h" -#ifndef CONFIG_USER_ONLY #include "hw/loader.h" -#endif =20 -#ifndef CONFIG_USER_ONLY static inline void get_phys_nommu(hwaddr *phys_addr, int *prot, target_ulong address) { @@ -94,7 +91,6 @@ static int get_phys_mmu(OpenRISCCPU *cpu, hwaddr *phys_ad= dr, int *prot, return need & PAGE_EXEC ? EXCP_ITLBMISS : EXCP_DTLBMISS; } } -#endif =20 static void raise_mmu_exception(OpenRISCCPU *cpu, target_ulong address, int exception) @@ -112,8 +108,6 @@ bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, in= t size, { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); int excp =3D EXCP_DPF; - -#ifndef CONFIG_USER_ONLY int prot; hwaddr phys_addr; =20 @@ -138,13 +132,11 @@ bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, = int size, if (probe) { return false; } -#endif =20 raise_mmu_exception(cpu, addr, excp); cpu_loop_exit_restore(cs, retaddr); } =20 -#ifndef CONFIG_USER_ONLY hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); @@ -177,4 +169,3 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, v= addr addr) return phys_addr; } } -#endif diff --git a/target/openrisc/meson.build b/target/openrisc/meson.build index e445dec4a0..84322086ec 100644 --- a/target/openrisc/meson.build +++ b/target/openrisc/meson.build @@ -10,7 +10,6 @@ openrisc_ss.add(files( 'fpu_helper.c', 'gdbstub.c', 'interrupt_helper.c', - 'mmu.c', 'sys_helper.c', 'translate.c', )) @@ -19,6 +18,7 @@ openrisc_softmmu_ss =3D ss.source_set() openrisc_softmmu_ss.add(files( 'interrupt.c', 'machine.c', + 'mmu.c', )) =20 target_arch +=3D {'openrisc': openrisc_ss} --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852691961181.53201942021303; Tue, 2 Nov 2021 04:31:31 -0700 (PDT) Received: from localhost ([::1]:55870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs0o-0007Ts-TY for importer@patchew.org; Tue, 02 Nov 2021 07:31:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreM-00044w-61 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:23 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:35364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreF-0000x3-Ff for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:17 -0400 Received: by mail-qt1-x832.google.com with SMTP id n2so18483171qta.2 for ; Tue, 02 Nov 2021 04:08:02 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:01 -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=b7jpFgMMciMmW9Xl8VdlfSERFh4gLfLYDvd7byDKhQQ=; b=w7Pm78LuAizvjoUZfy4dfSHmmY31Ki3yRDddBQ2xgO9Pq8rT2Ga3GHlNM349h7Q251 vXkACRNhmmFS7Igx6x0N1hp8k5XktLBqW80Ieh7YHmErXq3qR/T/jNQASwwawJiVlRuo DeiYdXvNyHnXVWwhDz4ebX43UyE+sztk46GNIfBiibfppj00p5hWNmBy7wAX7rufc1WK K6oAkk4SYHUo0DxeLBOeKjC7MuKAaUQzP5LPFRe9RUMdkpl1Tcw5ICs0ZItKKkCCsQ1O W0lQFrJqvgtVp6XUciRuX/fMVixB0PvhTTe3iBWf53bEvVsOYqkis61h8ySsygqBkE4y x9vg== 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=b7jpFgMMciMmW9Xl8VdlfSERFh4gLfLYDvd7byDKhQQ=; b=rvpfVapn8GoyJEsnYL4D3g8SNi7bS0KIv/37kcxaF3rpAg33ANoqy5q/9TEZh1E9AU j0ABhf6gGOeY4M1GdSEDXFu7aue/FvptyOnnHzfxtEx70zEQRElXs2DZReixr8Md9BMD H0epO8zCrD6qQuopnXlIa2RBbm60pePL/7E2ZAYdOFPjQwAR/9NeS2sGDLqg5oFfLO65 zoPMx6WmDd41wk7eVX30uAvUfkHD1f8x+z2WiJwHBXAw+5HBKZVUt/cXiF6pqtLHjrx2 ZH3pUnI0KBNvF8QMw8E3WnxrEGrMm3/mkhIlJMcn1+oGywn9OOMiHYvpW+SjKhy9PDXf Hztw== X-Gm-Message-State: AOAM530VexoXFx6v5R7ItVWATjf0YRroa0IKzPDddI3+trdd+k0XdQKG khrf0MwHgpEOv8qO3Nmeg2Se9W9wYXuPPw== X-Google-Smtp-Source: ABdhPJxXWwDm/kSPArwFLQSrHSZ98WVRhCaRPBEXcCctrGN5jBZ/1iiVsLCAX1utsdo1URjxQpoTkg== X-Received: by 2002:ac8:7f84:: with SMTP id z4mr20919448qtj.81.1635851281573; Tue, 02 Nov 2021 04:08:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 34/60] target/ppc: Implement ppc_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:14 -0400 Message-Id: <20211102110740.215699-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852692706100001 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. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 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(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 0472ec9154..e946da5f3a 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1302,9 +1302,6 @@ extern const VMStateDescription vmstate_ppc_cpu; =20 /*************************************************************************= ****/ 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); =20 #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) =20 +#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 =20 #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 65545ba9ca..1c7a7b4b38 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -9014,9 +9014,11 @@ static const struct SysemuCPUOps ppc_sysemu_ops =3D { =20 static const struct TCGCPUOps ppc_tcg_ops =3D { .initialize =3D ppc_translate_init, - .tlb_fill =3D ppc_cpu_tlb_fill, =20 -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D ppc_cpu_record_sigsegv, +#else + .tlb_fill =3D ppc_cpu_tlb_fill, .cpu_exec_interrupt =3D ppc_cpu_exec_interrupt, .do_interrupt =3D ppc_cpu_do_interrupt, .cpu_exec_enter =3D 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" =20 - -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 =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; int exception, error_code; =20 + /* + * 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 =3D=3D MMU_INST_FETCH) { exception =3D POWERPC_EXCP_ISI; error_code =3D 0x40000000; --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852285706926.7838407013592; Tue, 2 Nov 2021 04:24:45 -0700 (PDT) Received: from localhost ([::1]:59096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhruG-00077s-9H for importer@patchew.org; Tue, 02 Nov 2021 07:24:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreH-0003yN-LT for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:13 -0400 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]:33444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000x6-5u for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:13 -0400 Received: by mail-qv1-xf2e.google.com with SMTP id bu11so5128382qvb.0 for ; Tue, 02 Nov 2021 04:08:02 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:01 -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=HtawaHYSfgiYXorLPYx7eO4JeOJDito5IEpdHHHLhLI=; b=d5XBfcx5/8OSdGEct/WPG74GObZrYxKliUTjbRFV1f7A5bEhv3AgcYz0xLvQH5MuYj 3YLtiPsUc87wonpche+Yq9CnPP8tf9b+9wJXVDcOglvh3Tn/C7gFgJ03nn/JFJActgb6 N+7M1uPA7WIh9fdhTrgtzIxk5Ncu/dpNiNcSgnALn2UDO/O8I70gnIXeVmBMzNeaMqig gkM3oBvVKiWqC5WPYyTLe7mxl1fPHMp4XybjfVeYrbP/eFRV8yFbCNhW9lHyl1QhJPeJ 44Yf/VeUnrO6aF6LJ1zRSAzqiUS2L9mXHXC+EaURiYsVBCXOKKRUQB3JoiRZQn7yc2G+ MORA== 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=HtawaHYSfgiYXorLPYx7eO4JeOJDito5IEpdHHHLhLI=; b=pMFc9XfdWKEmsxT/SxvNvkVt1ceqvo5Rcm2tCxFGwkSb+kSjDdJQ0lxVRiVF5FNC0W BXQ/Gru36ljBjdd1GVn/UNBq/PfAVdG6R2XGGZnbyLDiXDY+/lRfHwsL5sDizPXvP5U/ cRDYgXFCIQKLeFnX//zZ3quEi1sWBFg5hksZLG7ue9rm1DAe6hnqciGS4CpZ0EIYRi4d 80Mkpp2HQdDfcFE6G7cgzRkNnJv+LBvQ4QeF0FSC+vEvDJ7TGuf9dDId9Mf/wTPXLjFH GpWQelzdaNS7kdTXMr3mCL93Mh46pYmVEilQe9ixM4a9ET52ssFbcF0BRVntHxO3Oo7E wVoA== X-Gm-Message-State: AOAM533mEXFfydxHWDE7zCY7GH42k50KS4pNMKckjyP8pjSzHdx/lrNj Co4vU3cJWGwQXt9d9Qn9/wgnisN28bbpGw== X-Google-Smtp-Source: ABdhPJxiKZvyo5zTeEQxTj5dzcW1xHzVh11zs9NFMHP1C5kInX4zmsgCYryelG5R6jpqTbJWNuyrPQ== X-Received: by 2002:a0c:b341:: with SMTP id a1mr33425202qvf.21.1635851282246; Tue, 02 Nov 2021 04:08:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 35/60] target/riscv: Make riscv_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:15 -0400 Message-Id: <20211102110740.215699-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2e; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2e.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852286174100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for riscv linux-user. Remove the code from cpu_loop that raised SIGSEGV. Reviewed-by: Warner Losh Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/riscv/cpu_loop.c | 7 ------- target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 21 +-------------------- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index e5bb6d908a..b301dac802 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -87,13 +87,6 @@ void cpu_loop(CPURISCVState *env) sigcode =3D TARGET_TRAP_BRKPT; sigaddr =3D env->pc; break; - case RISCV_EXCP_INST_PAGE_FAULT: - case RISCV_EXCP_LOAD_PAGE_FAULT: - case RISCV_EXCP_STORE_PAGE_FAULT: - signum =3D TARGET_SIGSEGV; - sigcode =3D TARGET_SEGV_MAPERR; - sigaddr =3D env->badaddr; - break; case RISCV_EXCP_SEMIHOST: env->gpr[xA0] =3D do_common_semihosting(cs); env->pc +=3D 4; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7d53125dbc..f812998123 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -694,9 +694,9 @@ static const struct SysemuCPUOps riscv_sysemu_ops =3D { static const struct TCGCPUOps riscv_tcg_ops =3D { .initialize =3D riscv_translate_init, .synchronize_from_tb =3D riscv_cpu_synchronize_from_tb, - .tlb_fill =3D riscv_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D riscv_cpu_tlb_fill, .cpu_exec_interrupt =3D riscv_cpu_exec_interrupt, .do_interrupt =3D riscv_cpu_do_interrupt, .do_transaction_failed =3D riscv_cpu_do_transaction_failed, diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index f30ff672f8..9eeed38c7e 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -814,7 +814,6 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr = addr, riscv_cpu_two_stage_lookup(mmu_idx); riscv_raise_exception(env, cs->exception_index, retaddr); } -#endif /* !CONFIG_USER_ONLY */ =20 bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, @@ -822,7 +821,6 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, in= t size, { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; -#ifndef CONFIG_USER_ONLY vaddr im_address; hwaddr pa =3D 0; int prot, prot2, prot_pmp; @@ -954,25 +952,8 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, } =20 return true; - -#else - switch (access_type) { - case MMU_INST_FETCH: - cs->exception_index =3D RISCV_EXCP_INST_PAGE_FAULT; - break; - case MMU_DATA_LOAD: - cs->exception_index =3D RISCV_EXCP_LOAD_PAGE_FAULT; - break; - case MMU_DATA_STORE: - cs->exception_index =3D RISCV_EXCP_STORE_PAGE_FAULT; - break; - default: - g_assert_not_reached(); - } - env->badaddr =3D address; - cpu_loop_exit_restore(cs, retaddr); -#endif } +#endif /* !CONFIG_USER_ONLY */ =20 /* * Handle Traps --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852431; cv=none; d=zohomail.com; s=zohoarc; b=njNwjIYlMgYiGYczJc5s/pohURTK7/ltBNRNZmBrnejs0IJwnPlt7tFKqe+kyVB/rPUg09J5kMuD1V3qQ5r4E/MitXOOx+Fd32JVV8JDIYu/Qm7ipV8v7N3OcYoy7PEVi8U2Yur+i638N4Lq0QeG2zJHFniIJLebnL8Zb5mCosY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852431; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ky6yY478j1xSRIHIN9BTjrdKe+bHyugXQSySqll0teU=; b=K9mS4o0I0/qYZ11oufo3d0pk5cy9fKQCfhc9bijz9KKfj6QzJRy1QUhmCIQp14M2wTJC6O74A2qlOJ7XpodA+9jEYB0GtloO2A38iLfU5CXXnRavE5fYrcD+zURPfQfwnkQRaQSIeWCDllx0BY/8JdZibmLNNWEf9yg3qmmkcUs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852431276833.2162665203261; Tue, 2 Nov 2021 04:27:11 -0700 (PDT) Received: from localhost ([::1]:39230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhrwc-0004TX-7q for importer@patchew.org; Tue, 02 Nov 2021 07:27:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreI-00041Z-Bn for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:47032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000xQ-6D for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:14 -0400 Received: by mail-qt1-x831.google.com with SMTP id s1so17058306qta.13 for ; Tue, 02 Nov 2021 04:08:03 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:02 -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=Ky6yY478j1xSRIHIN9BTjrdKe+bHyugXQSySqll0teU=; b=CoR6ArYsP8cXGcnYSe1j3CYMMo2H73WLCf/wQpMdMeLfaQ1jYWBc1KSTVpEV3rn+b3 wTuvvqbp9Ex3JIfTPzvflGTKsg+Cwr0fNf5z503IsmgqY1nXwg9tooyISVt1TGU6Ib9V EDi++kN0Nfz3PE8lIP2bz2rMZakWO/5kGfHDCNr9gnARGu5TWCbqHQoPkc5/nyuWSjXu Hc4z9xC39PYods5jFRCBLAa9xqUO0oeoytSFdVVfsNjI6nbKZao/N2OSTNZawBzjXdOl d90CB11Sqaa/eZjd7mdyNuqz/7/Hnvev80nZy8Fkcysn+RcLrWziKqojURPCyHx+TVPF +PRg== 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=Ky6yY478j1xSRIHIN9BTjrdKe+bHyugXQSySqll0teU=; b=NWk+5/bm1pohWuq5ksOId0xufln1iVCeKyu5KZdJ38gD/OhKD2mzRySmciXY7ipZ5e J9UNpq2b880U+nROnR01STA4Y7O/BQkF7a7JdgnKf+aYufhud67Xuz3HE0/qXfuOKuz/ XRwTG9O2gCFCR5YJTEtFrt3Pq0pBzmmbSgISdYWjPbeEMNcrgt7bG+GtAidDTD1VbXBV jTy/nGawyr7Icqq1koNVG3Tficrvgb/tz+9AC0n+oE6+qZg1DWYJNpH8KyfJqz99fq7c wy5OqFdxmxCdN2dtUq408xlfz6vRGggI0hBmSECgAiH6x2pm13iVep+3j8gCOwSJad+L GhjQ== X-Gm-Message-State: AOAM5332eSq8fNkDwY1TOpPAaLdGZoEesGvWQrP+i6wdufnH5FiGitg7 CFDyFkxCI2I6eGpS5QslaHUfKxr7UYIHzw== X-Google-Smtp-Source: ABdhPJxZju3CNfW8/yNqSysTC966zo3ozGoExvG7lk6dTRZfw4cyYnqS6CifSIHYlnBtm5XhHQ3DWg== X-Received: by 2002:a05:622a:1883:: with SMTP id v3mr625816qtc.21.1635851282808; Tue, 02 Nov 2021 04:08:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/60] target/s390x: Use probe_access_flags in s390_probe_access Date: Tue, 2 Nov 2021 07:07:16 -0400 Message-Id: <20211102110740.215699-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::831; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x831.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852433469100001 Not sure why the user-only code wasn't rewritten to use probe_access_flags at the same time that the sysemu code was converted. For the purpose of user-only, this is an exact replacement. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/tcg/mem_helper.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 17e3f83641..362a30d99e 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -141,20 +141,12 @@ static int s390_probe_access(CPUArchState *env, targe= t_ulong addr, int size, MMUAccessType access_type, int mmu_idx, bool nonfault, void **phost, uintptr_t ra) { +#if defined(CONFIG_USER_ONLY) + return probe_access_flags(env, addr, access_type, mmu_idx, + nonfault, phost, ra); +#else int flags; =20 -#if defined(CONFIG_USER_ONLY) - flags =3D page_get_flags(addr); - if (!(flags & (access_type =3D=3D MMU_DATA_LOAD ? PAGE_READ : PAGE_WR= ITE_ORG))) { - env->__excp_addr =3D addr; - flags =3D (flags & PAGE_VALID) ? PGM_PROTECTION : PGM_ADDRESSING; - if (nonfault) { - return flags; - } - tcg_s390_program_interrupt(env, flags, ra); - } - *phost =3D g2h(env_cpu(env), addr); -#else /* * For !CONFIG_USER_ONLY, we cannot rely on TLB_INVALID_MASK or haddr= =3D=3DNULL * to detect if there was an exception during tlb_fill(). @@ -173,8 +165,8 @@ static int s390_probe_access(CPUArchState *env, target_= ulong addr, int size, (access_type =3D=3D MMU_DATA_STORE ? BP_MEM_WRITE : BP_MEM_READ), ra); } -#endif return 0; +#endif } =20 static int access_prepare_nf(S390Access *access, CPUS390XState *env, --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853931; cv=none; d=zohomail.com; s=zohoarc; b=E4hO3BB3eRVEb/jvuJU3K/NIFU1GgGw298BDfYP0mRJaW1sj6I/JepSVwop0Cwxmtk7/mJ4xFvnfcsI5i7BP619eNm3PRd/SOn7ar6jtVrgJ0DgnTkaN9AkixVoiUVuFIHXanL1/Wi5DCF1L2+6B7lGns/PjzXAQFbuee/CHsgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853931; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ij1YRgU0peRo+QSVg6ezzkIr6IGfKaWXUXRkApukMz0=; b=HksvJjEKFpwPYX4gmpKDHON+SJ/nM+Fkfp05LmGe3/zMXZHWwKfujQgg3Tey9AOBrPPN/wmt0thJ67CPx7uhw/uUQBzDoptYXRFcwTHaTlZGDc54NloDFeEe7PqQTxQ5nCd6MzPjsGtszstMyzfSdboBWR9bXTfmCRotG7KAuL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853931647565.6230935558331; Tue, 2 Nov 2021 04:52:11 -0700 (PDT) Received: from localhost ([::1]:42872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsKo-0003Pz-KP for importer@patchew.org; Tue, 02 Nov 2021 07:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreH-0003z0-Rn for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:13 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:44742) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000xv-5A for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:13 -0400 Received: by mail-qt1-x834.google.com with SMTP id j1so11231808qtq.11 for ; Tue, 02 Nov 2021 04:08:03 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:03 -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=ij1YRgU0peRo+QSVg6ezzkIr6IGfKaWXUXRkApukMz0=; b=mijVd7qt0SQmG3SprTb4p9iFUztYn9bWxJNV38KjaLdCsngHxnTEcDXPYA8O864+JC c0A2huwxLi1As5sRkDTHQXDnlRxnLe8kOIBQo45Bx9xwtkFQHNiRk68xsx95be/Q1ln3 zwSjRnvLdEIaCLUEtre+7ScAS/5/xZ7ARK/kGoKwFTAC33qQqAaf9Ey9x2PLg6OBIG4L 2fMma8Q3QmkQ7YofKw66VyDUyARXGvNGArBI66pBAMueFa8A9N8qIo3VuAeoNJj5qUIB YGH1rrZb/kccQBSSSIBqwfG/oqAgQQIQ7IPJP9WlIXrnOQwZckDVo55GkjMeQsOBo/a3 DNMw== 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=ij1YRgU0peRo+QSVg6ezzkIr6IGfKaWXUXRkApukMz0=; b=qiSSkDCTJkBx0uja3n1b68N/xjHhISK90lk3tsnD8vK+Iz7Hs75n3Low1u1DRtTvF9 mxvFBH0//bDRpDU6X8cuGbjAGxUsxzfZKDwtmOw27f2cL5thpoS7NUuw7F5pHs8zucgk R4tuQFhbHjoGA6W59X8BbRZpbHEhu4tR7pbSp+lrlSs4kW0KgGxq/OWTT/yl4RtNfrGx pxRgqT9duTPhYh2dm3F9aqRLmQGB0Cgq1hZqhL3Rf8+EcL/d9upgoiCP7wGMGswRLl7e zXH8JRSZG81839XaoyY+8pqyVD20KkMgARJd1bhTUyFbipsdAY2LAaBcUeRdEuEug+qr AWbA== X-Gm-Message-State: AOAM530qTtyWB+EXaGya/U9aakPDpkW6YTupYLJFZJXA6eOaCXiNZLxG EG+zP6Rbvroqc7SEuUB9qklBDnTDXJJ8fg== X-Google-Smtp-Source: ABdhPJz4hwCehSiH4mYHkcleRW72IAIEB7P8lbkoQ/wWH+7uoB1f5Lq65lWA0Yu43KGQappr3+in3Q== X-Received: by 2002:a05:622a:199c:: with SMTP id u28mr27407417qtc.124.1635851283375; Tue, 02 Nov 2021 04:08:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 37/60] target/s390x: Implement s390_cpu_record_sigsegv Date: Tue, 2 Nov 2021 07:07:17 -0400 Message-Id: <20211102110740.215699-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853933026100001 Move the masking of the address from cpu_loop into s390_cpu_record_sigsegv -- this is governed by hw, not linux. This does mean we have to raise our own exception, rather than return to the fallback. Use maperr to choose between PGM_PROTECTION and PGM_ADDRESSING. Use the appropriate si_code for each in cpu_loop. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/s390x-internal.h | 13 ++++++++++--- linux-user/s390x/cpu_loop.c | 13 ++++++------- target/s390x/cpu.c | 6 ++++-- target/s390x/tcg/excp_helper.c | 18 +++++++++++------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 27d4a03ca1..163aa4f94a 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -270,13 +270,20 @@ ObjectClass *s390_cpu_class_by_name(const char *name); void s390x_cpu_debug_excp_handler(CPUState *cs); void s390_cpu_do_interrupt(CPUState *cpu); bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req); -bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) QEMU_NORETURN; =20 +#ifdef CONFIG_USER_ONLY +void s390_cpu_record_sigsegv(CPUState *cs, vaddr address, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr); +#else +bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); +#endif + =20 /* fpu_helper.c */ uint32_t set_cc_nz_f32(float32 v); diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index 69b69981f6..d089c8417e 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -24,8 +24,6 @@ #include "cpu_loop-common.h" #include "signal-common.h" =20 -/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIG= BUS */ -#define S390X_FAIL_ADDR_MASK -4096LL =20 static int get_pgm_data_si_code(int dxc_code) { @@ -111,12 +109,13 @@ void cpu_loop(CPUS390XState *env) n =3D TARGET_ILL_ILLOPC; goto do_signal_pc; case PGM_PROTECTION: + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_ACCERR, + env->__excp_addr); + break; case PGM_ADDRESSING: - sig =3D TARGET_SIGSEGV; - /* XXX: check env->error_code */ - n =3D TARGET_SEGV_MAPERR; - addr =3D env->__excp_addr & S390X_FAIL_ADDR_MASK; - goto do_signal; + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->__excp_addr); + break; case PGM_EXECUTE: case PGM_SPECIFICATION: case PGM_SPECIAL_OP: diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 7b7b05f1d3..593dda75c4 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -266,9 +266,11 @@ static void s390_cpu_reset_full(DeviceState *dev) =20 static const struct TCGCPUOps s390_tcg_ops =3D { .initialize =3D s390x_translate_init, - .tlb_fill =3D s390_cpu_tlb_fill, =20 -#if !defined(CONFIG_USER_ONLY) +#ifdef CONFIG_USER_ONLY + .record_sigsegv =3D s390_cpu_record_sigsegv, +#else + .tlb_fill =3D s390_cpu_tlb_fill, .cpu_exec_interrupt =3D s390_cpu_exec_interrupt, .do_interrupt =3D s390_cpu_do_interrupt, .debug_excp_handler =3D s390x_cpu_debug_excp_handler, diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index 3d6662a53c..b923d080fc 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -89,16 +89,20 @@ void s390_cpu_do_interrupt(CPUState *cs) cs->exception_index =3D -1; } =20 -bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) +void s390_cpu_record_sigsegv(CPUState *cs, vaddr address, + MMUAccessType access_type, + bool maperr, uintptr_t retaddr) { S390CPU *cpu =3D S390_CPU(cs); =20 - trigger_pgm_exception(&cpu->env, PGM_ADDRESSING); - /* On real machines this value is dropped into LowMem. Since this - is userland, simply put this someplace that cpu_loop can find it. = */ - cpu->env.__excp_addr =3D address; + trigger_pgm_exception(&cpu->env, maperr ? PGM_ADDRESSING : PGM_PROTECT= ION); + /* + * On real machines this value is dropped into LowMem. Since this + * is userland, simply put this someplace that cpu_loop can find it. + * S390 only gives the page of the fault, not the exact address. + * C.f. the construction of TEC in mmu_translate(). + */ + cpu->env.__excp_addr =3D address & TARGET_PAGE_MASK; cpu_loop_exit_restore(cs, retaddr); } =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635852568; cv=none; d=zohomail.com; s=zohoarc; b=Jqn7vQ9DlQxfJIYGHNIM4vsirR/QESe69ws79GXrdO68ViO8ULrJibvzIwCk/GPOxDtjBpq7l7mRGAbsCdC6zqM8zYUcdPW014nWI9MD8sqAuY1+QlXo5E3foQGXixmWJSGeuAThAN2rzrkxRtG2Fd7MDbL16zyQ+JJWYnMvaxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635852568; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bSOPptd8n2vyIHjygFEkKtsmxu32Sh4/nm0zdx+yC2M=; b=UqMjxAIc7LzEP+js226E7RCd+V0YCzSSNa/71E3DEBM//UZ1WjYL4Je5r8sQgbGuTbUq0H/BR5GbrmkPFlxl4FN3IhwVQ8lkLq/9Mx8CqvAgx4xxiXVBrgvumoQueeW6kuHaH//PuJ5Y40nvHW8pd0tyOR8wkb69REHVPHyt8fk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852568280270.78163095500804; Tue, 2 Nov 2021 04:29:28 -0700 (PDT) Received: from localhost ([::1]:47546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhryp-0001nq-AE for importer@patchew.org; Tue, 02 Nov 2021 07:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreJ-00042X-AH for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:39456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000y3-75 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: by mail-qt1-x831.google.com with SMTP id t40so18450787qtc.6 for ; Tue, 02 Nov 2021 04:08:04 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:03 -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=bSOPptd8n2vyIHjygFEkKtsmxu32Sh4/nm0zdx+yC2M=; b=RWo6+dIKiAHeUzMx9quxbneqCPTS+sysEAb+8hRvjhWDjl3SnRAxDMLHvHmJTjVyH2 sZ9AuFAiXdDnRgkK3Vl6efh7oRDtjkRhljNSGCNZSUI3hIwXrrfD0m0fEjgduY8RP3a+ PGkw8WaliK21DZfJgWY7o1eFx01Usk4QjPEEH12xk+dHPJU14/64n3BVFBzDQNMUzNR/ 91rnUmcT6rgmAm93g9BT8plvctbuXQmqj5h7OjEe+ZpdgaEZtbPfc8NCfBz4Wm3L2IPw vcryYrLbYGTVyD1v2ed7NKoGJ6q+ndUZtrAiGyobwu0g3nXyO3AMeMfPpznU2cn6f4Ww QyMQ== 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=bSOPptd8n2vyIHjygFEkKtsmxu32Sh4/nm0zdx+yC2M=; b=k4Nkgax3UJWfIglg/FUFBVMBRLphKbCwJdfFx3/cO6FiRm2vkQldSO+k09ziNFQphH 5UZQMVWTMIMYYW9hi63S4TUwktrrbtfRRFbRYtS15hDf/gAv06jSl3movr8OG1CknjNl 41EzCQGkfIQawJ+CAvNrRtPZUWB2fAp+NOaUBspVCoT6tv85WoalhFesnJYRh2puWZs+ OumNIX51dKmAhmIcpNTx//hy+QyM+tzLu72+6Y6KUE9iwK4e6lZjs9FWHBT85zKz3MtU 1D+TLRu4Yb0iFf+50+mhtmvZuyS85TVxKt5adIe8oB6MyfWPTooue32THyAkDliPggkm /tLQ== X-Gm-Message-State: AOAM532U5mKZORoIYxO8DTx/W7xNhN1ctXM/Xdjis+XCdyW2ykXy1bUS Bp55mzphZEgnj8g8c6J73FzGeyv/8htPWw== X-Google-Smtp-Source: ABdhPJzmebVTRcAfLGJ2G1aC7ACa2m+1qAYfy+FYgTnRXas0dgBXk/j8joQQn/XpZFkInM47/vVKbw== X-Received: by 2002:ac8:5a4b:: with SMTP id o11mr38090678qta.59.1635851283926; Tue, 02 Nov 2021 04:08:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 38/60] target/sh4: Make sh4_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:18 -0400 Message-Id: <20211102110740.215699-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::831; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x831.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635852569483100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for sh4 linux-user. Remove the code from cpu_loop that raised SIGSEGV. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/sh4/cpu.h | 6 +++--- linux-user/sh4/cpu_loop.c | 8 -------- target/sh4/cpu.c | 2 +- target/sh4/helper.c | 9 +-------- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index dc81406646..4cfb109f56 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -213,12 +213,12 @@ void superh_cpu_do_unaligned_access(CPUState *cpu, va= ddr addr, uintptr_t retaddr) QEMU_NORETURN; =20 void sh4_translate_init(void); +void sh4_cpu_list(void); + +#if !defined(CONFIG_USER_ONLY) bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); - -void sh4_cpu_list(void); -#if !defined(CONFIG_USER_ONLY) void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); void cpu_sh4_invalidate_tlb(CPUSH4State *s); diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index 65b8972e3c..ac9b01840c 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -65,14 +65,6 @@ void cpu_loop(CPUSH4State *env) info.si_code =3D TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; - case 0xa0: - case 0xc0: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->tea; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); arch_interrupt =3D false; diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 2047742d03..06b2691dc4 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -236,9 +236,9 @@ static const struct SysemuCPUOps sh4_sysemu_ops =3D { static const struct TCGCPUOps superh_tcg_ops =3D { .initialize =3D sh4_translate_init, .synchronize_from_tb =3D superh_cpu_synchronize_from_tb, - .tlb_fill =3D superh_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D superh_cpu_tlb_fill, .cpu_exec_interrupt =3D superh_cpu_exec_interrupt, .do_interrupt =3D superh_cpu_do_interrupt, .do_unaligned_access =3D superh_cpu_do_unaligned_access, diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 53cb9c3b63..6a620e36fc 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -796,8 +796,6 @@ bool superh_cpu_exec_interrupt(CPUState *cs, int interr= upt_request) return false; } =20 -#endif /* !CONFIG_USER_ONLY */ - bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr) @@ -806,11 +804,6 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, CPUSH4State *env =3D &cpu->env; int ret; =20 -#ifdef CONFIG_USER_ONLY - ret =3D (access_type =3D=3D MMU_DATA_STORE ? MMU_DTLB_VIOLATION_WRITE : - access_type =3D=3D MMU_INST_FETCH ? MMU_ITLB_VIOLATION : - MMU_DTLB_VIOLATION_READ); -#else target_ulong physical; int prot; =20 @@ -829,7 +822,6 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, if (ret !=3D MMU_DTLB_MULTIPLE && ret !=3D MMU_ITLB_MULTIPLE) { env->pteh =3D (env->pteh & PTEH_ASID_MASK) | (address & PTEH_VPN_M= ASK); } -#endif =20 env->tea =3D address; switch (ret) { @@ -868,3 +860,4 @@ bool superh_cpu_tlb_fill(CPUState *cs, vaddr address, i= nt size, } cpu_loop_exit_restore(cs, retaddr); } +#endif /* !CONFIG_USER_ONLY */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853063; cv=none; d=zohomail.com; s=zohoarc; b=NBG77Jgumn5cVEn3p0468Ak1k6NSGTLeX1fSw5d/tB7jNG3gjedPpa5yDeLJUjDQISSn0A/G5UpS82nhAlqvyK05/YG7OtS6vvtOkbkuXXoXr1hI0YKAXSTjJU6ltt95vSEHsHxSR3LfeEkNip4hFd5mvsCSZOV4cWJsynvlluw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853063; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OFBASZgYo/dnEXgBhwjQsgVMikt4qFVfoC5aZFh8E0o=; b=WpzMeYJkZrY/8wqmR97FgGDOwbmPRFpsGt+NXIqUIHMmal2IrRmiywR7NhVIWBYCVp2SS/NCD+WNvt7EEMNyMhGYaGeAfdElJNF/FyEOo6nYOB52B+u3NNpTrZdUUQg0RhLqwPFOT2pWtLrJcbhAmWfnMRLty03DCVWZOxpRUz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853063141756.2050606293443; Tue, 2 Nov 2021 04:37:43 -0700 (PDT) Received: from localhost ([::1]:47410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs6o-0003re-6F for importer@patchew.org; Tue, 02 Nov 2021 07:37:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhreJ-00042c-B3 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:47035) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhreE-0000y7-6v for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:08:15 -0400 Received: by mail-qt1-x834.google.com with SMTP id s1so17058386qta.13 for ; Tue, 02 Nov 2021 04:08:04 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm7sm3568612qkb.86.2021.11.02.04.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:08:04 -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=OFBASZgYo/dnEXgBhwjQsgVMikt4qFVfoC5aZFh8E0o=; b=RspD3Pxth3eGJHiFoziZyuA2hRtEnZ118TfuUQX67JE+8vb4q1k3lnZeWRx5P/7Djg NFUsA4hOC8C1EIdHz10qFWzADBB4GLOTiJkR8H4CHJjoGtEVghBfdo5uivt8XVk5O3IS K+JgjqX6sy3hcuPnxyQJmZT1AiIypGUpwu7QqcUiDijXPwtFksBeFAOHf/tBrwfEkFLC bbjGoXUFhDqnLSsI1HV7p49HIhXvfbaVV2leHeO0NHOrrmmbeKy2qSVORYX3gdmE3GhW WRizh9U7dkJp2hRKeCF/51vbtMPuRko/IgOLTQnJPK0ArIjtB2QNDalquMNq7NqozrVn FLuw== 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=OFBASZgYo/dnEXgBhwjQsgVMikt4qFVfoC5aZFh8E0o=; b=NRQWvSlSOjrMdnTa8FFtAgYDbu4aJXHpGJrWxgDWuh2o4jqMScH6mAa3X6tJh7y/Ku QsfHwgFObqYcxA+X1muttrunm/mKoVOoKVgOj73hYzgi+NUrfGYkvfEDwYYbcJJoABTg GlHy8ZizS+bABUQ7B2An1M8Pjp+j7EgfGJjZRUUkTH6gNFIv3txqCV3UFXr1wVxurbhd ZCiWB4p/InKOzc3dPLHcXR1p+eC8VZzIyOQqcWQybnIpOPxtp2V1FHOZ9+XID3wwEOvM AurfS9HFVMHucNtgC/qFjPkYcBoK2EqIRjnBFSZu7P8PuklzrZAEYxgvzKz1cNfefSzw cKuw== X-Gm-Message-State: AOAM532iUs8A6k3KpMM6HrTJRYv6kkjf1k6YW2O61a0ZjvQhNhuN3Bd2 wvkqvzy1gR3qCt1wFIbOV8HsJz2IcwLfeQ== X-Google-Smtp-Source: ABdhPJzVsVPl6kw/DfF0KeHM6fg5quVzhWc1RnqEF0ZCM8CtrZ2WedQsrPsMuYWH2nboVro2avLAeQ== X-Received: by 2002:ac8:5744:: with SMTP id 4mr36840046qtx.289.1635851284563; Tue, 02 Nov 2021 04:08:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 39/60] target/sparc: Make sparc_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:19 -0400 Message-Id: <20211102110740.215699-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::834; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x834.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853063747100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for sparc linux-user. This makes all of the code in mmu_helper.c sysemu only, so remove the ifdefs and move the file to sparc_softmmu_ss. Remove the code from cpu_loop that handled TT_DFAULT and TT_TFAULT. Cc: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/sparc/cpu_loop.c | 25 ------------------------- target/sparc/cpu.c | 2 +- target/sparc/mmu_helper.c | 25 ------------------------- target/sparc/meson.build | 2 +- 4 files changed, 2 insertions(+), 52 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index ad29b4eb6a..0ba65e431c 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -219,17 +219,6 @@ void cpu_loop (CPUSPARCState *env) case TT_WIN_UNF: /* window underflow */ restore_window(env); break; - case TT_TFAULT: - case TT_DFAULT: - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->mmuregs[4]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; #else case TT_SPILL: /* window overflow */ save_window(env); @@ -237,20 +226,6 @@ void cpu_loop (CPUSPARCState *env) case TT_FILL: /* window underflow */ restore_window(env); break; - case TT_TFAULT: - case TT_DFAULT: - { - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D TARGET_SEGV_MAPERR; - if (trapnr =3D=3D TT_DFAULT) - info._sifields._sigfault._addr =3D env->dmmu.mmuregs[4= ]; - else - info._sifields._sigfault._addr =3D cpu_tsptr(env)->tpc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; #ifndef TARGET_ABI32 case 0x16e: flush_windows(env); diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 21dd27796d..55268ed2a1 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -865,9 +865,9 @@ static const struct SysemuCPUOps sparc_sysemu_ops =3D { static const struct TCGCPUOps sparc_tcg_ops =3D { .initialize =3D sparc_tcg_init, .synchronize_from_tb =3D sparc_cpu_synchronize_from_tb, - .tlb_fill =3D sparc_cpu_tlb_fill, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D sparc_cpu_tlb_fill, .cpu_exec_interrupt =3D sparc_cpu_exec_interrupt, .do_interrupt =3D sparc_cpu_do_interrupt, .do_transaction_failed =3D sparc_cpu_do_transaction_failed, diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index a44473a1c7..2ad47391d0 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -25,30 +25,6 @@ =20 /* Sparc MMU emulation */ =20 -#if defined(CONFIG_USER_ONLY) - -bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - SPARCCPU *cpu =3D SPARC_CPU(cs); - CPUSPARCState *env =3D &cpu->env; - - if (access_type =3D=3D MMU_INST_FETCH) { - cs->exception_index =3D TT_TFAULT; - } else { - cs->exception_index =3D TT_DFAULT; -#ifdef TARGET_SPARC64 - env->dmmu.mmuregs[4] =3D address; -#else - env->mmuregs[4] =3D address; -#endif - } - cpu_loop_exit_restore(cs, retaddr); -} - -#else - #ifndef TARGET_SPARC64 /* * Sparc V8 Reference MMU (SRMMU) @@ -926,4 +902,3 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vadd= r addr) } return phys_addr; } -#endif diff --git a/target/sparc/meson.build b/target/sparc/meson.build index a3638b9503..a801802ee2 100644 --- a/target/sparc/meson.build +++ b/target/sparc/meson.build @@ -6,7 +6,6 @@ sparc_ss.add(files( 'gdbstub.c', 'helper.c', 'ldst_helper.c', - 'mmu_helper.c', 'translate.c', 'win_helper.c', )) @@ -16,6 +15,7 @@ sparc_ss.add(when: 'TARGET_SPARC64', if_true: files('int6= 4_helper.c', 'vis_helpe sparc_softmmu_ss =3D ss.source_set() sparc_softmmu_ss.add(files( 'machine.c', + 'mmu_helper.c', 'monitor.c', )) =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853512; cv=none; d=zohomail.com; s=zohoarc; b=mAnfmHyD/QcybcCa9QGyb33DaPxD3FGjoxtEsnhdYZng5WDkcEVVtAAO0PlIyMxiDr0JMmVYpa8sh9pcUXWS3EjqkQa5BF6BDROriOGECxaWWfpOX4kQbVxRMwfF0pQwurLmyusc23bpLtFJF6LqH6JCI+Ro/nAXuH9q/2ZNDlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853512; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kAcqfrBKLTctf7S2SRnWlKvQ84+gE9eIlExzwRxWIv4=; b=W1fqW0s3Yvdh7ngKH5CZwAZq3UEB3Ru3CqW9ibAiKSbS2MZfVcAUQ/QgbPC610355eu1FRqzegO2t1ZC3+PDIG/opMUd6kjYClqhal581ZHKgoYdmtWX/jV5qxAOkeCHxzzB+CGWPXOOtJyIyU8C9sRyw4lJd3+lyk0naLjz8TM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853512321755.2800025707697; Tue, 2 Nov 2021 04:45:12 -0700 (PDT) Received: from localhost ([::1]:55870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsE3-0001KK-Az for importer@patchew.org; Tue, 02 Nov 2021 07:45:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh8-0001CA-0g for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:10 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:34346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh5-0001uA-Sj for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:09 -0400 Received: by mail-qk1-x732.google.com with SMTP id bq14so7754940qkb.1 for ; Tue, 02 Nov 2021 04:11:06 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:05 -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=kAcqfrBKLTctf7S2SRnWlKvQ84+gE9eIlExzwRxWIv4=; b=vQL3GNImmjm6ZYIT/J4mlwVLm4keuGkZF/RH6BBGw8Cg7obNQsqj97ScwVW5GjaUtG pmNRd3b01f78YlZ84RzM9EbkcXtCbjF1ulBHQEvlBtrZyrnqoEq5Qzbx5W/8rnseBKDB qqjnS51kFi0Dm57baaScz66oBccPRk5IDlT6Xd6HvBjJVBJdPbFUlRMV6vIosdmiwJOW qdLk/uhIcw56TJSnfddkMDeU0y85Zbs9sEwOPNx41BX60gitNK75tq2Yf4EfxeD4rfAW we73O+Eenk48GWQaswbbRSShh2htaWUyV8ipKW0C0kj1nOiGra2HH0QIhF3L+rebj6wP /oHA== 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=kAcqfrBKLTctf7S2SRnWlKvQ84+gE9eIlExzwRxWIv4=; b=Xfr9NsX6/wr19CZ3OiYx73oE99zmirQSXrNg+gr0B7PFdOD98Lv2LAOWlHxnU7wvsL 09hIEK6qbehgUr0WX/woATb9EFkstJURZugZ8nL1oT+7FslapcX2HBYYXYAoe4Agtt/2 moyvQyKexMvsK+3NcqjEkuN1BT/dmYEIXcLFpyxhtyS5u6xcA/AHNi0eRJbRqaHKKyHY KIFOiwfHz0Entcgywh8ogP1jHXgRniZXp6VJtYHHi3/VPGE9PHIYBbj7r93pnkZ5Fpx+ 48UYlllrIIuUvOXiePVVcRYzAa9cjNArfNM0UZl5Tvb7+FLCoFCumL+uRBoiWOaNVHid ynlw== X-Gm-Message-State: AOAM533WSh3tY1qomaOtjDzimmAGFjpyBPlKPOKlU1ZPbVVE9uRgvKDW HEhc4ZL1Rz3POY5vwT9IyPp34GN/+tWQHw== X-Google-Smtp-Source: ABdhPJzlELjXZPcMtYJO6upHtiLXwmpEy1v/OaX1d9E3aWfFT8p1lz+sFTM8l7rAq/RJNR7JSqRiHg== X-Received: by 2002:a37:f60c:: with SMTP id y12mr14098419qkj.407.1635851465581; Tue, 02 Nov 2021 04:11:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 40/60] target/xtensa: Make xtensa_cpu_tlb_fill sysemu only Date: Tue, 2 Nov 2021 07:07:20 -0400 Message-Id: <20211102110740.215699-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853513503100001 The fallback code in cpu_loop_exit_sigsegv is sufficient for xtensa linux-user. Remove the code from cpu_loop that raised SIGSEGV. Acked-by: Max Filippov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/xtensa/cpu.h | 2 +- linux-user/xtensa/cpu_loop.c | 9 --------- target/xtensa/cpu.c | 2 +- target/xtensa/helper.c | 22 +--------------------- 4 files changed, 3 insertions(+), 32 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index f9a510ca46..02143f2f77 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -563,10 +563,10 @@ struct XtensaCPU { }; =20 =20 +#ifndef CONFIG_USER_ONLY bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); -#ifndef CONFIG_USER_ONLY void xtensa_cpu_do_interrupt(CPUState *cpu); bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request); void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr= addr, diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c index 622afbcd34..a83490ab35 100644 --- a/linux-user/xtensa/cpu_loop.c +++ b/linux-user/xtensa/cpu_loop.c @@ -226,15 +226,6 @@ void cpu_loop(CPUXtensaState *env) queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; =20 - case LOAD_PROHIBITED_CAUSE: - case STORE_PROHIBITED_CAUSE: - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - info.si_code =3D TARGET_SEGV_ACCERR; - info._sifields._sigfault._addr =3D env->sregs[EXCVADDR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - default: fprintf(stderr, "exccause =3D %d\n", env->sregs[EXCCAUSE]); g_assert_not_reached(); diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index c1cbd03595..224f723236 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -192,10 +192,10 @@ static const struct SysemuCPUOps xtensa_sysemu_ops = =3D { =20 static const struct TCGCPUOps xtensa_tcg_ops =3D { .initialize =3D xtensa_translate_init, - .tlb_fill =3D xtensa_cpu_tlb_fill, .debug_excp_handler =3D xtensa_breakpoint_handler, =20 #ifndef CONFIG_USER_ONLY + .tlb_fill =3D xtensa_cpu_tlb_fill, .cpu_exec_interrupt =3D xtensa_cpu_exec_interrupt, .do_interrupt =3D xtensa_cpu_do_interrupt, .do_transaction_failed =3D xtensa_cpu_do_transaction_failed, diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index f18ab383fd..29d216ec1b 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -242,27 +242,7 @@ void xtensa_cpu_list(void) } } =20 -#ifdef CONFIG_USER_ONLY - -bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr) -{ - XtensaCPU *cpu =3D XTENSA_CPU(cs); - CPUXtensaState *env =3D &cpu->env; - - qemu_log_mask(CPU_LOG_INT, - "%s: rw =3D %d, address =3D 0x%08" VADDR_PRIx ", size = =3D %d\n", - __func__, access_type, address, size); - env->sregs[EXCVADDR] =3D address; - env->sregs[EXCCAUSE] =3D (access_type =3D=3D MMU_DATA_STORE ? - STORE_PROHIBITED_CAUSE : LOAD_PROHIBITED_CAUSE= ); - cs->exception_index =3D EXC_USER; - cpu_loop_exit_restore(cs, retaddr); -} - -#else /* !CONFIG_USER_ONLY */ - +#ifndef CONFIG_USER_ONLY void xtensa_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854097; cv=none; d=zohomail.com; s=zohoarc; b=V1rPq+KcP+Kt66RD/uxwsIYOkUlIwE4S3Q/fcukhQwBde6kxhs7qN/FNtPsuIzmnsRqqn7aj+ctG1BUXsymtTDNS/T0CSV4Xzszef8WdKk6pZv0aWda3cY4/2Mf/1YYETOqAqL8MiUVvB5WDuFzsYvysivcCoouGYmwJULayGqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854097; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AlAKO3pHLk0w42dzpdqlCWgmBC5kkngUdLfuQLXO9ho=; b=heUZxl4L1IITOC8uTbGt7Eyb/5hvAMSQ83sIIQv2FD8zpev79P2Kjvt0/ilkrZxUU03rJEUJtgcM6AFuD3pDdlaTi4GkTcgICV7De6OJ1YZ3aaIpbTNTVmRZmMJgOeqFVQLGWct0Cv9azZ9UuxX+FuSjqsDlk4BaEXVzpp1a3O8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163585409725116.7249974727182; Tue, 2 Nov 2021 04:54:57 -0700 (PDT) Received: from localhost ([::1]:51594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsNU-00018I-6J for importer@patchew.org; Tue, 02 Nov 2021 07:54:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhA-0001Ms-5X for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:45797) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh5-0001uI-SY for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: by mail-qt1-x829.google.com with SMTP id r2so17174874qtw.12 for ; Tue, 02 Nov 2021 04:11:06 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:05 -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=AlAKO3pHLk0w42dzpdqlCWgmBC5kkngUdLfuQLXO9ho=; b=FxzYCT3fu1jbNUPtE8I1elT6f+dE0iCYIb6Clzj8VIVRaXZTZUmlRg5HL8IN8m276n pU6iSM1MH06P15z/oo2u1wcBgZctGMPg04ysg6NLAM51npmIm2mt4AI/Sj3mJZfyw3/f +dZsHLgXDShBvP/rrQAjIHcTFeL2tCFFPGSGbWaDusMhrEtmaj1DltyQK0pU/ePYbKR9 LEMzyRI5+k00SgLOax1xPeVypfUFgSvdSfd5mQxCouSTTZCo8sOrstNKybwy3J7so7zx QXmB7WDBwzouYvGBHjICJKD3oYIx07puBJggklZyuiJx1unhIIvQ/BjcJNn0tXIl2AbK xTxA== 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=AlAKO3pHLk0w42dzpdqlCWgmBC5kkngUdLfuQLXO9ho=; b=Jqb/dlCtUzbH5sfKMdA4eikgXyUqNys5KPBbm+ivtYIEhTmgn4B2PxS+0dI3hvYkSf KRkuEjh2tUlaSrVG/3H/njQkmdSsnuSMbL/aTVqBfPbiz8gF8raxQghPyegH4BIhjlqC 91JDmbWHcHxh+/gyt3GG7+rRcmZdPFt5OQNpWx7eOyXTitpXojgXHSni6C6Lr58Jk80J HIEJCNBLzgzJu2qW5oBt5Kd+NtxxhFOwDAx2lPSRoHNXTGSRRLsDWzxS84jcrsY5jrAy oxFJ/l4eyV3EAj/+zr9+q0PgsK2Dq0YlvwONNczN/NDwORZhssz2murT93hN0qWXXTEz KuvQ== X-Gm-Message-State: AOAM533JTi4/H5OWlq0Kbl9+2KPWBamoCIV1Oa1uQw1fuN0pt+5c4Sea yjPqC75i4RSIuCwRwYGiHVQUqJHO7ZIRCQ== X-Google-Smtp-Source: ABdhPJzTGEESlICCikOdBKLo5Z8bF0yRDj89MXD7dI7cOHzgYPkCFOqYrCcZ0z5BxRbdspBhgFZMUg== X-Received: by 2002:ac8:5d49:: with SMTP id g9mr16196522qtx.380.1635851466265; Tue, 02 Nov 2021 04:11:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 41/60] accel/tcg: Restrict TCGCPUOps::tlb_fill() to sysemu Date: Tue, 2 Nov 2021 07:07:21 -0400 Message-Id: <20211102110740.215699-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854097706100001 We have replaced tlb_fill with record_sigsegv for user mode. Move the declaration to restrict it to system emulation. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 22 ++++++++++------------ linux-user/signal.c | 3 --- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 41718b695b..8eadd404c8 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -35,18 +35,6 @@ struct TCGCPUOps { void (*cpu_exec_enter)(CPUState *cpu); /** @cpu_exec_exit: Callback for cpu_exec cleanup */ void (*cpu_exec_exit)(CPUState *cpu); - /** - * @tlb_fill: Handle a softmmu tlb miss or user-only address fault - * - * For system mode, if the access is valid, call tlb_set_page - * and return true; if the access is invalid, and probe is - * true, return false; otherwise raise an exception and do - * not return. For user-only mode, always raise an exception - * and do not return. - */ - bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, - MMUAccessType access_type, int mmu_idx, - bool probe, uintptr_t retaddr); /** @debug_excp_handler: Callback for handling debug exceptions */ void (*debug_excp_handler)(CPUState *cpu); =20 @@ -68,6 +56,16 @@ struct TCGCPUOps { #ifdef CONFIG_SOFTMMU /** @cpu_exec_interrupt: Callback for processing interrupts in cpu_exe= c */ bool (*cpu_exec_interrupt)(CPUState *cpu, int interrupt_request); + /** + * @tlb_fill: Handle a softmmu tlb miss + * + * If the access is valid, call tlb_set_page and return true; + * if the access is invalid and probe is true, return false; + * otherwise raise an exception and do not return. + */ + bool (*tlb_fill)(CPUState *cpu, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); /** * @do_transaction_failed: Callback for handling failed memory transac= tions * (ie bus faults or external aborts; not MMU faults) diff --git a/linux-user/signal.c b/linux-user/signal.c index 135983747d..9d60abc038 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -697,9 +697,6 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong = addr, =20 if (tcg_ops->record_sigsegv) { tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); - } else if (tcg_ops->tlb_fill) { - tcg_ops->tlb_fill(cpu, addr, 0, access_type, MMU_USER_IDX, false, = ra); - g_assert_not_reached(); } =20 force_sig_fault(TARGET_SIGSEGV, --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853822; cv=none; d=zohomail.com; s=zohoarc; b=dm7wPSPh1TokRqfybQFwOpquTHxP0vQu4gzi+ThcGoXrD9G2ejVvod4QnHyJuLoDlbSLqmA88R3+qnW/O7IeVrk+RPkEXOi2mnsnwbzAAcKeN0OE/7iHWu1oliH4fVE7brnNuaiUD/q1LGCa4uJMj1WKTVCw5fhpau/vUv+Tscg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853822; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vGec2V7sqBlJXZFFOVGa4jSeCFBEP3Km3jAuCBMCplk=; b=e0l7EiW8AjwCZlJrbuEppLRKK88Ehx8oQWWBNbIC8/RagsEs0gCps0gsRvolkZg/FuHOVnzZitI/TOBt3UvlkjFC/dhC5TJDaOSzgmFbIT0d5d/7EHQSPcLQ8zjIg/BEnCMnYXEBGOS2dWX5opBAv3HcaBSNhEVslv3KyxFAiYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853822774895.0794957372357; Tue, 2 Nov 2021 04:50:22 -0700 (PDT) Received: from localhost ([::1]:35778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsJ3-0006zO-N6 for importer@patchew.org; Tue, 02 Nov 2021 07:50:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh8-0001CR-1c for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:10 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:35376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh5-0001uM-Tx for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:09 -0400 Received: by mail-qt1-x82a.google.com with SMTP id n2so18489552qta.2 for ; Tue, 02 Nov 2021 04:11:07 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:06 -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=vGec2V7sqBlJXZFFOVGa4jSeCFBEP3Km3jAuCBMCplk=; b=TJp+AxRIUnzrTleZR8gDvrA3xWHh1Cr3g0w/pgdUMlWn9ItNOYbeKSYqt33TWauMm3 6Lg0HrQa57Yc5/KsQnqAy3amzcPjs3EoCnXgFsC1BU0epHbynrNvBp5/nmzAl9dVbypO uXhlUuW21fcQn2NQQpPzT5ZM8BmqY4oaG9HCsUl16/pmMRNQGHOyzChTLgmSXujLd2N8 FNLAVO21YGYAjgLbUy8qJzb1W9iTmcA8UxEOrSnp4gveA/+LV4ACh1sjVzEEpn7yIguj zu4sPa1RpjebpXpUDUhneyMeIicg48cOYd4mzvZnBV+zM3K9GJL0ByCCD2RnJwbcD7a2 u+vQ== 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=vGec2V7sqBlJXZFFOVGa4jSeCFBEP3Km3jAuCBMCplk=; b=E0hb7owMa5MTTeevedkVTdCroT6q8HZFPAOM64mA4EZKTOwW03DKExq4uJQGjxGa19 TFInLOWobc97H0uutCKfCenW/Hjl5mreBIYKugAFUcFiDJjt3Gl2MbHRpFuOZ7hanJQA qYCR7FenSArQjEWweEWJYY2B/khu+q7g3sliBv0y6m9sEuOiUidfBbvWB45GF9wat7tc Q6JFSCQIgEWE3ryFjI7+BEQnVKjU2J6vKM768xiHYn+pOtiwYmAc14ZIYOqBWyvWm6/D oKUCcPrQQQ8022sznWVzCHvlPOHOwIE8W8bP7WdlXhl1O390zwz5TP1X1xtxOh9KfG8j NGqQ== X-Gm-Message-State: AOAM530mCAN5PzXnUYyurOuJLwJpsFqty/RFu//9PiTiz5rGJlGYyZgk VAyVMAQpJ6yK6V4AEfCpY0P5AIYF/Z86Eg== X-Google-Smtp-Source: ABdhPJy9Qnoaz1PJaDsya2PUtex0RfryAq4wi2ZixjbAKRYnXujDnY8I4PTevJ8c/cWpen6tbCpQOg== X-Received: by 2002:a05:622a:311:: with SMTP id q17mr11219195qtw.106.1635851466816; Tue, 02 Nov 2021 04:11:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 42/60] hw/core: Add TCGCPUOps.record_sigbus Date: Tue, 2 Nov 2021 07:07:22 -0400 Message-Id: <20211102110740.215699-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853824380100001 Content-Type: text/plain; charset="utf-8" Add a new user-only interface for updating cpu state before raising a signal. This will take the place of do_unaligned_access for user-only and should result in less boilerplate for each guest. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson --- include/hw/core/tcg-cpu-ops.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/hw/core/tcg-cpu-ops.h b/include/hw/core/tcg-cpu-ops.h index 8eadd404c8..e13898553a 100644 --- a/include/hw/core/tcg-cpu-ops.h +++ b/include/hw/core/tcg-cpu-ops.h @@ -135,6 +135,29 @@ struct TCGCPUOps { void (*record_sigsegv)(CPUState *cpu, vaddr addr, MMUAccessType access_type, bool maperr, uintptr_t ra); + /** + * record_sigbus: + * @cpu: cpu context + * @addr: misaligned guest address + * @access_type: access was read/write/execute + * @ra: host pc for unwinding + * + * We are about to raise SIGBUS with si_code BUS_ADRALN, + * and si_addr set for @addr. Record anything further needed + * for the signal ucontext_t. + * + * If the emulated kernel does not provide the signal handler with + * anything besides the user context registers, and the siginfo_t, + * then this hook need do nothing and may be omitted. + * Otherwise, record the data and return; the caller will raise + * the signal, unwind the cpu state, and return to the main loop. + * + * If it is simpler to re-use the sysemu do_unaligned_access code, + * @ra is provided so that a "normal" cpu exception can be raised. + * In this case, the signal must be raised by the architecture cpu_loo= p. + */ + void (*record_sigbus)(CPUState *cpu, vaddr addr, + MMUAccessType access_type, uintptr_t ra); #endif /* CONFIG_SOFTMMU */ #endif /* NEED_CPU_H */ =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635852987576198.82190234533198; Tue, 2 Nov 2021 04:36:27 -0700 (PDT) Received: from localhost ([::1]:45040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhs5a-0002Gy-Fg for importer@patchew.org; Tue, 02 Nov 2021 07:36:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh7-0001C2-Up for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:09 -0400 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:43617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh6-0001uQ-AV for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:09 -0400 Received: by mail-qk1-x731.google.com with SMTP id bp7so13985271qkb.10 for ; Tue, 02 Nov 2021 04:11:07 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:07 -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=1Ep7pHHg1zb1sPSHGpQ1/FF+Txy5JMnbD431/U5MPag=; b=MQMc9UQVF+oJp0CFP4SP5f5cysFZzMzv1FVu3vZPjgrJ94zLCmfnNcaYxwsaVMi4K0 rRD0bZB1FODVLejNbFxgTqjHBJyz91O7uDY/GE1mQHfwn/ez4t6JQXWq9VVD7L/X+uQn UHLdh0NACzcdItTfq6ixdsx2Tb1eO05DvApWSsvbTxDbe51U2glnVoKkQLJg3p8qNtex 0vPiT62/SZhJgm3B1mi3OT82672OU5TlNgY8Hzw2MAifpwFI1roWXGhW0Wn2oaevFRO+ i5dt70jwEBbv0xsTU/+BbhIoE15F0x2CNq3a5m0WgsXHVKKtcJsH+tcNBUe1/HHXNZSe 0V8Q== 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=1Ep7pHHg1zb1sPSHGpQ1/FF+Txy5JMnbD431/U5MPag=; b=uL9l3UBD2ZLH1qECoA4TeCMCK+OVkp+rbCoU5OBkrqaK1YHYZddDTIHUY8iPfJtj8K /lzO9zP6+GeKaKjjp1HWNp64UrH2x6YDO22jgswTHzvemqp/f40XdIjMy0eYRb0H765/ /lOtGJrrrTQmTUwi4G1kTk+no7fCjiM28lgzKRnVuhQSUCXfATcs1AvDrPmGmwqzXLWm MrTJxDorpYfEz98m2P9CFt4qfaCqiiCkVv/hwILzWGtB/awEw+CdQl5pSWnP6xT+JZN7 QGgBNg9x1mGYP+kOYZLQp9DmIUAHtzxoBR1KyaMDOy1D3SrbY+xm7XD2ufG478tvok04 93hQ== X-Gm-Message-State: AOAM533p6xgeLisETsjnasHv90Xk5WDDbrLJF/otqQipgot+vmecAWkW nJ+MDD2w6oXBMx9uN7gDjbYR6KtYlulztw== X-Google-Smtp-Source: ABdhPJwQ+EJbdKwZt+9xrrMYiEuR9yJSfSr1X9UeX/AJxcPsdd7c29uOo9qn3FVEQ4kwMTe9aOMz1w== X-Received: by 2002:a37:2c86:: with SMTP id s128mr27348650qkh.516.1635851467423; Tue, 02 Nov 2021 04:11:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 43/60] linux-user: Add cpu_loop_exit_sigbus Date: Tue, 2 Nov 2021 07:07:23 -0400 Message-Id: <20211102110740.215699-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::731; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x731.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635852988117100003 This is a new interface to be provided by the os emulator for raising SIGBUS on fault. Use the new record_sigbus target hook. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 14 ++++++++++++++ linux-user/signal.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index f74578500c..6bb2a0f7ec 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -700,6 +700,20 @@ void QEMU_NORETURN cpu_loop_exit_sigsegv(CPUState *cpu= , target_ulong addr, MMUAccessType access_type, bool maperr, uintptr_t ra); =20 +/** + * cpu_loop_exit_sigbus: + * @cpu: the cpu context + * @addr: the guest address of the alignment fault + * @access_type: access was read/write/execute + * @ra: host pc for unwinding + * + * Use the TCGCPUOps hook to record cpu state, do guest operating system + * specific things to raise SIGBUS, and jump to the main cpu loop. + */ +void QEMU_NORETURN cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, + uintptr_t ra); + #else static inline void mmap_lock(void) {} static inline void mmap_unlock(void) {} diff --git a/linux-user/signal.c b/linux-user/signal.c index 9d60abc038..df2c8678d0 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -706,6 +706,20 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong= addr, cpu_loop_exit_restore(cpu, ra); } =20 +void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, uintptr_t ra) +{ + const struct TCGCPUOps *tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; + + if (tcg_ops->record_sigbus) { + tcg_ops->record_sigbus(cpu, addr, access_type, ra); + } + + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, addr); + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, ra); +} + /* abort execution with signal */ static void QEMU_NORETURN dump_core_and_abort(int target_sig) { --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853412; cv=none; d=zohomail.com; s=zohoarc; b=lcX3tgZhZZ8xK+P9ssGCIpU5fv4RmoJ/d/TvfpLyDyP6I6ryBDIzesEPY49R19P8VTjAUPn21Wv0EQvXuFy+7AcpMRz7wz2zmJGBgCc3w6lmdPHbTGTxgspoDvHWMkhYqNVgcq1BaTJ2b39IXXOmxXkoGYw6iZEWhid1BynDkC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853412; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lCTWBHg3yAPeLZcM1I7LLlGr7M38G+m6NQblxbcjKCQ=; b=AvCK6tkOoxxExViqUXZEJOXwrfzZfFWXf06peMyHWDoPrc5VfRqRgMc/sXgnI0SbqUQnbJ9lwJOZFD/6mvfymKxxh5URMRh2APxQdfwvLCq7DTr3jRrttaYZuZ06dr1hmzWynxpP0LPeqXUWInsU6q4+PusyZngPuEhXYysUF6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853412249370.93883466794296; Tue, 2 Nov 2021 04:43:32 -0700 (PDT) Received: from localhost ([::1]:53566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsCQ-00089V-Nx for importer@patchew.org; Tue, 02 Nov 2021 07:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh9-0001LM-R8 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:40671) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh6-0001vR-OM for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: by mail-qv1-xf30.google.com with SMTP id b11so9636718qvm.7 for ; Tue, 02 Nov 2021 04:11:08 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:07 -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=lCTWBHg3yAPeLZcM1I7LLlGr7M38G+m6NQblxbcjKCQ=; b=ygL+JwzcnQXrPBY2UEo3CTtFx8eia8lQsuQ3t85CspfP1A6ipne1h+0PZDMI5Np/zH yS/qYabeHL6hoIbqOw4OHcg2gSpOGshe5Hnl+1mezsnADaA6Ae16GV6BYREbXZ7/arr9 npV2GnF6E36jvrQZ6m3u4VSsykOu3pBSxlm6JVUqZMwj74Iqv0/0pOc5ohmhxpmd8uKt 7KZOlVhO3VK95WM0vG0Zvz84waoR1OPENtOC5thWrL9DtqBwxQKkey9WkbVSBuSfqeXM L5WvHcUymNQzkBxi/D548X0AJ+MOwjFHnB200B79mv6ISGqDGnoy1BhSbNc7HV0Fi19/ mY5w== 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=lCTWBHg3yAPeLZcM1I7LLlGr7M38G+m6NQblxbcjKCQ=; b=rozDFYVazA+r32ZCJAsYG+hmmfG+ftftKHo5ALfOGLI25wFNDYhy143bd8dgp7khMf i38jj7v+7UtngjJON7CqG491HT2bRj4rbIGw8gxEwLWQs+rEf9JtNJ6frF2iwtR9KLX+ Oh1kSijtYvhdP8XtGQ0Mqh3EamotFJo3qu4bBU6UQ1q0/a8lFDUWDUX3XXHDKPJI/i90 vPBZ7W/qlOlpgCXsjnOV3J0rdd8xhyIxj5Koq0/+Q9XC8OxxXp2J0rIXPZ2ttn9HZUNS U7tVozDh6DkfZHvYVBH/tHPjT7a+iLRWI8IqfPpdGglIK2PzSknezAyvgu/KMLundHUd I6Fg== X-Gm-Message-State: AOAM533ndWkKyFePu6P3OT5/l4oAP8ViZOpyci0vq9MNmeMn7+Od/uIY /KCN6cUbSUumUQoxJ6LE3VLzZwUBD+ePoA== X-Google-Smtp-Source: ABdhPJxLMZwj1Vr86ZyKeCG7BvE3i+NWvgQeoy884GKk+Ue6SofXjid8sG9h1klEbg1TEJwqEyNKMw== X-Received: by 2002:a0c:c702:: with SMTP id w2mr34490446qvi.24.1635851467919; Tue, 02 Nov 2021 04:11:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 44/60] target/alpha: Implement alpha_cpu_record_sigbus Date: Tue, 2 Nov 2021 07:07:24 -0400 Message-Id: <20211102110740.215699-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf30.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853413612100001 Record trap_arg{0,1,2} for the linux-user signal frame. Raise SIGBUS directly from cpu_loop_exit_sigbus, which means we can remove the code for EXCP_UNALIGN in cpu_loop. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/alpha/cpu.h | 8 +++++--- linux-user/alpha/cpu_loop.c | 7 ------- target/alpha/cpu.c | 1 + target/alpha/mem_helper.c | 30 ++++++++++++++++++++++-------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index d49cc36d07..afd975c878 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -282,9 +282,6 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, - MMUAccessType access_type, int mmu_idx, - uintptr_t retaddr) QEMU_NORETURN; =20 #define cpu_list alpha_cpu_list =20 @@ -451,10 +448,15 @@ void cpu_alpha_store_gr(CPUAlphaState *env, unsigned = reg, uint64_t val); void alpha_cpu_record_sigsegv(CPUState *cs, vaddr address, MMUAccessType access_type, bool maperr, uintptr_t retaddr); +void alpha_cpu_record_sigbus(CPUState *cs, vaddr address, + MMUAccessType access_type, uintptr_t retaddr); #else bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +void alpha_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN; void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index 4cc8e0a55c..4029849d5c 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -54,13 +54,6 @@ void cpu_loop(CPUAlphaState *env) fprintf(stderr, "External interrupt. Exit\n"); exit(EXIT_FAILURE); break; - case EXCP_UNALIGN: - info.si_signo =3D TARGET_SIGBUS; - info.si_errno =3D 0; - info.si_code =3D TARGET_BUS_ADRALN; - info._sifields._sigfault._addr =3D env->trap_arg0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_OPCDEC: do_sigill: info.si_signo =3D TARGET_SIGILL; diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 69f32c3078..a8990d401b 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -221,6 +221,7 @@ static const struct TCGCPUOps alpha_tcg_ops =3D { =20 #ifdef CONFIG_USER_ONLY .record_sigsegv =3D alpha_cpu_record_sigsegv, + .record_sigbus =3D alpha_cpu_record_sigbus, #else .tlb_fill =3D alpha_cpu_tlb_fill, .cpu_exec_interrupt =3D alpha_cpu_exec_interrupt, diff --git a/target/alpha/mem_helper.c b/target/alpha/mem_helper.c index 75e72bc337..47283a0612 100644 --- a/target/alpha/mem_helper.c +++ b/target/alpha/mem_helper.c @@ -23,18 +23,12 @@ #include "exec/exec-all.h" #include "exec/cpu_ldst.h" =20 -/* Softmmu support */ -#ifndef CONFIG_USER_ONLY -void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr, - MMUAccessType access_type, - int mmu_idx, uintptr_t retaddr) +static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t = retaddr) { - AlphaCPU *cpu =3D ALPHA_CPU(cs); - CPUAlphaState *env =3D &cpu->env; uint64_t pc; uint32_t insn; =20 - cpu_restore_state(cs, retaddr, true); + cpu_restore_state(env_cpu(env), retaddr, true); =20 pc =3D env->pc; insn =3D cpu_ldl_code(env, pc); @@ -42,6 +36,26 @@ void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr a= ddr, env->trap_arg0 =3D addr; env->trap_arg1 =3D insn >> 26; /* opcode */ env->trap_arg2 =3D (insn >> 21) & 31; /* dest regno */ +} + +#ifdef CONFIG_USER_ONLY +void alpha_cpu_record_sigbus(CPUState *cs, vaddr addr, + MMUAccessType access_type, uintptr_t retaddr) +{ + AlphaCPU *cpu =3D ALPHA_CPU(cs); + CPUAlphaState *env =3D &cpu->env; + + do_unaligned_access(env, addr, retaddr); +} +#else +void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + AlphaCPU *cpu =3D ALPHA_CPU(cs); + CPUAlphaState *env =3D &cpu->env; + + do_unaligned_access(env, addr, retaddr); cs->exception_index =3D EXCP_UNALIGN; env->error_code =3D 0; cpu_loop_exit(cs); --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854453891715.879529011728; Tue, 2 Nov 2021 05:00:53 -0700 (PDT) Received: from localhost ([::1]:48346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsTE-0001fQ-IV for importer@patchew.org; Tue, 02 Nov 2021 08:00:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh9-0001KT-KN for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:34339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh7-0001wa-9P for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: by mail-qk1-x72a.google.com with SMTP id bq14so7755075qkb.1 for ; Tue, 02 Nov 2021 04:11:08 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:08 -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=6E2EHrVXu+fKkNaLcRStkdoJxkkRxYzYfXrw6rxs8+I=; b=Q6XFHrCupXMVTPp9bv4ETF+88jMNQPm3FFr07T/r3ZlW9LfqSGQ2BnW2e5LEvkTl7P KAhI4bTpZiJABaR2UPvlZcnBAfvcWCmSjh4Z3UkK+0n0mL1MgZGb9Z1t2j4qoxkuYkG3 37Rgn1SjlFEP9i/cUJtr1OEfNgilPxO6uxI8IpwAPtLqOYr0MnmJhRLJf8UQ5ZsHm91m L6NDOuHjo6LGlAPwgby3cRcgH4ieF/NB961ioFdUPTBs5XD4MKbCrV46TvIwG6dCOUeg 9mEd+rEHze5Fh19d+S+1hDIz/BiUclnrhXpqVHAFW5p6C0W7rrNzlYBmXzgVDxOZfFpU Vxbw== 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=6E2EHrVXu+fKkNaLcRStkdoJxkkRxYzYfXrw6rxs8+I=; b=n99zmtT+rYFeO7IdWtow8BNxBBpjF88/ySkeBZF1nDy9ADrBMZ05ovdUvIeL4kadj+ NFMdk8vBZph0tG1l1gXMvFarZEpdebykDS/Mptjv1YgnDXdI1nOFLx5zxp4Bi7eWqDfG xVNTPrPhWoIifDXoY3q0fTd40HciQQi32DreMSIAlMhRdkL/TQDpRGKE0uAbZP+MFJcJ iM1P+PFyXxwAbQqo2+0HRyddRqdG/cmLr4z/Xdgq2F2FT78/6esbmD6ehcsv7a0j1YAa WgTfdBQKLNvXCrZ4MmGLLreeGjZshvz6/VjMWZtjNlJhW1sPZTvEe0gJIPKFj70BgkET LY7A== X-Gm-Message-State: AOAM5339Fb4HekRnvUds600bdC5HT+pzcQmyA3HaBG+nVD2ar4emQ49h t9A7KmZ3UD8L3557X31FflwgTlctfzA5eA== X-Google-Smtp-Source: ABdhPJw4pgXNVM67twCoz7DBFw8qNnWrwrAhdDqRWD5bex0UPYu+tNRcuGqlX3DW7OcgYcQ0rj2Y9w== X-Received: by 2002:a37:b686:: with SMTP id g128mr28723388qkf.68.1635851468409; Tue, 02 Nov 2021 04:11:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 45/60] target/arm: Implement arm_cpu_record_sigbus Date: Tue, 2 Nov 2021 07:07:25 -0400 Message-Id: <20211102110740.215699-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72a; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854458293100001 Content-Type: text/plain; charset="utf-8" Because of the complexity of setting ESR, re-use the existing arm_cpu_do_unaligned_access function. This means we have to handle the exception ourselves in cpu_loop, transforming it to the appropriate signal. Reviewed-by: Warner Losh Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 2 ++ linux-user/aarch64/cpu_loop.c | 12 +++++++++--- linux-user/arm/cpu_loop.c | 30 ++++++++++++++++++++++++++---- target/arm/cpu.c | 1 + target/arm/cpu_tcg.c | 1 + target/arm/tlb_helper.c | 6 ++++++ 6 files changed, 45 insertions(+), 7 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 5a7aaf0f51..89f7610ebc 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -548,6 +548,8 @@ static inline bool arm_extabort_type(MemTxResult result) void arm_cpu_record_sigsegv(CPUState *cpu, vaddr addr, MMUAccessType access_type, bool maperr, uintptr_t ra); +void arm_cpu_record_sigbus(CPUState *cpu, vaddr addr, + MMUAccessType access_type, uintptr_t ra); #else bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 034b737435..97e0728b67 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -79,7 +79,7 @@ void cpu_loop(CPUARMState *env) { CPUState *cs =3D env_cpu(env); - int trapnr, ec, fsc, si_code; + int trapnr, ec, fsc, si_code, si_signo; abi_long ret; =20 for (;;) { @@ -121,20 +121,26 @@ void cpu_loop(CPUARMState *env) fsc =3D extract32(env->exception.syndrome, 0, 6); switch (fsc) { case 0x04 ... 0x07: /* Translation fault, level {0-3} */ + si_signo =3D TARGET_SIGSEGV; si_code =3D TARGET_SEGV_MAPERR; break; case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ + si_signo =3D TARGET_SIGSEGV; si_code =3D TARGET_SEGV_ACCERR; break; case 0x11: /* Synchronous Tag Check Fault */ + si_signo =3D TARGET_SIGSEGV; si_code =3D TARGET_SEGV_MTESERR; break; + case 0x21: /* Alignment fault */ + si_signo =3D TARGET_SIGBUS; + si_code =3D TARGET_BUS_ADRALN; + break; default: g_assert_not_reached(); } - - force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddre= ss); + force_sig_fault(si_signo, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index ae09adcb95..01cb6eb534 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -25,6 +25,7 @@ #include "cpu_loop-common.h" #include "signal-common.h" #include "semihosting/common-semi.h" +#include "target/arm/syndrome.h" =20 #define get_user_code_u32(x, gaddr, env) \ ({ abi_long __r =3D get_user_u32((x), (gaddr)); \ @@ -280,7 +281,7 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint32_= t opcode) void cpu_loop(CPUARMState *env) { CPUState *cs =3D env_cpu(env); - int trapnr; + int trapnr, si_signo, si_code; unsigned int n, insn; abi_ulong ret; =20 @@ -423,9 +424,30 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - /* XXX: check env->error_code */ - force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, - env->exception.vaddress); + /* For user-only we don't set TTBCR_EAE, so look at the FSR. */ + switch (env->exception.fsr & 0x1f) { + case 0x1: /* Alignment */ + si_signo =3D TARGET_SIGBUS; + si_code =3D TARGET_BUS_ADRALN; + break; + case 0x3: /* Access flag fault, level 1 */ + case 0x6: /* Access flag fault, level 2 */ + case 0x9: /* Domain fault, level 1 */ + case 0xb: /* Domain fault, level 2 */ + case 0xd: /* Permision fault, level 1 */ + case 0xf: /* Permision fault, level 2 */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_ACCERR; + break; + case 0x5: /* Translation fault, level 1 */ + case 0x7: /* Translation fault, level 2 */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_MAPERR; + break; + default: + g_assert_not_reached(); + } + force_sig_fault(si_signo, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7a18a58ca0..a211804fd3 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2035,6 +2035,7 @@ static const struct TCGCPUOps arm_tcg_ops =3D { =20 #ifdef CONFIG_USER_ONLY .record_sigsegv =3D arm_cpu_record_sigsegv, + .record_sigbus =3D arm_cpu_record_sigbus, #else .tlb_fill =3D arm_cpu_tlb_fill, .cpu_exec_interrupt =3D arm_cpu_exec_interrupt, diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 7b3bea2fbb..13d0e9b195 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -902,6 +902,7 @@ static const struct TCGCPUOps arm_v7m_tcg_ops =3D { =20 #ifdef CONFIG_USER_ONLY .record_sigsegv =3D arm_cpu_record_sigsegv, + .record_sigbus =3D arm_cpu_record_sigbus, #else .tlb_fill =3D arm_cpu_tlb_fill, .cpu_exec_interrupt =3D arm_v7m_cpu_exec_interrupt, diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c index dc5860180f..12a934e924 100644 --- a/target/arm/tlb_helper.c +++ b/target/arm/tlb_helper.c @@ -213,4 +213,10 @@ void arm_cpu_record_sigsegv(CPUState *cs, vaddr addr, cpu_restore_state(cs, ra, true); arm_deliver_fault(cpu, addr, access_type, MMU_USER_IDX, &fi); } + +void arm_cpu_record_sigbus(CPUState *cs, vaddr addr, + MMUAccessType access_type, uintptr_t ra) +{ + arm_cpu_do_unaligned_access(cs, addr, access_type, MMU_USER_IDX, ra); +} #endif /* !defined(CONFIG_USER_ONLY) */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853936; cv=none; d=zohomail.com; s=zohoarc; b=L7Y//589UHWHPQwNFR0W3WD5tJdL44Cq0WyHhZGjqamsaLcNz63JpEWLOQIPk33eJ+LawHhB8qrU7VhVSb2ulbegjWytL0ILBFCbRn9t9ovmI32ABvwH0Jg52uUfC16hcR2Yxn8s9OukPQ0W98TszFi9jKlfQl/vEV87yY/P0FY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853936; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QdBbkxzZXl4V2J/0UdfvZmZe+nM+srroKJ9DSgm4Qw8=; b=UW+SwjozIGZFF/vTCA/YjIdqR0BdYtOuZbaEOk5mrAEvsN2pvatTFvRXqlkuEC63PDKNfRbx7rWNewdygsa3U7RSkMplqVVpLk7D0xeNQbw9cPV91GOJm5eTxJ8gmDNYOq3oyC1iZooCmHvKTP4sQk7SJ3YH6LaeTMK62azOCgg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853936029323.802036700039; Tue, 2 Nov 2021 04:52:16 -0700 (PDT) Received: from localhost ([::1]:43094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsKs-0003ZE-Sa for importer@patchew.org; Tue, 02 Nov 2021 07:52:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrh9-0001JO-C7 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]:44546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh7-0001x6-PL for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:11 -0400 Received: by mail-qk1-x732.google.com with SMTP id bj20so7959062qkb.11 for ; Tue, 02 Nov 2021 04:11:09 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:08 -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=QdBbkxzZXl4V2J/0UdfvZmZe+nM+srroKJ9DSgm4Qw8=; b=R2nAmu+2sfXJth/YQdIWrQKcoAIz3txBAwnM4XJp0PAAGyASC+ocffR2dKOUdbqsN2 tdAerzBC4yQSIgXhF25CP7Cuk8HnhViPwFr3IVfN+vxYnks3nFAOK2thH8GiaqxQQutB 6urHjz7xqeIuJGzzmM0CG7bNDAXPSrojjJfmogqQc8oDhta9sis8dyb9g730iY/O4zHM AXHaJdOe9l6W3ZdA+D/upGRZdQbirt0g6SIZQNzZx+bFLBsr5S0D/fCBkmtPkDy7oQKY lujcoDPtcRVyDsRl1sdz75eXsLdwm3E1mrBBBKkwlCJLoKYZSbaEsIsHvVtaPgm3qdA6 Nfig== 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=QdBbkxzZXl4V2J/0UdfvZmZe+nM+srroKJ9DSgm4Qw8=; b=xqmA6m1iN4tPQTd5XZFFppJ0yICJt9C6PVDkepkEscYWY9EdCqK6RX+I7u0x20mDio qDp84z8Hl4r7QJec7VlMt8q5I7yl5DZfgFJ7xo6cjimZJUyWL/fXPjQpdw8EGHRZ2/TO Q9TjE1V7L4u6o9AeQV6kDjCbhV8/SN2Z+02JwSe2cTAFPG+Q8GP71jL5016fpCgH48Bo BHR99Kv+7pb1ZyPjTjG2hDGcdktWBZpOec7kOWLyNbfjPpJNw/nflCS70QvZcPsM3UYj dauklL3bx2pxKZCc/yVXNqPS0TEsczoEwt3rdKPua9vuTBkimKul1dbQtSBSVaKqJtNq cFWQ== X-Gm-Message-State: AOAM531jdk0KQHoyyKCTjmwFJyMyV1j/scsex8aVTQzXPS9uweE+9nhL xtJK/SpJbYIUtRU76sQiXXZ6LFwtzxMnyQ== X-Google-Smtp-Source: ABdhPJxfOYKzR6qn7RPwd9uzLkTR2APlQIW1TNZMkGamxGagKtgL1uvqRsphq6tqsJBYYS20kQRscQ== X-Received: by 2002:a37:9404:: with SMTP id w4mr28877752qkd.469.1635851468984; Tue, 02 Nov 2021 04:11:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 46/60] linux-user/hppa: Remove EXCP_UNALIGN handling Date: Tue, 2 Nov 2021 07:07:26 -0400 Message-Id: <20211102110740.215699-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::732; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x732.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853937348100001 We will raise SIGBUS directly from cpu_loop_exit_sigbus. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/hppa/cpu_loop.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index e0a62deeb9..375576c8f0 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -144,13 +144,6 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_f =3D env->gr[31]; env->iaoq_b =3D env->gr[31] + 4; break; - case EXCP_UNALIGN: - info.si_signo =3D TARGET_SIGBUS; - info.si_errno =3D 0; - info.si_code =3D 0; - info._sifields._sigfault._addr =3D env->cr[CR_IOR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case EXCP_ILL: case EXCP_PRIV_OPR: case EXCP_PRIV_REG: --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854228; cv=none; d=zohomail.com; s=zohoarc; b=CDlDowKA51eKYgXYLGbF6/8WUedFk9553rIYOpYFkz+IdhctV/s9a947UmfmGc9WikjYtLxyKgBlzp9tAcU8/04sRXm3gHQfs/HI+Vkn4c6ZD2sGVxyMeHtRPsixEDPmrt/5jkfeIK5773BhX00pnU+Q5+U++kP+j4ygSQiWWjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854228; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mTKdaHiEpe60z+ThGKt8c3K8jQRQXSW+5obPKHUiPMs=; b=SvnOYNmHyoJCw22M1KANRAoP245Y/I+O6BlKUJC2OoZ9nfNn6Pc+RQZO+qNzIYHSFKyd+3iM5XhbyZ//pkYwb1NcpPF7UNaqAbYI7+EQN7bantNTqIgTGcOkSEWe2PnPMowjBA+q27XaSVCTfSRgL0xCBLRj/2FuYlp9h+TuegA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854228179713.4653723776466; Tue, 2 Nov 2021 04:57:08 -0700 (PDT) Received: from localhost ([::1]:60146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsPa-0007BT-VZ for importer@patchew.org; Tue, 02 Nov 2021 07:57:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhA-0001On-PU for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:42843) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh8-0001xf-Fi for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bm28so4109887qkb.9 for ; Tue, 02 Nov 2021 04:11:10 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:09 -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=mTKdaHiEpe60z+ThGKt8c3K8jQRQXSW+5obPKHUiPMs=; b=N8TzaLvvmIePLT2XYwIKRPe9+0MMbhaLgC53JeuVd4JhDZxAJKGV/XpwR0wXN7u2VG 0vHglmEd20HGXzg7FDdY+xWtUS+7YCnLVV5D0p0ePpdcSLxbUGjyBDcnjEeSV2JaxZq0 gykmz9rXmH+JqpxPE27wGXxEyUoneSRoZKEFHCNFOUFx2ew7RrOoFgnd7hy5cwXiK9vM xw429n1VXwEzkgW17qLpLKz7PgSqYbwaojRhFZ067e/+CX9ig02uerbxnH89U2UAEuKV 5ekEytvQGP6GktlpnRgyt3ZyyW3t2RPC/LLK9+pdDuj+ys6ZqtDX8CQjqR42h0MTMN9I 1UuQ== 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=mTKdaHiEpe60z+ThGKt8c3K8jQRQXSW+5obPKHUiPMs=; b=7YByVAzegKcdtcuD9/3s0Qku8SYqFpeP8YgTZC2D4T+gmZCFXu5BLfWBaUBImwEXfg lkw/EhDCChSQdmCgfh3b1BxZ6K6H0dHnZXCJ9/MzWl/mCiS9yUZPeBZWYcHNOhAP50T9 oUYy+I/ZJzWVH16mCAgu4keXDoMQFcTO/8fsvlGSo0uNu/VgNFec9I33UpJat1dEOSAg FzgTrsO9o/VMxQBymVdGu2tzrryyKJqmiHoh0Rp3rxebfgrJ76z91Unm1SwRryREM2XY M0wECxegtw0l1JHL0ZKwGVwTZDFQqabXO9KcKKmnF0796P/cuqPiOIV1onaWJWYiN0I7 ujfA== X-Gm-Message-State: AOAM531uEvo1yiVmANNm6ZFm8gwHNOqPlJovV7tQLggdLUH9YgI3sQ2Z 5nyTyg7NLJQ2TikSrTpPY3Cnz193fco+Qg== X-Google-Smtp-Source: ABdhPJxdukxnvHQfwXfmtBJqx+6CknhBBskNy1FTSHAX9QEuSz5TLXYsQIxMh5fD6sIxQmkalKy58A== X-Received: by 2002:a05:620a:2950:: with SMTP id n16mr15421471qkp.405.1635851469541; Tue, 02 Nov 2021 04:11:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 47/60] target/microblaze: Do not set MO_ALIGN for user-only Date: Tue, 2 Nov 2021 07:07:27 -0400 Message-Id: <20211102110740.215699-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72b; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Edgar E . Iglesias" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854229653100001 Content-Type: text/plain; charset="utf-8" The kernel will fix up unaligned accesses, so emulate that by allowing unaligned accesses to succeed. Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/translate.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 437bbed6d6..2561b904b9 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -722,6 +722,7 @@ static TCGv compute_ldst_addr_ea(DisasContext *dc, int = ra, int rb) } #endif =20 +#ifndef CONFIG_USER_ONLY static void record_unaligned_ess(DisasContext *dc, int rd, MemOp size, bool store) { @@ -734,6 +735,7 @@ static void record_unaligned_ess(DisasContext *dc, int = rd, =20 tcg_set_insn_start_param(dc->insn_start, 1, iflags); } +#endif =20 static bool do_load(DisasContext *dc, int rd, TCGv addr, MemOp mop, int mem_index, bool rev) @@ -755,12 +757,19 @@ static bool do_load(DisasContext *dc, int rd, TCGv ad= dr, MemOp mop, } } =20 + /* + * For system mode, enforce alignment if the cpu configuration + * requires it. For user-mode, the Linux kernel will have fixed up + * any unaligned access, so emulate that by *not* setting MO_ALIGN. + */ +#ifndef CONFIG_USER_ONLY if (size > MO_8 && (dc->tb_flags & MSR_EE) && dc->cfg->unaligned_exceptions) { record_unaligned_ess(dc, rd, size, false); mop |=3D MO_ALIGN; } +#endif =20 tcg_gen_qemu_ld_i32(reg_for_write(dc, rd), addr, mem_index, mop); =20 @@ -901,12 +910,19 @@ static bool do_store(DisasContext *dc, int rd, TCGv a= ddr, MemOp mop, } } =20 + /* + * For system mode, enforce alignment if the cpu configuration + * requires it. For user-mode, the Linux kernel will have fixed up + * any unaligned access, so emulate that by *not* setting MO_ALIGN. + */ +#ifndef CONFIG_USER_ONLY if (size > MO_8 && (dc->tb_flags & MSR_EE) && dc->cfg->unaligned_exceptions) { record_unaligned_ess(dc, rd, size, true); mop |=3D MO_ALIGN; } +#endif =20 tcg_gen_qemu_st_i32(reg_for_read(dc, rd), addr, mem_index, mop); =20 --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853755; cv=none; d=zohomail.com; s=zohoarc; b=RJzCR5efel4T2E3xhcEKB6p8QizrM3Kx0RTv1pATNGyP942XtNEG1uJa6iI2uDsPKVWGgfX3FOkexFjlqiwvcF0YMrAvsvH0kesY2Ensu7YVTnkhRkb/ZKy/nd/y9/9JToltkio1Yin5CxqFUvTd6DKNOVVL+Z7RyLfulVFk34Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853755; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=Ne+zbDh5N4Zi4LWZHW/tRsKf29U1jcLzDs5IqCzVoIBCLZ3nhITg0N31Z/HtTab2OKBDk9g37uhfG7eN1aHZdBkb2jFLerYK2FakNrlGoIxiSRxIOk5A3aYv9/xdu+owoKZeRCrp3ImhJk1yRBD1amS5JfJqebDrSNYsgvUN1mw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853755552278.073039494995; Tue, 2 Nov 2021 04:49:15 -0700 (PDT) Received: from localhost ([::1]:33556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsHy-0005UW-Ct for importer@patchew.org; Tue, 02 Nov 2021 07:49:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhA-0001Ov-RH for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:34342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh9-0001y7-6R for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: by mail-qk1-x72d.google.com with SMTP id bq14so7755137qkb.1 for ; Tue, 02 Nov 2021 04:11:10 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:09 -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=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=UV1GmcKaWi7JsNo+xvsGQ3x42SkuHFt3TcH5c6MUvKIPtpGwpPELiaiEqsA3h/I+XK M779cpi6fDos5n9VSe13JQXff/YwkQrxD38j8YgPzAqBgPifyoEn/Twc0UfMtBoS2Off 3n32oUdiEypbw6sle7Bo+m1Cwdn6P8KsIftcFwRXeFiU9n+TM1WxDEN4p8k/2n1XqShD xGKmtL3ECFxfcFXDhSzNvaxQP37mzJTq55G0PPZvZfXNJf+aI84xlUfkZRniesOug/qC l5HudRzbxjyAN8YJLxW5Py3lAdUw98U3waDa9eGkm2yCmGYDDci2mUDPw1USfC4/rZCA ljxg== 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=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=6J9OOGEMIwLtCwlRID+heCiBHtDtruvAUv7Ixfc4/h5UnHHVlNEDEHrhH3ChHjW0wd ml8cNEBwb/YQJMuNGP2i1d8xUkAR1LE5qKwnlEuGPO20t4nRP6bZHCSGw/n0oIh/jTzn Vs0hsWAs8xgmXPYhRBKGzGqcSa/4vTe6EiCyJ3MmF9FLf2AFF/6/fn/Xh5z2tHQE0UA2 7g1L2HzzXmoLh1GaUn87/ITUxncgXkmmxlwv3k0Uf2usBIMqZHbbbSNy6meOyfv11/iq oLLSuLeor3b71IzCgPWc4ZcudH9DXO89eWwBfJPCPta4vAThtcty6Ue/uBRwkejg6tah v6Bw== X-Gm-Message-State: AOAM533L/CHV+2rjORGOAp24ATFQQ3qq+gMeQxM1YIkhV60Dqa7b+gKq 3Yjx3HArW/GZb8GJcKXXyGHECDgdwKM+HA== X-Google-Smtp-Source: ABdhPJz5qMHSebCncZ8uQCZbir/mzrpu9/TCf7eJTm8HyXB2B78mUNl0o/jYABTdJLGj71qM6Ai9gw== X-Received: by 2002:a05:620a:d96:: with SMTP id q22mr28577214qkl.219.1635851470234; Tue, 02 Nov 2021 04:11:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 48/60] target/ppc: Move SPR_DSISR setting to powerpc_excp Date: Tue, 2 Nov 2021 07:07:28 -0400 Message-Id: <20211102110740.215699-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853758254100001 Content-Type: text/plain; charset="utf-8" By doing this while sending the exception, we will have already done the unwinding, which makes the ppc_cpu_do_unaligned_access code a bit cleaner. Update the comment about the expected instruction format. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/ppc/excp_helper.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index b7d1767920..88a8de4b80 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -454,13 +454,15 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int = excp_model, int excp) break; } case POWERPC_EXCP_ALIGN: /* Alignment exception = */ - /* Get rS/rD and rA from faulting opcode */ /* - * Note: the opcode fields will not be set properly for a - * direct store load/store, but nobody cares as nobody - * actually uses direct store segments. + * Get rS/rD and rA from faulting opcode. + * Note: We will only invoke ALIGN for atomic operations, + * so all instructions are X-form. */ - env->spr[SPR_DSISR] |=3D (env->error_code & 0x03FF0000) >> 16; + { + uint32_t insn =3D cpu_ldl_code(env, env->nip); + env->spr[SPR_DSISR] |=3D (insn & 0x03FF0000) >> 16; + } break; case POWERPC_EXCP_PROGRAM: /* Program exception = */ switch (env->error_code & ~0xF) { @@ -1462,14 +1464,9 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr= vaddr, int mmu_idx, uintptr_t retaddr) { CPUPPCState *env =3D cs->env_ptr; - uint32_t insn; - - /* Restore state and reload the insn we executed, for filling in DSISR= . */ - cpu_restore_state(cs, retaddr, true); - insn =3D cpu_ldl_code(env, env->nip); =20 cs->exception_index =3D POWERPC_EXCP_ALIGN; - env->error_code =3D insn & 0x03FF0000; - cpu_loop_exit(cs); + env->error_code =3D 0; + cpu_loop_exit_restore(cs, retaddr); } #endif --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853954086483.4478962379179; Tue, 2 Nov 2021 04:52:34 -0700 (PDT) Received: from localhost ([::1]:44428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsLB-0004Wo-5D for importer@patchew.org; Tue, 02 Nov 2021 07:52:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhB-0001Pp-33 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:13 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:39526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrh9-0001yT-Km for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:12 -0400 Received: by mail-qk1-x72d.google.com with SMTP id bk22so12489403qkb.6 for ; Tue, 02 Nov 2021 04:11:11 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:10 -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=hDIIDmSt3XkX7dozNp8YyanBuOQiSpBj16JErrhb+ZE=; b=szYdm483ZYIEW9rjhhKgbOHvhrW8GatAFQojoPP/TJRC2xMCLCFHgWmnV32cyhbcg9 Ru+Z+9L1w7i8J+RferrqXTmfeFXCIg2FnseFMKU26dJwAXKgDfKQ2FXk7Sx4R6/t4zQY YoHEpjs1Wl/q0d/Kbw3qoS+NZt1P+RW5lO8mDCEAQzASPbCpdQjqvsuF3SY4D7GWAXxG BDva/Jty/okIoVVZhZbdjlCGw+ZYLO2uPyz2bIQ188oDLM4UKAMkyG27ykkorxYaRkuR X5PNju9iXkhCGMuWyxxxmtcaz87KwEDi9KIvg1NqxFSZzf7wfL4KjLONUWydFJlBMCTe mRZw== 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=hDIIDmSt3XkX7dozNp8YyanBuOQiSpBj16JErrhb+ZE=; b=Kc/nrew/LhRIecfglLLsR08dmdndI2Q3urStZULVqfhlCPQPL54UPdduOM1W19rUBk l/bhe9FNmEQyVJMVE5WjrDOJCBMSvf2taGRGLOkoJvZXQjBGoKV2XeUeLFCZ2xk3ubIL 85cOFmbvjlKKt/XRU4ZJOrHRhdpuBX901Rj35Z4eXjZKbBo6cWwCCQDY7oxwua4/jbTD slkSlr4LDC0p2adtpJthoeMcqbYD4owxX77Ly7EtvdgLWMIen3dcKANEZsyF2fqzFF35 qraVfzeMK8bvwEbKttDEXxv4AHmJBNRPXwQ8hFWSJO7clHUwF2Ogai3hDlPjVk8A9R12 BX9Q== X-Gm-Message-State: AOAM531QN2Y43nCgivSS/JnRUY1tph/UBh3TP6NqAkmOQY7L4HdXibTJ Z7qE2mxB8QzkGF/0pTNqSbuwIfw6wDTaqw== X-Google-Smtp-Source: ABdhPJwGWMwx4uEMmMe4xI35VJuKvVUh0iOMVdsx9PM2Ieciqnu7NTd4quAwzCMQs6ie8f1mhw21eA== X-Received: by 2002:ae9:eb08:: with SMTP id b8mr1484019qkg.1.1635851470804; Tue, 02 Nov 2021 04:11:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 49/60] target/ppc: Set fault address in ppc_cpu_do_unaligned_access Date: Tue, 2 Nov 2021 07:07:29 -0400 Message-Id: <20211102110740.215699-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-ppc@nongnu.org, Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635853957117100001 Content-Type: text/plain; charset="utf-8" We ought to have been recording the virtual address for reporting to the guest trap handler. Cc: qemu-ppc@nongnu.org Reviewed-by: Warner Losh Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/ppc/excp_helper.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 88a8de4b80..e568a54536 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1465,6 +1465,20 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr= vaddr, { CPUPPCState *env =3D cs->env_ptr; =20 + switch (env->mmu_model) { + case POWERPC_MMU_SOFT_4xx: + case POWERPC_MMU_SOFT_4xx_Z: + env->spr[SPR_40x_DEAR] =3D vaddr; + break; + case POWERPC_MMU_BOOKE: + case POWERPC_MMU_BOOKE206: + env->spr[SPR_BOOKE_DEAR] =3D vaddr; + break; + default: + env->spr[SPR_DAR] =3D vaddr; + break; + } + cs->exception_index =3D POWERPC_EXCP_ALIGN; env->error_code =3D 0; cpu_loop_exit_restore(cs, retaddr); --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854116624959.5413242378339; Tue, 2 Nov 2021 04:55:16 -0700 (PDT) Received: from localhost ([::1]:52778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsNn-0001vY-KL for importer@patchew.org; Tue, 02 Nov 2021 07:55:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhC-0001WY-Js for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:14 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:42848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhA-0001yy-IE for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:14 -0400 Received: by mail-qk1-x730.google.com with SMTP id bm28so4109950qkb.9 for ; Tue, 02 Nov 2021 04:11:11 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:11 -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=O2Pwh8dMK2GW2V5gEng3hQsybzKfwzmJDjUzbvltEB4=; b=KII20b0pklCDDjD92u60TiexbynYMZ1rJ567JVBsIMO3qgR9eNIoYa3pIxI2E+8Cy/ xOX3xlScbAGmR1XFsx2+KeJc577MRi2gchH3SCxiXdCXlyPlrOfZak3z/ov7xIl1GxMN QHo2tR+A4vPuGky7BGMjLeY0dnqiSGAIqiNLMSxpQIAAPYmYjiWBIl838DLTx+aJ6VuA 0PRHLEYHadH5u5IGndZ9/qwRilDajhqxQbRHzgOo2JkglBjLtc+ZerN2cXXauZCbgALt zqegLreuRW2GW4ZBuaMV2jiki4Q2lp1OFSKfLrachFLEmcifwC7NBuCTOXKRFhxwU+cd wyPA== 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=O2Pwh8dMK2GW2V5gEng3hQsybzKfwzmJDjUzbvltEB4=; b=Kp7xHMbUa4X9tb40oHVF6s/p+MP3MsB6OAtEj/eiNmyvtz8sefxY744raKNMaXzu4U Fm0oyLxf1QaRFPGaMsxeLfUznmJ4kCPomD6iVukIiB8zN13vWqtO2cFAxUzEz7/Kiypu zPnoNMIax1XHqv5AZtu3VpbZ3Nqou++5Tg0K7Ysu7LxzEV2ULh8jVRMHYVE2pAci2ccL 7TwLc4C9kcCwKTe9UY91uSNDjaW0VmeP6w2XO8uDE101BOg73E1koVxE6SmB2wc/VYXd fzFSONxwixrUQW0FG4IWHVbXwzAaCHU3TTx/UkEcaLfIjFhQaud2ZNmrK8ozdxH3OjhL ajSg== X-Gm-Message-State: AOAM531YVfpLyUIDAH1m9KFqYzAAUtqRLelHj537RVGkgnWo3Qoi4STW jENIIi34oOl5xtw1JUC/zG1Z1h8YlOt/0A== X-Google-Smtp-Source: ABdhPJyjtI+oH1eWqAYedfrPz6+vAx4nGHt+apGROHEfpv+WC+zyM+tLeI+DhzXJXbIp6Wy/hvdONw== X-Received: by 2002:ae9:f405:: with SMTP id y5mr442152qkl.233.1635851471394; Tue, 02 Nov 2021 04:11:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 50/60] target/ppc: Restrict ppc_cpu_do_unaligned_access to sysemu Date: Tue, 2 Nov 2021 07:07:30 -0400 Message-Id: <20211102110740.215699-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x730.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854116947100001 This is not used by, nor required by, user-only. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/ppc/internal.h | 8 +++----- target/ppc/excp_helper.c | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 339974b7d8..6aa9484f34 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -211,11 +211,6 @@ void helper_compute_fprf_float16(CPUPPCState *env, flo= at16 arg); void helper_compute_fprf_float32(CPUPPCState *env, float32 arg); void helper_compute_fprf_float128(CPUPPCState *env, float128 arg); =20 -/* Raise a data fault alignment exception for the specified virtual addres= s */ -void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, - MMUAccessType access_type, int mmu_idx, - uintptr_t retaddr) QEMU_NORETURN; - /* translate.c */ =20 int ppc_fixup_cpu(PowerPCCPU *cpu); @@ -291,6 +286,9 @@ void ppc_cpu_record_sigsegv(CPUState *cs, vaddr addr, 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_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN; #endif =20 #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index e568a54536..17607adbe4 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -1454,11 +1454,8 @@ void helper_book3s_msgsndp(CPUPPCState *env, target_= ulong rb) =20 book3s_msgsnd_common(pir, PPC_INTERRUPT_DOORBELL); } -#endif -#endif /* CONFIG_TCG */ -#endif +#endif /* TARGET_PPC64 */ =20 -#ifdef CONFIG_TCG void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) @@ -1483,4 +1480,5 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr = vaddr, env->error_code =3D 0; cpu_loop_exit_restore(cs, retaddr); } -#endif +#endif /* CONFIG_TCG */ +#endif /* !CONFIG_USER_ONLY */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854333; cv=none; d=zohomail.com; s=zohoarc; b=cbeNLz2/gXhE06rmvSnNQLSjGOEgymhwze/TrhSftsz9Sf3xDasp2kU9rbRBDbAuGLsyR2A3XnRfiCPMPmfIekHDMJ7CJ7+Se7XJMFCibjzudWmWZzBNcjEC20wjNiW558nrMZYnx3tBydgr72jEwibO724Ej1mFx1OjI7XAe6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854333; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JbVRREsh8zZn+CBQ6RQjqfCoQN/6HupmGu/vI+h3Hm8=; b=cz1jAFKx7zx6lL347LYSsGIzha11hfwY/5Uu7ZVIkIiM7VW/B9H6IjVd62bcRvL+TGtQCX/QnOXjQYavFStPiTrq2NJr9WEJCFTUf06ZduAQIAB2iMuhIH6wSqeyP7TvodSFmjFukLDesesllHrMZaHuRIMLiLzE/NwL8I3Thcw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854333876566.7300297429015; Tue, 2 Nov 2021 04:58:53 -0700 (PDT) Received: from localhost ([::1]:41060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsRH-000513-O4 for importer@patchew.org; Tue, 02 Nov 2021 07:58:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhC-0001Wj-LM for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:14 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:45665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhA-0001zP-Oa for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:14 -0400 Received: by mail-qk1-x735.google.com with SMTP id n15so5726660qkp.12 for ; Tue, 02 Nov 2021 04:11:12 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:11 -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=JbVRREsh8zZn+CBQ6RQjqfCoQN/6HupmGu/vI+h3Hm8=; b=vD2gFwofre/RV+VxOjOxKCp22c/qqzQ6pZw6nefkI+YyCZqlIq7GnnqsJIMe6DC0g+ Pqgkgjzer1ZxirHDjL3kze3pziC8v/Z5iYCc7vWxJUKQj3b6iwEWcvBv3IY7LmXgMYjm +uR5a/Gw3dVCt8bmplhnnofxuQpDF/YxpbWGHpeBZtalErywye0fJLiidnoye+0HoyAy oP6qmunBlYMWjaja6dNuumPJAjpAw3vLXIGTFL1OMZH0+yZmYyYFiuE/i72F13FDXS6l UDVcPgDcTfgmi/8rFD5ZW5qp7BYTD4L6GZmZmXgWX50+govv6KN2QxilALmwtXfm75BM 5FHQ== 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=JbVRREsh8zZn+CBQ6RQjqfCoQN/6HupmGu/vI+h3Hm8=; b=dX/8tGZbXwyelOAhXP3DSea8q0Rdivkexpig7FtVe7bgD07wVRSwI02wemaUjAZpgJ 7o7Kuew1FWHodjlR6AOsqRqO85q4sN8prpimz63n/eI2XLaz3oruk5/zwAt9PSy29ltP yVq5Y4ZqCfy0oKQuJcmylqF+PrCXhOgMYgZMW2p/JrS1EY6MgbLeP6V3IcRBDyzXxaCn ZL8spfq7IdnT7pMNnwqrHYKAqQLM6lH/7bUBlaPrsWB3M/VawP3QM69kqqFzWkLflqe5 B0DbtTEUdzTEBGYvQhfUmAEnvjoHgvNmMJx+YxlFs6WUJ5k2eYucIXTDmI0fQYxfv+Cc HEhQ== X-Gm-Message-State: AOAM533XKEHY7SlpRzIr9AG8MgBIoUmTFwg+giQ3M8GB0sf5IOijHsen 76muXE5Dqu5vuI5eGo76vb7hlv8BH1DcLQ== X-Google-Smtp-Source: ABdhPJyV3zYRxsxYU5+mH5RyR06NDDcOAo5DyRZKw63bARSGa4sdFoH38ooer9fjAj48Ia6WHYly0g== X-Received: by 2002:a05:620a:2954:: with SMTP id n20mr10164342qkp.472.1635851471884; Tue, 02 Nov 2021 04:11:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 51/60] linux-user/ppc: Remove POWERPC_EXCP_ALIGN handling Date: Tue, 2 Nov 2021 07:07:31 -0400 Message-Id: <20211102110740.215699-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, TVD_SUBJ_WIPE_DEBT=1.004 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854336036100003 We will raise SIGBUS directly from cpu_loop_exit_sigbus. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/ppc/cpu_loop.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index 840b23736b..483e669300 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -162,14 +162,6 @@ void cpu_loop(CPUPPCState *env) cpu_abort(cs, "External interrupt while in user mode. " "Aborting\n"); break; - case POWERPC_EXCP_ALIGN: /* Alignment exception = */ - /* XXX: check this */ - info.si_signo =3D TARGET_SIGBUS; - info.si_errno =3D 0; - info.si_code =3D TARGET_BUS_ADRALN; - info._sifields._sigfault._addr =3D env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case POWERPC_EXCP_PROGRAM: /* Program exception = */ case POWERPC_EXCP_HV_EMU: /* HV emulation = */ /* XXX: check this */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854482; cv=none; d=zohomail.com; s=zohoarc; b=lONqw/hwcgO6mOQD/M4BZmdSRudZY4aPss1bCvcBAWN+T3nzkoGoxARDUwDZRyexGn0yLKjPaqH2XVFfpn0KbFqJKgM6Jraadplj9Q7Hi8yUOttNgfSlskqGJc1oYvLGEUqkFscw0Swgnud13MvO2eeZsxHBAOW46d/yxp5Hs4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854482; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RjnbfjA/SuXJ4jF6cq76qF1xRJpDxH7O+xJW5W8IXoI=; b=hoUtiPb4Sxf+Nw9SkIawS4NEcyWJicP98/f1YdPZ71e0kjDv1xonYlmyiZJp00W5jfMOF3sXIFEnVppvy2mAo4ncOkpOk6gFqB1ZkY6tA0VEj3ua1lgC5VDfAF1emV+d2zo5PsdrPdqVzpAUCxlaGemgPzDIcutqJrVY7/M3agc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854482342853.6630416298726; Tue, 2 Nov 2021 05:01:22 -0700 (PDT) Received: from localhost ([::1]:49612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsTh-0002Vg-9s for importer@patchew.org; Tue, 02 Nov 2021 08:01:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhD-0001YP-0b for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:15 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:43614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhB-0001zb-7k for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:14 -0400 Received: by mail-qk1-x72d.google.com with SMTP id bp7so13985427qkb.10 for ; Tue, 02 Nov 2021 04:11:12 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:12 -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=RjnbfjA/SuXJ4jF6cq76qF1xRJpDxH7O+xJW5W8IXoI=; b=hP+qHktsRrJXjdqG2J4tf/0l3r+C9myl+rms1F+FRA1xpOrFGHv6ET84vWfi/iJLEZ Hd2Nzf5yDxBjJrwA9++LQVuLLEEHY7VmqGsn6d/DSdT5ob/N/FrGMx1LWFJE8xbtbcfB /7UkoLXb5UeSqsmzBMEmfs9rWPhNVyQaO5iPqLrA63r6tbQAdLGYPLfpsbz7xSUwlSHF lw3b9Ywyb8SBsoLvSYcq2txsXEaC5G474KbtCawYqlcrpWoQ6ofJDpD4IW+28NS8YJkv i5N63ya/iUg4BW3H+4SBakXMHOOyY87EC7c/UkzA7dwQQvza1vxwM+JueLX3HXWXiLke nNSw== 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=RjnbfjA/SuXJ4jF6cq76qF1xRJpDxH7O+xJW5W8IXoI=; b=WlS+8mfK0BxLc/YDonz/XqHM8I6FLaRe6IyGuXt2IsuLuOlw1epM8GAZzLy7+kKWgU QE0OEt7AyJEkgsH0iTzPgN4c2u3iUqF8uxFZqMpi4UO12S6dzL074azex9kvCOERdUXH zVZ+jBE3e93BSULV3cWRV1G/ePPJpWXn5egFyvhOOij+1u167j0OT/Yg6MAv7q7z1u4Y 0qBp+9vNPtD1sfiP82I4RNqxKauZvPy7sWZls6R7kRdHOScn7LphGNclAFRSl5heYDYk las4G2fiorlPPZpdpviLWLU7+u2VzGBElq1dt9NsBSVNmi4JTYobXAx471fYGiiXH6yD bqbw== X-Gm-Message-State: AOAM530zq1TM75ugce+Y7Q+W+rmoqdldy9PzYAFEKEhEAuvZa5Te90Ao FXBAITCPHUG87mvpFawPOFenQM6XNaPbtQ== X-Google-Smtp-Source: ABdhPJyOKGUDUZV4+i0EMGWgHH+8gEpdUXP1YQRVZB+mrBQkr77sh1P+U3CbJzC1G3n4v1xJO1HXhg== X-Received: by 2002:a05:620a:2093:: with SMTP id e19mr2767374qka.475.1635851472401; Tue, 02 Nov 2021 04:11:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 52/60] target/s390x: Implement s390x_cpu_record_sigbus Date: Tue, 2 Nov 2021 07:07:32 -0400 Message-Id: <20211102110740.215699-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854488139100003 For s390x, the only unaligned accesses that are signaled are atomic, and we don't actually want to raise SIGBUS for those, but instead raise a SPECIFICATION error, which the kernel will report as SIGILL. Split out a do_unaligned_access function to share between the user-only s390x_cpu_record_sigbus and the sysemu s390x_do_unaligned_access. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/s390x/s390x-internal.h | 8 +++++--- target/s390x/cpu.c | 1 + target/s390x/tcg/excp_helper.c | 27 ++++++++++++++++++++------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 163aa4f94a..1a178aed41 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -270,18 +270,20 @@ ObjectClass *s390_cpu_class_by_name(const char *name); void s390x_cpu_debug_excp_handler(CPUState *cs); void s390_cpu_do_interrupt(CPUState *cpu); bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req); -void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, - MMUAccessType access_type, int mmu_idx, - uintptr_t retaddr) QEMU_NORETURN; =20 #ifdef CONFIG_USER_ONLY void s390_cpu_record_sigsegv(CPUState *cs, vaddr address, MMUAccessType access_type, bool maperr, uintptr_t retaddr); +void s390_cpu_record_sigbus(CPUState *cs, vaddr address, + MMUAccessType access_type, uintptr_t retaddr); #else bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, int mmu_idx, + uintptr_t retaddr) QEMU_NORETURN; #endif =20 =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 593dda75c4..ccdbaf84d5 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -269,6 +269,7 @@ static const struct TCGCPUOps s390_tcg_ops =3D { =20 #ifdef CONFIG_USER_ONLY .record_sigsegv =3D s390_cpu_record_sigsegv, + .record_sigbus =3D s390_cpu_record_sigbus, #else .tlb_fill =3D s390_cpu_tlb_fill, .cpu_exec_interrupt =3D s390_cpu_exec_interrupt, diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index b923d080fc..4e7648f301 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -82,6 +82,19 @@ void HELPER(data_exception)(CPUS390XState *env, uint32_t= dxc) tcg_s390_data_exception(env, dxc, GETPC()); } =20 +/* + * Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, + * this is only for the atomic operations, for which we want to raise a + * specification exception. + */ +static void QEMU_NORETURN do_unaligned_access(CPUState *cs, uintptr_t reta= ddr) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); +} + #if defined(CONFIG_USER_ONLY) =20 void s390_cpu_do_interrupt(CPUState *cs) @@ -106,6 +119,12 @@ void s390_cpu_record_sigsegv(CPUState *cs, vaddr addre= ss, cpu_loop_exit_restore(cs, retaddr); } =20 +void s390_cpu_record_sigbus(CPUState *cs, vaddr address, + MMUAccessType access_type, uintptr_t retaddr) +{ + do_unaligned_access(cs, retaddr); +} + #else /* !CONFIG_USER_ONLY */ =20 static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx) @@ -593,17 +612,11 @@ void s390x_cpu_debug_excp_handler(CPUState *cs) } } =20 -/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, - this is only for the atomic operations, for which we want to raise a - specification exception. */ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - S390CPU *cpu =3D S390_CPU(cs); - CPUS390XState *env =3D &cpu->env; - - tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr); + do_unaligned_access(cs, retaddr); } =20 static void QEMU_NORETURN monitor_event(CPUS390XState *env, --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854605333901.1650651544318; Tue, 2 Nov 2021 05:03:25 -0700 (PDT) Received: from localhost ([::1]:58142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsVg-0008OO-3P for importer@patchew.org; Tue, 02 Nov 2021 08:03:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhD-0001b3-Li for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:15 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:38541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhB-00020C-Py for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:15 -0400 Received: by mail-qt1-x832.google.com with SMTP id h4so17869324qth.5 for ; Tue, 02 Nov 2021 04:11:13 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:12 -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=3/CJUXQvBCEoPlihnnAPxMwhS0SfN83B4jFLy6O6YSI=; b=HkmiMGnyWOOqa4GQSEbtV6qObdJv69K1qJh4yUj+/Ejafg4m9CoNLBbTIrypKWWRCh /2IpX9BFAeMknOr1zl2rtkTzX8LTx2fnpSHAZYpPHrkAI9DBRZxsYTOajWT7YA3pBXjD CTW2tdsSGdWLxhQKNP90VdWhHxDf0wY7olmcyUTFJAqox3xnAYbSzhhDEZ34r5iYWNJ+ wlJZnHXgkmm8b7n6uGY3ODcwCpZjxmjWqYfDhkQCUcRLIPVbWdkB+KeotSgjAI5TgwhK kR0ZwZjVoobV5woLHHYjmbAiEkP38nPXxn4r3dNIncB11QAez6nyxtOGPWaEucf6RAs4 jUQw== 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=3/CJUXQvBCEoPlihnnAPxMwhS0SfN83B4jFLy6O6YSI=; b=pnK1RhZ5ae4Ut5MVGy/VmEvQm67CMnoRADuJESWBl4HNk7q3N9Oz9S2O6JRZiOaFeY cKI+t9VCpk6PQqKMMAmznlW/Y3Yj8/J9z5H9E9Kvl2dx+vNjgSTsb3b95zD2L5fKIGZ5 0mqHta96WAAnBbujrU4K7EGtHC4Qi6NiG+r/y/wcqzppiECgrcAdKBu5bfvS2dFDRVIR kc+tSd0dufG/zrK6UP/1j3x31kU7CCM00zosHGyB9oC5dJfOjCtwglGaJ0b3XR9v9PhC 1qbjQATS8FNOCDNfvj2rhDD72ToFRDCClRFPxnXndsDdEahWVo0BJG/iHjvdJ5GaeR15 PzNQ== X-Gm-Message-State: AOAM533KAIETVrPMXPtevPkzZmacB+BwNnjfOGoQoWCCuqfKECGNjH1Y yiF0Rl/XwbDZPGsAkIpsZ5tiLL0bI6yAKg== X-Google-Smtp-Source: ABdhPJxdb52HZ3Za43UhrnYP+bN3QJOdiEHPEGTx396bs5SY5Fni85n+S44DcFldFbRx28jKinU1og== X-Received: by 2002:a05:622a:2c2:: with SMTP id a2mr32279346qtx.305.1635851472960; Tue, 02 Nov 2021 04:11:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 53/60] target/sh4: Set fault address in superh_cpu_do_unaligned_access Date: Tue, 2 Nov 2021 07:07:33 -0400 Message-Id: <20211102110740.215699-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yoshinori Sato Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854607120100001 We ought to have been recording the virtual address for reporting to the guest trap handler. Cc: Yoshinori Sato Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/sh4/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index c996dce7df..752669825f 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -29,6 +29,9 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr a= ddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { + CPUSH4State *env =3D cs->env_ptr; + + env->tea =3D addr; switch (access_type) { case MMU_INST_FETCH: case MMU_DATA_LOAD: @@ -37,6 +40,8 @@ void superh_cpu_do_unaligned_access(CPUState *cs, vaddr a= ddr, case MMU_DATA_STORE: cs->exception_index =3D 0x100; break; + default: + g_assert_not_reached(); } cpu_loop_exit_restore(cs, retaddr); } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635853923; cv=none; d=zohomail.com; s=zohoarc; b=hb4C2sGsvklRDl7vN3wboWIcdwaCRb4rDndK0FD6aHT4RB3wPc/4vSEEBlQj7B2l9FVpD1sjLtQMkvq60Cv22r7BGJ5l2FVmh+gzx2sZJXsv5B451rr4cThpn3/OBFxW9ngASoLGfNys/qG1sWO4bfJsGITlgk62rcjICKUSWYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635853923; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P+LiSx7CkE3blKbhg5ALaxOT08dtFOhalcqlNc9ibvc=; b=dTCSDOPGHaxwkh0knAh10j81EyV0gdzJXUGEcjM/nrzX1ffsH8CRceuToQ8D6O8YvKj+ugIcMK3IKkEFzVH2HtqrSyPxUh2YiLUolkaXUGwFnhgRvG0aduJg7RNvpLH5KnsTwJo6ETfZrwWNCLGSivN/LjTLtR0hGqhWq7WpI6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635853923776588.4054476130675; Tue, 2 Nov 2021 04:52:03 -0700 (PDT) Received: from localhost ([::1]:42158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsKg-0002x0-PA for importer@patchew.org; Tue, 02 Nov 2021 07:52:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhD-0001cb-Uk for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:19 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:44756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhC-00020Q-Dw for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:15 -0400 Received: by mail-qt1-x82f.google.com with SMTP id j1so11238106qtq.11 for ; Tue, 02 Nov 2021 04:11:14 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:13 -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=P+LiSx7CkE3blKbhg5ALaxOT08dtFOhalcqlNc9ibvc=; b=Usx/HpVAgrQX+OlK893iSPRF+0iol38QPXU3Hy/cSAXJKSBhhpYf0L+mzNS1/CugTV AAqvjPIN9SfJd8k9MqrHPzp06BOnZ+PyWMiEQ3HtUGZ3S7Tz7T1cHBTdaea0nQ+0ghgT p3Mrdj6todbzIq9G8qVLVeUclTeksXRY9BNscMZuOPFrnMvoAnNKjkA7haDl8VZAhH4E gCyLvKMWgmYFV+9WZDqrGncN++YCdAEIfxw9ogTFm5Iso5YUb+yJEBJzlyn4s1rDFwQm NFYNCmsEzlYmRorr38xJYHrihEqUym5UKgQxlRZI46/Y+8r3fu+/2do4DuNuDegtyDTT SBzw== 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=P+LiSx7CkE3blKbhg5ALaxOT08dtFOhalcqlNc9ibvc=; b=imZq+Ut3Ty8IG76N94iOrmEr4zLbc3Z+iv615tl2m0znlA0Vi+dABnNr+QzxsmU7ZX cWMLLkzoX11WN+jNstV2VBQeNeNBQWKsFR5+NurKMfIFgJO7i/60QJywmLwyIx0d1pDT w7Obarq1KRsFJ/QZsVy6oAcowfRXeFuRWgdGhzoJIcYMsFrVhbnN1n5oYsTAvpO+54p+ Ku/V2r019osSVblE8GZ405E6/itIGZHDypRIjdmNWDuvkDUw8GaaBfxjAR5C0kR8xsGI iIi8dP8L5s4D/jc4HBRfTWORlBc+Bxu1l8Poseo+TFVzuwXPqjeYb+2ZOhTcS9S/j6C6 8BPQ== X-Gm-Message-State: AOAM533g54jXSHZHyU1Cix37dwZTvVwyy5QUDkpb/MtPllBROsdzNTGe d1FyQ9m+135adIRJ8hPYR0u7Y91ihQhd3Q== X-Google-Smtp-Source: ABdhPJxMcxqeyyI/5AMpaj8UYyNjyCjUFW9vU7dY5Kmc746gMM0JS7yIelkReOECQnQFSUVaBPf+yQ== X-Received: by 2002:ac8:7a82:: with SMTP id x2mr36678971qtr.260.1635851473569; Tue, 02 Nov 2021 04:11:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 54/60] target/sparc: Remove DEBUG_UNALIGNED Date: Tue, 2 Nov 2021 07:07:34 -0400 Message-Id: <20211102110740.215699-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635853924285100001 The printf should have been qemu_log_mask, the parameters themselves no longer compile, and because this is placed before unwinding the PC is actively wrong. We get better (and correct) logging on the other side of raising the exception, in sparc_cpu_do_interrupt. Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- target/sparc/ldst_helper.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index bbf3601cb1..0549b6adf1 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -27,7 +27,6 @@ =20 //#define DEBUG_MMU //#define DEBUG_MXCC -//#define DEBUG_UNALIGNED //#define DEBUG_UNASSIGNED //#define DEBUG_ASI //#define DEBUG_CACHE_CONTROL @@ -364,10 +363,6 @@ static void do_check_align(CPUSPARCState *env, target_= ulong addr, uint32_t align, uintptr_t ra) { if (addr & align) { -#ifdef DEBUG_UNALIGNED - printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FM= T_lx - "\n", addr, env->pc); -#endif cpu_raise_exception_ra(env, TT_UNALIGNED, ra); } } @@ -1968,10 +1963,6 @@ void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPU= State *cs, vaddr addr, SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; =20 -#ifdef DEBUG_UNALIGNED - printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx - "\n", addr, env->pc); -#endif cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); } #endif --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854773; cv=none; d=zohomail.com; s=zohoarc; b=JKo8I46UXrVlcQgfyrLp+7kpjEkdIW82axmg/xLBnhg5Q2SgnOLN1FjuAOXe6w3tplm0vtmWcy3Cy0L4eqZcbX7W558Cmpt4fOZD5of4Z+6JCFCG3XLW74np1o3EV7EaHw1v5HGpp1aouhCRlqYtK1TmjrFGOXhOzmZdW45NMBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854773; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=X43IYJI4LUHHwKhWCZMrHOmuDgi+BPhlMJNkYxt+Keq7nmjCZJpMLxi52D5jTdNXSjf7aPCKHoC0f9hZh/J2BVkJCC8pxmGVSO1UX0eq3RZXEs+rhcxTBjpRhAQiwDC4qJB9oO6KucniozK/uzHtIQW2//zfFYKPA3xwrd6Qyw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854773859381.177757627313; Tue, 2 Nov 2021 05:06:13 -0700 (PDT) Received: from localhost ([::1]:38754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsYO-0005pz-Ox for importer@patchew.org; Tue, 02 Nov 2021 08:06:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhF-0001df-E4 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:19 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:33524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhD-00020y-5y for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:17 -0400 Received: by mail-qt1-x832.google.com with SMTP id h16so14043859qtk.0 for ; Tue, 02 Nov 2021 04:11:14 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:14 -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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=CTrjXnePJF+Rse4Oe5iu/WPsWydGurIrp4qUSUJsm4/Dm5fIuA+DBCgWMVl6g5/RcE ySoEGTJuVyEIBpHNIosgATegdoNOd1CRRuPHu9yBdC3h1DSmBtCi9KBiDk3HjzcYFnLb o/ZdCkhVbjZ2Lol2aTs8YpLZWCyJnePK6zGjHyzyufEmfY63NUmk5mH/1J7F/srbuhai X5XLpjfvrSewphK40H58Qi5n5SBU+es7Q/IB1xoJO1kOA58QkpMYpH5K7QUXXgqezyHA 0rqRbgRbZe+xwWEmOJIwsDqgxvuvYA0TwVgxfI2GP0ixxc1l9qlSiGZFr4bQ+OBDoVN+ BZSQ== 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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=AKU6G9P5etvYZE85b9fszYfbCxRxAItzuHKAEe8fqvYBZvaPTTlP2SqWMzem6xmLLg eJfS/+eAhb5QRSDHCCwwSBoqb6LWu2uHWPpNjlZLXcOk9IetdwqQunzDuvb5ZPgrVitk 9KQiz0oAQeGbCY4zzZaWbD2g9FU4ikvM+ZYcpGeNlXRpqT50l69Xh6os9enuYz0J/o+A 0Wg8XDvc/r5AlIqh3B6/fjCGV91rQwL4z8x2A4SskC5qnq88x9uQfqeNSABHK4p7ice/ JmXLkRtbROy2O1YO+Gl6ICqJP25XBbE+KEsFHOpQtVl6GLsBUFLD4rwMqdt41kY4t9Nr Jh/g== X-Gm-Message-State: AOAM531WSHXz5DSkhf2ciMdPygUBUTfp3SyL7RbBfrqTyfUqwFBF+s/9 O3VQNUVhPkzcrInVzZQLtV/TxvuBx4EV5w== X-Google-Smtp-Source: ABdhPJznlG4J/TJIJV51CCoF9D90+he7QbmomHUalNJ+KS+TMeN1KgqMLqsY74wAPa+/2u0212DzTA== X-Received: by 2002:a05:622a:394:: with SMTP id j20mr37681502qtx.386.1635851474332; Tue, 02 Nov 2021 04:11:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 55/60] target/sparc: Split out build_sfsr Date: Tue, 2 Nov 2021 07:07:35 -0400 Message-Id: <20211102110740.215699-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x832.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854775137100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/mmu_helper.c | 72 +++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 2ad47391d0..014601e701 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -502,16 +502,60 @@ static inline int ultrasparc_tag_match(SparcTLBEntry = *tlb, return 0; } =20 +static uint64_t build_sfsr(CPUSPARCState *env, int mmu_idx, int rw) +{ + uint64_t sfsr =3D SFSR_VALID_BIT; + + switch (mmu_idx) { + case MMU_PHYS_IDX: + sfsr |=3D SFSR_CT_NOTRANS; + break; + case MMU_USER_IDX: + case MMU_KERNEL_IDX: + sfsr |=3D SFSR_CT_PRIMARY; + break; + case MMU_USER_SECONDARY_IDX: + case MMU_KERNEL_SECONDARY_IDX: + sfsr |=3D SFSR_CT_SECONDARY; + break; + case MMU_NUCLEUS_IDX: + sfsr |=3D SFSR_CT_NUCLEUS; + break; + default: + g_assert_not_reached(); + } + + if (rw =3D=3D 1) { + sfsr |=3D SFSR_WRITE_BIT; + } else if (rw =3D=3D 4) { + sfsr |=3D SFSR_NF_BIT; + } + + if (env->pstate & PS_PRIV) { + sfsr |=3D SFSR_PR_BIT; + } + + if (env->dmmu.sfsr & SFSR_VALID_BIT) { /* Fault status register */ + sfsr |=3D SFSR_OW_BIT; /* overflow (not read before another fault)= */ + } + + /* FIXME: ASI field in SFSR must be set */ + + return sfsr; +} + static int get_physical_address_data(CPUSPARCState *env, hwaddr *physical, int *prot, MemTxAttrs *attrs, target_ulong address, int rw, int mmu= _idx) { CPUState *cs =3D env_cpu(env); unsigned int i; + uint64_t sfsr; uint64_t context; - uint64_t sfsr =3D 0; bool is_user =3D false; =20 + sfsr =3D build_sfsr(env, mmu_idx, rw); + switch (mmu_idx) { case MMU_PHYS_IDX: g_assert_not_reached(); @@ -520,29 +564,18 @@ static int get_physical_address_data(CPUSPARCState *e= nv, hwaddr *physical, /* fallthru */ case MMU_KERNEL_IDX: context =3D env->dmmu.mmu_primary_context & 0x1fff; - sfsr |=3D SFSR_CT_PRIMARY; break; case MMU_USER_SECONDARY_IDX: is_user =3D true; /* fallthru */ case MMU_KERNEL_SECONDARY_IDX: context =3D env->dmmu.mmu_secondary_context & 0x1fff; - sfsr |=3D SFSR_CT_SECONDARY; break; - case MMU_NUCLEUS_IDX: - sfsr |=3D SFSR_CT_NUCLEUS; - /* FALLTHRU */ default: context =3D 0; break; } =20 - if (rw =3D=3D 1) { - sfsr |=3D SFSR_WRITE_BIT; - } else if (rw =3D=3D 4) { - sfsr |=3D SFSR_NF_BIT; - } - for (i =3D 0; i < 64; i++) { /* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match(&env->dtlb[i], address, context, physical= )) { @@ -592,22 +625,9 @@ static int get_physical_address_data(CPUSPARCState *en= v, hwaddr *physical, return 0; } =20 - if (env->dmmu.sfsr & SFSR_VALID_BIT) { /* Fault status registe= r */ - sfsr |=3D SFSR_OW_BIT; /* overflow (not read before - another fault) */ - } - - if (env->pstate & PS_PRIV) { - sfsr |=3D SFSR_PR_BIT; - } - - /* FIXME: ASI field in SFSR must be set */ - env->dmmu.sfsr =3D sfsr | SFSR_VALID_BIT; - + env->dmmu.sfsr =3D sfsr; env->dmmu.sfar =3D address; /* Fault address register */ - env->dmmu.tag_access =3D (address & ~0x1fffULL) | context; - return 1; } } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635855013; cv=none; d=zohomail.com; s=zohoarc; b=A5rDwZHCWwTI45Fz+O7pPEOvKFvtXJsQYOSlhSZfTWucdKC9HvOFL/xI/kGdkPPId8Ju72NANeKKpgTPv1o2MSSPchuUxxZjXuLQ2gl/umiTmxAauW8QnEgZ3ry9k7a1J/HFJS6YkLjURzZazN4gKgEs/EdIc/WbvehiXcZzyoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635855013; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=muffzeHX3yZuoAcxrWs0UhKgv9u/j8rmCNk7xQHU/Hc=; b=FcvL8lohChtyp62zvoWsU8DcFWsFp7PSLPqfFNLXmUcAAD/Kp+3dFvVi2qA72As8ee78Sn1rn+cBoLJaryVsLA4ySP0kI4uWG3KYEF4Ff4erDy67uOsNYY/9+0p8vwXCPO4qxlN7Ew3Wpyc2u+8DsRDR1DgGcziUt3P16RCdIQA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635855013532620.4408267247397; Tue, 2 Nov 2021 05:10:13 -0700 (PDT) Received: from localhost ([::1]:47500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhscG-0003Fu-Jm for importer@patchew.org; Tue, 02 Nov 2021 08:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhI-0001gL-K8 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:20 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:34475) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhD-00021C-RU for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:17 -0400 Received: by mail-qt1-x82f.google.com with SMTP id u7so68531qtc.1 for ; Tue, 02 Nov 2021 04:11:15 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:14 -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=muffzeHX3yZuoAcxrWs0UhKgv9u/j8rmCNk7xQHU/Hc=; b=Lj+prjzCkRKwr8A/CCwy6qMqerbsh4bGMMvVIfAIG9Cr/VpQQorVXp0P/SDBLTrwF2 rDbQT3drlrBWj5UF8s0doENaizgjANjY+8T4rUAPqN+FWEpVQVEv3sDg+9spXN8NlbHT Yh0Of6TP62GxSCwqrYJ34svgqFhSNe8I7VoABmHqjGNTPC2DfLkGYFruNq73YeFnJtAj ulyRxzyho14ZCfTwtR8cl4tehOhOI385odNFreIKDi5m6WIM36Cl9JEoXK1sWoeqS3rg DX9eIcWNMc1jxhVfURpVAyq6dHDz5k1u2tK26xFaH68IHfNoafGBc93F6YPwwZCrtAl3 tzBQ== 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=muffzeHX3yZuoAcxrWs0UhKgv9u/j8rmCNk7xQHU/Hc=; b=hMfAotcs8r1PP3K2tCf+o0+ddA8/6s0OhZ8iPmhv8axs/+IJqFnjugx6oDXiDNU0zT on+5GwRP432kNz7MLsEg6Z2PTddSmINjhOZ+NgU1+rjox85kheD5LaTqgnM23ITioEcX yB5najqyp3xM4ikT7phIOaJYbbf7kzPspf5/EXwDZaPbJyVO13boopJ/bDHz2qCBg6hM BEAmXsyw+qOonl0CIOVHtAzPEzcflP+e7RCuJQQn5I0RQPIQipjovEoTf483GZmWQAc5 WSMp0Rtkq1PbkaKOE+6BqofAWi1vV7M32h4GxFQ9rQM6KecAVIFCCIvZwjgEzDM20ZVJ FSow== X-Gm-Message-State: AOAM5326mnT+HbmDJco8f2VLemkzviJ1H87FpyCn6mQ1f5dLrTO7PCIs I7cFYP4J4YHsuEIY/HrlDe1CtPGa8EHdjg== X-Google-Smtp-Source: ABdhPJzP1lqnDiXmfJCJOllmrxpWoPfqSGgVBDxEiTdQpVgvZglMBjg16+hIEnZqUKFAlakQ89ZVPQ== X-Received: by 2002:a05:622a:148d:: with SMTP id t13mr36195317qtx.393.1635851475059; Tue, 02 Nov 2021 04:11:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 56/60] target/sparc: Set fault address in sparc_cpu_do_unaligned_access Date: Tue, 2 Nov 2021 07:07:36 -0400 Message-Id: <20211102110740.215699-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635855014465100001 Content-Type: text/plain; charset="utf-8" We ought to have been recording the virtual address for reporting to the guest trap handler. Move the function to mmu_helper.c, so that we can re-use code shared with get_physical_address_data. Reviewed-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/ldst_helper.c | 13 ------------- target/sparc/mmu_helper.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 0549b6adf1..a3e1cf9b6e 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -1953,16 +1953,3 @@ void sparc_cpu_do_transaction_failed(CPUState *cs, h= waddr physaddr, is_asi, size, retaddr); } #endif - -#if !defined(CONFIG_USER_ONLY) -void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, - MMUAccessType access_type, - int mmu_idx, - uintptr_t retaddr) -{ - SPARCCPU *cpu =3D SPARC_CPU(cs); - CPUSPARCState *env =3D &cpu->env; - - cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); -} -#endif diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 014601e701..f2668389b0 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -922,3 +922,23 @@ hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vad= dr addr) } return phys_addr; } + +#ifndef CONFIG_USER_ONLY +void QEMU_NORETURN sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, + uintptr_t retaddr) +{ + SPARCCPU *cpu =3D SPARC_CPU(cs); + CPUSPARCState *env =3D &cpu->env; + +#ifdef TARGET_SPARC64 + env->dmmu.sfsr =3D build_sfsr(env, mmu_idx, access_type); + env->dmmu.sfar =3D addr; +#else + env->mmuregs[4] =3D addr; +#endif + + cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr); +} +#endif /* !CONFIG_USER_ONLY */ --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854066302140.64599460428258; Tue, 2 Nov 2021 04:54:26 -0700 (PDT) Received: from localhost ([::1]:50646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsMy-0000TB-KM for importer@patchew.org; Tue, 02 Nov 2021 07:54:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhI-0001gI-Ji for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:20 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:43690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhE-00021R-Ix for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:17 -0400 Received: by mail-qt1-x82d.google.com with SMTP id 8so986687qty.10 for ; Tue, 02 Nov 2021 04:11:16 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:15 -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=G7SBr/WksrEb3wfGw9+4/7HGKeZrYxUMshTizcIBHp0=; b=hwOxAJR38Bn8SzPMelDs0iP37VCMq+iC6HOQ5gkLmtWP4rYNod0JUbgYV83t8YKTk3 /+oGZzj+xTGXGeJuoMSHeYv+/QlPrmsJ5YodSrU3t7YHra/+OOfJA2XG9DTW1ofItvRz NjXs4dpzXzJrtakD9nr2yy76JlWzNsj/7FhB4SnJoj0FbnehR2/dguF39xfkbK/jLWLD IhwfL+iUkKnb52KJNcfT49xcqVizw5mQ5vuI/tAWsD3wShsPXEiesgJK9eoYHsyPO+ya BxPk8NTlIPtCMNsxZ8o6QEch5IIjHmIk9af/Qw7GmGQMFpr3+CGf+3ikwrdnjVbyX8Ap ROeg== 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=G7SBr/WksrEb3wfGw9+4/7HGKeZrYxUMshTizcIBHp0=; b=iMkgzXdWZwbTgRggwy8wbeIGgcdVRFNwRUZWqI+dPvoq9jrLBHKQkz/s42ug2aU48m /iBwswlL4/LznSJvVuFJLV4DpfVw82o8n1d2c8wHxDXeiVLltG8UrnE9Y38J68Inapwv xF5rqIRwIyw3H7tJnc8VXz9w+D2sY/VVtanOu+Eh5zkPzYi7iBJGGWYoL9r6EljEvxGp m/eHTdOB96+gwOXLdFSpZLRXsN3XZkDGy6mE3vcVDXcz9bxKdoY7qo516HFHhnLQiwZ9 KWNVu49Xh6ENOuG7vUJGU3VFNq425Me2wmJTA1mrEw/gx/m7P06eXHyeNk7qQRZQFdFa 93dQ== X-Gm-Message-State: AOAM5315AvZVsublBL/VczFJfDWfT7bhuTeBoaSp5EkYGQTtkAODfiNs H9ErNf9VpZLEyh4d/XR+BcGYswH8dKAKeQ== X-Google-Smtp-Source: ABdhPJwCSlh3cxeorN4fHXa7Hk4OokZF1NzPd0aaN+Q88C1VR7xiYHnBcopmfjvvLYZBM3qwoG87xw== X-Received: by 2002:a05:622a:1313:: with SMTP id v19mr5966344qtk.340.1635851475740; Tue, 02 Nov 2021 04:11:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 57/60] accel/tcg: Report unaligned atomics for user-only Date: Tue, 2 Nov 2021 07:07:37 -0400 Message-Id: <20211102110740.215699-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854067551100001 Use the new cpu_loop_exit_sigbus for atomic_mmu_lookup, which has access to complete alignment info from the TCGMemOpIdx arg. Reviewed-by: Warner Losh Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index c4f69908e9..1ee64f01fc 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -474,11 +474,22 @@ static void *atomic_mmu_lookup(CPUArchState *env, tar= get_ulong addr, MemOpIdx oi, int size, int prot, uintptr_t retaddr) { + MemOp mop =3D get_memop(oi); + int a_bits =3D get_alignment_bits(mop); + void *ret; + + /* Enforce guest required alignment. */ + if (unlikely(addr & ((1 << a_bits) - 1))) { + MMUAccessType t =3D prot =3D=3D PAGE_READ ? MMU_DATA_LOAD : MMU_DA= TA_STORE; + cpu_loop_exit_sigbus(env_cpu(env), addr, t, retaddr); + } + /* Enforce qemu required alignment. */ if (unlikely(addr & (size - 1))) { cpu_loop_exit_atomic(env_cpu(env), retaddr); } - void *ret =3D g2h(env_cpu(env), addr); + + ret =3D g2h(env_cpu(env), addr); set_helper_retaddr(retaddr); return ret; } --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854644314436.1682233618981; Tue, 2 Nov 2021 05:04:04 -0700 (PDT) Received: from localhost ([::1]:59790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsWJ-00011f-Bq for importer@patchew.org; Tue, 02 Nov 2021 08:04:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhI-0001gG-Jk for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:20 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:43691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhF-00021W-5q for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:18 -0400 Received: by mail-qt1-x82e.google.com with SMTP id 8so986711qty.10 for ; Tue, 02 Nov 2021 04:11:16 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:16 -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=MIsR5ntgtAsaxoJ+NtIU7qk3vK65x7GB6eb5bSAQ4NA=; b=idtZ3bpWwOwDhGsa6Tp4Y07D2p7fu5keQIByYmeHsYQ8rjwyhhu8eCDyEzMdlMOGo3 AO5RQ7cCTvAYgtB9iXFu5FbuxH5Gm6CdVt9mcj2fyVV+ceXk3ybqz3KSZWpwm+VEo5wt n4zO+bhbQ8M+ZnNQp3JFJWLUDX3JXJJii0tI54VP7/CavHVo01rKimcJgrIBzEjbUgYZ RGhnP7CKdBql5goDmvXk04ddw6BZeXUHzpyEKzRBQ4o2SHdezuM5Pf+PCXoqN+OxfNag 0u1eU53lVwVKwlueWRmc3bLPZilHi93/comh1uz6bmNBGE8Rq+YT+7BhktMFdrclb7nI amCg== 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=MIsR5ntgtAsaxoJ+NtIU7qk3vK65x7GB6eb5bSAQ4NA=; b=DI1Ga0z7wuendmfiSSv5KgJa74eM0XaTxJ/HtyCIt2oZMZeRhku/3DLEQtTXUCh2xg dpWDok0DFei141YdrOksJUpSUNtB3vz+He3JTGaLEtZ8iEagSzZfLkavLNefS0FfkiFi dv3lpV3c+8lPKRNrrE1VrcU6I9DuifLED9vKZdbWskLJFkmp3degbDiFB8zwreJ4wYuF o/5CrPqNDfAA8yD8gE1Ufgg0j3sb6KElrLiq96C8RDEDWkq4OgY5nXgBwgZlSb2PkmIe E2Gbj+VsmdVMsPs5dMXgw2mdU28R/8kqGokGkWqGmymk3vhYCQtMqfuxoQurjnUcuVBU 4W8Q== X-Gm-Message-State: AOAM5335mVuYMXZzuvCPeKrGcZPEIHNX4A67ELXpcF8LaQKGpUfLKGqL Ax7IhsYwnXQ80rE7G+KH3sSao7t9y6x4FQ== X-Google-Smtp-Source: ABdhPJxNESCzHQbmUOceW/4KvcE+sz0PEYjEkXP+XL0L4kBBfFjZumAwXaMP3GlZ8yr7JKaqpKUi3A== X-Received: by 2002:ac8:5e49:: with SMTP id i9mr36082947qtx.145.1635851476337; Tue, 02 Nov 2021 04:11:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 58/60] accel/tcg: Report unaligned load/store for user-only Date: Tue, 2 Nov 2021 07:07:38 -0400 Message-Id: <20211102110740.215699-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82e.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854645126100001 Use the new cpu_loop_exit_sigbus for cpu_mmu_lookup. Reviewed-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- accel/tcg/user-exec.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 1ee64f01fc..aaf47d89d2 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -218,9 +218,14 @@ static void validate_memop(MemOpIdx oi, MemOp expected) static void *cpu_mmu_lookup(CPUArchState *env, target_ulong addr, MemOpIdx oi, uintptr_t ra, MMUAccessType type) { + MemOp mop =3D get_memop(oi); + int a_bits =3D get_alignment_bits(mop); void *ret; =20 - /* TODO: Enforce guest required alignment. */ + /* Enforce guest required alignment. */ + if (unlikely(addr & ((1 << a_bits) - 1))) { + cpu_loop_exit_sigbus(env_cpu(env), addr, type, ra); + } =20 ret =3D g2h(env_cpu(env), addr); set_helper_retaddr(ra); --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854239393355.0734040302898; Tue, 2 Nov 2021 04:57:19 -0700 (PDT) Received: from localhost ([::1]:33042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsPm-0007zA-Ei for importer@patchew.org; Tue, 02 Nov 2021 07:57:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhL-0001ud-Pi for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:23 -0400 Received: from mail-qt1-x82b.google.com ([2607:f8b0:4864:20::82b]:37866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhI-00021d-Ba for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:23 -0400 Received: by mail-qt1-x82b.google.com with SMTP id o12so7706651qtv.4 for ; Tue, 02 Nov 2021 04:11:17 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:16 -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=7mVMLvhvHhRE4SNYEq8lTvIaJ67DT2EyP7H4YHihO6k=; b=EXCMgBL6JncL+Ht+0m6fVjNh3/ZUBQ/484zt/rmGgjE0SHh1ps1eFlUTIvhp0Kvq6v ju7flJy/ekZoO75GuO1xg0QK1jSy6Xu2imlz0R/lLcYOJRfC4bOafENaABZg+hPqci9p YF6NKDp0V/FR/GM0En/KeRCf7wW7IR+FqB4WABV3Z3bMYRKWCsdGbWsIqMqqbYc2V7Ou hISYPeZIQvbPczOwVePTPrHosDM51Bx4jajTyTZ8Y6HozLxSbbcKlSMXiYEMncVl71Mq c6T8cWxp3QF9G07XK9Z7OxOGIhNp4RyxfYRALPqExztO65hDLHaWNPYcL2y4FkMs53ql 1jUA== 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=7mVMLvhvHhRE4SNYEq8lTvIaJ67DT2EyP7H4YHihO6k=; b=seDqJpNHmIkteiALw1mfVAtBUij5rJ+oKN7nYtlG/PxjPHi+bgu+eRgn/Hi8EpgLY1 iuecoBmf1kmjkEcRCb1jr7bzeuoyqetwU5SJGEKa8bFqcEHnOrgIMEf2W2C48G7gMf0b ViogZreqbaw5/O3BKQ960SpK6po0oGwKkhE2Y48x9wVYhdVghOV3Fy5J56X6DFg315B/ vg/fLBBUuyydV/ri2r4zzM3mV9vDcilep9PSGYJZiQgBfTj8IhOmDSFYN5qXJJapreTe m1pO7gG7q1oi6k12DhXOl4Yj7LxaluCNCYaEEpj/wJKCsvQPa75TF4WsfB4Gzh2ct6ot JSjA== X-Gm-Message-State: AOAM533Z7bzVUGNZXAh+YPwCJqhzwTzvTMVRnTWGK63ewzct8U+UxwQD NUinzg9KbYJRkb8TlskpH/pI5Tldyf+2PA== X-Google-Smtp-Source: ABdhPJyiOGNaUHTOGdov4J9GPUtNwsZKcoYtu/AMhiNZV0KBoMiP0IYZdr87kKlRboVXhlCIIUueVg== X-Received: by 2002:ac8:6158:: with SMTP id d24mr36642804qtm.115.1635851476932; Tue, 02 Nov 2021 04:11:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 59/60] tcg: Add helper_unaligned_{ld,st} for user-only sigbus Date: Tue, 2 Nov 2021 07:07:39 -0400 Message-Id: <20211102110740.215699-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82b; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82b.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635854240505100003 To be called from tcg generated code on hosts that support unaligned accesses natively, in response to an access that is supposed to be aligned. Reviewed-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- include/tcg/tcg-ldst.h | 5 +++++ accel/tcg/user-exec.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/tcg/tcg-ldst.h b/include/tcg/tcg-ldst.h index 8c86365611..bf40942de4 100644 --- a/include/tcg/tcg-ldst.h +++ b/include/tcg/tcg-ldst.h @@ -70,5 +70,10 @@ void helper_be_stl_mmu(CPUArchState *env, target_ulong a= ddr, uint32_t val, void helper_be_stq_mmu(CPUArchState *env, target_ulong addr, uint64_t val, MemOpIdx oi, uintptr_t retaddr); =20 +#else + +void QEMU_NORETURN helper_unaligned_ld(CPUArchState *env, target_ulong add= r); +void QEMU_NORETURN helper_unaligned_st(CPUArchState *env, target_ulong add= r); + #endif /* CONFIG_SOFTMMU */ #endif /* TCG_LDST_H */ diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index aaf47d89d2..1528a21fad 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -27,6 +27,7 @@ #include "exec/helper-proto.h" #include "qemu/atomic128.h" #include "trace/trace-root.h" +#include "tcg/tcg-ldst.h" #include "internal.h" =20 __thread uintptr_t helper_retaddr; @@ -215,6 +216,16 @@ static void validate_memop(MemOpIdx oi, MemOp expected) #endif } =20 +void helper_unaligned_ld(CPUArchState *env, target_ulong addr) +{ + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_LOAD, GETPC()); +} + +void helper_unaligned_st(CPUArchState *env, target_ulong addr) +{ + cpu_loop_exit_sigbus(env_cpu(env), addr, MMU_DATA_STORE, GETPC()); +} + static void *cpu_mmu_lookup(CPUArchState *env, target_ulong addr, MemOpIdx oi, uintptr_t ra, MMUAccessType type) { --=20 2.25.1 From nobody Tue Feb 10 03:16:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1635854343; cv=none; d=zohomail.com; s=zohoarc; b=LzVEcmubcSvsdF7G35eX87kqV9G/LzWj+pccsjp5UQ95qxt3s0kWnzynkSXq7GS5elDafuiLs9bm+e49zsMP91QfVSKZ1cvDC510Wb1RTP1cMs0VrYxnJllPYp+gy+sZNOAjcuPun+q8CDlr1QN0qL03EXLnD8ov+TeI0tuINjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635854343; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7lLZzifCuDAFtBOJRXRut8iWPXEYL/L2LC9pwY/6QWY=; b=ERPxwY5BzwX+ucYQ6QvZ9lmE3y/Rk4GqXypYgRblLGN0YNc9oIEEFsvVXajAEELuXxtiGH4sOwNs0fX0lKFkkxovZkLTriN1R7umFrVVMA9+NJPX6JguE01sIYHaHi1FPnEuFRYrvr9ePj1H7RaxWhS6KdxhrsZUcO6Zue+SVro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635854343545634.1684282344145; Tue, 2 Nov 2021 04:59:03 -0700 (PDT) Received: from localhost ([::1]:41382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhsRS-0005Eh-Ho for importer@patchew.org; Tue, 02 Nov 2021 07:59:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhrhM-0001vY-10 for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:24 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:37868) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhrhI-00021n-BF for qemu-devel@nongnu.org; Tue, 02 Nov 2021 07:11:23 -0400 Received: by mail-qt1-x82d.google.com with SMTP id o12so7706668qtv.4 for ; Tue, 02 Nov 2021 04:11:17 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-57.nyc.biz.rr.com. [172.254.253.57]) by smtp.gmail.com with ESMTPSA id bm25sm12730854qkb.4.2021.11.02.04.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 04:11:17 -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=7lLZzifCuDAFtBOJRXRut8iWPXEYL/L2LC9pwY/6QWY=; b=G1hYnCJ1LayxyZpilQvnLE4XfaY/AcXvxVzGjz6CRfEywQ/KnPsip6x98wvKKDXD16 bdfoN3XTGxsZiQGznOW7P6/VZfvIV7lZtkcU/+nbWzDJ+95VTaeTvhbQlMcEvVpUfYsE g07g5dYp7Eh3Lh8BtVIZrpqh5etObL6OIP8I3LanqquMfyi9k3YqJ8aPHhegipkTfmSi TdpLpmW3zTLrLam+0uzwQ/447l9VbAIsTy9SQaeyJMd5DdHRLMhuShvl7RbX48lVyx8C rlVaVXdrc6CMFtFI5xIbCROxfP3ZwMegRYMEax/+XUymaWmq6L/2sHxtEbYbhPSlgBnL yK3A== 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=7lLZzifCuDAFtBOJRXRut8iWPXEYL/L2LC9pwY/6QWY=; b=fC0tYrJ3SjqHodqgRmrC1JLQIZEecRjnk7DxZlrtGXJ5yncGVRc6lkx7VKV8npYbew 2a1ktc1/AYHgwIbNIvmDpTwH8wCO1P2KdobM8HH9SHYJnVI5KDPf62KvbCM9qP2AYjFr Tk+iNE4Q1hvH4sCxIWgZTFIuHKK1gh7mwN8dH1mZOsukyYf/5Mj82cT4xEM2V01Xg+tR zdtqeUg9JpxyRFafnOYW4BjwdZ/IfbXPRl5+wokvDD91axxvccSNT0ZEYs23Rs8UR3Om A2B2UVQZ0wxtowglyyLkbldQdP92QCnLRM9IZkor4YegCcCS8TeLJg0NtB7TwwkpeDzE 7M+g== X-Gm-Message-State: AOAM531XxtLl/8YCY5dukacLfUrEmCm64HZ8Fts4AbiylTnrTyxg6h7J PBRzx4etLujSLhq3XbS2xh2ua9NXGKEkNg== X-Google-Smtp-Source: ABdhPJwA8glHF2o8gJIwe1AHpNtIiT3qJLJPfgwGYCFHHdbGEsfV0Opipqz3LAFdYZU+01yM1qdGTQ== X-Received: by 2002:ac8:5e0a:: with SMTP id h10mr36257566qtx.195.1635851477537; Tue, 02 Nov 2021 04:11:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 60/60] linux-user: Handle BUS_ADRALN in host_signal_handler Date: Tue, 2 Nov 2021 07:07:40 -0400 Message-Id: <20211102110740.215699-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102110740.215699-1-richard.henderson@linaro.org> References: <20211102110740.215699-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635854344528100001 Handle BUS_ADRALN via cpu_loop_exit_sigbus, but allow other SIGBUS si_codes to continue into the host-to-guest signal conversion code. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/signal.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index df2c8678d0..81c45bfce9 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -860,6 +860,9 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc= ); } else { sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + if (info->si_code =3D=3D BUS_ADRALN) { + cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); + } } =20 sync_sig =3D true; --=20 2.25.1