From nobody Sun May 19 09:23:43 2024 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 163578783753931.843209212976376; Mon, 1 Nov 2021 10:30:37 -0700 (PDT) Received: from localhost ([::1]:47560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhb8k-0006Hs-Ol for importer@patchew.org; Mon, 01 Nov 2021 13:30:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5q-0003GA-A9 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:34 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:37553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5o-0000Zx-Jc for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:34 -0400 Received: by mail-qt1-x834.google.com with SMTP id o12so5763514qtv.4 for ; Mon, 01 Nov 2021 10:27:32 -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 t5sm6075331qkf.34.2021.11.01.10.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:31 -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=hVEJUb/CKaTtun64AztJP2LYVZ61YcOdf/Oz5XZPlg0s6pyJI5NAmpgpwhD5xW7Yfu dKUWgjXPWkUByVXKQaVlZxIYfsTAAJdYawItAAIDz88F4G5g3EmxYek0UdeICWyhMnTf 7VAlJdXBBvBGAi1hfSPwfWibykG85/HRNQ74+Ue+OMWTUQUIlGUSiBk6yOUS0xF9NBqs Ccj3H2AOt2p3HuY5bDmVkPWLGJ0LoD7YpyBH4vq2adQAem5d9yeJiILOMSAcW7xNENrI hWvEY31605gvJgsKERRu52oJPN+mQeefV+Kz5RCEl+j9LQ8DskgBMxO0L+d63PlVDFgs xKIg== 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=iBXKnmd4sU81Iw69Dmrz2sDQa2mog252vKlomjrDuZcEWMogT2OOW+6Rgz+jVqW6Nm wSlYr9/WV54gvboPq+ABuZ1+Yrgn2wFCToVKAu3hF4OYu0C+2k/f774bInwt4NErjXoC p4sQSuuiNy5wcxXJNoKLzpDjKOyzJERuRX3rEXYFdeYYbTIJzEfzRabst+3DZ5AxwvTi 6N5zI0pO9OlN+zXEsdrPDSQMZJ7Fyyhd0kuGX/LNTsw8JQ+asqgCFLgbnQTo2g3u5Feh 9jlXFjblYCRFDPqVsN9Md2LHFy6lXipIbxCV+Ki472pukoUQu0Pa1PEmbJhE1WmLK8ru 2BPA== X-Gm-Message-State: AOAM532V5WGsvAW+fENDmHVu1l/EOs6QIaY1pDiR5CpO9fj1M8HaymaH cvcmylNPNd6cO4ZMrDuDTYJU0BuN3EyV7A== X-Google-Smtp-Source: ABdhPJxXj0c8/X1qSI3YTgUo4SFgziAQvSepjH4Te2qUGcQhA+QVHggkQC2kJNrA924KNtHSPhcoQg== X-Received: by 2002:ac8:7fd3:: with SMTP id b19mr3529615qtk.235.1635787651488; Mon, 01 Nov 2021 10:27:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 01/60] accel/tcg: Split out adjust_signal_pc Date: Mon, 1 Nov 2021 13:26:30 -0400 Message-Id: <20211101172729.23149-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= , 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: 1635787838930100001 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 Sun May 19 09:23:43 2024 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=1635788223; cv=none; d=zohomail.com; s=zohoarc; b=Sk7s/g6Byohbxsu7KprQomaLjUq9W88c/bAMLBd9esue5Nbd+G+bnDiG2lW/h3I5ZrY2zSVx38Pe1HA4RUNdPn67D1l1i0rtDjgyDGXCbpbXocObFrhW1mH/0yM60SC0MSfG3j13GpekNXcNYta+om2rjEbTE0oItYXfV6/JdsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788223; 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=MtUY/rk1JqQVP/K74YoAov1l4Jpf4/6LooMtBidT14o2+MzlGpfaPZfQgiIcQn5SRJfdcMGiHbIxVJLBjjnzawm46ld48U/Wx/PeMq/5DNpHQ/DWfOYXDqTBxyutVuPcwpgeVdMn58M9rpGsqXwEKDNibwlVLqwsIKMX2jn5YGg= 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 1635788223442483.301889002134; Mon, 1 Nov 2021 10:37:03 -0700 (PDT) Received: from localhost ([::1]:37114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbF0-0001c9-98 for importer@patchew.org; Mon, 01 Nov 2021 13:37:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5r-0003KQ-QU for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:35 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:43627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5p-0000a5-0C for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:35 -0400 Received: by mail-qt1-x835.google.com with SMTP id v29so15196693qtc.10 for ; Mon, 01 Nov 2021 10:27:32 -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 t5sm6075331qkf.34.2021.11.01.10.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:31 -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=VExdrT1z0TiLae9uxGL3Fq56Y7jjMe2eGA304jyvdBg9zFgDIN+BwcYaSS2viIbomS uxTXdmOphPzZaEgZT2RSF2XFseJNSBNw7Zhoibjvh/u1LuJV1SN2jk8VnBj0h4M8Sfdt 18gaNF+5FhQlHhr39I2WXOw5fyrUtEE9WOTstYS+Aei5VDKeFldJ9FBIbrPatGx4pJB1 vF4+eCyP4xoRpePNde3ilR0w4XfZcSxDiVTSXw3G2H/H6ix3MMWjRPk35eN0rxCXAW5n 6/dL5hLjI/1RoOevoZwVk5ITVlOHxTlfiy03XgNkUK77TpQqJ6XuBcsQ+ApHdrnMK/Lu co7w== 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=sQJWfx9fyYFoEqxqudRRpuVbNU0r7OkUO2dv4eXwYNYNblx3ECCXPuPcLb5JTkxty/ m/bKznSmnViHQyfIelAnOWrVvOGyUaXOCvwCMLPJmhe9GwD4taBqxNJoW+pvLkSse8QX PYXb4CcUbb6MQbIkJt5AzXb/p8+Bq+k/UELxMPXwlwDUyGv5Hte2NPG3Bp7x2ySSx8wg Z88iH0dlHDBX5JU+9KYSQOuypx/AuW8sJD0OZx+3c84M4dD6sDlwsLRoeX5u4UIM5G49 ElIb/4y3YzLsnNPDcsRLRBpWnqmYs2WhaLuWvNfs984yNzHa2urskuj+4dlwQO6SuquR /qQw== X-Gm-Message-State: AOAM530k9xZW3ude59pd+DrO+DrgUbt9P6U8pkj3mZ2hhPVWAVpAG7cy Jf51DwXjmnF2cLmWuT7Ht7ZfTKIQN2OFVg== X-Google-Smtp-Source: ABdhPJxd88MZsWriGsgYt23fSGFbDE9B1OgdyneQqYy3JTfUiu1rJcURvVdadPMKls+KUxvp2YbzmA== X-Received: by 2002:a05:622a:1111:: with SMTP id e17mr31898253qty.217.1635787652035; Mon, 01 Nov 2021 10:27:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 02/60] accel/tcg: Move clear_helper_retaddr to cpu loop Date: Mon, 1 Nov 2021 13:26:31 -0400 Message-Id: <20211101172729.23149-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: 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: 1635788224877100001 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 Sun May 19 09:23:43 2024 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 1635788353282131.83569871070893; Mon, 1 Nov 2021 10:39:13 -0700 (PDT) Received: from localhost ([::1]:42458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbH6-0005Kl-0V for importer@patchew.org; Mon, 01 Nov 2021 13:39:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5r-0003Ks-VU for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:46715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5p-0000aD-Jz for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:35 -0400 Received: by mail-qt1-x831.google.com with SMTP id s1so15127199qta.13 for ; Mon, 01 Nov 2021 10:27:33 -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 t5sm6075331qkf.34.2021.11.01.10.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:32 -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=hny+eU4IsdY7TzEPh8LZ9CC5yWAoNqr2qvIlhCIjcAj5wZUYI/dUruyQu6HkHT/wDi hAHTmSrvmZE2Bww9RgN1cY2dm0Ck0QpeSdN6rTAsVZjehaChZ3z8tYXj6ccs/paeBdoI j3DpmXmpNf4xnJHr7HxE5LtqNqrDJXPdijdWCb4l83xw/rEplVc808IbDY1kiIlZitcK SBrjFTBKnFI9EdWtQLBSRbMwb7Ml85VB/jLngxe79lXzcgmGDDFcJkgDTtnSkJpqeMko B8TvF/sMG1XAdm3XCdUX0LmrFDTsNjeoa8ea8kRJSYSmViiQv6USfoT4qltKtmarjAMd MnXQ== 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=MfEoWoAitHn9lWYhHAP6/bPFZOxSEDcGEKNy7G16QHSGRRtyBTAc7H436bDelkB0UK X8o3Ji9GFCJiRxpfFqvUOfraIZQj1pNgeG+JDMxKnm6RZwZInWMyLwS5LD6LALcopTWs FGfLYXdo9eVtNgOOpvdagoPK6b4kGKFiqg7+2NhQncYLUTEnoPB3RfqPraevXrCbhTaJ WiaHFyZhLZOLF3ScMe/+i8FwEMDXx9GLZYBJnNXrgIeLHJEdNMoa0NRnAxA6kJaI1rNI XSlyQ+yhLeiFEMiF/VEcxpDDx+BEd7Wldp1jO3z008zHnmjLVSlSq2NAyJTUo+F8M8bg yR5Q== X-Gm-Message-State: AOAM530Rgyk3XzQGFL2q6BnMZY/0iuVelIlVmv5RL15UGZ+dVhIZbcM5 pVUYNblB73eJZrT/POmFTW7gq8ESsVM/OQ== X-Google-Smtp-Source: ABdhPJzdDcx/87EffNzwV2ZXUgvhS5aj5LLMc1gM7+MymMpsbEEyF385NeJH4CVBOumK6jNKDxqYiA== X-Received: by 2002:a05:622a:550:: with SMTP id m16mr26772305qtx.125.1635787652665; Mon, 01 Nov 2021 10:27:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 03/60] accel/tcg: Split out handle_sigsegv_accerr_write Date: Mon, 1 Nov 2021 13:26:32 -0400 Message-Id: <20211101172729.23149-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: 1635788353853100001 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 Sun May 19 09:23:43 2024 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=1635787860; cv=none; d=zohomail.com; s=zohoarc; b=M6rO0RGrK/Cpbtg6ZUXiwe2vzsSMo/CvdiyulvR1dEM8vGuYVy4RBthZqz1UqIwOwIxag3hL4+OJreP7xRHmFvBpIknrx64nYxqFrFRdbSKrZmGJXnuZ6sD/F3gpwk2xh/8ajxHsVSZssa87suI9ZLXS1p9xB+36Bt1mPM3gafM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635787860; 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=LvT5a9FtOhPT/61MoCduYf3mYgrQsnHC//pnoyYNd6QlLb+j6qTJ+KTPE0TP43EIG6SGelGkeDSZ9hoe2roYHkF2oVj8huV+LcMdsk8Zv8sNtoKf1odiMS2QsWfaYPgWcvWEmLMeceQe6R1lQ/mGCVx7V/Sdv05KYYuO92QSJ38= 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 1635787860885144.7991728836281; Mon, 1 Nov 2021 10:31:00 -0700 (PDT) Received: from localhost ([::1]:47758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhb98-0006Po-LP for importer@patchew.org; Mon, 01 Nov 2021 13:30:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5x-0003MM-LN for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:37829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5q-0000aK-8y for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: by mail-qk1-x72b.google.com with SMTP id r8so3404752qkp.4 for ; Mon, 01 Nov 2021 10:27:33 -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 t5sm6075331qkf.34.2021.11.01.10.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:32 -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=UA1eWGdJyXvTVpgLElnO8dC0Hxdiku67oApmHxJ7IjgtfADt77JUZp8VE6hMbSz8JJ XV2Lc2PAByiW/Dk11ToczazCNbuVaCdNWUg4BZd3OM/lQWhI5BCqZykRVsiTg16Q6wF0 2IRHTraifY/0UPC+obHyCf/r21QWXqSS1CmWMjrFcuvO6QM0Ye8Msu/MJjFTqe1ZHuoQ r9LSyI9LOnzrZ14XzGqdODNV8zw6yaKUJSCVtiwR9/SEWXSxsmNz/Mcd1NeuBoar6y2C ff5YYsViVvQv+s67QX3nQQBqFvNGLIC7nwHJJglv+nxXVrUVR4BIw5u/cNuLAGVbNrL+ 5pnQ== 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=etY0c4GpN1lPRQ2iHt2gH/8SuYQlXKO88mdg14zV1s0edxBv4lNrC4dIHdmfl0SMfZ tgHJ0No6NuL5kPAV3pKUym4XcqXivDIojmSwp8D8QMrE8ZusqlTSVH3JxTuKZuBpyRQn bykuHZI/Kis1MAZuQyG0JO9rwXB8I06ZPlhYl8uwdML2JvXFsYnswlHtxItbH1jE02i+ VJBumBNM0RREl4r4APUsQfzZUfeCveY6gBITzCvgHKWiBK7ienokScQSXGf8nWXn9Goy 4WGMYH2vB4sm+KoeAAAplbgMtZB0Ec4yz6+/jwT2tyzHfWepRQYJH8GF1qKogIEm/9mr Df6g== X-Gm-Message-State: AOAM533jyl1hJXsCZsexc2aZBi3Y4qFhMV29TzDraeBZ6TGGDjLnOAt3 SYZ8rMIZNh0XDqFB8WTDFmwdiTiQY5tYag== X-Google-Smtp-Source: ABdhPJyQ5Qlvq4HDzsqMdrPXuvMfjsCAB0K07fLfp7MsVGhJ4Ep1lAseWRlCuMQ8v+RdyEyzkML05w== X-Received: by 2002:a37:8387:: with SMTP id f129mr24437537qkd.79.1635787653282; Mon, 01 Nov 2021 10:27:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 04/60] accel/tcg: Fold cpu_exit_tb_from_sighandler into caller Date: Mon, 1 Nov 2021 13:26:33 -0400 Message-Id: <20211101172729.23149-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635787862632100001 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 Sun May 19 09:23:43 2024 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 1635788003723589.6878443552412; Mon, 1 Nov 2021 10:33:23 -0700 (PDT) Received: from localhost ([::1]:56552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbBS-00046Z-Pj for importer@patchew.org; Mon, 01 Nov 2021 13:33:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5x-0003NY-VH for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:45678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5q-0000aZ-Qi for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: by mail-qk1-x72e.google.com with SMTP id n15so3733352qkp.12 for ; Mon, 01 Nov 2021 10:27:34 -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 t5sm6075331qkf.34.2021.11.01.10.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:33 -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=tIIKdMIOIihcW6afyz4OW4RqnYHP5Dr8jHbjp6/60b8FcTMnkD+RJsAR601q2HLpiX at3z6kMsV5EiLpuxHgrWDKkiZWPyplPJnV4FmvPncMqaA5G5GV8I9c/0TjNNu1fCK5ht D4mtRLhE8e/cxB+cYHDEp3FA0qV1mOXMokEeaHpinYq9jSlj+jOeiu0jPnUle0Q5jg6m PtnizY+JXHocm5hcG1svDV8OSX6nzIZ0iwEFi5MB16F8N9pTf/y0l2qj6wxgGdmqDP3l Ao9bODqKtEkRQM98CIPo6B2kzr+bl/lvOSS8qcsP/Gk4FfC62OmceiXa4LQarYkMj/G2 R91g== 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=Jnts8pPgFjanlClKhTPil4zwy2hAXrn8J13Z+1IPBqlm2Odr4kbyoq4sMj1g5ZMOu0 OEkimlTPFIb6BBguwLd4sLfDsK86/G4fr0erMGXpG7rlo2ExZ3oGUqxwcZOHKMQKXS5k m9dIJgjRBKo7wtxBni9SkMQcX2ZFvKEnNGey39JtSffIlDdCHggUzUUbVPIRQ2BQePBt 1NqaCyJv+9oj13S6IpI36vshqshl2rjj9LKYqDgQ3YXgHgcyimayny4JV42Nd2gJwBZ+ yon0+hd2BGG97x/dWYQA7hs3ipvaYU955EXJk/KJptTZjL18jg4wFXqQR2pPU0XdPf1L p48Q== X-Gm-Message-State: AOAM532/+Tw+An81Ix6Uw6/R0C9PUQlftSAKcwPjXbOte9kNK5bxoW1j T8Wwworj91CSC3GCBxhGFKSXIuEehra4qw== X-Google-Smtp-Source: ABdhPJy/EGs6JhlBxvzRGNFllOLvX4nDvrgE4gxRY5x8cK43Ty8WqPFIj+OEiA8EYbgWFSa99G19Xg== X-Received: by 2002:a05:620a:2485:: with SMTP id i5mr6426442qkn.381.1635787653908; Mon, 01 Nov 2021 10:27:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 05/60] configure: Merge riscv32 and riscv64 host architectures Date: Mon, 1 Nov 2021 13:26:34 -0400 Message-Id: <20211101172729.23149-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635788005069100003 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 Sun May 19 09:23:43 2024 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 1635788138472660.8643614207899; Mon, 1 Nov 2021 10:35:38 -0700 (PDT) Received: from localhost ([::1]:32996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbDd-0007Dt-6f for importer@patchew.org; Mon, 01 Nov 2021 13:35:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5x-0003LU-C1 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:41 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:43620) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5r-0000aj-HA for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:40 -0400 Received: by mail-qt1-x82d.google.com with SMTP id v29so15196841qtc.10 for ; Mon, 01 Nov 2021 10:27:35 -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 t5sm6075331qkf.34.2021.11.01.10.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:34 -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=Tyzzs/THC/VCVt+ePbh5c/SiaBvuL+1wDa06MQPEVQMXYknNII38gezPwAMHqO75LP S3WMoXVXXaQA5P6kANjf1Ba4O80WQqvbTOUOKydlHztikbSDifEU89fzM6C9tU263InR AurlXFi1fPtZ+U5jEowF+qU4HKYMU6uMCVH3RScwtTo34LQ3ujO42qdty3RtQxQ6xkcz Cr70+fy+9PTqx8z+M6gH/f38hATBbbcb/iYRzTc0bE7qdUYlQOSQV6hcerDXpCBw/ZIA /zmlO89zDbXmY+628ZnhMv18RxlwQa28MCgQosol19kzuWmBaTAslUOZ7oSK866QOnBP kdUQ== 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=AliDJUVvCHFMwZHzTcX491cqXI5+jZaN5rKAKUxmEEOo9qu05hlME9ehk3WrScCkOk s7L1fiMwkwAsFVPkn0uL32fADe0tDezexEvK5QSEu88ZbKxFs/syyYIE+ZbYH+sJVWVi eeXPKqlGHQmmGY+13lObF+PAaM0r2ieHo934h5LpPrCbtF9/p7jOKCqHsv5t1XXiAz1D 45eAgZKgbBJjiPKsEijDzTxMupQntmHdQLzpadVNeRYMOPggvJMREq6CaKHXAFwzoOhp ayHmZ5f8wOYKDoGZdwi89mLGZaLS+EITkFnGtgUimFevpGdu5gpo1H8yY6LIGNEw2OW3 e3Vw== X-Gm-Message-State: AOAM532xo0NbPxvd+wxo0hCZJg3d/Sq5EzRJOKf3ma33bldRAPFPNadR TuZtjU6hUU+I6sAuYGFLojoF1T7MRHryFQ== X-Google-Smtp-Source: ABdhPJwqcNK0ZwpVXE+l6VVg6su8WakPLOWy8nPwyRu/PL/372HAN10i00rqJJd4KUnwWXtJ0vwEsQ== X-Received: by 2002:ac8:7c51:: with SMTP id o17mr11749922qtv.99.1635787654528; Mon, 01 Nov 2021 10:27:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 06/60] linux-user: Reorg handling for SIGSEGV Date: Mon, 1 Nov 2021 13:26:35 -0400 Message-Id: <20211101172729.23149-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635788140518100001 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 Sun May 19 09:23:43 2024 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=1635788289; cv=none; d=zohomail.com; s=zohoarc; b=dtwREUIQjUD/XZIMGkvpPPz1Bv8rwHb3Cj64oW5dZMy5csa1XTejnFWqeKKrsQ8M6rQvmNrQgIHJwO2RKRz8k3d0hvKR0tOpb0oZyjv1VGcFoeZLNh3cvTWnmlg3U1pTX4Ez+6Rv5pZsrgkCOsN7wCb2SnpmnZrGd025Kp3yN7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788289; 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=SmsSs7EfDBZshINbUUMSpKI3P2c0Oof5lu7hgfIyMJw=; b=fRgAb9I60mqS00YPPFUW2/Vu80/EBzbsqLggJPvKW8xE3lxTBpzrtbqoxaVnbMfPhj/nbpj00SXLixAzZQM29AFvYLg6ZBi6M0VC5O86U3GD9FI97l3F0n6XCgT0jzgZ0z0ZN7/6EMEfEIJ2/pTD6z/+9JCPLVyEo/HIrSn4TCk= 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 1635788289788947.2602036528489; Mon, 1 Nov 2021 10:38:09 -0700 (PDT) Received: from localhost ([::1]:41578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbG4-0004jn-Kp for importer@patchew.org; Mon, 01 Nov 2021 13:38:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5z-0003Sg-92 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:36640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000aw-Pc for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:42 -0400 Received: by mail-qk1-x735.google.com with SMTP id i9so16692838qki.3 for ; Mon, 01 Nov 2021 10:27:35 -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 t5sm6075331qkf.34.2021.11.01.10.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:34 -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=SmsSs7EfDBZshINbUUMSpKI3P2c0Oof5lu7hgfIyMJw=; b=xG0zFgJuaNax16CLdZm+80k8XXKfH/uJJ+ygaL3z2pKkSvmiYEqNwuUXJ4MJ/Ocbsy whVlrIDdai6DwW6pJ1kFJxjrnuEnWLV72WpOjAIA8h3AIw/KDSdjGbt7o64mVV8ich8A PaNW31jEZFP9ztHz7zV2DEANVs567Lr2hFTEtGqVQg7kz2ygDTdBE9kFo1dBcEX7LYuQ mmB5MWj5ljZg5lhxwnQE3GG/b+Sh9AJmK2pc87/8f+FwFTM/hJnvN30lb0MXv/DDrKh2 /OH53lFOzSsCg4oFmIs82ikRlcEecfOUFkaCGSTDJfAj1mVIu/7IYjkp408nfCNlI/sS N1HA== 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=SmsSs7EfDBZshINbUUMSpKI3P2c0Oof5lu7hgfIyMJw=; b=Mv5c6P4N1eb3hGrDwmvohEYPcmNh4y53OrPdRAnUZCvzUta1acxb8pErhHik+iwrhs CxO06LMBhXfsd75ywywQ/KkdkJRfXZuz+vSmurmKSXLonKpGjs7rexLJFl/AXhWlOCt+ pvXsRjeUV2F7hKFB6aALhIkewvQn5nYCfqBGXc2Xc1ZSAJcRwIrwBmNAgvHKcvEKq7ce cdmd4kfubKyzMx5iFXZYXK8r+ddX5xTouKvRyd9p4oVPqZJVJ+rzBOHxZXFLqRrDhP+h RRZV8/Ov+kltW6Ec3faWeGw5Cr3MIF0AeGP/mN27UF4auspT++edjP4zYVxDsLCxj0zL 2yxQ== X-Gm-Message-State: AOAM532r+vVCtw5ncweUmeS5G0l7kUd/Raish8vlGa8xtQL8Ktn1yotr wFtIfh93m7970OezzrrJlnG9XQn0KGu7sw== X-Google-Smtp-Source: ABdhPJy68HjL5N5GfC20ek6XxqUT6EZoImBgn0gRHrahHybwb65UJGnRbcph1+7cBhBlltDgwCA+8A== X-Received: by 2002:a37:9606:: with SMTP id y6mr23931417qkd.13.1635787655076; Mon, 01 Nov 2021 10:27:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 07/60] linux-user/host/x86: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:36 -0400 Message-Id: <20211101172729.23149-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.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 , 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: 1635788291818100001 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. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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=1635788768; cv=none; d=zohomail.com; s=zohoarc; b=Ea62kn6h9TNlBiGRA2iWdJjg8P/W0KCmSwLMLkjdNIqak4CPWa+dxNaNRIWRFUNai2xRKfrwml66jO+DihMzLKk2fTHjlqD2O8KNHFc48BqZQGtyNH9ouvsgS0RdmBBf8oZ99nA+N5hXQ0HbIuzJLu9A2SfSdDKvxrX0ilyEJXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788768; 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=TZablReYyMhZZRtuFhH4b/hnVjulBdbu56o5gMwMndM=; b=eLoNgPvNGSdNxuoo4q5YRlKWlkexujjmAz1lxaXyv1JDrvmyn93Bh0FkgVrsLLtKSN5iSfUi5zJY5jevbS642Xy6vm104ihfLKi1PrYbk2wKJiJ3ib7Q1XDuLKhXz9eB+ja7XIBDQvujgzY54paxsrXvadp8HhJCFTU7GcTWrpI= 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 1635788768450268.6586278341747; Mon, 1 Nov 2021 10:46:08 -0700 (PDT) Received: from localhost ([::1]:50036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbNm-0002NM-SR for importer@patchew.org; Mon, 01 Nov 2021 13:46:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5z-0003V1-V5 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:33591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bD-TI for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: by mail-qk1-x729.google.com with SMTP id a132so16128641qkg.0 for ; Mon, 01 Nov 2021 10:27:36 -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 t5sm6075331qkf.34.2021.11.01.10.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:35 -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=TZablReYyMhZZRtuFhH4b/hnVjulBdbu56o5gMwMndM=; b=Yws3637BZ6sm9fDtMzA5i18gQECM5451RiYVxuiB151N7JgcCGRHAHKTJdV9/SfelX 0j9LvcD8SrAqmSodggnltT39MtGHYMR//cednKxjWS81E7Stt0XacK9ErENtL2SdqkNt QL3+I+l2YWui1P4S05LYbRqbMe5fUxW19JOFJ+E7TSASwSJUcCHmFwCpxBJyNYo5DVIp YIcCWtO2sQWWg7ioOjYjHDGIQP4vES5Hhdt5W2wB+z2uDzYCSW5tEkqoucHL87UP9RIM 3ydIye0o4DqBsaCQPigOkhklPuv0gX7bE2zwVo2yoEAfOk1R02eYvZuRz8YA5cAc8vhu tMhw== 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=TZablReYyMhZZRtuFhH4b/hnVjulBdbu56o5gMwMndM=; b=xRNCWDG4TTW1Aylpyt0+pLCo+H/SR55+aftrAOWs66xrJX9itFeODbpnCxfnW3BClo nHBia/PBEzRyeNUMeh5tjSuOLDYxqeQ/wLllokXONIl0Joo0ijq+/1OZtUURXdj5D+vs Qv1GQoKBzCkeNxjfLVG/ZqpyIfn/f1z1Ot7yp47KZadYPGgHGeoicMfL9RLFKseu7Xm8 c8RukYHDGiZsFpuRjb1QmW+jt1xvZcYPchtsBym6fEiUNkGBwLCySkVstlGP6EJZ15b9 WBK5HM0EE1HFaMCMFRoHYVb3H3fnobxsehzl5dkKkHErhc0J2akhoO4o4M+DukoBGQ5c 4Y/A== X-Gm-Message-State: AOAM532+9uURvvDzy2J5jKFDAyZegRMTXvDwX9epgAXxd+L5egsGfhrv TXjaomyAbRutK1wVDTCPQzVMx2HJxt7sqw== X-Google-Smtp-Source: ABdhPJydHIEihn330nFldosUZ5C4Nsl0ApfKrAXe0gzqaSCFOp+DMAuzdcxjnzGHK0QSTQNExNyDDg== X-Received: by 2002:a37:ae83:: with SMTP id x125mr24420211qke.37.1635787655611; Mon, 01 Nov 2021 10:27:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 08/60] linux-user/host/ppc: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:37 -0400 Message-Id: <20211101172729.23149-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::729; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x729.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 , 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: 1635788770580100001 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. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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=1635789348; cv=none; d=zohomail.com; s=zohoarc; b=bMo0sLx0xSC+A6e5Ou9Cni5EKtY3jpT0ddIa43JER0swmMJH8QJ/xH3rOpGuwcVklQaI8rSp2nRL3bwVEqeAub/gaYlU6Dw3PWSGS87scPjZDTlT1T8BVh15bPe0GHLQlGds5bANhr+WizT+Xt3aGrh+mPRuM6C6qe5pjkAQLxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789348; 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=myv+iQtBsawIfO0tfuLs7BJIaq57M/hqyMfjI6iF8H8=; b=cSKpJsvgnaas3BlkpIeNDeB0JfbY4FHYnUgxFR1qEEc5ZOtC0YtSZqInLFn2d1mWylkW4dTYeE+vG/Fq27kGCMLhsPiDEZ7kIGVbt55UxBgjHgfbmHwJxb6WmPoX8lyFKm695xDRL+m9aRrykgN9Tp4flD5hDuVvP/1nP1E79R0= 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 1635789348557272.34070490442684; Mon, 1 Nov 2021 10:55:48 -0700 (PDT) Received: from localhost ([::1]:56462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbX9-0000iP-8i for importer@patchew.org; Mon, 01 Nov 2021 13:55:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6C-0003o6-Jr for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:40618) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bK-TQ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:56 -0400 Received: by mail-qt1-x833.google.com with SMTP id 19so14949478qtt.7 for ; Mon, 01 Nov 2021 10:27:36 -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 t5sm6075331qkf.34.2021.11.01.10.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:35 -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=myv+iQtBsawIfO0tfuLs7BJIaq57M/hqyMfjI6iF8H8=; b=i7IhrguKzsWmc0ws4tIoi5JDd/Ma1xDyjlHbuDdKiVbVDCx7PdnNEZ6kE6lflOPr5p Spt+uHlBUUB15Y7dwOhXhlypOioRKnylsv9pYd939RZzH9wYIf4xzY3n2owd/jv/spLS fabJn4AUBRoOckLeLBbqJiBO3IxXPSgB1Ivs1+zybidkk+UhrYbKJQERkReYmAi6S+g+ E/xna6OApSzyRSN88eBonQCcBC99AFsAC/cYN64Ipdm+9zj0g8Y08shou8YxowtPJ5HW tCegtCW28/y9M1F6BSWmyQc9LNf9CkyBzckc3n86NTDhP/BIk0qbQtA3KOopuQG9M/Pb FPIw== 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=myv+iQtBsawIfO0tfuLs7BJIaq57M/hqyMfjI6iF8H8=; b=34ThzBESF+gc8JhkTli3eLZ+p43WQs8gnj9Ceb5FOlxQyBWlurt5xhpa8vIQDy5ocV PjbDqlgV2O+6nJ29KBB2gEB4ficazV5dbpU0fKs0F5kiCgcQR0fxXhMqXm3ZYaecKMqz VbyfiiyRPZy0QiLujXrfJ/CYOC2isgkuhheovMRICAkriHQJiWvoX1ZZMwxdfj4T5oaw YMiJt6BgIEQFL3kIkStGLq3yrQTeOTdq6+YgU0Udt4cJhB9PVQX9WYI4EAibdEyZ83rq tCPaza0vNFh8s4sXJJG75vmwRbbXjIr5+J1w7a1NiLBR5xGZidce1h82LpI46GW6gJnS nZHg== X-Gm-Message-State: AOAM532Bz+gxMiA2uHRzWgrHTfE+kDjASKmKNtqCCj2CH09Xb+o+6hsb lcBilnv52qKhKJvgT8fkKzJeXUwA+Yc5jQ== X-Google-Smtp-Source: ABdhPJzZrwIa4ZxmiUemDvlpgHwHPLw9TWqmIVrH15usxEIm0EggB71HHxXZ3Wr4/kE37J3ZspP7ww== X-Received: by 2002:a05:622a:13cc:: with SMTP id p12mr32209754qtk.255.1635787656122; Mon, 01 Nov 2021 10:27:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 09/60] linux-user/host/alpha: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:38 -0400 Message-Id: <20211101172729.23149-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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: 1635789349392100001 Split host_signal_pc and host_signal_write out of user-exec.c. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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=1635788999; cv=none; d=zohomail.com; s=zohoarc; b=eub0NUr8uxNkEawdprvGtXhO5E4fRHw3R7x653xPm+eGE49Bk4VEDbhsr9EeNgseqzZucxLR9xaloBw1uVlBHtpb2HbpmseZnkJo4QyAXjyak26Zf3Gu9Ny+NB0aKpui2v3A0SO6fpUZRE6ANtDjQQkHBhQIQqOVDGMvDzxGifY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788999; 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=BEDwxUXgiYnv/fNgu18FTMT9QLfw45+NrWi/CrHqjtM=; b=Wz11BZVc5jQCNVeD/K+JCcp5aWwzsa81z8CnFclM81avfyIdLk8M1iEX+YUHun67BVzYo/e6+Bo4oEbQzJHAh8ghgoV81FgOyBPDrUpk3NQLVIcMQVMmr891KTnjhJ2e9hYM6fM82+3Mm0tIuRot4DwEDaaiZgSubTs3p2OZTuY= 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 1635788999036291.1671623269807; Mon, 1 Nov 2021 10:49:59 -0700 (PDT) Received: from localhost ([::1]:59332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbRW-0000Us-1G for importer@patchew.org; Mon, 01 Nov 2021 13:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5z-0003UL-PE for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:40619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bP-Ta for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: by mail-qt1-x834.google.com with SMTP id 19so14949501qtt.7 for ; Mon, 01 Nov 2021 10:27:37 -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 t5sm6075331qkf.34.2021.11.01.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:36 -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=BEDwxUXgiYnv/fNgu18FTMT9QLfw45+NrWi/CrHqjtM=; b=bZX63F4QzUDnm4q1Koo//0uTsJafG5c+HaK/3SpELTEC4s7YX4xETAOMDEaC+qnYhm +AuClDol+DryWDCwVjv42bjteOIAjHaF9heIyqtWwN96GmrU464QDVj7dEg/kkkOhD17 ItMFTUv5sCHVJApj5AYf15758208G6peXLLZ/73gKAimPNWpY+rKoBqAtZJwPRsA61iI CLK34V9W3ax5xGM2xJfXVPSoANsZBddV/NS7XyqRQ5sJDxWvUg9GtYseCvufc9Otx0Ta tckzNhAuGU8P5mGFTt7pxX+oNWy1+HVxHUB6eIjFO21NN5jvY3LJdWxX/KNBDP5dqlZt jXqw== 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=BEDwxUXgiYnv/fNgu18FTMT9QLfw45+NrWi/CrHqjtM=; b=7Wvyd///IVoi3P4HNfA3f8B8xb2ZPUdcCmGZV649m+sayf0901lURunBQfGjOnNjRl dARsHNunez0Ks1IRD12gIk3M7GVteQ2MjQ/tCz039Ws8fT2E5yIcVO/ngy4ZK2GydAA2 IfWWNhFjIJMv/VgIBJ2Ar/xszeRJGtDX2F0vmRX9WAvPA8DWmF78IJRN4XqG220+Qkyg 8Rq9ZKuhfcjIi3sHkdbgRjD3HhPzTB0ZxQDQAJb39hE94OsURrelHZm+6zmhA7lG7H41 ErnVexhgScApsvaKJuC3aSnTrv9pk31SwxTNwn9Gi/db1U72ceEDA5sxcGNazx6LWxLb +pLQ== X-Gm-Message-State: AOAM530WpFnIW6h4j+rri0EuAVVvNElcKESDwtVTiyuwsCWLs+zHpwu4 K7VTzNAvJHYHe5y0XUedLPK66aZopZRRfg== X-Google-Smtp-Source: ABdhPJwSCXuWJXWi7fukSvdJsc3cGn6aYywajomY9IpIbBeD/QUUfNbCnxp3LdO7HGSUi+qjdt99NQ== X-Received: by 2002:a05:622a:b:: with SMTP id x11mr31559665qtw.211.1635787656755; Mon, 01 Nov 2021 10:27:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 10/60] linux-user/host/sparc: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:39 -0400 Message-Id: <20211101172729.23149-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: Thomas Huth , 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: 1635789000922100003 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. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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 1635788888224116.85354446907422; Mon, 1 Nov 2021 10:48:08 -0700 (PDT) Received: from localhost ([::1]:53514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbPj-0004wE-3o for importer@patchew.org; Mon, 01 Nov 2021 13:48:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb61-0003aO-B0 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:45 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:41815) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bV-UL for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:45 -0400 Received: by mail-qk1-x72a.google.com with SMTP id br39so4060090qkb.8 for ; Mon, 01 Nov 2021 10:27:37 -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 t5sm6075331qkf.34.2021.11.01.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:37 -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=8zdgSjVcgig3g8hdbqYsAKc9D/WSYZskIFgwWrF7DRk=; b=sc9UQVSXBwS5Y2NaATpU60XEKCCdjLkIvvvSuMXc6vwuAKK+YgpT+i60YiFV+tyLZ+ BRxEP/nYef+6uklpv/xaVknhdik2UJn5kdo7I9P8cuotrGvP6+i3UiFrxPZS7SyV7mhn 5aYLvCD+8EnkeUw+gAO7bYnNXzEwmBHBa+kqqPBiT4zlkgZvso33XAJQD3uuyh0+BTu8 AJUhHBGZCMBi2Z3Qmw8ikPO5t9Ag+hrBQJ5JRjr9XOaO/MIs5mgNSZugeItOs8dUHVJC FPTvfnRGC/GgTt/ofK9UhEhqP+dZn0wUUaTp6kPlHLz4ix4Quo7Py8EuZxT5TfR1GwUp pn8A== 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=8zdgSjVcgig3g8hdbqYsAKc9D/WSYZskIFgwWrF7DRk=; b=A7D2FrfAzwpy8fMVvQOs8butVKcBHNwT78oHcDCzp+ZtDa2nrzW0t48f3zK0vFo3dk tYHr9eYI9IlGcDyW+DirKrqI+FeHIKMiWCzhwDPik1WbdGUhNXqabPPokXElCHOSvoTy 9HGK7xuO4pWPsPuCTe3ZB8FM6pLXikOHS+vUzazIsBfyNaWd1FC3J0qxEpFlg4JVVM+F 5g6XTCqVIGGa4MCOkmGBWZepaEyJV7CaC8BZWq+Ff4XZI1OYmQ9sA0cC10CpqxN5MeNt 4WacFILLR/fg+dVqZuuYMvenz2IXm2DRoc7XUlwb/B0ivdp8435PLLEO/8NKfHn7jtyV XVGg== X-Gm-Message-State: AOAM532pxNK0QeUj2fkD7+M/wmgWr7kcKGDPxydQGsCB0m9TvraeTSEK jAkiLSV5ZToXazIvORxafkb3AKbiERD/EQ== X-Google-Smtp-Source: ABdhPJyobcRrLcLKZhcCs2migFaTfaBtnparF5I858dy9p2+kOaWZde+xmoNzR6kYchzjuwIN0UFQQ== X-Received: by 2002:a37:f902:: with SMTP id l2mr23587606qkj.511.1635787657282; Mon, 01 Nov 2021 10:27:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 11/60] linux-user/host/arm: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:40 -0400 Message-Id: <20211101172729.23149-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: Thomas Huth , =?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: 1635788890745100001 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. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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=1635788812; cv=none; d=zohomail.com; s=zohoarc; b=EBy6Nqqk2jD4wP2paRb69c8R+d026UHoioMCJBddaEMdmVm4IOszLcV9qZXHPOrmaB5ViQr3siTIN/VKAN5u8v6f7ugHWZxKLqOsNBAoqjL6+ZTik3fpvRoh2HBsfspQNWYH5PPcXb10xPwQ6MfOQt2jTaz/uWtMzontORDCTxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788812; 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=6mixELSr1FgeWIqsDvnN/onJw8tvihy1WGIJ2b0tP7Q=; b=GYuKRPDrN354srzD0iMOhqQpF8oclc19iw2e7ZLQn8oypEB6dowqjg1GrP6+uILGIJcqsqt/npehW+FG2rv+DOxf/9Iqxl4kc57iGFv/P6pq+9GF5Qqt5V16XMc+tc2uYXWkWj1kFuPRaqGHmIyShmaZ3riwaKVButvvL65dbZE= 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 1635788812905403.4596643793866; Mon, 1 Nov 2021 10:46:52 -0700 (PDT) Received: from localhost ([::1]:50958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbOV-00032X-RF for importer@patchew.org; Mon, 01 Nov 2021 13:46:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb5y-0003Q6-M2 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:42 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:40610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bc-TZ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:42 -0400 Received: by mail-qt1-x82a.google.com with SMTP id 19so14949574qtt.7 for ; Mon, 01 Nov 2021 10:27:38 -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 t5sm6075331qkf.34.2021.11.01.10.27.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:37 -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=6mixELSr1FgeWIqsDvnN/onJw8tvihy1WGIJ2b0tP7Q=; b=fSWfh7mC1HwMJVCNOlvfFmqxBtQ/e9PFYgyClJkCGgXkP8vC7qiLgmKob6d2nWM5I5 41zhaBOrWJpwEUJei5WqolVOksfp/wALzinNmbtJsqpjSTTyH9Pxel7/YGQJHMweABbX 5beknXNYIVAltCnbwUrb3gXcDerxqoAbseeVDjhovByxwAIPx/oGSxmTEJUYWR0H90hl rsXdHxco68wKRwuh6OJYZxglC6Qo/LjPVkHLTrgigWE59ogjB8PF5CGfYNDb/7NbEeOj v++A5L6W1L9K3C2RbjCfqrJXsiqcJ6ubFybNnPNcpTjbPxVXsOYnNj3QEKeEl2hwc9BY V76Q== 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=6mixELSr1FgeWIqsDvnN/onJw8tvihy1WGIJ2b0tP7Q=; b=OmruPnTgxyRXHLRCU2N7Ch5QQXISD3xtIKyFnVVMD+UvirID7/dXBWTSL+qUHOjDzm eUSYwZ61KGMxZH4B7xGaIYU2KFxpm/NUXSaxK54Q5FJxuZfGzAmV638p97XHFqKSazV6 PPS3jy/tFNznPwJBKq8aUPnELHIdshSfPG90gWE9yPE3mEnbb5wwS542hUSGabVNSq9T nhdCEDmVfEVKi49NnX+3X1JlJsTWzTcb9FSMEQdozHu7ZAG6y5/LLIGwLaciOyANekw/ w7HkoLd9b+94ydzik6q6OUbrqbD8cqGon+Q1Ok6HYpkVog6wF+fkygPkqxN0i5yU0vyc h2Mg== X-Gm-Message-State: AOAM530p8WJ5ZHueNVc2/DueUghXcvPfOZXFEjUcRI4wRj0mM4p1Yr4p erKo4gko/wTK1Mr5UpMTgkXFbYVWE6QhcA== X-Google-Smtp-Source: ABdhPJzQCVjhC1N/2GzW0wx8l0YaULop+J82ZW+9W1RRN+glgTJWq5tMsjgeua7omK3cW5nSS0wdLg== X-Received: by 2002:a05:622a:394:: with SMTP id j20mr32021779qtx.386.1635787657904; Mon, 01 Nov 2021 10:27:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 12/60] linux-user/host/aarch64: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:41 -0400 Message-Id: <20211101172729.23149-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: Thomas Huth , 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: 1635788814090100001 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. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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=1635788002; cv=none; d=zohomail.com; s=zohoarc; b=NjgMnJLqLn45BM0G97qV8Fvm8IGunUdFFGUOkOU6nEelfuIbbVyKKt6MI163LGhtatuf2Y4fOFRHq/rM6w5ZDHcaPofkg6K31AecfjxxMS+1pd3YNPZ7D4vY+JHMcGQxWImPmoUvOmjYdelAU9PXn6VGbeRuNsGbFoshPGMb2Xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788002; 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=c0j27DsofdkhIeoTGchjjch6t7JyCvna5l49xmny8FA=; b=gSHS89khzM5fnICnhOgRQKO5k1I/OzWCyH72IWmm3dyfo8m5H8qbaQG1v/RhCxtJu/YSaot5SFLYksySWGCULn67J7rbGxG9vkmDgqMUBwCp4bpEYa9FKDLjmkQXFLTIXPtO8Hkt+IFcJoa9AH2C8IPvOpYahqn/iIHrJvW6XEc= 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 1635788002409951.3816703731814; Mon, 1 Nov 2021 10:33:22 -0700 (PDT) Received: from localhost ([::1]:56462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbBR-00041Q-AU for importer@patchew.org; Mon, 01 Nov 2021 13:33:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb60-0003Ws-AW for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:44 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:42922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5v-0000bh-Tn for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:43 -0400 Received: by mail-qk1-x733.google.com with SMTP id bm28so2116429qkb.9 for ; Mon, 01 Nov 2021 10:27:39 -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 t5sm6075331qkf.34.2021.11.01.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:38 -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=c0j27DsofdkhIeoTGchjjch6t7JyCvna5l49xmny8FA=; b=TZwHQmXlcNe7pLhbkeO4GNrfWVxEc2D/pKXMANRr9UwGvwTRbyiDaJ8pWyTnv6++Q3 jOktQk3d9RfoZ9Cw3sFPhG4aI2tUNP+Z7NUSIu19fSyf1yS5f9ay1ZFqZl9f0KqgkyuS QYl9G4dLk+Yy/dNRTfWQQtrH4hwgw7JLdiFY2y3905RXWp1vnEHvRG0CAONlORmZ5YID OshbwtwYG5TkBmSUlUZl5SFB28dXiJE//8HrbjSukMwTWih+vjxo7jL+EiJuCfa+Jvo8 xwOVaDk4GIoW7BF0d6R32Fr9mp43PBoTsCfbi93pYQfdkWD1CKFgCG0cZ1oWGGYTcGPW w8tA== 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=c0j27DsofdkhIeoTGchjjch6t7JyCvna5l49xmny8FA=; b=7/cqhCKSxNvAsqLOvZtf4DIX/pmwvoh77IEzApbcS8vCSTgHXat0c/4iLrZTePS0GM hSbMT8UQ8pyHtlnqxbHYvuy/tKhtS0cbe2HG39Me9xrDOj8m+VvljV+Z+uZg2Id/HIWL LCeXHjjug17vnIB2ATp9n+Dg88z73yL4+8ARFDITLnDZcDMElbbdLt8p9pSsm9nnz6iN X79dcIFwz115jPQUO5ZgCQaL2pPlPpNNI5o2NtRH8De2B/4FK0GDwNpw5O9iJDL0wJbO 5L6jXyOpEpYQLzz7Bo1jKHuVTMrIUtiy/P2Mi5Wh0drBVkTISuXHFC4Watr9NvJSUs1u 3p8w== X-Gm-Message-State: AOAM531wW6RcDNFQ7t998gA8ev2cJTdXLQKtQ3mdnJeLUQ2cQ7bUSAI8 AoG2x04QQPFtnwwgP+Ds+eswaZU1e6uCHw== X-Google-Smtp-Source: ABdhPJxHgMqkKLLEKZKpXvUHk0d9y5RzJTPMJHgj+pPhbjxGa/QHP3V0zT3Ks2fcPlE9ciH9htTBDw== X-Received: by 2002:a37:ec5:: with SMTP id 188mr23891371qko.23.1635787658519; Mon, 01 Nov 2021 10:27:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 13/60] linux-user/host/s390: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:42 -0400 Message-Id: <20211101172729.23149-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.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: 1635788003077100001 Split host_signal_pc and host_signal_write out of user-exec.c. Cc: Thomas Huth Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Thomas Huth --- 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 Sun May 19 09:23:43 2024 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 1635788199173988.6199658008493; Mon, 1 Nov 2021 10:36:39 -0700 (PDT) Received: from localhost ([::1]:36620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbEc-0001GQ-1H for importer@patchew.org; Mon, 01 Nov 2021 13:36:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb61-0003b4-FS for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:45 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:37544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5w-0000bn-3j for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:45 -0400 Received: by mail-qt1-x829.google.com with SMTP id o12so5763923qtv.4 for ; Mon, 01 Nov 2021 10:27:39 -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 t5sm6075331qkf.34.2021.11.01.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:38 -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=gfFeCAHNmLamMmWHeLGWsNhRmIhEPobah538FbvqWFw=; b=vtCCfnziXGBI1fngjf/qYZBWa10hkrTPIXRCKzMbJcvjtSpESFB74w32QC+oxngB4I C2qovjf7IFhKNi6000ljpdo9QAuqSZA8srGq6CO8EACvuj8mGMFNLC0YcrgD/XbbdL6a /QdKNY9soBf8CZsy2e7D8l4ylSNE+WcGTgxI+A3H0PoMji88/FqAYlva/smCwurPHn8v MfN6pVwAd5lcUdBloxbUijlvNQVOHRU9dvQwJrUX6xNKFBax2PCqXaln6haGjnq66INq snOwrfp4jI65/UqPla+5AtF3LjV7bEaoy0P4IDm7upGG3m7dbTj6UIA55s5u/EFJC2rr 1zdg== 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=gfFeCAHNmLamMmWHeLGWsNhRmIhEPobah538FbvqWFw=; b=ex9MpuuudYpeDdoYBOSlzuNUmTpv7UZcC/z16V/hVK1e9da+q/DShVFhJVrzYZgT+B Bv8JUCbKX0nRgoJMkofU4ONkAa74jUNr8HP/PzN/p4ML+Jh8bqGF2adj9IgmBbQvUu/4 kJKHNVTaLQ5MjpFKWlMBpY3qctDowivbBmYs+Y5nX5IeevZfhdDxa41ea8xler3k5MNt FfP0aGSDH19l+mxChPxWchUEdOTM6UEfmhodn6W1iX36h/UWrRIvDq+1BKEdD9K96Ap0 pdIdufZyUCF/023tWje1UzvzloFyJAYP8DaVIXjYg+bexJneq4o7pQfgRfpYVZvDAfZC fIRg== X-Gm-Message-State: AOAM530gXJogRJzmkjgoKT1ZFWjCD+NGNgOzkNyZS54I7vK/cGoTWbx2 /3/93/xPVTy6MnqucH94sRrqWK2upuTbKw== X-Google-Smtp-Source: ABdhPJyAemXfCtHyvfrlnFqBxK53g9HL3HPBypka0AarDoNISE1gdA9Y9kAj0WpeqcUQMB+/Sjtx5A== X-Received: by 2002:ac8:5889:: with SMTP id t9mr5049764qta.362.1635787659114; Mon, 01 Nov 2021 10:27:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 14/60] linux-user/host/mips: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:43 -0400 Message-Id: <20211101172729.23149-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: Thomas Huth , =?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: 1635788201023100001 Split host_signal_pc and host_signal_write out of user-exec.c. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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 1635788521155273.6973708172087; Mon, 1 Nov 2021 10:42:01 -0700 (PDT) Received: from localhost ([::1]:45156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbJn-0007GJ-MB for importer@patchew.org; Mon, 01 Nov 2021 13:41:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb62-0003dc-0k for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:46 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:43696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5w-0000by-Jq for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:45 -0400 Received: by mail-qk1-x735.google.com with SMTP id bp7so11991692qkb.10 for ; Mon, 01 Nov 2021 10:27:40 -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 t5sm6075331qkf.34.2021.11.01.10.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:39 -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=Xgy59h5PK+sdBlw/Sd25XUenAcGDXNsVYhc2txOg2GE=; b=Zd7jC9f1xfgSeFQp8hijxiOCt300rxSJnkOkCJPlQ8fqDUkgSADYVpPTodIkW6+35n pziW+5OJuC/2b0vR+kg0it+cqaqpI6D2ERnee5gGi7yI4yVAGoQIm5cV0TzZ+1GdURHn Bpqe5NCG+RBS1OE4QIKidB6IwlIMiinJoMdV/6adC6+zsiRMLlFldyl/eIY0gLknth/6 3DoIHjySWl6RFv1kmuIv1XYRxL1Mz0WoXP2+PL8u3byq3QzLf9hUWDw+fGq9Z1o9H/xS gXzRhOuQbwEgaZcHNlXL+j/oasvdXR4ZQS+rDyoifdRAUYg5ZABsb4mXDejaLwYdm8lH N+WA== 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=Xgy59h5PK+sdBlw/Sd25XUenAcGDXNsVYhc2txOg2GE=; b=RnevjXNqGhQyDabgFKpi7tAVouBtfS9lmjgi8bWJNO+Y0exjkX74e5yuQ9d3YqaQZa Aek520761v7hM9nAf8rCvkaD5phRVuJKvSbsVYkpXNV7d9QC2RKjadBYC9UUPGNCt6M1 InvYfcvdNDyyxKCu8tYoVWkwXU270GUNyHbyLuX/k3HxvxGmyWlSEF75HtYZq7MEMuWU s74N4w1x/uovfNmwA+rfUtMQj33P4vRKDjyNKLyeYyoLQ/IMauWV7pXYczh6/UCxtIa9 s7EsEpmOElEigllojADl849Ly30X+Ev+9RHW9ISym4T6jCmqfnTlJ6HH2h9EuFV0E2xT X9XA== X-Gm-Message-State: AOAM530v2qx5wTFHWcFQ5RDAWBzfvOjIkKC7O0pWVNJ9gCXjiHXo9O7y JtCYgKPy1sDQuwmbBzPSqvTxKnrFHxaPzA== X-Google-Smtp-Source: ABdhPJwXBHh6L7MDL9vlRtu1cK/FtWNTsf8C4l3026DYOwji6Zoa0H5QfWFFRO3cJuYEPyfsq1Uw3g== X-Received: by 2002:a05:620a:578:: with SMTP id p24mr24906679qkp.237.1635787659749; Mon, 01 Nov 2021 10:27:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 15/60] linux-user/host/riscv: Populate host_signal.h Date: Mon, 1 Nov 2021 13:26:44 -0400 Message-Id: <20211101172729.23149-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.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 , 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: 1635788523198100001 Content-Type: text/plain; charset="utf-8" Split host_signal_pc and host_signal_write out of user-exec.c. Cc: Thomas Huth 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 Sun May 19 09:23:43 2024 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 1635788982926344.9384742641838; Mon, 1 Nov 2021 10:49:42 -0700 (PDT) Received: from localhost ([::1]:58428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbRF-0008KC-U8 for importer@patchew.org; Mon, 01 Nov 2021 13:49:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb63-0003iB-ST for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:47 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:40615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5x-0000c9-70 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:47 -0400 Received: by mail-qt1-x82f.google.com with SMTP id 19so14949679qtt.7 for ; Mon, 01 Nov 2021 10:27:40 -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 t5sm6075331qkf.34.2021.11.01.10.27.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:40 -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=TxSSZ2rzDd1MVzTpsbz7nMhyU05MyChncIz43o3/9/6dugeMJgZwQLAbl4wU+NAGjp 8voqhRgSMa6xAfe2ps1sREiwNdcwOGw8W0z8eP56tG8UC6t3ebdx5xBIki2S6+YYmvJA koUMpA+VfBBRgXbgFA2G0uWRCn6tn9cCOwieyZNY/3Beg4WD8o6jj+k9uA1iLosdEt9V U4PN41FD5vmLw/bVsC3kkfds5+gxbcEgapUUcObKPRTHDKWDT7OpMs+HnLpHVqbOXeqy d/0YV0RHMwfM3OscC+QNXeP0Exopjr3JkgdNw9SrhvDp75Bg5Hv6238yy3DmWUOggzuK WYJA== 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=a8mt3xbxV4FyHKV97TvqarOV9O7/eGwsJCBflqQ0aXt5xWvGduSMxgnduMQF4nj82U F3nd1O/K5UyJeUvloqyQpgwbcNFYhXHMSt3jtB+C/eOYqFVVfn5IGo+NtcWa5Tzh2JMR BnwJTfIw2kdRAG6sSt4B0dpGz0m/xiAAcVJm3Iyv0+XltTQXkGH61GzaZByhCONORkYu 9oePfbBvzueRHer3cd7w6IAt0qpeUcF8kAwt2Qu6q8UNWXDucdbBS3sa17hpUbPKDfjD zzq39IyXAZzYQ5nakSjiCAMpwslQim6GFeConFnhR8yWBB2TNHWOPwAldcF9FOLa49X8 xRYQ== X-Gm-Message-State: AOAM5301K+JRrREo6xh6RvDcGIxuk6l7I2x38opoJv9T0TuniWFPQy3d xg2BBoa5vYcjP6WskhgGb0PlTkyY0y5YyA== X-Google-Smtp-Source: ABdhPJyd6seCk5vJVNrDexaNdtSYinZmMaFWnfJLR6/8basJEY2zZZOhNitUs17H4oTBusokASVf8w== X-Received: by 2002:ac8:7fd3:: with SMTP id b19mr3530483qtk.235.1635787660353; Mon, 01 Nov 2021 10:27:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 16/60] target/arm: Fixup comment re handle_cpu_signal Date: Mon, 1 Nov 2021 13:26:45 -0400 Message-Id: <20211101172729.23149-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635788983881100001 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 Sun May 19 09:23:43 2024 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=1635789154; cv=none; d=zohomail.com; s=zohoarc; b=Jlt8YlPv0lKPKM2ZKbvUSo9RxPrTx3wS7YclCfucZ8xXFUTwZZ1MsFXJHEP8cVbVRJ63pA8biTBgOdoWWphrB4mjk9XEtcgNKipdExcxQNCY9bFUXkIwvaOxP/YJdR2+Q/O39dIT0fZNo5bupO77+WZJ/yV3HaQySHRpmYHV/K0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789154; 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=FBTKeq9XabtUZBIh+yJGa0GF9dTRQTrs3kQQyvnULGp4Q6Sd9NyUj5t2brr/a085cq2nwqAXwI/ypNTDK+WwVngvgrQhc63ISsYdN4jFBhrBWoM6viarNA01qM2G4dAWFxwcr1zDj97hzckPAkfcbiut7is5JPyi8eepDklLPNo= 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 1635789154653670.3264452103649; Mon, 1 Nov 2021 10:52:34 -0700 (PDT) Received: from localhost ([::1]:42306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbU1-0008E0-Mn for importer@patchew.org; Mon, 01 Nov 2021 13:52:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6B-0003ns-6i for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:43685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5y-0000cM-Qu for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:54 -0400 Received: by mail-qk1-x729.google.com with SMTP id bp7so11991747qkb.10 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27:40 -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=A+qfkBKj6zishRfu8BOJ07T7mTZpqTd2ChOut5mEyB4VBSTtDSXdkIONUDGfK7ZzSR Q2Bpv7pBncB9HUwrPy/4puqjsXHvWnDm9zPJEXuz4D5Fvr3DMU04wg3dFJnEKLsuf+12 IjQ4/BMEHuMgu0fzx65wzeVkWSTBkgyg48ENh0AiPJe/ZCrJsRrlDxsT71JUeBLtZBRC c68TQUpsO2VCKttk1c6nl6n5vPdWPym0DlefSKdrs7fPfJYkEQgKSLTwPZtHaBIwZCiu qW2+MRcNgTFOz9MLTOvtIvV/vlwrRapx7oeXRssYQwwbu2zDDHk88m1CTYMTkFH+JKc0 fhUQ== 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=Xfwu7YKQF9OI8cpsRJeSs7zPHCuIgDZE0vonrFlD/U+igWWRvxQbvYu3j3vzn5+PaH SE37gJvNmQAGYZjyLSlnGFqkQKF/nFp0mVDDiwBzCG+g1EdiZfa8aUvYwH8ZoDq+PUmQ 4bXxsF8u1FJuqF3YUTAjllRXu87rWYC/cS0ANP+19vegGddpTbdeffHrih8TF/jghike Ij0B1HXJ9k5PfWqJYIBBuQAx7oWiEf8mrun514DHY96CA8oDtwHxJOWe9ZWpG8fRl7pt SP9pTcig6F3rgqVq5UxNUfTU669ai8+WBz3EjDZMQlofIOzBQPRzyUHpbzRt0Ul2NHB3 vFog== X-Gm-Message-State: AOAM531mQ+tS+R/v69+koZ9phaWK4ZfVgnGNIJMPDd6TYoZKi5X4Sxsh 4GUHvlHaNKIJb19lTW/srPT1J3TH+DX0mw== X-Google-Smtp-Source: ABdhPJzJVV3jSr5aFo8P4hu4Fc5YC5L4OUPqWCke27KHKnIcoAM1RzHamfoAujvOv1VFGXvNDBt9Ew== X-Received: by 2002:a05:620a:89e:: with SMTP id b30mr24680349qka.154.1635787660936; Mon, 01 Nov 2021 10:27:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 17/60] linux-user/host/riscv: Improve host_signal_write Date: Mon, 1 Nov 2021 13:26:46 -0400 Message-Id: <20211101172729.23149-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::729; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x729.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 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: 1635789155358100003 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 Sun May 19 09:23:43 2024 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=1635788893; cv=none; d=zohomail.com; s=zohoarc; b=InbeN2JTWal8NSNud7CPw5824F5FAVQwpsx+Fd8jHoiQ5j9aVrkrRf7xFaCLHosSDaeDm+RFnLoTSXzZLFrjpw75yX3Lpf4gWBA7QLnCSqhyqYyWQicFEOj/ddTFZLerqY3znbuyZ7f8HXlL986lQteTxe/zPZEr0UrlmDD40PA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635788893; 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=DoMg3vbRjlk2FtWjjs4tEEjuHAGUCsY3uNNt5oKGkZOR/05eljgYjgj1U7+TuFdPF0+/c0NW6RqJoTjnmsrzwY93mnFAe2V1aWzn1toherAzctKx/ol+Wg0ETbvqpQvVPHNLefFw/T5klpp5vCNF7F5JENd94uKlHsLWtetbB8E= 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 1635788893592596.9409846981558; Mon, 1 Nov 2021 10:48:13 -0700 (PDT) Received: from localhost ([::1]:53730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbPo-00054o-Fw for importer@patchew.org; Mon, 01 Nov 2021 13:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb63-0003hf-NL for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:47 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:43687) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5y-0000cZ-8T for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:46 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bp7so11991761qkb.10 for ; Mon, 01 Nov 2021 10:27:41 -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 t5sm6075331qkf.34.2021.11.01.10.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=BEoOYfyvrRlliP3CVpcV5+AEGq6qhapGY3bb4mVGTHg=; b=ZFu/X7kcgmlrLRSIKJeaG4icaNj7m2zvhirGUtcP4BBFKttgroETgqF5pEnigaoesq EprvdNBkfd659Y5pRoHTy6+fqtje6nkeLfwKRpXhFRlXsATbFnK2q1NVOzm2lWIqJJjO VS7StUN/eA505r+p1t4gMK5QYvs/ckJ+a4i1ZQTLVMWDLD1Ou1LjA8dZjzYFVTRS49Wk lu3TuTX19LEpvbyxkxCekbwrewNdo7QE/tACo1fLflUERsTiOFN49xKZ9Af2QttvJ4qM JKyJ1+Z+LRIKr93a9P3eVo5KRruieTfJ2siiacYqNwSUdL7WHtCiVdYrtFOucE2b6X55 pVyg== 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=Ino9Cl0CO1euryMN2rHrhNJbsPAqNZjfezAwf/+xHTPM/BNTdHn75UZ9cfvsSYTCz6 JzbWrGRfxvX5mE/k6++nlW7ODyBRzsUGf7X75Vpn8e7jHjcQ2D0mc7/gwo24Njc+GuaI dlftfoLTbebqtyB+y3UqDT+uHDR7kKMJjSFunDgacRnZneUCVQySkzMMm/gaH87mffD6 6ED9+nV6hBNK+/IJn6clciNgzWQyHgOeHMSag6fWR82ECJEBXAmEAbyUHNxcywYd6X+z dYj6pYnVls5QyqJFEVdj2kyo+WjgLR/eu7Nl9a9PMCnTWFJxMkXO3csx/O7d4RcmjTSB ioJA== X-Gm-Message-State: AOAM533ako8r7V/P0KB69zNeq2jKmTaES5O8W4Pp2NYzJtcF7g/i5j8O hIDMDReWnk6MoHRZVpnInovAvniqN9n7qQ== X-Google-Smtp-Source: ABdhPJy5xDmc/M0RXEctFVIz/Ugl3F9yLy4mFRoxcTrObxQvsU5Phc7DiNsyHJYNTGJ25F0ovJJTlA== X-Received: by 2002:a05:620a:4091:: with SMTP id f17mr4248507qko.56.1635787661463; Mon, 01 Nov 2021 10:27:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 18/60] linux-user/signal: Drop HOST_SIGNAL_PLACEHOLDER Date: Mon, 1 Nov 2021 13:26:47 -0400 Message-Id: <20211101172729.23149-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: =?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: 1635788893888100001 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 Sun May 19 09:23:43 2024 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=1635789043; cv=none; d=zohomail.com; s=zohoarc; b=RVAyAXG8D36IUoWOOuD2dkmfODoOq6twzgNQj9XUIrpy+xwdAJEW1AW5g7vGuARWQXNFJF9JcrsuUzp0VM/oySW7LE5jDKurK+h237MIu4oVXEs/B50/Az50JtwP+HS+6LXmCOu0f+JijOmI0SMZzXPos0IVRhK1Berl0ntUm4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789043; 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=VnvW28S8lj25xzI2JgDIT81I7OWwdOARtuKOzJkAlJ/IUlohBvCx8iGvtNES6MO/Z4VGYzU2SAPkiFexahUykGELfzIt05rWRCV0GT3eEMBAGqi6xc3IsX2FYG1PaMXSFIr8h1DQVZVOk00Dyt7RizEoYD2vRkI7UL6fk69Amaw= 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 1635789043222168.85482769047087; Mon, 1 Nov 2021 10:50:43 -0700 (PDT) Received: from localhost ([::1]:33846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbSE-0002NC-9R for importer@patchew.org; Mon, 01 Nov 2021 13:50:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb64-0003lV-PP for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:48 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]:36762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5z-0000ch-3W for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:48 -0400 Received: by mail-qv1-xf29.google.com with SMTP id d6so11688561qvb.3 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=p8GaNWW3vnRejpH0QBiQY2hh87QfB4bhIFphc+bCE2U=; b=bu+b8DIA8sIT7NiYQeVxdE59RqzuDEt/K4dgmFjATnXouweHEE45Hb7LQs/B8gRDaw MmiktxLVRtqM3A0YplQwmL0VqjT9jy3iRfUMhk4jby8RqVcp7nO2ocqXWuwZrvOanHUX R9i9QkIX4PC3RWTjfjWu8GmkTWeUJLpRE88ZWwlLC7atC4eiq3FjxkOSF17OTCleouTk ZDpW+qTqbr7ya87hC8DfGqnyEZu02ikyER/fHcjP2snURdKlnl2O9uPR9CGYr1nZZFvh M6nPEOsM/xcnu5ZkJgxQ3PcIApdOV5YXFmF4eG3Vel6Je+ST3SSoX1qOYREgEjgN5Mpz Zqbg== 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=TN7DlR94noh6RyW4Cj/vRZ5xa2UFaXJsO4ieaRs2qRWkF7+gQ10yxzW6kFGIFGM4lG hIqdMapg+LAuvYWc5mFkvqjuInNC8EYcIpI/2uEVQrYnK6/diM6SS0aolw8vejgpwgsy znq3iUt7v+yVmZjuvzeicq0AQsL4BbLLGUwlqhmouuHwZm2Lh8C9PZQdsWmvEiiCu0b2 VUKMbGh8b6gsLFnI6t6sDNx01xBaH7fM8JLjaXZM53xo61ycZAwOBfOT3u7lNrn4oFp7 y7yTgznUaHrWUbtIADfauWpCyKKb1/VV6Vc+TTyW/Xo6vKcczEsqZI0iqyCpi1lE5R6b 9p4Q== X-Gm-Message-State: AOAM5326908z62qaiGXxyouXDG+6Lo4tuNLu4A6k1whmEBkjpftxWbLw BkwhDioJF+N3vyuH0+ekYRhchZLyL6dzMA== X-Google-Smtp-Source: ABdhPJxOXyPYBMB+N/7ZcA4Ll2kk/TUUTot3sF5UMwB6KskTE60Z8KElcvYoegYKMqYLTNDskqb8Yw== X-Received: by 2002:ad4:41c3:: with SMTP id a3mr17272271qvq.51.1635787661973; Mon, 01 Nov 2021 10:27:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 19/60] hw/core: Add TCGCPUOps.record_sigsegv Date: Mon, 1 Nov 2021 13:26:48 -0400 Message-Id: <20211101172729.23149-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::f29; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf29.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: 1635789044850100001 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 Sun May 19 09:23:43 2024 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=1635789041; cv=none; d=zohomail.com; s=zohoarc; b=C+HZvIoqZYIq0uuQg7Q5ydOA64qhe7CZFA0U4Ju0iCl9YgvRlMT+e+kNUiNIfQXPRB6nmaltMmX7dapVqjJVvCoLpz5q0khy+w/wn7ncUADuMiqWJwo+ZM8Sr7ANZeQm15unYEIaKV/hYpnhHeX5meI8AzIFM0ORLOV/1Roy2Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789041; 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=i8ukAmHWIoGWIqOJ8WgPBgG6rhPf/NswJy97jfSJ+nnQw4JRQOZaS25g0va1Dsg5JdNTsPtirHBJIpf9/zx/MltGYynWqfYK1r00odgoAm165rWVW+iZwbDOiaT8licoYBf+ojVjHKMmFUgg/BZ5sWLmDrbC7kiMbIPQKiOMTug= 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 1635789041290399.9074372379903; Mon, 1 Nov 2021 10:50:41 -0700 (PDT) Received: from localhost ([::1]:33616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbSC-0002Dw-9J for importer@patchew.org; Mon, 01 Nov 2021 13:50:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb65-0003mD-4n for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:49 -0400 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]:33666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb5z-0000d9-IN for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:48 -0400 Received: by mail-qt1-x82c.google.com with SMTP id h16so12100578qtk.0 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=h74jAt7hxYWJ8vb//ZptaTN1DfaIP6MJ1JsKHfl8Ic0=; b=on5tq4qo+tJLbWVX7GnVUcuIup7bOn+pSBjxneGmik30TkVcs51qfKeR2fc/T7meQt vfxOcNqdcpsLQ7ANoLioYgvWwzTsusSTF9UQ9zv6qr6JRa//azhXjU01n+xZh0Efe0// 32liyiS2Lp69c/IsL17yqflUVQBNj4Oq2nMvUwlMRFQYTgZ/w63g3K8l1tbXYBB3SSPU 5cG1BuSUJ1CBIvh7MlAZZEm2U4L2VvaVkSkOoj4l0v3IUixiL0btOl/tcnrz7XxZM/Zl 9sK41XeWRfHA8mPLAegVHFfgSeKavN1Mz4bwJxvs7p7yOiie7eoDIE9g/b42lv72IMha Qpdw== 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=fNNxyQYGt0MiIiwtTxiNZ6QXL8fryZBg6KqITvJPdP5wqCCONMvXHZZvl1mAo60rVA WZ9UdtM2UiiNFGzh0sskKn3bBLkXcCTPeg1QSSyMhdHdQUJmh/Ij6E69B2dxRSzGkZbH IeGwkM/atHPQdF8KtdUC3U2OfrWBHU8SPUhbyWqSDjXUAaQdeObHRpQ+sJsRzvVkFZln 7c2+H1jX8KWwJBe5oYol3VfI0l+iQhSDvvvEaDWs+gEZsiHvRLi25MCQe7D5hax204p0 HGIqHGU2Vzqp52MjyatEJixNfCJCaG1PtLif/i+Kmie6ePKGCYWbn9HwQ00NBSp7ueh3 ugiw== X-Gm-Message-State: AOAM533e2WiN1xpiCzhksatBoDzVmCNU41oVii2nuTX5nMkl3oD6WVhT no/8q/ptPzFwb6SeFOsajOtdgxazMZfAKw== X-Google-Smtp-Source: ABdhPJwdP1dvSxl+r4hXMWngHPmTLkNbUS5ve6yggIJIsYc7h2QhvG+iO4EOpxU+34eizXl1a1MUUA== X-Received: by 2002:ac8:56f9:: with SMTP id 25mr31617190qtu.374.1635787662581; Mon, 01 Nov 2021 10:27:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 20/60] linux-user: Add cpu_loop_exit_sigsegv Date: Mon, 1 Nov 2021 13:26:49 -0400 Message-Id: <20211101172729.23149-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::82c; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82c.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: 1635789042657100001 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 Sun May 19 09:23:43 2024 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=1635789152; cv=none; d=zohomail.com; s=zohoarc; b=F+E5IQs1FsM7VZDM6rQ8srw/bu2/HbdixCz7HbHwZaO1Z/84q9iPSaAx43XEw08DMpIdwZFDMSXaveuTa5yHF1yeSgQPY/t73TeCNbOFzkJAsjGqu7Tqj3ONVIZz3/MKO8mw54lBHjZv9nmfh3w9703vWrva3AT7+C8vocw4e70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789152; 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=QGfQnATfJJIB0Eypv++HB82OIPni3uS/0nwowqo1Y5MZn+5xwga/aAalDxTvs+bJ1g5Jmgf48M+iCOZzkTD8yc9S0R/m6xlZcEy3ApleOh/OOU1p6kQTPKgZ8cmQIj2+YxXJjqraQOI6zIlsHt0Z9JYoxFlPjaW3uXwm0Tw9YeQ= 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 1635789152702335.448790423681; Mon, 1 Nov 2021 10:52:32 -0700 (PDT) Received: from localhost ([::1]:42056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbTz-00083r-F0 for importer@patchew.org; Mon, 01 Nov 2021 13:52:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6B-0003nw-BC for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:46710) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb60-0000dP-4R for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:54 -0400 Received: by mail-qk1-x730.google.com with SMTP id bl12so2950730qkb.13 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=AEaCX227BZE+QCVidN+9WkHpAoM/8sOPsRQn51mlr6o=; b=xbRTjY2ZMvMlNvKEmwfOTwqk3wQ6Cro81yTKe7m1GN6hrRortwwxK3bAU6U6dMdrMY TTaXKx3Ku5zszkUDh9sp8K/MfCplB0xqeowf5QzpZMEpareNhXHDiSOmNp8fajD5w1oy xFA1I2bhaV+bS+EnH0+SbXiV2sHG6bsYaJmab6k+RC+UkkQNmsqMiyQO/XSMxwWwtDrz U7b3BPYPfHPeZeVb8uHY3gVtBpR6SO3g3sh9Se4tlOH6M8TLU6d6m4KWx6GQvSREXOYc eJCAoMCWhpRdBGYEPecvqK7IKYZqJff3yaUaM1WLcSpK5qAjgMuRFJsIWgyi5hKztgaZ jwPw== 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=d5QQP6dndBfG4u0+rkU9L4flFYp6MaYn7FBrq/ecxxCVIPAk5pTTBCOc6TIB1nNeCB Eluc91s2dvEp2wgyrE1Sve3b0CZf7vBZwh3fCxYe2MteEdsKaxrYoFWyHbj10kaHQax5 k7vZfr3Sis3ERYaCjZgEWPB3lD/U5k0nowvEBNcuti5tc8FXHjFgVDk2SYtLGz5tciTw rDvdCYlpsNFArLxPfl5bbN6dhigT06u02vqRPt/tOhXrUlwGOoTIbP+FhEKhn/NZN5DA 0gabbE3aiPa533i2/57UM+BO+5lng59HnnWAJDvq2CrTfJMcFkblg3CtK9oLjUc7Iz4w xKaw== X-Gm-Message-State: AOAM532ajILcYALY7ZA1UdRhcS28PaKkwKk5qIv4FKHKPUD1bxnve2vq xekxvWKKTyWi3oOr3XmcJj8mPjOfxYRUYg== X-Google-Smtp-Source: ABdhPJwxhc8Dz1jclZckQay5iKqYXy8eBCwjP8Yox1NAsYdWkbrji4aD1mOctkxRB1VtciwTtn/CaA== X-Received: by 2002:a05:620a:1a85:: with SMTP id bl5mr11983587qkb.200.1635787663220; Mon, 01 Nov 2021 10:27:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 21/60] target/alpha: Implement alpha_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:26:50 -0400 Message-Id: <20211101172729.23149-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635789153278100001 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 Sun May 19 09:23:43 2024 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 1635789380838378.91468538709285; Mon, 1 Nov 2021 10:56:20 -0700 (PDT) Received: from localhost ([::1]:59492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbXf-0002li-SC for importer@patchew.org; Mon, 01 Nov 2021 13:56:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6B-0003nu-62 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:35457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb60-0000dk-Mh for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:53 -0400 Received: by mail-qk1-x736.google.com with SMTP id az8so6040827qkb.2 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=fofFGJJJzbXM7L3Ibz3JhPAmpo8LElJ1YWB6iIwHWsU=; b=iJz5aBp5c5DmycG9BeNmcEJaa7U+dntpj/XdowBohvetysOrXufHfUAts+tRn//gWD z/3yj+ghOf+aicrZQJ3M0ss9PM3k6/nteqLfJNX32bqjszbjjHYkNGlt5nsIGADJO/Tt W0Y/ruhyiIR6sYwey0x+SamdyNh3y5Lc4hxaHAnfnbZHGPMIVgmrZFobB5vs1k7ObPgN ZBPqQ5ypltEfCUW2Fwgg9sz3syYWT/zkG/sYjR68df9WI5IvyMIFiy/A7jmC6Siqd+Ef DAX22/lp2iwz2CA575b55oA7ENiH5neH9Vi4kTSBJpKnhPNPg3YnvA0okVCU19ZV18d2 /mqQ== 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=fCuG0P0SwukmaLCKSJBa0ICzNUYEJy+BZO1QRGSMqq8deu7HASywNT+vUZiKkhzYhH oAWk7sLdRPPy8AKMuzLP6PwJY0l11Fm3nvPGI8XmMSQg9QZup4UjL9hN2pVMHfJycjEz B5hQSFzJScmw4dvBmhumfUETUPDRw7vsYoXcij59SLL82DdL7DI8oiLNXS5+fTJbPAns VfEH+I05WJGQP5a3YMMsxA5oD7+UoyoRCoLuBw5eJA+/gGRRwGen3s4kEDth6Pvk98jW uMJtQgN1GXpFTKuHi2JLIeaB3aRWD08F2gWlhUbIMS7Wcb1n9blEJmjOt5qo3owsu+Kq aelA== X-Gm-Message-State: AOAM530r91Bj1TLI+9kqoyaUhNu7RPG5a8YnsIjWrZtLqyc5sqAiHUXn yNAID9pkC/goK9gGu5hl8dxYGjO4LxiGDA== X-Google-Smtp-Source: ABdhPJx/MjBSKYVgkyYAXzC6Kj3C1xb78zct1s/6wF0h/uEymQb66lOtBVKACTRyKpIsL8YqVKvSyA== X-Received: by 2002:a37:b2c2:: with SMTP id b185mr24576789qkf.272.1635787663810; Mon, 01 Nov 2021 10:27:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 22/60] target/arm: Use cpu_loop_exit_sigsegv for mte tag lookup Date: Mon, 1 Nov 2021 13:26:51 -0400 Message-Id: <20211101172729.23149-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: =?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: 1635789382308100003 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 Sun May 19 09:23:43 2024 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 163578927068221.81441500159326; Mon, 1 Nov 2021 10:54:30 -0700 (PDT) Received: from localhost ([::1]:50754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbVt-0005Nj-KL for importer@patchew.org; Mon, 01 Nov 2021 13:54:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6B-0003nt-5n for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:44931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb61-0000e4-AH for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:54 -0400 Received: by mail-qt1-x834.google.com with SMTP id j1so9299250qtq.11 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=GxgKUblSc/AuTdeTrCoYEJS946D/KatMQ8ilg/nMD3U=; b=gTsi6l4g+0ho/KbOcFEBSdVMM2iTv+nKVO+AhSBroZGXyDIiZ3of7M8lc2p8xoTFkX /z4D+2fizBIxsuea8wRMHCiVpP0GOxHOSKLG0kvdq/QJPVxgozaDgG6oXj4o+hzUbWXg S8KnR6dvBlluYf+DTJvKDH3QW28efRmqBAok5PdF9EMfZrpSJqbi8lxeEBB2vxc7Exgs Kk1P7F88oGAsvGFdUsmj3HtaYiZ0EGM40O/Dup63tuL3Q02wjwe15XJqAvqD7k+EoNN7 uLf5DXIUE5EdMFwu29XQwze0V9rLfAm89Yq/mC5/M8Teef0HqdA27iypXx5pQHkV2gbB SIKw== 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=lgLmum1+yD1ox6Bzm/tO9odHHq7CA+MYmzcJauHqlYoVTDkHjd6quJLh5hDYj/vemH y3+4iDifdAVstkaDIzaHP6m74SfVAanVUhuTaP8zzPn1WZ8faPPISc9LEA34JfHoqsAi 77LHkxCMu5vYsgUXCqlVTn7G9cOkNyRppHkIMosSaY4+oh0kTLF0/j2OqgZXAUfyw5Gv UO4QyuyCJcnF2i0kBfsm9zrB7GkdiHQSZk8WqNdbFbMzvlr6iHD4palcgHIrULaslTJv 7uwEOkd/3iIytHYjf4rk4l/ShCH42NrwpOUctk7qJZL5JjOMSmEoFGlSU/81EW7cre8n Fbbg== X-Gm-Message-State: AOAM5335vAkX6zMRK6BftKKNqazoQ0e2lfE2/eHsD1isTr5sLEgEEUQ6 elaL6o1vtg3BsOCHsapKZQDDC86cQZm8yA== X-Google-Smtp-Source: ABdhPJyVk+MXGIIjOTHTX9XFFTsToocO2hkya4PPdE/8zIFcWicVsabI0WpAkUVbTz/de74rLWgltg== X-Received: by 2002:a05:622a:46:: with SMTP id y6mr31987990qtw.244.1635787664448; Mon, 01 Nov 2021 10:27:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 23/60] target/arm: Implement arm_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:26:52 -0400 Message-Id: <20211101172729.23149-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: 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: 1635789271733100001 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 Sun May 19 09:23:43 2024 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=1635789381; cv=none; d=zohomail.com; s=zohoarc; b=Fw6Is21IEjSOXL1L8nN9eLOiTm5u78i4yZdx+Xq5I0Wk1u620QL6BC5BZRggs+8jePnSa48MiXBBcwVkdzLctYKHIM4bFb9ZARstrf5aSiATenNGA7GFGHuBP7idbO916pNXPKcMfAKIcI5AbQ8T+i+Svk9AUkLw1yFj31nqMrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789381; 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=M1Denajbe8VmaagK68lqexAvOB/RxQypdFoqqkMe+bWXwXaZOqWPGhlf2t2NnoQmwO6arCIksCJTDJe/h19BEskKSibzAi1lO6zFEevTuw7yRjELyLPT/RylNI+PNNvlbaRcJsR5zZSYetqkxhiS1dvWshSFX//Z8SVdQjUHw3Q= 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 1635789381028631.1902944159676; Mon, 1 Nov 2021 10:56:21 -0700 (PDT) Received: from localhost ([::1]:59482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbXf-0002lU-VU for importer@patchew.org; Mon, 01 Nov 2021 13:56:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6B-0003ny-K6 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:43627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb61-0000eI-Rk for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:55 -0400 Received: by mail-qt1-x834.google.com with SMTP id v29so15197391qtc.10 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=LvK67GkX13tDj2L9Y8ql/Gd7bbn2JZgBQ3dF7lXKOxQ=; b=H4AWdKx3rx6hSw+f/sc4w33ixdVizq8wTL1Oa3v3dm4zVr3RxjFPZ9/R0rjCZFaXwK 5Dx977ReNnu5hS4yU3JL9K0SHDOLR5ES/jX4A+eRuyX6J6hL1PncJAippz7r5QQKBTnz vSJkYPv/iZELTo+xJbHxoGd1upun9N36pXZq8FWi//RIXt9cTObOCAUzS+MiM2bUyiOo CoH2TYQPbxYewjCvHOnL3uU5Ldb/pY/0pSTzjjE2kkjG+io3J5ZE2sRIH/NF5GvgbVKn S6SjCpZyDcTbvDtMxzkpaiWexUGcIln+UH64N+98HKwQEkARjedaPaoZ8xMvkZXi5/yR LCng== 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=602BS5TszncLAahzUNYrGW10lqd3JaqUTqrZ/pA3Jv87ZmqKAH+FJOyj7nhlgmlTxb hQZiRWp/WjPJoyTyvUIXymXUGIJlCNVmhVcuUCv7b5fGmFDkpZL9DnyoM5vr0unbUgeh D4V8m4XpNGgWYGoByldmdAJe8oSJc/aQnSGd1gLbch9JAKK/DPzp46pJvyeVeQekImTf sFGZA+hrauMpOjOryZ5opS5PtLc+a7vROaB8DW7BuQbWYvO2/i9MrRw/eJQEwjIYzh5o xlWbUZEHAhBAeGoiOLEn+TVCtBS8igur+xQDeLtB2XdnwjV7zrP5pF1LtHXb/tE3CWXw QWtw== X-Gm-Message-State: AOAM533gfyQJIQU02ayS8JyGRzJYahhxL8gq/dz0qS2P7iLVbANOOjWG IKNijEw5rD4LPPLwrKDLDAtaRT9rUucsyQ== X-Google-Smtp-Source: ABdhPJxBIyoTzjFkSmw+UrUVCZ7z02zu7he6Lkr+xuYoKrfQxpYnlRbMAbObbYQWD8oGx/pmXT0stw== X-Received: by 2002:ac8:7c51:: with SMTP id o17mr11750971qtv.99.1635787665034; Mon, 01 Nov 2021 10:27:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 24/60] target/cris: Make cris_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:26:53 -0400 Message-Id: <20211101172729.23149-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635789382310100004 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 Sun May 19 09:23:43 2024 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=1635789232; cv=none; d=zohomail.com; s=zohoarc; b=D2rgf0rAoFwDyt5ztFvex+uGSJ8UmoKyYXcODJcrrMaase7QX2xi+G1m4pw3D9wC4wNmYguivgpG4/BKsPl2Lbm0ERfNR3DuWguw+PzjrNVfxPgPwTj63sjjC2n9q27vvKA5JM5kRbj5QeH8/x8Qq1l95I30RHfvwSOLNs8HRuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789232; 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=A7ENTKJLNE+FrcWknNfY0JAr10L3BYbxw3NL9d1mTGIxxMzF/R/nHS65Ess9vfo7FAftQDnav6CoSm0MbdzcF/Jz5hj1TZ9VHVpp4pmSTDcWLdNb2GywboYlpJFpeoTl4MwXnj492jpdrcoWunc3b+/IlfXEj0qLEuxvobwOHmw= 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 1635789232329490.74041629007536; Mon, 1 Nov 2021 10:53:52 -0700 (PDT) Received: from localhost ([::1]:48020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbVH-0003Z8-8W for importer@patchew.org; Mon, 01 Nov 2021 13:53:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6C-0003o5-7p for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]:33602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb63-0000eV-KF for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:55 -0400 Received: by mail-qk1-x733.google.com with SMTP id a132so16129125qkg.0 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=z8ecs4LTwGjkTaIMjFwaDU18rjRNxTTeFlYdhpfOXR8=; b=LmMbj8qzjRgQykPT4dCwpD/o7dhNRuK8kbb845YFRuC5ISdf0yKGyyToIO6la0qbiY cozeBZgvDYwx9Qc4JZ91TKs1WYB/bmRDaEMfn1EzK9IEcJ+Pu+RybkbmedUzHMPYA43u V3MsgoFcPJRna06gS5X/aA5OpiagMsxqp+8PLGdYV2aPle8cfu1Gjj6sMby9ry1WHYEt SYGBG7HtFbCkEP2XEzySjo8u+p9RywQDuCLa6NXPTj56rQyD1ziDft8SeLqn3bvhIcWB Xeypwx3QGULOLwbSPtdqR3WXSw0kpzs+mIinRgU1ViqvUbU/dlIugKajRNON9wGDiFAR 5crw== 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=rksJ3bs8eDX87JodZRD8KAdQr9K/HnbbNRRQ9ylGzAwrOZ8XxxEfvCEDzoLcMzOXRN S7+snZn4ZjDYmXmT2pz1PIyk161QQ3UO0F22M+5nUDPAkXuRszZrUyq4PRWZI7+wmjLz apz9PoYxaObXVUiDcAmVpVwC0OolCvezoMslKkzQsSijAoMOe4/P0rBoWNm0Vk4LlyOz jvo+ksV9MI3f9sH87Ml1rTUx55/QesxpVMQl6DtgaqRHZ4OU86pJluSUfXtnWSiiMEoK ffOu5uxkLnAuUW+1HgT6nVCcw/7K0jGjPmSAbSqBqC45Oove45CrDGQplBctf8lDkE5r FayQ== X-Gm-Message-State: AOAM533p93cIgD2kX0bmIDd/IwcBm96fS6uC2/B5Zv66r2/4rekowwVe aZ3TB36PLuv+/kQhrs/69yW4zrdMwLjV9w== X-Google-Smtp-Source: ABdhPJyy4O6V1oGFXBif7f3pvaMu+LPtoRg0nLPzY79yQwNk+26OeWFbNxTyCcKnVDPPREN7lEcCkA== X-Received: by 2002:a37:ae83:: with SMTP id x125mr24420977qke.37.1635787665694; Mon, 01 Nov 2021 10:27:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 25/60] target/hexagon: Remove hexagon_cpu_tlb_fill Date: Mon, 1 Nov 2021 13:26:54 -0400 Message-Id: <20211101172729.23149-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::733; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x733.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: 1635789234166100001 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 Sun May 19 09:23:43 2024 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=1635789114; cv=none; d=zohomail.com; s=zohoarc; b=WmuE6Z2SczHNLbpLfpluU+ubHP4rRKIx4yqLXGoeSvBwRCsT9YI0vevbRJlpxzvB7m9Co2fswr7wiIjnkS7gMshDEGpRpIS47xzz9QCT6NUJBWM5sk1+tHTkjMNb2CbIjoHPeuOuDt9JJjkX7lv/HIU6svMBhB0OcYaeC4bL9ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789114; 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=g8izGBP5Et2ahPzYWgYW059ofNdcTc6e9P/pAeGlgBbwtFuhR3vOMBkiKx4IIADC7y3KAFU7Yg6aU8mNZQ+mTURFhPdvK2sbGtEhyrWqXcxIDqUYW2zdu7nDPzfNhYSl3YxZgiAWxCem967KxaKpPZUodx9DtgRhpzYrFjf6R8E= 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 1635789114544456.5061507067535; Mon, 1 Nov 2021 10:51:54 -0700 (PDT) Received: from localhost ([::1]:39538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbTN-0006Ld-Fx for importer@patchew.org; Mon, 01 Nov 2021 13:51:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6C-0003o7-T2 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:45676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb62-0000eg-WF for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:56 -0400 Received: by mail-qk1-x72a.google.com with SMTP id n15so3733959qkp.12 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=StWIwDrqZSFeqnqFg+3hcLpPKjUfEIhsbr06iPdg0Gc=; b=rr3XMECdGPHlIqWddEGXVZMaPBWwTgH0egnh6lDpxX7kumzyi5/glzuvm5yjDjn5ZN h551eeQbX358oTL18TkjW+HlPBI2Tm9nJZMyaIwsuSs6RGf59xMMOnv7FzS6R+6xLQoW 7VRPODVDUbTyytF6WqCa6vrabqq2KW6/wuf7HFHu1INWLkSdIHFIaniunO2JBawmVYBp a37vUmvVB+0GbhljcOgNWc4PuIZY/R6kKhMgJrYIGIBC+hX7opeXjtHz5Uwb3eKoG0C8 DgeLylQl1Bd1qd3Mw2TtUfRfzmp6RWXXY7eVb9P+MGsT9arIO/bHowaGXS0P9P8Bow3x ftMA== 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=wgWKvjb19euWRphhTBgWj9zQUZiN/hnOZSay6M//EUOPK4+fk8Ytx3QuJFIROW0KHW /pJe96uz3l+098FKhxv0htgZBuy16DJ5sbysM+Be8CNTcUutkaDmJRVCbzEzdBaq29t9 u0HQgC5HrhvyIHZfe+1LaCXjoIIBA8CYP+xM5ChsXeDvlxBi6lL/KDmHPPQ8Ql4Ot6Hp 4xc4nFOZfhq+5mpP9xPXdomHEeFKHa8HXD/lk55KwA8U22hK2nEOAsteZstFrYv8taEa 5ezcq74k77+5ggGz5nk3uHqD7wA7YUCd0CZVVQOwMr0LLLHYlnZmmf1Gywiii8vQkSee 58JA== X-Gm-Message-State: AOAM532jiQB/f+fjiCWsEIxbCyr1EwcxlpZneFmpVsWwlbb7Yxt26U/K Phz9DGoAx4wbU1XzhI2leqaPH7qv6wKk9w== X-Google-Smtp-Source: ABdhPJxha2WgOnse4HiQgz9sD5vpgGSVxsMPtUvVIp+lQqCr8VYnKzugXZr+xCSM2+gomDbN0uAaPA== X-Received: by 2002:a05:620a:1999:: with SMTP id bm25mr24307853qkb.40.1635787666241; Mon, 01 Nov 2021 10:27:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 26/60] target/hppa: Make hppa_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:26:55 -0400 Message-Id: <20211101172729.23149-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635789115229100001 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 Sun May 19 09:23:43 2024 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=1635789271; cv=none; d=zohomail.com; s=zohoarc; b=hr7lLnlsXp9OwsMnZhHL8xgHSPxTYrfaou9HlS9Vnqv3HhWRl/Z7MTvBJZaK8/jPNK6lJTxr5NMhOrjZC0gQkPmoRGgEPKHBGCZ6OVVqgD25/exRfI9jQhr7SnRedqHWreJeIVT9Ukx43Z7cacY7WiSyGVNVxlN+qEZ02ER+Jfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789271; 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=jTn1RJeBkXH+RQ+JF6wB5bXLNzdAXFRw2kXcoIxMShSstPZ2GKmxo7wBsvRiAoa+y47LQtuXm0i6b9G2b9bPKvWtSX8Bug7f+SkO+4Bmnrm6BFk29uxa2qbHC80SKz4VLgTaaKeU3xxpwI/IO53CqodqquFbTREpURlVLTF/dZ4= 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 163578927160519.402120042633328; Mon, 1 Nov 2021 10:54:31 -0700 (PDT) Received: from localhost ([::1]:50908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbVu-0005TT-Lw for importer@patchew.org; Mon, 01 Nov 2021 13:54:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6C-0003nz-3o for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]:33556) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb63-0000el-Le for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:55 -0400 Received: by mail-qv1-xf33.google.com with SMTP id bu11so3795098qvb.0 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=Bcv7+vrfVWDaxhREKP7oW3QycojCjuZf0xWMtNuZYi8=; b=tUJ6NGEblY1X7fQsccxxNFdG+BN5St0p4hy0u7ZjpCx48TysS2noEhwRFPlFISx/qx ODh/Q/F5NGu4sUkW7i8MGd4KvJeWjm0f4dBgWVK+EMgln4oD4TO7nr9Fya8arKgS2SXt pfHFBQT/K/NYosND2rekydk/ViwRbtKAw5ibiBd2fr7tCqmHoXoC24zFWqQsKpI/9Z7L s1rC0qqWLLICpD+fUgBmkkM+Big51F4RO2/T8tM6GIguY7VJ3FWxk/frtXhmKLy91d6n Q+pKImJFz5JSZQlUEqC4U7ZTLxHJHu0Q/roaXnUSM22RfLrlWsqXCvPFNwWYiKzDu5ij Em9g== 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=r2tfH6ja7cYLUUlV3Yy71i5BChFVNRSsv7DuhmV67keve8OX4gLIjPeP+NnXAtdf50 BbGL0tgET7tatENFKhAQ1fiAplbI2zbvERJKBvm3sMDDxK7vu2+YOytzrmUug598ORdw 1qyCZdE8i/ayZZW+Y5SyXQMr7IDM+U1EwhH/aDu6pVddBuSbmC9XWYjPrImN5bBrTqzE 06HKt79UPLrGCQUSbVgTnGg7Hy1/ax6fFKS9QxYTcozEwtGVrKeObjdeRxzd2pPamHgy chv8tnuAeLorx+xYSdLBwEUadr4fJPt8Xg2a2We+mchx+H/Gk6/2hqtKsjYgGfpqMh3E lFYw== X-Gm-Message-State: AOAM5323Tk3LKzukB9gPm7zSkMrZx5a8R/vGfsPP+3cfZzK0Z7j+Z0OK vh73iuA4jEzteyiuSFq7NHInZp7kVJlG+Q== X-Google-Smtp-Source: ABdhPJz+lGjHPps9x2w8LvJOi4jAUci5DV8fO590cPVHse79ZaICbGsk+MRguhiYu/CasafLNaNnlw== X-Received: by 2002:a05:6214:234d:: with SMTP id hu13mr19723826qvb.7.1635787666724; Mon, 01 Nov 2021 10:27:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 27/60] target/i386: Implement x86_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:26:56 -0400 Message-Id: <20211101172729.23149-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::f33; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf33.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: 1635789273591100005 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 Sun May 19 09:23:43 2024 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=1635789138; cv=none; d=zohomail.com; s=zohoarc; b=aSR4Xdc1ol//VjaJSuWTjErmvxSWaSmFNKVd8CAMfqeRdH8VM/X0Wgd0ho8sfP2gV85r5HiUNlq5LV+RqI3QJ3QYPYkpCwRlkk+GtF84Uo9bL9TD6qpv2ccoNVD+eawbduZoMisN10VUCPYE7bNDDJa1UyWv8RQOLxIC6x1z86I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789138; 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=GmPtUwrnL3qm0uClZi/DUjO0bLr0EpuoMNgMrMKqHU8NTA1aRnPuvUvl851tHmtj5zMv7f8ysJ+nxH4WhzW3d/gFYrubGwWGx5wFqa+litvfwwjKc0CgaXUBsDFJSaomQY4+yShWbQ+TRp4eEQswLAUFgHVGmbi2RYbJgl1vnzQ= 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 1635789138705206.30550996915258; Mon, 1 Nov 2021 10:52:18 -0700 (PDT) Received: from localhost ([::1]:41290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbTl-0007Wc-Jr for importer@patchew.org; Mon, 01 Nov 2021 13:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6D-0003o9-4q for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:39599) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb64-0000ew-34 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:56 -0400 Received: by mail-qk1-x72e.google.com with SMTP id bk22so10495235qkb.6 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=/utnMsLyouv7LilvnHYZPxrZ8zRoC/jZ7xS1qGJE894=; b=uMRuFyoHe3DFWXikZOF+KRdmMfIB3Xycz61+QfhjHQoQ9H0+wWW/XS1qeDi3UBFGoR YbE9GSDJ7G4YjZfILJGQlaCKSL5r3rHFvH+u0MGaG1DYMsElpBaxqKW4PU0V6OGSGFUq q38fump4Pf5i3wUFwxmLs+5DNBodPvC7f9AhEGY5oycL0NGix8rFh+WlXds2uPUHCrpW pbIRz7wZkXeE00rP1vP1FIoF+6k/Wm/OjAIBYviSMfd1PeDUomb6aOneTTZ0y9MjDgE6 ls+k+BQP8nfRj/VCzAfP5eZUN+MLtH/V4p3GJ/6YH4KVsxWmw/mwBj/mKSgUqpGynOhQ MHhw== 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=XOxn4ADpvbq6oQ9QD4w0y2LMzgNls6UW8CDGgJQArE4MSrza9LdBdj7vXR0FLikz2U SjA8quIrl+r9JM4K0BfKfDxoSKOUi7GZ68gaq5xA/ub6+AMQ4fJmnexCR+XUls/HxhlH 4z2hBrLIg+Qsj9WumDksvS5mpzVBLTVqksVkOJqF9tcbgISzPDSjbvT19IdKCn2jtFm9 oGVzBHAk0z3YzyoucPDQD6wBJ65WA+RsFdAO3ukSCY/jEKvnEbyJQJEDGKf+jzv3h54A p/xlqFv4bAF+2WZj/sLx8A1repYbBO79jGDvZpt6SaIhcBXKl/U9h1G4YfV8xX4t6Fh1 oPSQ== X-Gm-Message-State: AOAM530hZWKF2yFoEGHp+R9Yw8+fcf+D13qxfR5PyR81KjGxnhFq6No5 moJqz9f/EBwtcZsEFL/Ufyo3K4M8qcfxBw== X-Google-Smtp-Source: ABdhPJwFFfl4rfAOS9fq1xYD1JzgjZr6MU5GmsyL2WSLvI2bHlSJD6Nh/dyGv96HF8iquS7rWZSlUg== X-Received: by 2002:a05:620a:2545:: with SMTP id s5mr23473450qko.323.1635787667281; Mon, 01 Nov 2021 10:27:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 28/60] target/m68k: Make m68k_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:26:57 -0400 Message-Id: <20211101172729.23149-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635789139792100001 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 Sun May 19 09:23:43 2024 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 1635789491064341.3415380752666; Mon, 1 Nov 2021 10:58:11 -0700 (PDT) Received: from localhost ([::1]:39812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbZS-0008Rh-5D for importer@patchew.org; Mon, 01 Nov 2021 13:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6E-0003po-9u for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]:33547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb64-0000fE-Nr for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:57 -0400 Received: by mail-qv1-xf29.google.com with SMTP id bu11so3795133qvb.0 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=Wm8ynGMh6kJsv+mBV6l6SdFFT71ClM8AMZtK4AOJ7uE=; b=Hu8BKDqXp+ml25WceAruJPaBNmIz8UzmFA5AYzbFegacL5JwezXFN8fsw7ucofVZew PLMs6YJW1Ca2TZNb8Y0p6oNhEfRfDiZFCVVNFUDlklKl21GOtpFe9NNDs5RSWzqRy7oP in/OW+FFHMDDc67l2P0sGY4Dt/Gw4+gjd5PKZNGoaUDxLewqiqY1ZT2OagLvCROYUvB2 j1HkhTyDEQt4TLWNO7rjcrezd4aa1etzgkSaNeKk+CaIjbNJelknk6PAK7GEFUe8VHQm TF60/EGnx4DhT4Vjq4azjiyF4VKdjVCP8gZxiAfHPVUcCINOoXx3OcbgkhsA4k+wz4KG zIUA== 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=UphJZvmTl7f5hwpj+9+gCEIjk3N+3EeMn1AR82ARZR6adEgYj6cegRxSWuGRCliUB2 0XhgVc9eAbrZRbBb7n/1vdA9Hir8dPZzUFLBiZjcR4fXPbZsog7N0VbDvFHST4A3Je9W Ln8UVaZNYjY1S/zxDCqhj3OsJoRQs/5H6MogRAPl/TZacspUaE1tdvBq5t5AEgQ059XL HXLjnLINMV+5lWP+XJlECZmH7yD5l3ic0IaWS8CKJmaCzTY0AuXcEGerlqu4iAofaQoA cx+locZ2xebq2ZvacSltnBLUYF5RqYoszn/HksFAYkrqtzur7z5FCU2IJpLlXs+Qjwta mKMw== X-Gm-Message-State: AOAM530z3mfw6CLeQqCVGV/JAGW5pN9agfyZOTW+QKKI1Y9/xx2vTzic C31PeKHYDcGXGpaudvs2kXPJiqVgFDGsGg== X-Google-Smtp-Source: ABdhPJyp9eMyRF6XyV7cPXZgURO0aQ8uVSUeAOdssdny2FipJNGLE+DnWAq6I4b7OjFNE87RmMSEFA== X-Received: by 2002:a05:6214:1d2b:: with SMTP id f11mr13966991qvd.7.1635787667910; Mon, 01 Nov 2021 10:27:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 29/60] target/microblaze: Make mb_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:26:58 -0400 Message-Id: <20211101172729.23149-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::f29; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf29.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: 1635789492416100002 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 Sun May 19 09:23:43 2024 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 1635789250625804.8380855338464; Mon, 1 Nov 2021 10:54:10 -0700 (PDT) Received: from localhost ([::1]:49802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbVZ-0004ke-LH for importer@patchew.org; Mon, 01 Nov 2021 13:54:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6F-0003uQ-CK for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:37834) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb65-0000fO-6i for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:59 -0400 Received: by mail-qk1-x72e.google.com with SMTP id r8so3405451qkp.4 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=ap2DHedkoq+uxK6WhzWLDOfP9mxx1Wp6apyTQWx8z3U=; b=EtsR7E8jvdV/d1tAfgeKkN5v1JfVO/hq/YXzwuRfFTuU0TnilrYaukSb49xw4rco8t fDTaT2dCb22fA9ugOdw3N+oO/9mvHPmm5NMtF9SzQBE8IZbTasLt3DuJ1ltE5NaYT0b3 W2RchqFNxK93G/PF+Luint5J5hsNZvztskqmCiawmTrIorJ9HqblMnXN1PiQ+f/cJKS3 7Py/SfR8Qw2PEZUYj6OXq0PucJ0XPyXrvY+L9xT3G/L5QmxJnRbhtI9/BzX5wCFwKtGQ 2NSgA10IQDIKHMKNEIH8dLONYl6ajIVOQiEX2uj58u55DqjUQB7YEQyIkqjg7q6LIFzf /WvQ== 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=NysGatxR0okUbER4aLK7wcVxnk2B8cWHwFQ29GeRtfY7pA+Fl9ymEgZc+M+Ax8mm+x 0WUflcaJeYMdpM7yZDGIp757DW4nbqrEa2z2y/QhJIMj/bhQTotsF1gf+OkcQIIU+tti lKcEhhOynl+0oA6nAwL0kcf/nSiF5WV/D+9nkBrFXdrWU2Cx0x67vzbY7iEFk0ZitIwv 9UhQrGDH360JfFw6Z4UaGgOy0pY5hMvX/1FzgOQqjFIh/u6gJXYR8LSXOVfpIFnT1ezR XFVGdmXdbAs4YwEw/LJaRwlw4a/twE/Mc4slDrU1+p0m6AmGE/GY2vWadNszhEkjPpbm LDRQ== X-Gm-Message-State: AOAM531Rhsp8GdUh4wMQ7FnDSWzXa8plazOPrNisCon7oY+juN++wV3d chjc4oUWhL+Ql5w6CmCseHlzONrGctpXEA== X-Google-Smtp-Source: ABdhPJzSKRmgdj4gsDMy4pHTTyp6xdUtKAZYNtwnTOEQmnUXAQ/5J1tYv6TB+6im7iN8nX6APFeQJw== X-Received: by 2002:a05:620a:3194:: with SMTP id bi20mr11212455qkb.478.1635787668424; Mon, 01 Nov 2021 10:27:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 30/60] target/mips: Make mips_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:26:59 -0400 Message-Id: <20211101172729.23149-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= , 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: 1635789251774100001 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 Sun May 19 09:23:43 2024 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=1635789617; cv=none; d=zohomail.com; s=zohoarc; b=Ka8a0Nc3k7PvHPKvcT2T9gB87VGlEv0gpj/Za5jdb6DYFA+AyYS5JRAvaVc2zER4HClT09sH+9lTOkddSBHsK2K5OMCDmeD8j/o7hA83Gg/EENoyvzLzJTmQ6oRmm9/B3D3o2PhBWX2Ju0yLPTiIsSrupUxBpE5tn5C/ugvGXaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789617; 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=WoZWj4CYZUMsBWlmnZsY5vIzWWvkpcnEbfPCRTu3BpSen9rdPNebdEY8alVwf9RGh6Miu9FuF5BAjRf19nkKEy/jKbbC+6ICnHmKNKiZxxBEHGu73Fgl82jSf2LClEZ3bDdYvOBXPzFYI7Soqhg31tEB4Rl4hDJNA6TqGjc54hc= 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 1635789617406612.3034198701929; Mon, 1 Nov 2021 11:00:17 -0700 (PDT) Received: from localhost ([::1]:45432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbbU-0003kn-8A for importer@patchew.org; Mon, 01 Nov 2021 14:00:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6F-0003u4-7k for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:38677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb69-0000fW-Hp for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: by mail-qk1-x736.google.com with SMTP id bi29so17216993qkb.5 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=zhmoQq400LN3ckB+F14vIMLu76bali80G5XXiJl040k=; b=RwxJI93B2WTakdCMhcPmizzdT4lvHvBXy9PrGrUJcBRA4a+mgv40MIiy2zJMR7Jpot tNDZ0iEaSuunim+Cf+mP8f2o5gOcxJyIBPebfy6Z78KxOcwPDclH49G1Hvqzn/FbPA8q yK2kP4dlwIlnqAxEuaxxTC5jgzqooJwNf+Y5L/rI+DSO0ZUXStqBTy7VWUCw91jSnBW8 KbDzAPiEpzBTD8gMyT+j9LSY29Pp4uKgga3ll+U8NaZZ9L0bDfS1I6blHmxHko48jIFn liurLajAhBY3U8xmfhTMPXR5bJSSnm17TwmQyXwsloCuCZgvu2LZLfq5NyGdIaEZOkgt a7JQ== 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=jUqmJNdtQYxAOarhoO9XttVEP01QYwWVdHanyqAjPxTiGji8rq/WewuD4paHom6w5g RQhrhAsWJ2Y7O9NUwvxYBmMEJoVAPcX3JgyFnBXEGQnDX4nfd0IQLYXPMvyBP/9Vju3f 8L2U2/wBIkVJCGj1d43e2GkQ7FMplT1wKPxvBJg8rDTLSTely8ivfaP050nsDNrHsom0 OtqTP5MDO5oATnmwhc81rWoHjwA10ZoVav7WaT/XxV0Qv4uqPCTLdrPAHetlKTh28jUn uIBH80VprnyS594ha7bvLTP0bO3Sy78VKBnOfAwmH1PKQ1p1ankDCFOqt22kIaaLA+C6 5AjA== X-Gm-Message-State: AOAM533XHSnnQAJAFHfWQtylapAzFVuuCcuVD/I4SejtYC6KyHsiJVrV EERqm/M89JsJCzwnvJNkKMEELl3NiwosyA== X-Google-Smtp-Source: ABdhPJzguoYC0SBV0vaqjaYtvqdlJVvJxudT11k7f0wXIrFsRg4jtOcoTG0VPo6qNPXWIZFiTY69uw== X-Received: by 2002:a05:620a:28c7:: with SMTP id l7mr6716849qkp.375.1635787669005; Mon, 01 Nov 2021 10:27:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 31/60] target/nios2: Implement nios2_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:27:00 -0400 Message-Id: <20211101172729.23149-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: =?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: 1635789619522100001 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 Sun May 19 09:23:43 2024 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=1635789457; cv=none; d=zohomail.com; s=zohoarc; b=JYn9qUgDTVmVGcACkL8hJJ9VbicXc7qR3wp56ZisU4sBYLqov4XVyMGGEqHB1TA6lCfU3dtjUyIxNT3LTBEbN7+3V7kM/hrESUtOwE+M5yNVokElzebkrUfAUn1IwqxlV7/bXYYI38ar09YKmNQeau4XUZrHFxVshhvkjKYBZuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789457; 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=XnLFrz8UPCvOHtpkqHv2FiohkEDB1PQpv/UXaCMz6g+GS02qleTA1b5vzGoOnnhqmYnCLoDW7C0/9nL+bpFMnMIVBHQhevYliAHzl4a7iEM/YOu0p0Kna9p4VUpD+kZT16XQqTfHslAb/3vtMhROpGNcI0KXRhcNZfO9urmfNCc= 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 1635789457241257.1440659718935; Mon, 1 Nov 2021 10:57:37 -0700 (PDT) Received: from localhost ([::1]:36856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbYu-0006W2-0Q for importer@patchew.org; Mon, 01 Nov 2021 13:57:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6E-0003qk-Iu for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]:35446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb69-0000fc-I2 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: by mail-qk1-x729.google.com with SMTP id az8so6041119qkb.2 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=mXI5pLklfarH8j3WhgGW5xn4dLCOLkkDAfhYzkOpzbo=; b=o79TDMCIth9BAZqN3Dhzf+fW+9FveYliyLR5UQxymmXnx6C6UO+0GeIIxEUQ/8cSOV WV7HYQP6L+3waGhKz1u1tF3P5Hf4fX8Swhpdg0msFN+r+gsIR9W7AUm4mw5JqDDKIo7H y8VlLZ7W1VfAB7KQQIzaKke/qisJEKifNSxBpUiumCiPwWKpay/bVf1nwHV3EGw/P7Z+ V7MdYDPTnCktsj7f+SkWIS4/1frP/upJ6J5xs1bn3IBOMXZsnFOA3vTf1LY0ggqmQ1Sr +PINVJMx6r1CIvrfRRAP02S9fTRSP7M5s6bmBBqzYUUQQqEGUWkL9Rd3Avc9QuGr/t0Y DLaw== 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=LKrVSKRfp9FA3wHzkYvksWPvOavj0swLLCUokLS3Vz2Tss3zqy9vma6UbiFIAPvaXA OGuh4+J9SXobo6c30Ht+bQBEs8NiFyGcVbMLZSqFG8rb4BgZYUaLbDFdwrNzbYyNptX/ 2JJ2ZvugCSK8nD0ksNiYuIZHAsHe7bdaKJBI75KtUzNXuiANSQYLryu6EkldyDeXAp3E 8MooSt9XUysyWAvt6k5eFxgdxRA/rnaikokzKTrRNO4rupV4EUGkWuoAWfou2TId9yET F1rihukTbh4bS7G9vY9Uzm54r+p6IEU6VaTpTKqJ7NSC90V4p7JMaNrg+NuBo7hQcepQ n7HQ== X-Gm-Message-State: AOAM532sd6hIDrXJTT2gszyX/3M+V/5Q7P+15fZ3p+x6Q0N6mkKxMLRR oACPvkVriIEvBW4UCGEt/GSF1DsbyBkfxA== X-Google-Smtp-Source: ABdhPJz6WfGmV2DnAnCuNG+xocC+VMPHp3rps6xZivXpBW/JrnEL2oMLc/uhZVGO1Jr+w6F6WOhFwg== X-Received: by 2002:a05:620a:44c8:: with SMTP id y8mr4458538qkp.327.1635787669525; Mon, 01 Nov 2021 10:27:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 32/60] linux-user/openrisc: Abort for EXCP_RANGE, EXCP_FPE Date: Mon, 1 Nov 2021 13:27:01 -0400 Message-Id: <20211101172729.23149-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::729; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x729.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: 1635789459164100001 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 Sun May 19 09:23:43 2024 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=1635789836; cv=none; d=zohomail.com; s=zohoarc; b=Onw3PNOh2BHsYe46Vzilfi/ZyK7VhIeQZQXxB5Pt7nXL9A4/+Yn4O6XVKFjGdqyIZHjTxvwAFFrrHsAhXG1X3z1WnpVhNfTjmr16gTumhfB43mvchYc5VIJctatmXQIvGkHMP+ixcOtacCh45BDwZNOFiXoQZ8eIlLT64Du6OD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789836; 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=mzbzKa7qSL7dZ4QQBHM/FXZVN48t6a2Nz+wPbQ3i6qa47VyrGAROZsCLT4vBnXf+wou4uT3SGa9QvEHjtZefC/cspmO9F1NXbx0LVu9qfiRpSHdCKQ683MymLdSRrW1EYY4uOSkqF719LVcJYtkg787TJRDQX2UaXIZT1+KYZkc= 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 1635789836011554.9315389357475; Mon, 1 Nov 2021 11:03:56 -0700 (PDT) Received: from localhost ([::1]:56888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbf0-00034F-S3 for importer@patchew.org; Mon, 01 Nov 2021 14:03:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6G-0003w5-Ls for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:33598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb6A-0000fi-Se for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: by mail-qk1-x72e.google.com with SMTP id a132so16129399qkg.0 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=pnbVDz2F7bl2MnMZvXAf7/LYYOvOlpdsDMsaNKSumSw=; b=jCAopIgdKmDshH9485eiYuo0XHaa2g3+RTqqygc+w96vZ6mJsVbrLd6cQ89/H+YbLn bikGKk+klu1w6bLaRmJmD+TLoZfp666qQFwGBXdhJb/put8O1BfL/HfpmYthnx5dFDRi fs/NaIbM2rMWlLVL1YTwfCDmmXYdrs4QlecIFaxd6Y3HQk912VXerXddgNIFu+ixkUbt x2SooLAhiKI9TAugNZqLkW0ooG+CuF/mSMhwzD1+e3NCcCrPmjVT29G8FOglo9Wmg6ho W2UE/R59Ngb8pFaCQ8aRbXDJTwFx9DUOaDIOu1xGoCu7ZRqcqp1y+AaCh8qWZ9Y4uk0X /AOA== 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=MFEOW7p1LRZd9ne4XjAkTEfZxbhwyApTH3V2jLGmRJD+JisdAmkVBFDfOKNw39rzXt E7u00jtzenqNMqbnpDcITG6srN+UXQtatJcRrjogxd8DWAE7unCIxKQ7kob5jZ6Sp6Th fdkPfJDfcSZ6xs8hEO//jyTZJU+mT6ch6i94lje8K7Lkdys+qFtyqJHQEaxkp7EzGasD /nnlq6K9SiWPNzkAMjtZGgwe2OoFPdHY0FJugqOcaabERVY1hXwGUphftSbxfOtOYWHD 3kSIYldZS0cQghlLmZK3y2NBBMJalzuD32HH4156uvmypaOBi41jLQhIcFNau0ZO7FTy M4+g== X-Gm-Message-State: AOAM53321E/jIqCa7ixzJ4dfTIIwD+ric3QrJDLn3TwlJYaCUU5B8jst aSFk2Qejn3GvRpnOK1XYntg8oVu1iPvfSg== X-Google-Smtp-Source: ABdhPJxTHJZghckW0+mJ2eaUHzuMvOTN4WR6mTZcSPNIbILSJ44TvSSAOvnx8uW46psUa+W9stBt3w== X-Received: by 2002:a05:620a:28cc:: with SMTP id l12mr16667918qkp.423.1635787670016; Mon, 01 Nov 2021 10:27:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 33/60] target/openrisc: Make openrisc_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:27:02 -0400 Message-Id: <20211101172729.23149-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635789836478100001 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 Sun May 19 09:23:43 2024 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 1635789685603539.240647036143; Mon, 1 Nov 2021 11:01:25 -0700 (PDT) Received: from localhost ([::1]:48570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbca-0005wV-Ez for importer@patchew.org; Mon, 01 Nov 2021 14:01:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6E-0003qx-NJ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:42918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb69-0000fn-I8 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:58 -0400 Received: by mail-qk1-x72d.google.com with SMTP id bm28so2116996qkb.9 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=b7jpFgMMciMmW9Xl8VdlfSERFh4gLfLYDvd7byDKhQQ=; b=VJuJMKaWdiOwy2VjgAyJZMRPlM5pmCZs9G0s+PfukhC2jn2d5a9/er+q34yL4C1HOF SLdE9Rof3gCDT1E2hp2qqxYvujjYzwjhMP0o7YWoFZCD0UlpvGoQoeq5VXYebBu6CINQ 7hEk6QXYWk3tfqqdw0/qWHxf5pRYjGWJy/KcXMAtnLmmiAN3xcKUJyHkvoiMZZrUtStP JckDP6HECTmOCe86HtdL00x5gftdu+w+uwJjRddEAvF84EB1r3tLoeY0IykfMDG1TSwE /aSDVx17JMwHuOMhC+4mA8pHXovZaQLt8is2iPgjoeHuhBbEMA6q9VrFk/RSGIEkyxn/ g/ag== 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=LZ4Jc8uksci/NS68AAz5fURlyDqUEDFEO/PwbZdxfWWGjWksexcG1fZ09YWqllprB4 K+9PjbgGlB60aweGhFqwZBJclvukdESXJaQ05ZaxmD6iSMP+hCO/NNY7geDzur7OV7TO ac18bcbeR8pSTce3u0FJxePwuNjQG6oBhqIkHqRwzIbhuA6Xb4jc0Td9aeR4koYdQbpq oxpmnMjYjYPspGgrggoSwztVnMpxeHmTf8G6LJP1IiJPa4fQhHX79n3yXdbzDzf+dbBT HvaoC/fdkMb2wueSTp3GMTl+jd2DraRlFwYgXaqxbzP3583FW+0jAvYIoPMY6dvhn5X3 OJEw== X-Gm-Message-State: AOAM530t9GqaHJmijF9BMd4VI+hYFWXchZpgas+sfpZclC8V46jLAxsl PDp5VieyavMAmwVpsi9LgQJlKynF9KulAg== X-Google-Smtp-Source: ABdhPJwD2e9hNhLW6c4gCXnLcy9QZ7Ch2FtGQlM5sO/62h09MvnQ0+4jFOdK7cAo1h6okFtT4I1JWg== X-Received: by 2002:a05:620a:12c7:: with SMTP id e7mr18162535qkl.520.1635787670592; Mon, 01 Nov 2021 10:27:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 34/60] target/ppc: Implement ppc_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:27:03 -0400 Message-Id: <20211101172729.23149-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635789687275100002 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 Sun May 19 09:23:43 2024 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 163578995175978.52216126648011; Mon, 1 Nov 2021 11:05:51 -0700 (PDT) Received: from localhost ([::1]:34776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbgs-00078Z-Ql for importer@patchew.org; Mon, 01 Nov 2021 14:05:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6G-0003w4-J7 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:38670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb69-0000fr-Hv for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: by mail-qk1-x72e.google.com with SMTP id bi29so17217108qkb.5 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=HtawaHYSfgiYXorLPYx7eO4JeOJDito5IEpdHHHLhLI=; b=dJj+mSSFptQx4/Lvl+mjYuEtJkxG+nE6EeioTsZC/eLGjtDKLHEU2M9HfeE7wrZSCM J0IvhhDLKxWzOP01vJyueUlhwuu/z/ouKHmWwYGxsS5AgKfAKgNkOmKW3FxJc5QSfQcf p6pfKxYhm5x5AJM7yvyGDmu2bG8hY3Llm2wH5IWPtBm4V9cYMsWtpdq93y0ljLnsWkcH f/c6BfNbYHjU1yDNzdXJIK9hEanvBSwpjkkfM0AqTYLvWfOOje17uQfk5T6nnHtdmJ9y 9hf9iAP+hzxsYl9iQAOfnxW/8aydBboEiPYtIrZ0633+YVlch/j1tKhBsE7WD1qrJ2Qd 1/lQ== 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=oOdGOOYJqaEAP5KEJTba4ap3bElGUW3YAZ2tgZpO0TRw3GitIm1NM1nZamDpA671FN dQzpGxFsLhx/5nyPcXx7/wjEN8+hoYabhN+o3F4adRV1nhFqHsOJlWn+zz+Chsysy6+c bXTVUGlf+3HM6oMbJJRUfszlrUPG0EQPYjl0Cmp32Ub+eRFWkwE+P5iOXWrAXZodTDMt mr/hJ8bx+4SltJQE6GkxM9R3clvM2NxQ8994vKNBKpWfN1Ht/2sluq3Y+hXdLiBFjiyh ZpPx+IWsPychvG8bpeID13NXZhFHUBDP2ND58wPvJGQcNPMIz+3azsHTKA3Lm24Jwe/Y 74Tg== X-Gm-Message-State: AOAM531VCITZKiATj+lG4pf7DIQndQGIcMLTLeIFE8d1GX+tKl7oyn7h rOCD6M5d9IS53+dPEPtlUj6YolgfhRDCfg== X-Google-Smtp-Source: ABdhPJxariVysMo/oa1V4vQeBWSnVMUz0fyEkd2wOsygfUq3NuiSJnkSP29h2cORvpNE6UHTk9VdyA== X-Received: by 2002:a05:620a:254f:: with SMTP id s15mr23849778qko.397.1635787671220; Mon, 01 Nov 2021 10:27:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 35/60] target/riscv: Make riscv_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:27:04 -0400 Message-Id: <20211101172729.23149-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635789952501100001 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 Sun May 19 09:23:43 2024 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=1635789685; cv=none; d=zohomail.com; s=zohoarc; b=mn8FtNIG02RZPrJnn69QX5v9dWhqGgFyxuFwWzUBn2Rs+0P5L0zwGD81QJ/2oEeO6YqPyiM6haQveMAfr54sl4qubIlSQzGmYRGGvOVZZHCSTSZ1xytdyeVbNaQxI4Cyl6GzVt5kevVjUEL1zDW9tEuLo8WmbP/ZGg/Sd8UG6NA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789685; 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=UT/p84ffUn1zG1q+hPN/m4wP3vQLsuc0HycFcC893P9ZS6XUC46EZyzIXJy/zCNKPCXPIO8ittQsYG6OeH8Zkzlf5v8XJPzW/ft6USAhEofG9IT43BSVd8xAYVHsWIEdW7GWKV24IXzPuzp4mVVJcvcsI3BmVJq/8e5acWWv3pk= 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 1635789685595744.8840861423462; Mon, 1 Nov 2021 11:01:25 -0700 (PDT) Received: from localhost ([::1]:48484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbca-0005tW-EH for importer@patchew.org; Mon, 01 Nov 2021 14:01:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6G-0003vf-EQ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:45992) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb6A-0000fv-RO for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: by mail-qt1-x835.google.com with SMTP id r2so15235257qtw.12 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=Ky6yY478j1xSRIHIN9BTjrdKe+bHyugXQSySqll0teU=; b=MKhXscidvPb6EqsDTUo+4VxlspmHziy39kEabPo2fRWtR+jkuQ9ijJFzNkjRZAmR/s /keFdev5nObKAF+mVowNz6+MiT9u7gj3kygbhNl24ae7eWZ8kwrXkeoDFvSnIJIibjFX JYb8zgKAaVdWDkEi9sz0e+I6YrpvXCXt1cVU+Xo8X2glZcA2+mQIGymXQ0JZ4F+kxDfw FooTcdUF97CbNDXyQEOsD4WrU/xdiG9jtbJlFqf9Oqblr/jaMv3hrpu9ujvMlV5ubM0x DPdL4ghGz2YSCPYjH4EbfqpWrkQNqk3igGhHLuh0607JqYn8Gzdta5rVLRTPJhEgQua8 rtdw== 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=oE0r/Qwbfl67if8bbazyxlfJ6T1U+AHdqvaFI9WohGNE8D1QKnFKckUQsrzIye4rR3 NhenT3M5qa6UbDoW+Y9DgWOeO1UJIQh+te7LGaUU8JjIeJ28cALWZYyTh4bU0LLJQUl0 T4DHtrzQIDznNVVg6JTdsYQXQtGkO8RsbiEMDmB9cOmsBCk/EDVPa1joKlwKJz1o1uMz TvuovG0dKRCAqbRySUIiJFylFPXbodkRo9vtFa6DDS6YK+jVJ7hLBmhFXE7zKIvEYk54 f86x0o15Q5dtD5EQ64C9w+vdsqZJAl//a3AINq0IZF/AO7SG1pJVC89YQ7PxjwuG+KCO ue6w== X-Gm-Message-State: AOAM5305TUe3BBO7Tp7RSiKjRonWy9ZSlDQJg4VR4lDAc8MNAXE83omP FnvWsQY2G83wxefulvAgtbLrS/Yx949O1w== X-Google-Smtp-Source: ABdhPJwE7HPG31GIm3xWOxMEBRpodfGOFg4KLx87b7PKn+hI3lzsBTZ33EmOd0rm5gRM2L9maXDCmg== X-Received: by 2002:ac8:5f0c:: with SMTP id x12mr32094388qta.309.1635787671889; Mon, 01 Nov 2021 10:27:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 36/60] target/s390x: Use probe_access_flags in s390_probe_access Date: Mon, 1 Nov 2021 13:27:05 -0400 Message-Id: <20211101172729.23149-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: 1635789687244100001 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 Sun May 19 09:23:43 2024 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=1635789796; cv=none; d=zohomail.com; s=zohoarc; b=RHejAJUYsOV412K+UqB+sXqJuasDYv6nm5zT1zsLrMVYiNCBhW/YGLTUXWcFbfhtN+8D+EThjKJ6cRkRgki/wQwqDEIjGssAwdSDD+Cz/mxyNswi2HT5W80CB6dq/S7nFy/mdzoaobzN67jBtCrkmTG2lKRCqhqwcQlLakzn1RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789796; 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=Ni0+M14J56BvEB1y1mAhZI1HbpjXo0XxHDNMZ73vNZdjEFaG1+8D5sU4cWtfaTfPPMH2URsNSTVVS0rk/mkLm0A4gXl2e1WCZabYpwsXYnwU2lHxdjlI6BSWlWcuDwl0qjvm0cDGj0GcBhtCrCSMYurOm6KvMKtSqT59lm+e9ng= 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 1635789796286754.1958836051227; Mon, 1 Nov 2021 11:03:16 -0700 (PDT) Received: from localhost ([::1]:54268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbeN-0001KS-9n for importer@patchew.org; Mon, 01 Nov 2021 14:03:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6G-0003v7-Ca for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:43689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb69-0000g0-Ia for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:27:59 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bp7so11992320qkb.10 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=ij1YRgU0peRo+QSVg6ezzkIr6IGfKaWXUXRkApukMz0=; b=y5unP1G8umjeK+1689CXhRdpgKbaKFALVpn61wwJSDW7hXhnZFi5ChtcXLqs5XauQJ NOHBXd6Z7LSu7gUpWUJEU2o4TeSbz3Szh8B6cEXdN882tM8PYqhtPcQgPctlqMx5REjB bwaHEgldNG/rM1K2EeFO0j4yBpO0uE8vxH9gUo06d3QqEcLxzb8CmLg3obPOfptGYFRL G9yEXI3OFLH9UdjgylLMPz5D7xiaOO32gO/hipGa6NLqgy+JuY76rw65ejbg/EskhDOx wtTPVY6Ahr0Kv/e8XUxAhdA67EX04X/SyIRTLUmwgjGe7VePmvzy4ex95VjB+pbXd026 P0DA== 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=1j7bBz1HLfg0QZQio9UgfWxU3R+C3W1xmE73AMBJO/qcfaTlOnpF7WFW2f5c4KF+gn lTV5cDymRGCY58p0raotE8bOlIOZ9TluN+zEfMgloI5SzEUqua5es2JD2NQU8xlKur7q su9gc9L9L2X4si7WSteAxjOYUenLZOdDXjQFXtUTAPXuTDkSJCh8ypa7Fove5+wlLTBR ROAFAZKOcr69/l+ATYhUjpV/RbKsKyNWgsZ2OVKW5mDhP+ejjxwcq3cgoU+KnyX877S3 oz16PMVRfryMQa7kZzdZjHEvWoX8vqY7dn8Rco2hVnjlABJuj3HEYleME6UupCTqbImz EVgg== X-Gm-Message-State: AOAM532vo8z/eOxhd+bAQ+bIHn3WVxsliC1+65ewa3hIB7rZ5BLmeggZ zP5dw3TnoiNjZfoJHdrxQB27Gog8nJsXNQ== X-Google-Smtp-Source: ABdhPJzvXpzzd/xb8t6ScNWdMEFRVMiEnABRiUv3p+WpLFjjwsjNVlo6ReEfyU2pmihFbZHN3orJZA== X-Received: by 2002:a37:a105:: with SMTP id k5mr23641085qke.427.1635787672533; Mon, 01 Nov 2021 10:27:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 37/60] target/s390x: Implement s390_cpu_record_sigsegv Date: Mon, 1 Nov 2021 13:27:06 -0400 Message-Id: <20211101172729.23149-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: =?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: 1635789796940100001 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 Sun May 19 09:23:43 2024 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=1635789491; cv=none; d=zohomail.com; s=zohoarc; b=c8q8Ix6ckLsbZouM70CoI4a0L27SXaxg52E/sotuh7exBZTmasWEpguuh8F2GsWBneMFf0q1BPHEvLmU5mWunXs3G4gwfk/BgAlniPlxjfXnASM+VCst5LsQ6cZ6pqLEP/s41BD8eVrMWGQB4DQHwNf2S9O/LmYwAFO12u+10MA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789491; 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=TrfLW9+eZLVMwagnh1SiUGIw3dfipSYwzVsEvcKMwRkxwHdJH7aOrgo1gFvJOJ/m+pQFYmSO7ibLILI025TTC/lRWvPM2mw8Lajq4OJXK8isMsu6kU5Zd0oMhB+KTA/9xmDvuDA445Wo1MEyf3YB72vSeekeUl6Vy9PtYZ33IBA= 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 1635789491285514.5373802124757; Mon, 1 Nov 2021 10:58:11 -0700 (PDT) Received: from localhost ([::1]:39796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbZS-0008RO-7u for importer@patchew.org; Mon, 01 Nov 2021 13:58:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6G-0003w6-Ot for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:38744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb6A-0000g4-U2 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:00 -0400 Received: by mail-qt1-x835.google.com with SMTP id h4so15922554qth.5 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=bSOPptd8n2vyIHjygFEkKtsmxu32Sh4/nm0zdx+yC2M=; b=VpocW1Q8s0IHHHfzGmG5fOCrimmensfERl4uBlNSg+9cfByiEwoSVDLKB5uEcmqpH0 6e+GRLL9py63d+krAhWgBU5nwtcNHiPBJCGvBlVcIQxE8paQV03xYUnyeBVW/WDbd4aw OV7nLnijqO4rUS2WVP0gGdcSfD1aZMzr/qEGkRuLEIEmjTI/6eya2vtl5URUn3FUnWiW 29YtEQYEmaB2NyNMe/P1vioWVBREAJkwMIun1WFvWBaBQeoaV590x7Tc8/PWSdnoS/7K WCKb4GUiOO7c4GUcI3/WX07aWKEXVGkHAomeIdl3JTMSSvwOsRPg6RJF9iSXLZOlMplq Jy1A== 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=b3D5pB4BwEAazVTVnm4cLiSSRN1gRU958UvBfO4c0TeIxorh0lNCGdQpYbhInPRLv4 /AXmWuQZHZAaRHqU24VSJwHy44YpmA6eOZ67F7lXYeB6tQGWBRG0w53J4CHRoQjAVjyX 5ArVaplIghvHQTsOV33148ku1Le0TQZZkkAhN//z5I/iyZd4vB1Zo1aVSRl/v23i9je1 IlCGXrUTx7NH2Q3FwUXVh4OVSINZdFX7rMuNFAGQNaG0mmJ/nADZ6Y/j5y+T5tzpJSyf oCAj/kP1i+Mkodx4UgbwRaIzYm7sSApo2hBPzZrymoV7tJRWgt1MqZjw+rDaXQsMc/oL TGYw== X-Gm-Message-State: AOAM532DsBai81z0zX2Ym8Js9c/4jBiJ4t24SPbULStLmPgoyidCbUKA WYgw1YAg5H+OCtkTEINsBUW4izCDaS0m5A== X-Google-Smtp-Source: ABdhPJxjvsiqQIWWlvyjjYaWrtUKiOg91hE8fAZwXx3AXpPrqpaABMPFj6QZnyR9vk3ENHruRD1cxQ== X-Received: by 2002:a05:622a:38c:: with SMTP id j12mr31842544qtx.63.1635787673114; Mon, 01 Nov 2021 10:27:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 38/60] target/sh4: Make sh4_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:27:07 -0400 Message-Id: <20211101172729.23149-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1635789492396100001 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 Sun May 19 09:23:43 2024 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=1635789370; cv=none; d=zohomail.com; s=zohoarc; b=TvDxl/lEbBJmHbc83z/a6/KLQxB8QzLD+e/0dfiCBCcN1TAjGm3/Uudgdl5axMHHFgDqjXsyOxgTpTJ8QRcItwlNqNVvOJEDc7T2/MUSFC8gN1TWwhGHvCeg/sLH/WVEZhkYi6dm+FUw5nSHhtD+x9bm6wuoLfJgfDiLNk4g4hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789370; 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=BIjX0gRiiHVJy2hoL3XBV5hlqgBCKEbNHmnTF71o2AxKNI0DMbO+OUqZrsNrEpFe3/LPy47MXvappwwIvYeVPLYLlXNp4MghrWYKWe7C8Ul0Kx66hOaR9p6HUHqHut7SU3wZi776vRB5pzRf0CCTDdQ1PsqQw0FOVrfiCQyldjA= 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 1635789370244209.02058157930003; Mon, 1 Nov 2021 10:56:10 -0700 (PDT) Received: from localhost ([::1]:58402 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbXV-000245-75 for importer@patchew.org; Mon, 01 Nov 2021 13:56:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb6L-0003wn-6w for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:05 -0400 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]:42922) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb6A-0000g9-Ul for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:28:04 -0400 Received: by mail-qk1-x731.google.com with SMTP id bm28so2117144qkb.9 for ; Mon, 01 Nov 2021 10:27: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 t5sm6075331qkf.34.2021.11.01.10.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:27: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=OFBASZgYo/dnEXgBhwjQsgVMikt4qFVfoC5aZFh8E0o=; b=wQI0shq0lD1M12UnnUQFskMElA1km38wJ5Z/OsXAGW/yzwzA9qKLNJNkTMpmc2w9BN 9bFWSm8ukNVm8xa+5YWogZSrczp4yDgUlPPfWXhdm25v2NLwJifZri/6bl/jzz+zVg6i qGsJKF0bzmbJwf8I4VbUtLjHMp8pde8q4fPXPv/gKWXh+p1hOjTwJOfOn/YBac8QsUxm JVCkaUbNH4jPvnHysx53xMHSbElFEyV1CZUthrKEhjBK6TbI33iKqd/93bT+4YIMGRL2 b4nt7/+naX89hZsVUOCBYpTjY1IxvBMiehz9IkSzCeuvHcAGkNHeuhzOYuOFvteDZCSj 9xGg== 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=n7Xv/RrLPX3yWXp/z5e1WP7owNabMUuIw4pSl9Soadp8NfJeYPhSKXyMNwiwh0eD53 xhD266I+Io97RQf9ywqtrBOnYpocwQTOwfxPzZmLJIXq2xftc1ltoatpSQ5v/s4U43Ro 9ai3wMj/tLTDLC2Mkf8HjqDnm8MYBP4SEQ3hngbRkUyA9oW17HbPbIDa7WoJLfvyPqJ0 F4C+20QMv31cWs9qdxgWFTMEuDBPYHFz6dyzKlkX6+o8OtMRZ3v5Ihdls02FTUrXI0Uw u3vWO6HHf2zUKe3gUZIjn65eN9/Kfds54tNsFlPZCmAoXNre7NeMFQor1tRC428O/fBH LGcA== X-Gm-Message-State: AOAM531EeC9o7EtQuIZwgMGGcEOHi7eLli/qBBfQvnCA9x+cXWaeZT6q B5/wdPBBnWsWD6UJ6YIiP0ocW1qfRjvVnw== X-Google-Smtp-Source: ABdhPJwcS8c/uB93M5wFgwreiqISHZuT6oT5i2ZMvWTcx0FBmvsrSV7NhbMF6MKhh8ofcxHF0cO0tQ== X-Received: by 2002:a37:9404:: with SMTP id w4mr24638911qkd.469.1635787673649; Mon, 01 Nov 2021 10:27:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 39/60] target/sparc: Make sparc_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:27:08 -0400 Message-Id: <20211101172729.23149-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635789371266100001 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 Sun May 19 09:23:43 2024 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=1635789752; cv=none; d=zohomail.com; s=zohoarc; b=DKAjBlycLzPIDaoPW3fBbpJAbPR0Xpwhb095luVZJfg0j5Ar95AQ3BwCHOI0ev89Eyd8OCoUVyBNLIyzVS5MxE66aPb4Ud5RdiAwktsHmybhhQW3y9dHicbO1HBUbf1cghDs10JFjNbmWZ/hKZpESPd5MpVAZOB7Ofyma0/MCcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789752; 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=cQmrboM1pjsgyWcCKog2q5D67KMZhcUdg/rvjj3M/80jci4NKVgGwvH6Rd3hEK0kb0JYytrwbfMLfXRTKPh9Rns4WX0mXOJEziia6XKqt1vB+C684D/WmqnzHeNtW3AoCozq8uDN0jQzILBHlKh2qMLBqR9+623ri4cdX1G8D6o= 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 1635789752961953.4119353518786; Mon, 1 Nov 2021 11:02:32 -0700 (PDT) Received: from localhost ([::1]:52598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbdf-0000Ce-TX for importer@patchew.org; Mon, 01 Nov 2021 14:02:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9A-0007ow-6I for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:00 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:35473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb95-0001BI-Ml for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:30:59 -0400 Received: by mail-qk1-x72c.google.com with SMTP id az8so6051415qkb.2 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=kAcqfrBKLTctf7S2SRnWlKvQ84+gE9eIlExzwRxWIv4=; b=ykl5ZlwRrgC7z3ei8BsniBxhkudtigX32LT3slXDyqH+3CxWVRyAZszh/Ix6af9v8z CQ7B1NMzvgxxJG4LCnOWZcEyI1sz7CU44p7S9IQCYQYRScgVZmZf8vMApO14m3VUL6sx vw6cfkc/0stMUln/tHjsv0XXh/EAHvD6nfE0wvD8f07RNWM+oj1prXA5nRrxpA97tElU cTSevb7GeUGzyF4QT8z1EzNSUjVXP/tyWntvlfg7ivZP/iXklDmThcgiq+fb6hcy54hb zmcdmpGCllGPIF5QACe2yl68v9vNe99tHyPsn68KEtI3qaU12/+RD0hggIN+yVLfK7ne Ul6A== 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=TouPE19wcBwCo+sRsMiLs2PrCs5zY1BvxHuoZAv1Ad20WFpa67f5XYoa584+/uhz+K wVFFyokLbnrILxuuXd/Qc1J2Fhik+46ZhDWcQJkIPKL1/6jI4A9Qz9L7JoRwSv1CgQY+ DsQnUiNSRE8H58ppccgM2BvV6cuMt5Pq6u2K0cFsEQtch1/aR+g5L1mB45/xykOK1R1g UXhBtiru49QZfazfPZTB3fuEvTnLqr/9mx5mtsruM4UjKREgsztPJLt9Nzqj5AYMsOBU itpYcnqcjsWI5I6z00udU/Z3q0RYcApMsvriDUZXVhreyNwVzBFRq1p2dLfTYI9pSL7t Hk4A== X-Gm-Message-State: AOAM530PGEVAPFuPEVTQB5VLtnXY+gkqaL+EYZzkZmwj2ul6ieUSSJbT QoYpIKqZyEktwSibgPuxAKSAjhcDdEigBQ== X-Google-Smtp-Source: ABdhPJykGU/bVIkxhTB52az3Uc/Q6QWofs/u3UdnIgI+SxlL5SCzaOc5S5zpaxQHE9b0Rf6LdNQugA== X-Received: by 2002:a05:620a:1aa3:: with SMTP id bl35mr5166328qkb.450.1635787854667; Mon, 01 Nov 2021 10:30:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 40/60] target/xtensa: Make xtensa_cpu_tlb_fill sysemu only Date: Mon, 1 Nov 2021 13:27:09 -0400 Message-Id: <20211101172729.23149-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635789754929100001 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 Sun May 19 09:23:43 2024 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=1635790373; cv=none; d=zohomail.com; s=zohoarc; b=lOnj9asnbkUr8vVZEq6kfglrMgo5s0ca+vUgprcH0zn9lQ2pJu23qSDEz2w+DclaEzmbQ0gCJfwHesbA2gQt/JCfiNiZf0+tVJAFc5qHAMecyjRjPY0b4OU4GXyN5z+q1D6nMyme5i6YCZ9cHDbpl9/U1560k/RRiiv9m/2KpuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790373; 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=VCouktvXfAga/GJWQSxzkyFIndwtxPF/Gqhqfj3jtoZ/U2lJ1VwSBjYA5UkqZooXaf7naeUZVTNTLaZFdNwuzRxraTzJyC9TIy+qQA6G4LlCZuwuMz1Eb4ij01fF8yH5F/N7VrQ8zpMekq67Jn7atQxHnlSb8S6DTHiD7avaIhM= 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 1635790373259259.37222384223435; Mon, 1 Nov 2021 11:12:53 -0700 (PDT) Received: from localhost ([::1]:48774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbnf-0008Sv-TW for importer@patchew.org; Mon, 01 Nov 2021 14:12:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb99-0007nM-K7 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:30:59 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:43717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb96-0001BN-FC for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:30:59 -0400 Received: by mail-qk1-x734.google.com with SMTP id bp7so12001741qkb.10 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=AlAKO3pHLk0w42dzpdqlCWgmBC5kkngUdLfuQLXO9ho=; b=PpbPMVkXeomNsZeoSgLpp+YasKiomCQTW4/4SHDN7W+swgL9vnBh8vbriy/ftBWkEV BvbZhiGTgTpyEAmLH4v46aAHVMn20W3Gu/owMc7lp6SBP5q9yGnWdP4oohMzOGZhjz0Y pwFq/Ew8PgycsFkHH0673c0AOyi/zqNZShXYdB+Z4myBbyzlNwMNSaLIBRx3+FxFF7kY 2BxyyweCa8oVzfoPOQZw9/TW3a820UYS7JEmZAJ9HXOkZG5KCCjyvGcJC+a4TRs592CL 02Kn6FW3gC1oGoCUmAe7b14g7mOcswJPuEyL0Rnsv8k95OHwo9n0Ucv22yBvfXcz6Y8x 1/HA== 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=ySTFG/e53eOPLfdQNA5L2r7HYkizIuXXetthlnoMnu6h1J/FOCzp+GSezRsJIMpr2n kXP2dku6nfvKmRxVtKRbDwv+2791lZVV9YIpOOFfYJLwhmOxj1GCYfW4unbvrHFg/4yg Hxm0yoFLsWZnQ/5uUSUgPBS8tfIOmQO6foAN7Q6JjbzlB/fU1tD6zArCdgBqi/g73laj q9mTDbuWk9INIOC+zwExDl3cuDVrzGYT4t23H0WAQNK0EocQn4Z2+FogSdY9mfHIpKmy fE7zDBIRyfXpZ2gwsfq3IYbShf2qte1w5eoMaBZA/wltW0Ktiox2RprODBT+z5cgdak/ tOjQ== X-Gm-Message-State: AOAM532nWpB4Mey3nH5jaUjD5Tu/n5GW6aK1GRvvKLhmdGe7QA4mQJCQ bwiTIbWlCiaXKJV6i4QpGOb+eFS85ALADQ== X-Google-Smtp-Source: ABdhPJyZyQG0w1Kg0RkepMgJXlgSh/geD939yGN5R/8FneXfUYqRr5kpY4BT/G8Ca1nGR/st9acdmw== X-Received: by 2002:a05:620a:4706:: with SMTP id bs6mr23795494qkb.122.1635787855338; Mon, 01 Nov 2021 10:30:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 41/60] accel/tcg: Restrict TCGCPUOps::tlb_fill() to sysemu Date: Mon, 1 Nov 2021 13:27:10 -0400 Message-Id: <20211101172729.23149-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: 1635790374314100001 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 Sun May 19 09:23:43 2024 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=1635789572; cv=none; d=zohomail.com; s=zohoarc; b=IiTZyNgJQdb5KhArDPUqH5vEifKmurB37q0RMQ2AzFSbVhRjDG+qWVd8BvJeBWiNh9dmuNql/IhbY53OcgcCceYdENp8inQexkr/74AKq3Z4YLnsAsKQE57/yHE7lLXS66ltQz7sOqnz+NTNOfHs1E60JCvLGZ5iMD8ZIfKlMAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789572; 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=b/SrMbv8VVx8zOA7PzE8jLB1UJ7j7tDTI/YO+vSOBHB1+B+H0FEDJ3cUaQwegZz2HsCxZCJn2OZh66kwlXMobYkWiQzMb3wGvVLQdSmAjlDbj9vJ/dsPV3rBoieo/oWFobyoTX8VvB7lw+/CIKIww3dqCvE1JnRvRdOyP9toQiE= 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 1635789572043711.895937954378; Mon, 1 Nov 2021 10:59:32 -0700 (PDT) Received: from localhost ([::1]:43858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbak-0002h8-SY for importer@patchew.org; Mon, 01 Nov 2021 13:59:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb99-0007nN-Jv for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:30:59 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:44601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb97-0001BR-19 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:30:59 -0400 Received: by mail-qk1-x72b.google.com with SMTP id bj20so5971010qkb.11 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=vGec2V7sqBlJXZFFOVGa4jSeCFBEP3Km3jAuCBMCplk=; b=uL2BuegEf/bwrO4a4c6q9GujS24PmWjf4NXikyrI85wu09/AjYdmSoylaCxzUsDP17 qOnnvPZ95fmMqwGSDVG7ThJRCum5uEbn8+d8HyXcIPw7hCfcr8IsAOp/noL45DubZSkV 3MJwiGTbcqsaKK/yPPJRr2FWqsP85kqH1HLATCryYkThtgbB6RB8lt/1rQyu1NfxUnbN goIWXM9Luq31j8fXJWJvsJcjvCtt3m72hzqbIlX0RUL3t17csVlVpjeRYqEW0h7ocohU xh9iUfNj9k3F8dJYEKx/0wXge7ZbJzsb8A1BZV7cliHe7R0HfDaugi3jwCsR/Ta07mXs bkqA== 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=ZcUGxpDrWPDmUT9LA8t3/LUNw9/00pF4bHTg1KheMnDw1n8xd8ICaxHzo6YOoMdg0s rzPfOLYO98FrT2NstTMDF8IT4x35aAHLzt4blSg2q2g8662cbjaXt/8YEJjszmF5X/zn 7/RiFmbt8VSTPSiWWfMShKoHsMkL9p8EyNFs8IJsdc8fAaqXwG3n5JXxwFB+erZTu7Mv 2hJxCwFFy5T6Uqb+A9Qw34SyOD/FG9+dn+hD/SfvcZcAMvbJNAOs2HfJefP0F2q/LFAl lJfY1grqIt+18W9CeLtujvkGm8oCwyEONUJUuslR3A6VdNPNr1yFtDaKup9hzCUTRcji 9mVw== X-Gm-Message-State: AOAM531GF8/Jzk4olFfmqkNqvvlmi78exELAsd1hGsKKODUxyWsmvBu0 GfM+NSJrx0y5kEELzk5JlEEJK4GX58zwnw== X-Google-Smtp-Source: ABdhPJxGUs34H7AK+A9lEB0UvJdnBc403MTN6uQX9FH+13SNhxQ3t/m1w0DA9oaa7kAhU6d5YvC5wg== X-Received: by 2002:a05:620a:4403:: with SMTP id v3mr11305076qkp.383.1635787855866; Mon, 01 Nov 2021 10:30:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 42/60] hw/core: Add TCGCPUOps.record_sigbus Date: Mon, 1 Nov 2021 13:27:11 -0400 Message-Id: <20211101172729.23149-43-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635789573366100001 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 Sun May 19 09:23:43 2024 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 1635790012812265.0379087570873; Mon, 1 Nov 2021 11:06:52 -0700 (PDT) Received: from localhost ([::1]:37738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbhr-0000nE-Kj for importer@patchew.org; Mon, 01 Nov 2021 14:06:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9B-0007ql-0d for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:01 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:38689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb97-0001Bc-97 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:00 -0400 Received: by mail-qk1-x72a.google.com with SMTP id bi29so17226598qkb.5 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=1Ep7pHHg1zb1sPSHGpQ1/FF+Txy5JMnbD431/U5MPag=; b=eLS85f51FkQhA4d5K4CglCP7g1P9dKHkau2QtyPOtAQUa87Uz3mAHr7xffSOfG59Wg TTUTwcryXcV4sqhoqNplo6ufIqYWtgiIeLiQDXIUMrzL6SH5cysnE1X+uaiChX2NiN4/ Fwg2Jg1PZyZyCuOttAFISuYSG9ZV7egBS4ckSIaSvf2JVg/dEADBVBzWfATFFM96iKTD QE/V1cQQOjYIyAxCA8bZu/1ZXjYDwhMKuTo1UxzHLoK0NmsUQTEsZF3gzi5dR1r5qQRc co4fRv1/sV3J15cyEAmJOFaoHPApil7qRItb4GMk2TFiP6TQ13rXt/HP02E+iV7T4a8X Jf4A== 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=cmpoKeJ1CQNaympoqhEBf46xg/2wIoeqYb6jskXNJvSODc1KiMCTKj3hU2ZOLtZuIB tGmEruIFAXjgTxcmtzF0Zu4lXp1w9nXo1YXjIr43yZqJwz7sCZWzbmnUXm650H5krea5 Piy368QjPGWV2oTX1JAbHfBJmB2v1EvqHp0TqLL1QEPiIeg+Ow+LZCk0Nw6s6Jr4PtqB Q/a408FWc01GpFkNgko9GoBALDo5j4X0GYwrt7Ov/N6431DKVBmc7ECcl9GIIYDjHhGv Rbv3kmPr3oJAbL6kHSXxoM6YtDnyW5SZjweCdVTvMX2csYtXSvFTziphzQr5pTax0nDe 88mw== X-Gm-Message-State: AOAM532dLTJrbV7/j7zqQlC0Ufrj5bAAeaquGvh5q85/xvX40O6UEVSQ 1/KpzUvo1aDj3Jqqc2wYW6i13+HxAi+VDg== X-Google-Smtp-Source: ABdhPJxJTFBd1U/flWN3IhrjrDYUY+iDbsFg/uXMvb1sHQYWiDwlBprmlaAzMVTErkgtUBRTBSmx9Q== X-Received: by 2002:a37:4050:: with SMTP id n77mr23651706qka.267.1635787856357; Mon, 01 Nov 2021 10:30:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 43/60] linux-user: Add cpu_loop_exit_sigbus Date: Mon, 1 Nov 2021 13:27:12 -0400 Message-Id: <20211101172729.23149-44-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= , 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: 1635790013835100001 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 Sun May 19 09:23:43 2024 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=1635789900; cv=none; d=zohomail.com; s=zohoarc; b=ChG/7Bofv8HLY4LUfZwkO60UjxG8FOUpzAhzQmr/dkoWX3ZRv6EDgwTWOMuyZtNbEORuxJmLyZI/jMIULbZ//sbqie6o1fUYvCkdTZ74+CV/fH2wLsbd76ZQXMGs3Gehy2dtK76ZIvudT+6/flnBu75eSPfggoptzr1Xm3AcwD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635789900; 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=LQQehXtfXW4B12BN65PdmtgWySao/FzKQ6Fk2phId+tL36sdoCLZ0Nt4+KZWB4pFExv+ptZtTwreS2qHeHExOprehpqaL1GFJUSFmnDaSXPza0beow+b4D1n0JpJMVk+5iY7bqHXdog5fAGU7yqcbtOgCHAa605jYxvOiBy1t1M= 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 1635789900817123.07231588618004; Mon, 1 Nov 2021 11:05:00 -0700 (PDT) Received: from localhost ([::1]:32882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbg3-0005uA-Me for importer@patchew.org; Mon, 01 Nov 2021 14:04:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9A-0007pu-Lm for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:00 -0400 Received: from mail-qk1-x72f.google.com ([2607:f8b0:4864:20::72f]:35476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb97-0001Bi-VM for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:00 -0400 Received: by mail-qk1-x72f.google.com with SMTP id az8so6051519qkb.2 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=lCTWBHg3yAPeLZcM1I7LLlGr7M38G+m6NQblxbcjKCQ=; b=RjnWtbc09lCG6wRNhSZSl3Xi+ou5OzS5T1bpLTrWkn5Ss2bSLhi/uuO2YB40hGCSUx pLPb9Peg+K+egkagGl5WDbO3rUIb4XVm0VYkEzjCkuD+lzVY5ysy1hs7X2ANR4E5se2W NKK6ldp8m5Xh2po7htmGLcL6UZ01W1MIXTlvAzyEjcSbieSnF4dVTvQ5QmKc5KXCbOKc ghEEbvZ8CHO+GeYleSdtTk6viAQMASoIquv6PcUec4TaVec3dKmrYvLvKvWbRzJgjEPA osz9PQ8dzTBNXK32bWqcXaVn5fSbFB3XD0CNa0eTybBjkhKx1+LDTxCnvOirVTVuHi16 0LHg== 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=D0uLTqoqUnZcpl+fSxHDrGzaOiyRoblkk8+YuISrbAmcdJteFy3OTIokaNQVaVT5nz hPgwR/Vvaj8WN8kVw+3s4q72YWTAhe3DZZXekGeKt9IfiPJ7uD5RKd/yWXzKIjc1L8vf V+9HNJNh/q0BOuwV1AQ0NDx46ehEtEPSIlcJWKJvZaFNoidisPEB0s29DWmxMmyYZY6S VIGKTBe1i0lw7ViJiKe6Zh68YpZtDw/gVd3md5QRcDcXwxVvxgxqUCZW93AEMMj+cBuA SHTaaowgIrLJd90l2rDdbv6BZDpgx5Z+HpMmgWCejQTlACvl0hBg8d+wT20M9G+E6/h0 4TQg== X-Gm-Message-State: AOAM531OOS1xN4HTPrpbDOfUZZf4+jhUrrJk2C1lC4VJv/WVhZAn2ntX PHKYQ6F9bxKu5lthIc7M4gyPbnaGlfK3YA== X-Google-Smtp-Source: ABdhPJyRAljvyMppvRYqvudiUmBIbI3O0w7pxi80+6xcEslmwtu9ZwYnDLAMOPo88plLGx/nARoDMA== X-Received: by 2002:a37:9fc9:: with SMTP id i192mr21046898qke.182.1635787856924; Mon, 01 Nov 2021 10:30:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 44/60] target/alpha: Implement alpha_cpu_record_sigbus Date: Mon, 1 Nov 2021 13:27:13 -0400 Message-Id: <20211101172729.23149-45-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::72f; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x72f.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: 1635789902814100001 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 Sun May 19 09:23:43 2024 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 1635790111313737.0211218827171; Mon, 1 Nov 2021 11:08:31 -0700 (PDT) Received: from localhost ([::1]:41684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbjS-0003Pj-8u for importer@patchew.org; Mon, 01 Nov 2021 14:08:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9C-0007vv-C7 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:02 -0400 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]:40877) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb98-0001Bs-Ed for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:02 -0400 Received: by mail-qk1-x72d.google.com with SMTP id ay20so1931301qkb.7 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=6E2EHrVXu+fKkNaLcRStkdoJxkkRxYzYfXrw6rxs8+I=; b=y/2DAusmr58qk+0j5ChBadldsLcd3ywmFJsY3pD8Mrv4OALbJGaTdnQy/Ik/xcp1z3 6LfmnnMHQKhNYPUmZMMktCAS4mjW8qcLNh9/qpTtD79HBf7pypYd+M5eiBBEz97HXGeH W09m565TnEzGu1rb2wK6Z2Petfsc6EDMefz0QHYKrm3bk6RGbxzRu30wnADNyDv14UZ0 StYQGjsTurKOfE6enr8ooMRQc8notxRdEm5oNqCJBuAUXKqxiJTQ10jOAbEpnHsiq1N3 cTwbctReDttf+zZFSCGvN+hyiSp4vJhrAcYASb3d42Wre1QxWx2n5DMsAgrX+uRsD8S6 6pOg== 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=YbNODofFyNSEOC2TyZzPcFarWAELDGjTKQmsYpM1fSRCeuXbjL8QwrcHcgoSTq725L NJIBPMHjhvRUPPEKRUoThFzy+cvIlwvEzJs3nwuS8lYS/6O17bxZgtIwt+jYizltH10h UatCYgosaqVRlH/3Fw9bMmsr8S1mI+ScMTfyRE69vvu+4d23Y4oT/YJJPyaWvjz42aYu HP/0vSmTPmB/LGmGD5/fgvquHY8hQEQuhNxuNS54wCusZHJHdGruXesSeocW/7c4t5Rp y7zCuVh3d0mgtn7tP2ir70kC6XmMurbcGR+sa8b6SZM4JnJf1/gPUwHvAz4dffGQtgwq 3zIQ== X-Gm-Message-State: AOAM531DAAihD4u+c+lJzP0mvouSElixdYaJl4eG0QaSJbYOP0TUzdBS agifmYYKQhXGr9tf3w8VKjpr4a2/xRBNQw== X-Google-Smtp-Source: ABdhPJzCvgeTUPzHfjfsBI36VaUeBBz5Z/fFWRy8aCe+ZvocYlqNDwBSUBWcRI37i1o0PvZilwu5sQ== X-Received: by 2002:a05:620a:4721:: with SMTP id bs33mr24191250qkb.0.1635787857536; Mon, 01 Nov 2021 10:30:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 45/60] target/arm: Implement arm_cpu_record_sigbus Date: Mon, 1 Nov 2021 13:27:14 -0400 Message-Id: <20211101172729.23149-46-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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: 1635790112297100001 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 Sun May 19 09:23:43 2024 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=1635790473; cv=none; d=zohomail.com; s=zohoarc; b=FqWzbd3fjaiXzQtGdKNhQY1Ja43sw0wFrxt+jRvT1fvnvziy9mTVufoHLK7gvo8MxTX1CxzeUyphYhJ9qPv6XterIEwOGexHX0jiw2wDi8y+rQouURy83sI3+gHX6VmZ8+0cgoymmWwi5QW1HSzVrBWU1NJAsaL7BKeaFcvnpjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790473; 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=AEPdpyDOmL5FY3xZL9zcXcrU/fVi9wsjnzHOfcCEcBKEN01SWgePxD0q91JfYfLv8P3T1yOmbBiTxhwyuCf62MtLORVl4sVjsYqDK+svtS27J32447ZJQDB5JCywe0Go48oYEzAuZ7gH5b+Sz+XWWqtVdAj1hp90rxlDVAkGuCI= 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 1635790473810707.5523220254423; Mon, 1 Nov 2021 11:14:33 -0700 (PDT) Received: from localhost ([::1]:51918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbpI-0002FA-Oe for importer@patchew.org; Mon, 01 Nov 2021 14:14:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9B-0007rO-7J for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:01 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]:45709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb98-0001C6-T0 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:00 -0400 Received: by mail-qk1-x734.google.com with SMTP id n15so3743886qkp.12 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=QdBbkxzZXl4V2J/0UdfvZmZe+nM+srroKJ9DSgm4Qw8=; b=S/z3RdXmXNm63qXWjIjgSWqUioV7hvmM8EBv4Gc+BNIJLbjRLCXAGjiShg1XAfWHeS igVoCWZhqwTh0VpFVrYPchSbtqq+WwPiANE5lQneYDGTRvPIsdaU/IWMIHt3sNVZ/rmA 0Enjg/TK2p3WDlwlUewJ6LCC9rBIde9qDW9b46CYldAtktODVphyCT4gK7JnLDsRW6Dp aI+e6IylQQ1HiAUOCU76xa+xIQ/hcjU3FKriGbtyUE23VgYVos1oDTJ01vgVoxUVrS8l p3R1T+hJ2caLekBsbnDUHeh+/XdSJk8veJXYdxVEx+w+2m6ue8Qx9dR4Ot6V57ecm59v 3KhQ== 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=NiZBp7CstAwlHqPBGWQrNxYim8RkjFIdJEhiYG8aF9J+xTSLba19YyYiAklCN9Et92 u8FuU6XMPx9mynN5P/g+dOJ8GH3XlwLnQv7k3ZKIsCTK8ZDhq1yyHFjRMaDg6NQ5df5P OZphDnt07LRUjsKIllFSBo/k6mihLDS9i/GIBdbDH4TgCKL0CjNPH3gozHj2kqVKc2Lr 29GvH3qF3FQanYk8ujvoaHvVyHV2/OPBTQIOfk2H01DTE6+TEmbQWq3eVat+W79UPkom 3ghlr5IFYHRvO6RoDO96J5OOsJIbn4hybnDlQGOClHoyiiOXjQbZCE/VX/vgfk5EcvJU A6YA== X-Gm-Message-State: AOAM530xmC7MBTtBmMNNclzqNJ7/+jztVNxmu2vmAL9bjo5Fs6F4Ageo PiAaVzCmTjOyXKBvptP4KnV3CJVbBGCBUA== X-Google-Smtp-Source: ABdhPJwmM1iz9xMNfo3gxjMOFrYVWIPRf2o1kUV2frusBHDh9tvR+Yc4MOLj09aeTFPbXhjle/odoA== X-Received: by 2002:a37:b3c3:: with SMTP id c186mr24279874qkf.464.1635787858044; Mon, 01 Nov 2021 10:30:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 46/60] linux-user/hppa: Remove EXCP_UNALIGN handling Date: Mon, 1 Nov 2021 13:27:15 -0400 Message-Id: <20211101172729.23149-47-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::734; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x734.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: 1635790475708100001 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 Sun May 19 09:23:43 2024 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=1635790813; cv=none; d=zohomail.com; s=zohoarc; b=kBBVD0/wc0gPHsyMuS8LMollkSg73KD6dmzKzcdaz3AzcMh+EciI/w1IO60j7hWHSWens4APZ5m0xkYf0YadH8/Ss9z+QLhFjl2PFoP8uZcyipWQ7oZMR1mbf4P+WOR1whRHLegP/LxT6sayDbUo5SjLPnV+Xc+YlwNTHlbL4zA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790813; 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=Wl3mBEpzq+H75XAvI3OUI0V5o3phOvlUYRNye+H1k78sKTyMsi9t7yoihzm1aG91kNFNzb4LUND8OUrHQ5FLxLmEtVJKFbf42jWRb1SKuM568uD9axErb2mmQ0S7jBQOGqkWQM9t1vSQGBjAUOBmCkLoZGKcRJJRp59EtniIe8U= 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 1635790813415869.8061133323839; Mon, 1 Nov 2021 11:20:13 -0700 (PDT) Received: from localhost ([::1]:60320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbug-0000Mu-AM for importer@patchew.org; Mon, 01 Nov 2021 14:20:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9B-0007tr-TY for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:01 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:34328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb99-0001CN-K6 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:01 -0400 Received: by mail-qt1-x829.google.com with SMTP id v17so16553948qtp.1 for ; Mon, 01 Nov 2021 10:30: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 13sm1222289qkc.40.2021.11.01.10.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=mTKdaHiEpe60z+ThGKt8c3K8jQRQXSW+5obPKHUiPMs=; b=RwYtp+HJ0qo3kSBV6JhaZvb76eRw5Yq8Hkhu/Zpo0GcvsPan/2mj2+fDdL9EbDKbiW HgAset2upzR3bL52CHTmSyPs4iG/FBU+FbkqiKk5MnRVpw3lt7WfyVMtMq6v1Q//8Itt TnZoPfj/7spT0J1zRevlM0fm352gnjSLZgPW6oQSlj3vcLzngheGT2qlN7kp1sHNzB+k W8WH5Z3wotvPF8XLm+jZUax89aOYgwH/o5GLcS5bhrGSnhnFirfaCrHQeZ0Tuaf6tAaR /gdHHl4U9mkX9qozpDIXGjgqw5vyYHhq0fvULiOiFbF1XkI061gBZRAzQfTiGttqY7tt O98Q== 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=kHS6kgXihJqVGzb0VT6ikaLkmPvuPmVpXTc4IWD7wToXrKePN/UVTpunKSGBdVKjdb F6dVqFaTsOxFQsGHuzcaYk8JL01JFxeH046vxM763DQi0vSCV5J0XPZPDyon6ic+3T0w AwO/n/rNGRs9IeFgfi4oopj/m/5W8/yaXUzBLcTNqWl9QYoEdmZ17TfoXI+kHB6CPIjM +y25yccunpP8e5NeKHHjFHwKzQp4f8/hKamTHMd9FRaBA3OfPBsisU/+vs3Na+Dt6Hgx aWCGSBE3SWGI5nmRDvrchHS27BBImGxQ+RduxZVz2XG4GJaABEFj6kspn5n702MAjubI 9rQg== X-Gm-Message-State: AOAM531k6TzJGMHspQyDX0+VxeLt3G2RqgaTXLzk+hQQQNAZQ07Douks Z7BcUVZtL5LTZ5cna0BNXF9uq3eUMf4LBw== X-Google-Smtp-Source: ABdhPJwjrfHgPH+jmAUW3Wqmep4WCmLU0unWjH4nJbRIEuBmas9w2OPEz8B/e0f+dLeLWE3jOu2Cjg== X-Received: by 2002:a05:622a:52:: with SMTP id y18mr18468744qtw.177.1635787858678; Mon, 01 Nov 2021 10:30:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 47/60] target/microblaze: Do not set MO_ALIGN for user-only Date: Mon, 1 Nov 2021 13:27:16 -0400 Message-Id: <20211101172729.23149-48-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: "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: 1635790814267100001 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 Sun May 19 09:23:43 2024 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=1635791112; cv=none; d=zohomail.com; s=zohoarc; b=Jet4dEUDWXIa6JhGAA6XuMo/5t8xZJEyVLFignGBK6fc/+Q8pSJYkkyUqLyHOeM27rZ8R7wOf23tgKg/nRsLUpWYAi4cQkfmrUKS/zX9y3ilWDUJI11FJtIl2fEnD8PKSkc1ECo4JAv2zmHcs2CkS5qPFB7FVH+ZxgW+E7ajASs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635791112; 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=BzF4rP9A8ym8yctJnuyYXdEHVI987f9HsED3FDaT2jo/+CtIPr1bDA7kHFXERSSKT4w9ffbaxIIfjLAozPZjK7DCWnJR59fSdzAmSIForl8NFKK1UN7RLWryiBTSfIz1I7DeDJNrT2xgX61AEKfeALfqx5W8Z4ZFDI2awpigsuo= 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 1635791112055818.3227601001752; Mon, 1 Nov 2021 11:25:12 -0700 (PDT) Received: from localhost ([::1]:43734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbzZ-0008WH-CK for importer@patchew.org; Mon, 01 Nov 2021 14:25:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9C-0007zA-WB for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:03 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:46014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9A-0001Ci-EJ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:02 -0400 Received: by mail-qt1-x832.google.com with SMTP id r2so15244312qtw.12 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=QX8lpa/N6MGCc5XN0sEQ8Tozk/ZcRRE1sKnK/UAcaUYvlax/L3h/Z38wKdpO/t91p0 JX7jUZ3wkH9lryP+LW8tXF3h5KLQzfD5br9Xd5KgqoNoaX8KJQ0iGPAoCLIEW2J7B3p1 C1/VQ/2oQb8Aay/uYIBLE+9XZiSKzp1MGVyVqjvUtR9m0BBiuu9e/IHmIhnhjXw4xUPm hE7SbBJzIFVEbfDF28j74+OWMCti7+O+IygVexfgmTJCzMlHqzSuOjhycHmXyT+ShmhY 7Bw/Voe/YzD1e7+34DfunY6D2Qvm7BlY2d6avghbwMtZFhjssfHNhazu2lFlh4fz4a4o 9vHA== 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=Mk4eETm7mDd0biQPvxfpX0fmSP1Rl1Xq81dRlu6tDQ7hjZ/AIjPASEhmT3vaGYGANL w8/E7HGnVF8FJXGSNkyHT57Opn8VI0LeXq7W6npXpjBha8kRbFa8BmN5tr4PcSB3g22s 2jYHcvPbRNxRUOmOkOxqoZ4wBWQL6MsGqTOfQQRK3looO2QDQZlnpFMu8HN7PX8+ClnN HMZw7frEi0vJkHDsXGEWZJuAx9GlwdeAN4CY40nipSeLO/aZuG2++1DJX2Lsv5VaH/uI Ua3rCSjBKJNtcD7xabH7qmioVSc+X7PHTQX55BjR4FQS2DlrTHbfgSq0LB2tGicvgNUy 6Onw== X-Gm-Message-State: AOAM53252MkFKalyHjKt+3X80jp9rIBdaAB3M49DmJwlF5zkqNa4OTiU aG0rauiSIr+YJdX1FyFHEWmgiY8JoI5u6A== X-Google-Smtp-Source: ABdhPJx1U+T0jy21FCOp2nGRsnxUoeYX2O0X51TGdFkyla7n7V6sdWqqctt4njnho5MRKjxJSC4WvQ== X-Received: by 2002:ac8:58c6:: with SMTP id u6mr31956705qta.230.1635787859555; Mon, 01 Nov 2021 10:30:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 48/60] target/ppc: Move SPR_DSISR setting to powerpc_excp Date: Mon, 1 Nov 2021 13:27:17 -0400 Message-Id: <20211101172729.23149-49-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635791113082100001 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 Sun May 19 09:23:43 2024 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 1635790402825275.59128277704826; Mon, 1 Nov 2021 11:13:22 -0700 (PDT) Received: from localhost ([::1]:49932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbo5-0000rm-PR for importer@patchew.org; Mon, 01 Nov 2021 14:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9C-0007xm-M9 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:02 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]:46730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9A-0001Cv-VB for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:02 -0400 Received: by mail-qk1-x72a.google.com with SMTP id bl12so2960375qkb.13 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:30: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=hDIIDmSt3XkX7dozNp8YyanBuOQiSpBj16JErrhb+ZE=; b=Qxaxl66+AXyAg+0wnk9+Q3Dxm/ODm1dIJY9eW8/8wmRb6fgJfWKhx/ZPSagefZrMYK B6l6CtxrMeB6cKThVqoXXQ/vmVxiKdjkeQfdvHcK/0gyXTwRgzN8h8IYSyNLB0EpTszH 41iNSK/uPBro0o8K6WG56+qbYFVUX2GSt0n9w3a7uK67dfF7insjIxbHvit8K0r2J33i OzwmDdbXM8oGNXLMSRcp4lmGM3jzVoRyhabHt/ci4eWSGW/Hnu6hL+UOHgpjLkKovoBI 5IlfJjJ+dDRf02CXqGI2McPl7zjb6Sg+B/ViC0TwMAPOmlyjEcL8psxtMSvhf4fwJtc9 mh+w== 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=OoVZ9V0aBXLyYPehPgz3o7Rk7viW2xk59RjBRMWsGVfFE9RvoyAKww5mdYRcg+RR1x C2dLVCz2Y+z02yLaApObq5ASHDqe5qhqAu7Aa91+lXeLXZ+EqvQRGFO1IpGxWD6kdYLc dRYkaGBrTCpMMTcFlYHkqQEOE3xXK4QZDXoBXTeB1tgUu5iUmnhijdQP/8buewSSdhOY P5hZf/1eLWMclb+8mL7jkvxC9Y6rGkZuYrAgdulahFOxVkch4Ojd2KoOXmHYOctMKSJ4 36TJySIehdzSyHKlbsqdokKVIyG3raBtWMaMTK6LhgKlR1ZDTDW/wX6E8LJs/4CnChkS QzCQ== X-Gm-Message-State: AOAM530psNKTxCp8qnk7HYXhOfRGU0vuJbQJskvtpE9056aPNdD7G4yt 1K1VRPlVaa5XGCgSDWOkABgObYpaU3tTGw== X-Google-Smtp-Source: ABdhPJwNojeT09w/prxyJ7Fxe5KxR1nOGBMThU3AcDXBVlg70VPC4Kq9WyZ2eeG3RDVjGAcjudjT7w== X-Received: by 2002:a37:dc85:: with SMTP id v127mr13213183qki.45.1635787860133; Mon, 01 Nov 2021 10:31:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 49/60] target/ppc: Set fault address in ppc_cpu_do_unaligned_access Date: Mon, 1 Nov 2021 13:27:18 -0400 Message-Id: <20211101172729.23149-50-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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 , 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: 1635790403264100001 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 Sun May 19 09:23:43 2024 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 16357907255777.426687226618128; Mon, 1 Nov 2021 11:18:45 -0700 (PDT) Received: from localhost ([::1]:57258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbtM-0006ZI-Hf for importer@patchew.org; Mon, 01 Nov 2021 14:18:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9D-000815-S1 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:03 -0400 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]:39756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9B-0001DC-Ku for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:03 -0400 Received: by mail-qt1-x829.google.com with SMTP id t40so16520287qtc.6 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=O2Pwh8dMK2GW2V5gEng3hQsybzKfwzmJDjUzbvltEB4=; b=Gr+Wnx8CrjT/aQVQwdaRjnwHO2QJkZAeGv7ZDZkm8KceV2rYdMfV9ydG/Dw3gg5gGs 9cerUNKSDelv2h7lK3xlPQwsh80WEUfecmG1tZiWPI1jFs6bry6k5s6IuhbVGg4tFrgk 9QYE00dY5QUtzfTsl8O6h98rTipO7agk4sSQa8aJGJK+vWMbIOWWD2qJ3gWj7a2uegl6 qZaKWxpKK6tFjqegv3nW0A9S//4BnnDsh+lIZgek/POOdSLbGVqXq5QKs8kwS+G1j2VW 9sSGJ9xdYa7OLgiL18zX4Y+yo2Dm+05GywGNqh1DqnlmiiYhE1rfETLVNirv4TUeTdq6 ejHQ== 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=m4RJ6MCUpscf8R4hqzC8RRIXxV6NQ1dsd+7xifDwHn71C/3816WjxagOVT8j1ArijJ 8e9H5PTmcxGXmgZsOTJ/TAlwKHsP8m36HkJ0Ndy+kJVOmr9RdNaMJUJiIPVHJSrDwjzb A6o1U4haq4YoBFG/jxBnIHNRj5hf6A015eyjhSIJMvDOyzg9eWAzlbx8WYbF3nad7rcN rDwvMst3aqY1q/im2UvFsYRa6Ltw3GKO8FR4kLYtUywtfPX4yFJM6/5HiE2G7Wpvk0u7 5SSGxnc6BOEj7BRKocIS/PYLbBBY6i3Uw2ouVcoUwrwvNYahkm8I0IpcunJm8m76g1Ce QdXA== X-Gm-Message-State: AOAM533iNlOzlwlzHNVY0O37swa4kqleuXEqOMCcpFT1FVAFP7tkQLAO HjOnw47z9N8mYfPWEwAtP8EAd/8C1Hxq4A== X-Google-Smtp-Source: ABdhPJxxyT4GC2suEnn3JsQL5kTNhIFoGC3+QHK/vpgpzusWyyfheqW8esyAOF+s/CgmIZe6cVDnmQ== X-Received: by 2002:a05:622a:1342:: with SMTP id w2mr30549547qtk.39.1635787860720; Mon, 01 Nov 2021 10:31:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 50/60] target/ppc: Restrict ppc_cpu_do_unaligned_access to sysemu Date: Mon, 1 Nov 2021 13:27:19 -0400 Message-Id: <20211101172729.23149-51-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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?= , 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: 1635790726127100001 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 Sun May 19 09:23:43 2024 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=1635790289; cv=none; d=zohomail.com; s=zohoarc; b=YlxtYn8pONdh40dw/YbV0h/19a22Dkv6CcU1fWml2j83IHdieTtHt1dqAPKV44tkHUzpNSbogIDjnf38QQyMBUfUYvIcYNYLOgwHrWGnT0xJ61FQZBjjnoGbTN++3edgtMFCWKgHAuL9B+5eVDY6FiVrHRiNASNv7zxErtJZXVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790289; 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=akYwQxS//bMOedZ9f8QLR0p92AwBFLPOYI+XRwsyKkeNjQBZ7HnfihUwLTXF9jEU2xwKrCxFT3TdDqLso0cOdlECiscZ5ccjkHKB1K4bN3fLFn2c0B4GsJv8wbzqNqpC0OuT4Xqlox+Z/gQFLShmfIxCrLFcMAqnKbd4tPegK8g= 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 1635790289517677.5651858858807; Mon, 1 Nov 2021 11:11:29 -0700 (PDT) Received: from localhost ([::1]:46058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbmK-0006QS-EK for importer@patchew.org; Mon, 01 Nov 2021 14:11:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9E-00081a-6Z for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:04 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:35482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9C-0001DO-3j for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:03 -0400 Received: by mail-qk1-x735.google.com with SMTP id az8so6051712qkb.2 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=JbVRREsh8zZn+CBQ6RQjqfCoQN/6HupmGu/vI+h3Hm8=; b=vxu5Sn9KbBVAMZWGRzXQGpwfoZLC6NzqkTiTlVbwW/IOYozD/smljBNqBkFie22ecR Vl0ickzmGezIJ5nkixbalCQdyLzbwOzouCxfhHOpKnpyNMygyzuqdyHj90I7/rNuUtVn aXsgFwNhXbCjWd8/OWetWl6z0nwWYYUv553xbnU7TqF2zoNPmBAxI6pyD5v1WQ5HLsX6 RiIhpi3O1vfLP9WprNe7OUVrvAh5aa9BcO2kYoS52sXBtD86CbphMox92V9ITCGNPCy2 GqZ8jlNIaERhoywEJF4hRngs+SWN5DOs6jnH6wn/HLeHOTmygrhQ9ltBo3ZFV84UPGr9 6BFQ== 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=vQZM/Z7PTpRDvdqMCyBRack214ls04ZPG6fynCw0czBow5eqES9g7nHwhe/TYG7T4k V+vKAezRcenVY3OCHkfpxJ+39J0yqWy/1wJLFQefCmrlnU+SUQ7rhWqw6y1zHX6ZyAlX nP4GKQabZ/jXOlsOl/I617JN+kCGuw1i+kc+Yo3OzyCcBSWwtNK7mu95FkZcnUioX9Gb UCW8ekHcGNub7vnDsTn80DPBygW0lkbqC7xQNmvEBFj5DTgHB7fW9GNTlgxmNTlDSGFU y3l+sAl3jkqNVyfhGpoZDiLNYaBmFoHdPo6JN6KvPzvbIAEiAjnEN5Z1iZkEH6xNmhWj lclg== X-Gm-Message-State: AOAM532mW/Egc3+43np1DtsTrmI5to6wouqBSqRFZLNywDLl7lq0ezHa HFInf2K3I3ja7/xvn25YQohBtslauZLS2Q== X-Google-Smtp-Source: ABdhPJxg5js9RGd/ZY8hC2cTZFJsfD/u95OiNq/WcxKt1JXpDwJSqMiFsKjIAFhiklruBFH4Io6mpA== X-Received: by 2002:ae9:ea19:: with SMTP id f25mr23885100qkg.341.1635787861192; Mon, 01 Nov 2021 10:31:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 51/60] linux-user/ppc: Remove POWERPC_EXCP_ALIGN handling Date: Mon, 1 Nov 2021 13:27:20 -0400 Message-Id: <20211101172729.23149-52-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635790290259100001 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 Sun May 19 09:23:43 2024 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=1635791763; cv=none; d=zohomail.com; s=zohoarc; b=TT3BnnhniPE1uFcbJKtwl538uxcC0pWYCnojcDbxNW9Zd5eKr2Dy+TlMBdwHs/l/15BwMUMyLhnUsBPsZZt2nOJLRlDHiYId3sgfvKZ+IYjfXCF/WgLUdRzcdMGoq70MuPIB4W7r5uGH0+pszaBu9n/aRXQRsvE6hF5M3HV7Ti4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635791763; 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=RXuyrYyOwhGczjAZk5ejxSXOQf2agSADmmr+QZe7LI5aPqQu880Q6pXqX3zGNputlEACioBO+E9HvFE6WBiy2Y/atFMFY9bSWbQ1LnPxXOo8xlxTh8u+ppvToK5wQ5PcW+XlpI3nMk8cGBCYGNiimlNxBgekrEZa+9y5+1TliQ0= 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 1635791762976448.17895958958786; Mon, 1 Nov 2021 11:36:02 -0700 (PDT) Received: from localhost ([::1]:33082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhcA5-000434-VO for importer@patchew.org; Mon, 01 Nov 2021 14:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9I-0008Ee-N1 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:39762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9D-0001Du-7k for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: by mail-qt1-x82f.google.com with SMTP id t40so16520362qtc.6 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=RjnbfjA/SuXJ4jF6cq76qF1xRJpDxH7O+xJW5W8IXoI=; b=plXXNTYXSncNiHlCX8GbBY6YZCcG94D72J67+5hUA7rcmOTrqy/5YBsj8kuyK4PoCr OVBlENimqVc9BQt7O3tgNqf+hwV79U3HWYVFWRR2F4RO883QfATUeYiPwaQc6SXPZ104 k6QGLbXhcf18OEcu01R4zp0NtKN67p7c5dEZ4oniL22QMVqwuJV3c018MKFFryvgoNu0 +3tXzbvh5SBJiK8LpwjmyDtamW1KbNC5rb50Q7Rq/b7pjk+e1VtBXXHyO1a6VhtMwyBr KMLkGaAkJL1O5iHvdmm3CKAAHzDj95a8wb4Zo/07BjBc3FZLUCGKkotM17f5HyC9np68 8opA== 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=Gs1T9o0q0GgFyKtj71+YcDcUEBOQceZO834hTZm6wfE/wIx2qOb6FKJuafp3HVTL3s UPw7wTTGyUVUVozyZJpct8TamyxVxZwdOjvtjYHQqXAfocdbLwPHS5ZUXM+mf9wGzRtn 67hfs61qqnMQua1H/tmwBb2QhWMDIbibnzhhjuCYSt3TDMTz/A6znL5WtpciETeY02p2 t7vxB+20gRmG1Uzru5EnAr1Vwpqqmm+0w0lRNAoh7c0cciF42m4RGeJoU8HkFuZCj9Ww 7gEqDQUI0vVEYFgnl91tpostxwYYGRY4CMufMjch3hgV2jcQso/uDFgxpHV6Y1IHaJVi fodg== X-Gm-Message-State: AOAM5300U/1LsdbFrxhMXtazgLSXe1mEA3BHqrTQfABZStdR/IXIWvqt +SLeX1mrZ1dIKS2G5V4nxKXhgsinm89K6g== X-Google-Smtp-Source: ABdhPJwRRI9sjklJE6SJV29tBtbncXppR4qz4eZs9OSDMo4izo43SlGBY79w+nhXapU6zyUArOczgg== X-Received: by 2002:a05:622a:30a:: with SMTP id q10mr9636222qtw.296.1635787861665; Mon, 01 Nov 2021 10:31:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 52/60] target/s390x: Implement s390x_cpu_record_sigbus Date: Mon, 1 Nov 2021 13:27:21 -0400 Message-Id: <20211101172729.23149-53-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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, T_SPF_TEMPERROR=0.01 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: 1635791764813100001 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 Sun May 19 09:23:43 2024 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 1635791175280215.9428453118095; Mon, 1 Nov 2021 11:26:15 -0700 (PDT) Received: from localhost ([::1]:44638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhc0c-0000hL-02 for importer@patchew.org; Mon, 01 Nov 2021 14:26:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9S-0000Il-2g for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:18 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:39763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9D-0001E1-BO for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:17 -0400 Received: by mail-qt1-x830.google.com with SMTP id t40so16520366qtc.6 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=3/CJUXQvBCEoPlihnnAPxMwhS0SfN83B4jFLy6O6YSI=; b=k8pcFj7PwobkSZbG+qXXMBqC7duxK5atVPtouxFkztt/FdWPV/xebSJpQEd1jVmGhv cvuq518G+IaM39I7N5QeWQWYp21LZVW833bvctT1o+U2VVIv6IHF+0LqHxpibsLcJShF VGI694V2V1WYcFP/3QzYCDFozbYlVzsJWieLxsiU4JcyrwBf0zOHeOunLP3rTvT50MK/ hLRi/NepPFCHYHfQZmAXqrbFEsqpcwwBNGpxPOMcdWnlMGo+HnhgVfNeq3rrIRbP6WVt jXfQ7ZeC6H1GOA93XrJZR1KJhQjiRQlIX05d1AV7q/ULWCimUoq7WCqUeg45OxxOqnW3 0rWg== 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=atdiUdHab0jMUqpxE6IL+PL591L6X1q39b89ZcWcduPY3VdNDjRZ4eaU4IqU7RcFlq +k+hEK+7Vmip13D+iL8pzbRDwjt7rOZl/lMRqp9flMqCclL7t9tXS+SZMOjhY68nCgJR Dnc3lXBipe8W9liEbp3I1UtaZh7Bpbol/yMRtxdFmvlcfIEjLgY0boLqbz7j6s+mzsQQ 9ZLEQXyqBLY0XPEEGaEFcW2QwTdpBN39tlJp7YcsrUy9tW+3qBYrTEkGoS8vZb0ihSiZ l0JcS67GOaN4oHLWLo0uf4lXWfwVLZ2pzUOArOFh/YJFEtrokZa7yNHQD/k1USEDYGFl LECQ== X-Gm-Message-State: AOAM533iXfHW1FFSkrq0N+NYKGr0y7s4Wl9fq64FwHe5vAsjbyit8rpD 8YhjogG8IgD72Vp/zwtNsEEY9U9+XwvcRQ== X-Google-Smtp-Source: ABdhPJyg92OuxlSwRaakzoymmyf5Z+4c5J3EU2+8E7VeZJVxYTtyNb6/7YkdNXUsdD2cOBGwLm3wfQ== X-Received: by 2002:ac8:578d:: with SMTP id v13mr31662103qta.61.1635787862255; Mon, 01 Nov 2021 10:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 53/60] target/sh4: Set fault address in superh_cpu_do_unaligned_access Date: Mon, 1 Nov 2021 13:27:22 -0400 Message-Id: <20211101172729.23149-54-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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: =?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: 1635791176015100001 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 Sun May 19 09:23:43 2024 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=1635790773; cv=none; d=zohomail.com; s=zohoarc; b=fYqVb7pmv4Af6h1qOVaFdT36pBv94A8IgZW36vk/EyT4Pt7rahVFPdG4w1TD9jjEpo0GgafZLZW57yL5NjZACAuSPOoFGZKYonh37JUtFd6TmnZ2hEIFFCUIfbBFEEtaH3Ds61G4t53+oQeO0FkghAcy10WAQ5CuKPUba5AOAFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790773; 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=OgOlIfyHpGx9+b1vrdyVcJRCXX43t8YGnKJVJZ8wFodqwin6Ocf4WTrQN+j+0MTgOf9KnmBod6U+doO6SXvEjz4c8CF7+bSWRbQJ7EnGYBEiAKlku+/cNPMXT7qu2VPy84GfcMml3KiomAJwRIP/ibp1iKCVRrBjbAqyK0dX1YM= 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 1635790773355577.5428213899878; Mon, 1 Nov 2021 11:19:33 -0700 (PDT) Received: from localhost ([::1]:59392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbu8-00089I-40 for importer@patchew.org; Mon, 01 Nov 2021 14:19:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9F-000866-KK for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:05 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:39766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9D-0001FG-Rw for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:05 -0400 Received: by mail-qt1-x833.google.com with SMTP id t40so16520396qtc.6 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=P+LiSx7CkE3blKbhg5ALaxOT08dtFOhalcqlNc9ibvc=; b=V2lTA/Y0SyqkI3F/CVO9xLOPxUcBsX96fctV4MaXRrmuy/GFlWThtW+eIMBiBLzJ1Q k0fNssuOgFT7FW/qtw1Giww7NalQV9OKG21SkYCghWbjWY5Pch6FQWlD9PdGZSlliCG8 FC+nnJehUVwsWXceiPNTcXyxozB4Nb0+/w5mEauCG/LRUHX6wJueHgiazK20hx39OrjT KQPIWgXWcAKE77sFe20QIFECq3JZAwLpWZjbKC7Liae961MFjfJCQZ2PDTw5O8+UUBsX cLJq32is9OSkPzjlA92PMPltDq3dSamMLogjEOL51W+vCL2nAaAgu75nwtJgjbsHpntd JZqA== 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=k9GU40NemSbWa1ApSlthFpXl34KXP6hJGU23qQ5Ermnr3pQTbP5GAzMbjcig0frUs2 IBkjNzzZR+bavTE74Uyu7aaXaXcdxtpFFz+mpd291QSspSDy1jvet+DVDNt4Hu1KnYQD u//Z7xI441nx/lr3nXqROPpIBg1GUfpw0DuGi1kmQ/zUMnrYErT6U9pzpCp/RQbt7siC sS/jJwhMFx/pubDds/pj74W9K0HJvptc/md3jbAc2jbJnpHlOHG3uXnegfiegArp9jqS 30lw4DkX5i92jbqXoiET0f7jydHhVKluOzPdqkSaUcyvhM5DNpqeKNt1hywweHiyMDy9 xnog== X-Gm-Message-State: AOAM530Mn1oDsAaFTSZUDVtvPmxYNSVUpp+fS+j5KA1jHqswp6rm/+u3 2BBq5NGRO8KfYGbN6X+JpZlfuc/yqe35iw== X-Google-Smtp-Source: ABdhPJx5xUg+zkzQto13rFD6lj1i35sQPUPQjrEgHUbwtqbhe7+6eDk9DjBAjEIv7ovm6wjmSqcj4A== X-Received: by 2002:a05:622a:1305:: with SMTP id v5mr31970764qtk.62.1635787862856; Mon, 01 Nov 2021 10:31:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 54/60] target/sparc: Remove DEBUG_UNALIGNED Date: Mon, 1 Nov 2021 13:27:23 -0400 Message-Id: <20211101172729.23149-55-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635790775245100001 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 Sun May 19 09:23:43 2024 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=1635790876; cv=none; d=zohomail.com; s=zohoarc; b=gi9yRABhXpSgfiBpOcm8zM3ZlTT9BbfOWcnuIK5j7yHhOLY8p7QORzVnxWxFroKeyrETKhoo3jgYh4GqRjWFDfdG9CS7iwq43V/tG3l28OSm5dOuVOewOjEPFEiW9XxEvFBDtu/R+ZgDL+0yagTyko8lH+p+7Sb2ysrPE0mFMSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635790876; 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=BCeaduGDg5lnQDJz/0uLeTcM0XRT3o+s0e8BHkxPyJL92L081D6M7Nuqq1IGzM4ZniS/IdCnZrfs1bnFdQKPXhCaFw37oobvaNYfnk3Rrbli9Cs8j+1EgGjBqFjMKaPiqvK7wp+TSaYsS92ZkJ+6qdYgmawhBp5VC//45svUCpA= 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 1635790876539485.55042721179393; Mon, 1 Nov 2021 11:21:16 -0700 (PDT) Received: from localhost ([::1]:35416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbvn-0002fu-Ci for importer@patchew.org; Mon, 01 Nov 2021 14:21:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9G-00087Z-29 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:06 -0400 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]:40640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9E-0001FV-9s for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:05 -0400 Received: by mail-qt1-x82f.google.com with SMTP id 19so14959868qtt.7 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=fVhlPoABQmS8wc89+ovGDAnkicIV2MZx6WAeJyRD9lM=; b=g3a3YzkCrQ0FDH+4E6/7l84PYcgf7XRqHalyloB5YOnTK1uZ0uSMgRWJEu8+0dS9z0 pgI1ce5loLXKU2Llfw8pqUvsbhV80dgLkM0s6EXD97TF50BHvvNa2f13D1fofdUloLm2 QYPIliZwEQwlc7YEJb+CnRtHlia2iLCQD/WfRZ8uCLRRpkmXLvvtyF5+dq2+x50TS1ZP 1cK83TURr8BA6L/Vk7SwnRgun6hmzw6uFzfHm81q7YH6PCSkdkt6j71uf4GB11u2aJLX ErMgTRh2fQyFuYWao0UtLH8Xw8hOZPHdsD71cW0PvuW0EkLe6t3L6wGNvIIzw5VlSxUJ 7QIQ== 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=tMW+57j/jO8weTMs/zanweRgWBok/zJNbcjztzNAzOE7NQ6TG5mk7aE8cWM133pzga f61fi/V1SEqkNbwlR2mZeT27xmWREsFZvPoGo5pYsIK5LdRiEAmrY6jBa7irGgQ0CZ+u HlefZysPWM0AhmXwfoJOKcwmzHvP+LLUiQQxECeCfQmZRcMpdfBUiRMsxx4UFYDqlEsh RgT/LhWhpx7wgx7zOWwx3kr1bxMf03hQQ7zdhZSZqnzw9DpPRVOHq34Fm6wG3zHUVG6j SjGBOpklwHxntz/6HgWcINU4BRk13tMmorOFPtXIzsFsNMN48F4Dz9LNgeFsu05XC0tH g+Lg== X-Gm-Message-State: AOAM532Mi9cO56ub+DFlVK6MX6bW/oPqgEfG2sP+O3E66ZVNTigKAxOs iBaE/bgIoq4wTdhkQZXZPdhhvLFBgR11Kw== X-Google-Smtp-Source: ABdhPJzEcX8Gy/zLRRaGWFNuoQKQ9Cy0h5ddTW2GZn84mfAj9ajktxgrs3hn6G8GBWVQDD6znp6U8A== X-Received: by 2002:a05:622a:4d4:: with SMTP id q20mr4789192qtx.142.1635787863378; Mon, 01 Nov 2021 10:31:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 55/60] target/sparc: Split out build_sfsr Date: Mon, 1 Nov 2021 13:27:24 -0400 Message-Id: <20211101172729.23149-56-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 1635790877975100001 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 Sun May 19 09:23:43 2024 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=1635791022; cv=none; d=zohomail.com; s=zohoarc; b=ji3UAT8R/9+VNSMsJQeJV6J364gElewk+Le6zi8UwC4IPRiT4fXtvsAWxDpcXBUrOumFjd42pVhIqpoxaLKrH4ECHZKb77q61JurX/qtiaSgZb3bARR13gnk3vJaBK6KSN2cEnAVzNq6ok7q5AYTlMXEUfNqNkKUa58TUpwS4YE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635791022; 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=FCclqZgKxL9budbKaI0KUoVu+M/8RYOeXvdh66K4rPAOTK0Oi5DGBGWVPhROzNCt6jC0LpvO2kdm0n+ExxUNR7VK+JD+XWU+KcYZfa2AA4NRLc0Q5VHhxCH6cUU9Cnkk4YBUikE2GwDfOQM7qwaRFP7BKlBCs0hcwaTeGYR9YyY= 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 1635791022206875.4045513381415; Mon, 1 Nov 2021 11:23:42 -0700 (PDT) Received: from localhost ([::1]:39372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhby9-0005dC-6G for importer@patchew.org; Mon, 01 Nov 2021 14:23:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9I-0008Ci-Cs for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: from mail-qk1-x735.google.com ([2607:f8b0:4864:20::735]:44611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9E-0001Fl-TK for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:07 -0400 Received: by mail-qk1-x735.google.com with SMTP id bj20so5971416qkb.11 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=muffzeHX3yZuoAcxrWs0UhKgv9u/j8rmCNk7xQHU/Hc=; b=IZii9fkJSqj9VrARGRXj9xIOsxlm8xoV0Eln16pxKBywa+lboZudamj8dKEbGdys47 HmgDgYAr0A1j55ahfC3PNrtDsXHinL2fhOJlqysIELcjnrBCMkdrpV6wtdwl89LSklpw hk40Qyvtujr1As50GaWL1mviIohe/Kkf+gP841tt778FTHsjiINkLHOE9bFMYEonVafa l6E+eMoPvLCWwWLkZbzjw51+v+C2BX7lsf3VbaLiyem44Zi4neKjyy5QXLukg2w3o2pM udcSaTblaxlVdTGUfHaELtAaIUkwvGJeaeqKb7XdspPiJXh7g4kIgGA3WZvc9Rw6vU5R D2kw== 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=7pLlFaGCM+KwdDoyMA2AksLmSrzwv61X8CoOmWrTiUSZ3gkCaepaiN0ZJKygFG3ZUy sWNkStJEskUmkGanKtIz7DmFZjmDci9+9ckkM287JECtxDMicp655UkL2qL/kWXbEnqI UlaQxd3KJcpYovOu0HV3ndaKvX3GZBgEOA/A3RmSIeAkcd3HpWp8/YFf7XeldCKya2Bp ro4+Co7/9A9qTIDbWug66YzH8+d4910v8Bgvro57pm7oMZXwQB+YcLLW/3UsYZp5VLfP tOSLWsmSDK6w5Nx6xNUE4mrtSqnAiQie6NqGCLvm+qtGjXWHRQbRO3tB7Y8DDn5y/0ZW PRcQ== X-Gm-Message-State: AOAM530UxoU3KHgWsQnc5De5XyMCTzDZ19DxtUywNrKfZFIbIg3oEqtl qVF3jUTFiAq9p/Iay5nLThfSxkSSFRDQ0g== X-Google-Smtp-Source: ABdhPJxVGGN1OoNWS5Cd3mXE7BwHLp1OvbC7nOSSUkHGNyo+LZf8mD71fSP+oy+8WxUQ7Y1E1wbmHw== X-Received: by 2002:a05:620a:414a:: with SMTP id k10mr8156132qko.309.1635787863987; Mon, 01 Nov 2021 10:31:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 56/60] target/sparc: Set fault address in sparc_cpu_do_unaligned_access Date: Mon, 1 Nov 2021 13:27:25 -0400 Message-Id: <20211101172729.23149-57-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::735; envelope-from=richard.henderson@linaro.org; helo=mail-qk1-x735.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: 1635791023977100001 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 Sun May 19 09:23:43 2024 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 1635791428405130.39979887397385; Mon, 1 Nov 2021 11:30:28 -0700 (PDT) Received: from localhost ([::1]:52628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhc4h-0006DG-9P for importer@patchew.org; Mon, 01 Nov 2021 14:30:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9H-0008Bg-4F for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:07 -0400 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]:38721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9F-0001Fw-Fw for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:06 -0400 Received: by mail-qv1-xf2a.google.com with SMTP id a24so2769124qvb.5 for ; Mon, 01 Nov 2021 10:31:05 -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 13sm1222289qkc.40.2021.11.01.10.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=G7SBr/WksrEb3wfGw9+4/7HGKeZrYxUMshTizcIBHp0=; b=IOoUgL18/wQee0OnpOMixbyFV2o9zbdDNpngx023fYhHLHk/8mzdQRuuuysYNssYDl VmfS+YqjQDtMZXX6n1YWLThrO57VB45rME9Bh/Di55nac90iuH10OLlz3+Je8oZtEsnb uDmB3jtxBSRzukxH6WlLUWVrOALWoOoFi76Bzk/EitIc+Pr76pWFGB0VWJT6zOGYjj+S Fj9ABMJnNdkBF4gGDHXtlT0x+G8ER+3ADqeEEfE3nqjPyTYOdvKq0iyjC6yHV9q3qDNO 6XBavW7mWvDk8pxcZLkv2TbyPqq5ZuVFY8Um5bre0HzPh+bSKGb5X/YyHgYNLVyYL/EQ 14aQ== 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=Snf0bHtIL/5l/28TQduL0AZqkZ4/3YbyhmZFgFf0HsqYVpiqkXftX1GTTrJHCtUaxb M7G40P4DEJlBNboBjqXrhsRQMYw+pXFOvOwNopf+8rRsb8p6+t+6OAFzGUhdQyCYt0zr e/MPb9Uo8r5UJ8F9nVJC5TuKTmR6Rvin9puBwg1YRalYvzFar2ZxcwtHOE/uM7N03a8M YxWfm8OMKZGiw9OQaQwvmjSZAUl0hK1rbeJEl2wDrIwJgmKX4bkrZ6Ydvh77qDW2TdtH W4uOBFtBXfqDsyzwtz53qB+beq8YUG9LIDbXb8wP6Zrvomn0hoBFspvEVc2ifP7X/GMe BQJA== X-Gm-Message-State: AOAM533zWZMH/eESelxNMRskmBWCoxFQhg4BT4uIyjVxfJGPRmhZMCpS 2qWCt1z1Ru93477r8XrkXxCJHLsnUNjvXg== X-Google-Smtp-Source: ABdhPJyJnR4n1z/QiF/o7pid1CSyNLAr5kdB51UFfcFuGxLplPUnRMRoBodk98axS8Wq6HVBwgvNsQ== X-Received: by 2002:a05:6214:1d2b:: with SMTP id f11mr13986523qvd.7.1635787864522; Mon, 01 Nov 2021 10:31:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 57/60] accel/tcg: Report unaligned atomics for user-only Date: Mon, 1 Nov 2021 13:27:26 -0400 Message-Id: <20211101172729.23149-58-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: =?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: 1635791429301100001 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 Sun May 19 09:23:43 2024 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 1635790986693152.0737304943383; Mon, 1 Nov 2021 11:23:06 -0700 (PDT) Received: from localhost ([::1]:37554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhbxZ-0004Kv-Nh for importer@patchew.org; Mon, 01 Nov 2021 14:23:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9H-0008DJ-Un for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]:46015) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9G-0001G7-0T for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:07 -0400 Received: by mail-qt1-x832.google.com with SMTP id r2so15244621qtw.12 for ; Mon, 01 Nov 2021 10:31:05 -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 13sm1222289qkc.40.2021.11.01.10.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=MIsR5ntgtAsaxoJ+NtIU7qk3vK65x7GB6eb5bSAQ4NA=; b=wvE/eYX9Qyng6ZlBHRzu+Ez/di3OPcag/lccP/vgQGCh9A/I1V1oSGMAZNZoqBc29I NIDEOt9oD18caUnxwnWGp1uVvTKcaFJ1Ym/9UovK5RCJQrHxxXUXQYXLnJ6QNPzYX1bJ omlK1pjom3TDe1GYG0hA2hro1h94LyZW1Wj5yn9jhlFWjp1ipo8V50s9wVHdvfhHbSQE aQFbiX3in7azYYu9XRdbAJfwRefkIkIRbwb98xvE+ze3KcNQqbICM6yvGX2CKeY8wrzy IOq1q2w11hcUb9O4S6/M8uwO4OngFaC7aX9vrL9pQ7G9aBrys04mk4uNudc4uDuE6PGR SsqA== 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=k7mXIdLWVIs5x6lvoNdRu7fUQLXlVJMqaL/m2aMuHrAQIYIYQailRJFScbQtQCUE8b Mwr1mPnd3dAXa7L/Xp/O9+BD+72259lFOABLCIQcUIvTwBj+blU3NaWEKnY6RZVHRurA uV4ilbIq5s+tcHecNL/FzdAAHhlKGKjj9YLQ64abJ+TA1gSYbtwo3gF0VAeFroSa6JC5 HRHicit5KS4qeTM5AFVhiDwW4PrY0l2XkeE334Yh5pJfdUbCYks8d32SpOfufm78n+h7 xZxJSDOx0QkaTnDJAYIwrV1Kdef8k7UfsWKWsXBKx7mRKuR7EiXYdwmo+mnaVJZrhA31 H5Iw== X-Gm-Message-State: AOAM531emFsFwXOUbrGSP3eT5b92rnjpZ55/R00v5lqlk4FHj+s5RlrX j+yes8Zzm5YkdPwV7SvJiBHhd024bSLeLg== X-Google-Smtp-Source: ABdhPJxK0QNJlMcSseGIw3Wii3/g+pRpE++4tNoowhfXH4PyNutb9AhY2j0dxqB5XkUEPm2lzoJCtQ== X-Received: by 2002:a05:622a:1007:: with SMTP id d7mr7855829qte.233.1635787865136; Mon, 01 Nov 2021 10:31:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 58/60] accel/tcg: Report unaligned load/store for user-only Date: Mon, 1 Nov 2021 13:27:27 -0400 Message-Id: <20211101172729.23149-59-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635790987449100001 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 Sun May 19 09:23:43 2024 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 1635791995284132.3232446353228; Mon, 1 Nov 2021 11:39:55 -0700 (PDT) Received: from localhost ([::1]:41818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhcDp-0001YO-Uh for importer@patchew.org; Mon, 01 Nov 2021 14:39:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9I-0008F6-SK for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]:43652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9G-0001GH-Mp for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:08 -0400 Received: by mail-qt1-x836.google.com with SMTP id v29so15207723qtc.10 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=7mVMLvhvHhRE4SNYEq8lTvIaJ67DT2EyP7H4YHihO6k=; b=Hbii+yw9ke5otV1LPIoAoxV8MB/+v2oJwLAG8mbAJBIXVwSx9iOQos7PtKUmOVCqU7 Z/4ThAPzxYU8Vuzv//CYBXfJHHqiwxmfUtWz3JQWpz9chsuHpSllOX2xyHKRyGXwQ8fo SY29iYFKXa/QxucwGXU7MPsi+EVSYo2iWDDNHs51TbNR/ewFBHE2ptebzc/K+9pOQWdm q8dRFV3EN1C3WFGiqLMqCPXyHE/aeIN32q1MaSYcgq6svVDIMKHmTX6hnoYAPBtqIuWh PXoPZMCpOYXcaUJAh+889Qf6psEWS3UXWDTzwI6UGrj5shdrMWQCMqUIBGIdBS4Oa+m1 bBLQ== 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=55f74LOSL0ZCitcqt6aTtj6AH5539e2KqHI3oB39P1P0/szTsF5sJMaskZ8ofXh9AV i7e0ib+r26DGY0U4zfmlU63PFz0hiAABKNyWis79YCuYGOcoJrNP4lsufy48CxA/93HT n5n+7veg6vjfatH8KSiDIsSyG9r93obVcNdGsAvw4F9egD1R+XxS63V4z9SK22YsVkAE s/4iYj3xABS33sG4R5AO3Md0wrGp1BR5BmbyJslzC3UgS+0LZMBvCWKlhBwLFDsogMs4 H920SvhJ58iOBvJE2ZAezOLto+zBJ60VKGfz95Dx7IizFUzx8bYHdy1ojkJn4w6jr97V gVqg== X-Gm-Message-State: AOAM5324h7166fZQzXIRmq9GPgOd/ZhKbCZokCiyaxZjBowhYBrGcTwK Oc3tGfAKofOXupjpWDL3mxAXfLSTka7cJg== X-Google-Smtp-Source: ABdhPJwE3mhUy5gvETzL4aLDAcPDYoSme9HbnP8NvafaobGw9UY0EkkFVNo/Q2lGdZRuyjuuFom5hw== X-Received: by 2002:ac8:5d8c:: with SMTP id d12mr8610580qtx.191.1635787865747; Mon, 01 Nov 2021 10:31:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 59/60] tcg: Add helper_unaligned_{ld, st} for user-only sigbus Date: Mon, 1 Nov 2021 13:27:28 -0400 Message-Id: <20211101172729.23149-60-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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: 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: 1635791996347100001 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 Sun May 19 09:23:43 2024 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=1635792406; cv=none; d=zohomail.com; s=zohoarc; b=ixONgWcNDdPn10UxhfiddIYfdMn5Q44jQfVN+gW9eS0jlqXml2mNWbCjHFwi3y1MpNR0jzveOo5HIa70W7LwPm+IxqZGEOhpp9Lm5blA8nEmvDJLXX5f8+kcNBfpr54YZ84aDKDJlSICi0znJ0sdHN+6sXgsbEZVgHLbReizQ7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635792406; 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=UZdGQKz5iwGjxBiJfevBwDyfsKZEm3Qcs1ABmMfLYdg7KyJUnsICxnLeVcR9HoC39cYAwUdTqLVp7ery1mq0rCg8kLXLitkUiASoNrERCn2Ra3bFeWWBoZmuDnuviB9koLoB7C/QJHrXoimau9SUKDWTMVOh6yfzmvPxKJc3k2g= 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 1635792406752628.1648138672047; Mon, 1 Nov 2021 11:46:46 -0700 (PDT) Received: from localhost ([::1]:58742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhcKS-0005rZ-P1 for importer@patchew.org; Mon, 01 Nov 2021 14:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhb9W-0000Wz-IJ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:22 -0400 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:37865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhb9H-0001GO-9U for qemu-devel@nongnu.org; Mon, 01 Nov 2021 13:31:22 -0400 Received: by mail-qk1-x736.google.com with SMTP id r8so3415539qkp.4 for ; Mon, 01 Nov 2021 10:31: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 13sm1222289qkc.40.2021.11.01.10.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 10:31: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=7lLZzifCuDAFtBOJRXRut8iWPXEYL/L2LC9pwY/6QWY=; b=Apt32m2gVLDak4Y+MuMtozXIIfonDVj5IwrO1VkBi+rBJ9jpg4W3DNcYEP5jaYboPH t3t1tvFa0cXUfnY8qAK/7J4RrOTYZE878N2QNACZ7LGfNthBO9owfqVEZjwvE5po5OMU 0F63iUApzxQLf+OwAG9RSGnGO8B1lQLk40T3oW5vMDkIYrKu5ONO++CpFWztBDWxDjaH 937aQTqK0ZxJJi4nUz2FWdqFQCYQtoTUJJh/DyMk6SyUaMbq907sfRTMMBkzukYkAFxF XVfSkCgKGUXvt2Bhb11wmXiM6f1xOu/SkZ449C+tD12kc7T62ahpLSg4UZ40LEYDLO5m qB+g== 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=KwPMCOB+CuM7bSjR0i+eIx7rNa2iPax+e1+r/202+FljTy/TdcjEmXxfadkz6U0V8h xkEP3hA+CSf0dr0k9v6ecWXe/QytXz1FVFYhYJdIAQ9WsoGHQz7COZJmRZypokQ7dYAb 4bCvN1qqZvumiotdIf/ur7URd7qWWydJ8bgY8j1dDsi01W9pB+bIxxff9uyG4tVIEsf4 l9WVoVYV4kF/EejUdno85VoCSX/pbbMUwfOH5MpSKQHzUvK+jXPB/xYRauMDhCEa9fvR pfFTVV8P5b39l5S9qoMgYM5aTpEk4fIMFEYsZXgK8vl+cgQFmDxu7NPYbjD2VeFrAQti qcKw== X-Gm-Message-State: AOAM532td1QaSX3Q9D4MdEjowxj8M3sOc7LB4g0L/zzBggj1zXA1sqNa A4gmFUJDjoZ/ewuwIO5AxDqa9BlO8wdHjg== X-Google-Smtp-Source: ABdhPJz6EbPMSjjJR12O73DY51uKibIKg6P2kUgslPE9ltBTMbY93TBOZJLDvSICOm6zdNe++wzcEA== X-Received: by 2002:a37:b147:: with SMTP id a68mr25092790qkf.157.1635787866355; Mon, 01 Nov 2021 10:31:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 60/60] linux-user: Handle BUS_ADRALN in host_signal_handler Date: Mon, 1 Nov 2021 13:27:29 -0400 Message-Id: <20211101172729.23149-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101172729.23149-1-richard.henderson@linaro.org> References: <20211101172729.23149-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::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, 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: 1635792408421100001 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