From patchwork Thu Dec 12 18:53:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 849754 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp1103983wry; Thu, 12 Dec 2024 10:57:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWejoqZmH5D2k0RaEAfowlYidhfzVmE7WnoMLXIt+0Zgb1WsEoV9RdNw+s4b1dOX9HDbXEcMg==@linaro.org X-Google-Smtp-Source: AGHT+IHLmqGXYfBxIXWZ6bNzot+qjJciz59xKjAwbQiKGG+k3TkTGGgKWxOvHz35922EkY0m3J4m X-Received: by 2002:a05:622a:4d43:b0:466:a6e5:6f0f with SMTP id d75a77b69052e-467a14ecc0cmr30696431cf.4.1734029852628; Thu, 12 Dec 2024 10:57:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734029852; cv=none; d=google.com; s=arc-20240605; b=TeQnYuafnJjwBhrCb/qI84s7Um/etjIibAtz+JTvy263sh4+8B1uIYAvzpiSWX5CNd i6o9HMKKp6gDzlx1+WSNuxSxmh1QFGy8QYmQB2Tnxig0hEkAxX+7TNACQ3N5XAoeYPuD zf+KdNlPy+IVDMfxfq/q1I/BI3n/eDdp1llGCz9IROsnok9HHoDh5xPJTV1apBHln6K7 vgk5kMED1iasbREb23sofq+fEdIalh5IIGocSTLI+TJNSxhLCsaF1etEQwh6fWruFC0f nTIqUBNVDkSLSRLu9fu80LMJerEvQbTiYfJRPFZq0bKxUcJEL0/6070awpWQjFrNwExl RbMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZoaiN8fGbAdoZl91RstCXbOrdj9RzBIlWptTLfxPGQw=; fh=pnqwS/3OtHZ8LqG0NTMbRB51yilWjG1VtPDdq2UnsIY=; b=B/hsWYdvNzglTG657c2ki6NkzeKvNExgHC9/6Yy8VWlwas6hl0zzqUtDXUdrl6F0x9 qIzOPVEu+TJZzObN1TaJI88IUA70P+kQCjBoqYtdoTZzMt3hm546rvkxiKYVaI51yTIN kOLHmSLOVaRMWI5lF7nBv2099mQ/1f1BeDt8Yi91rEELwsEnGJw9XNZ2Ob5u58LLq7pH U69YYUoA4BIjJRWta6U+CWQcrxEwLyYWTgDYnHAZNY9sGqOGt7P8+smkF7NgX+mdR7fy zrxi13ou0TysGrhiCcRht/eAY+BQDdSw6Q2cB7ZQGWhfCA8JC8SbP8/9UtwnGVf0blX/ wCuw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HNYLi/sz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-467942a150bsi33964011cf.680.2024.12.12.10.57.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Dec 2024 10:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HNYLi/sz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLoNH-0004of-2X; Thu, 12 Dec 2024 13:57:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLoN6-0003T7-5W for qemu-devel@nongnu.org; Thu, 12 Dec 2024 13:57:12 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLoN4-0006wD-4H for qemu-devel@nongnu.org; Thu, 12 Dec 2024 13:57:11 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-434a736518eso12507085e9.1 for ; Thu, 12 Dec 2024 10:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734029828; x=1734634628; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZoaiN8fGbAdoZl91RstCXbOrdj9RzBIlWptTLfxPGQw=; b=HNYLi/szYbPQjuuFSC0A3aRyKVOkuUFuThdF3h2fjqKXs3RzgcTTdq/LrZovOvr2IO ITPSF0Bu381MPFAgZY5R46l42w/E+VWeXVghtpLl3gtdH/TsAofFhAq3LPB2i17HvjuR lS+5atKhZJzfblqjrQ12N7Q1tc31UATJVXJ4sxFUrWORYOqWBlFTaqnPViHt767Gn2mf UwifhWwpF3hLVHybg/ShiaYEnvVLSr3cby/gs+6M3w5i+eaetky+y311lzLqgWAfXkDT sN/OZH4YUVMQn1RRK2JHptNa/HweTl9JLGA0C+m48F0JK4o8CBgR1KrsclG+yAH8ZnD1 VuPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734029828; x=1734634628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZoaiN8fGbAdoZl91RstCXbOrdj9RzBIlWptTLfxPGQw=; b=oF2jaPECk4zvov8styU2qK2v0peR7z7A8s4DL252jd3HwqRKNJVZshPhcKsk5zTUC9 3S89PdF3xS1GxQ15QdrztAIKEOtmqmbRBfGuqB14TFwWs3MzrckE4ePz6pYHuQX5+7zp wH0IEUpeycha49JGJD0PmRRoHN5rOTS4nMOJxVrK4zHiu80kGIyYzhOwazE0n/rA8tBe Gw+uPjVVrnI55l25W2qknYxPM2lvDq7apEHvmNbyYEBSSAMnIUR0RrNKb7hAZ/gZDtK7 Hff8GlL/WkBjQB7IYWmfY+etr7P1DilbFj8fXDQhIBF6iHez4Fnyu9WTG4HNJAXgqWga Ot5w== X-Gm-Message-State: AOJu0YzIV6E/y7jFUz7fs+qFssHvsXLMZOivC30+vs7i6jY+m+ZSTOxI CxF0SrEFrZ976VvVPzvuGFmaWlwhzE7WCg/NA6BaI23jvcBz/8kBNgy0WpnhIDCTjUKI3dMPoNI 0 X-Gm-Gg: ASbGncsA8LRM+AQ8z79i8LESYsUWU4MDkW7lQK3fnAV9b7RKw3tq+N1y1PhnJFEHE6m lST/3bXwShzzmpGEp4IKptu7cRxfNOkv63P0mbVk/JUbBuZ2EWkHHRNRKNjKghEMUn3af5XoO7y qbPdFdZRAc9b52RbeJ7ehktceMVFfkWyS0xG5LfgRcGFWo5TrIHPmjbuVHdatcLT/pdFGEbmWTW gicyG2anuU6BKz6J+k+/l5AOrQqp0nr0EkyMGPeJhq5I3ZcqRE1vN4Gk7AFIKTUyZFm3YkQlTdP tFPbxhUILC7bW4VvhfwDF+fBEEk8Hxo= X-Received: by 2002:a05:600c:5122:b0:434:f586:7520 with SMTP id 5b1f17b1804b1-4361c393894mr70283425e9.6.1734029827803; Thu, 12 Dec 2024 10:57:07 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436255531dasm24469585e9.8.2024.12.12.10.57.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Dec 2024 10:57:07 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= Subject: [PATCH 18/18] user: Move various declarations out of 'exec/exec-all.h' Date: Thu, 12 Dec 2024 19:53:41 +0100 Message-ID: <20241212185341.2857-19-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241212185341.2857-1-philmd@linaro.org> References: <20241212185341.2857-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Move various declarations related to user emulation from "exec/exec-all.h" to "user/cpu_loop.h". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Pierrick Bouvier --- include/exec/exec-all.h | 55 +------------------------------------ include/user/cpu_loop.h | 54 ++++++++++++++++++++++++++++++++++++ accel/tcg/user-exec.c | 1 + bsd-user/signal.c | 1 + linux-user/signal.c | 1 + target/arm/tcg/mte_helper.c | 1 + 6 files changed, 59 insertions(+), 54 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index b5ea607cf45..c4a6ad3af2d 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -22,7 +22,6 @@ #include "cpu.h" #if defined(CONFIG_USER_ONLY) -#include "exec/abi_ptr.h" #include "exec/cpu_ldst.h" #endif #include "exec/mmu-access-type.h" @@ -518,60 +517,8 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, return get_page_addr_code_hostp(env, addr, NULL); } -#if defined(CONFIG_USER_ONLY) +#if !defined(CONFIG_USER_ONLY) -/** - * 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); - -/** - * 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_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. - */ -G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, - MMUAccessType access_type, - bool maperr, uintptr_t ra); - -/** - * 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. - */ -G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, - MMUAccessType access_type, - uintptr_t ra); - -#else void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length); void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length); diff --git a/include/user/cpu_loop.h b/include/user/cpu_loop.h index b0d4704018d..2f93575e2f4 100644 --- a/include/user/cpu_loop.h +++ b/include/user/cpu_loop.h @@ -20,7 +20,10 @@ #ifndef USER_CPU_LOOP_H #define USER_CPU_LOOP_H +#include "exec/abi_ptr.h" +#include "exec/mmu-access-type.h" #include "exec/log.h" +#include "exec/target_long.h" #include "special-errno.h" G_NORETURN void cpu_loop(CPUArchState *env); @@ -33,4 +36,55 @@ typedef struct target_pt_regs target_pt_regs; void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs); +/** + * 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); + +/** + * 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_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. + */ +G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, + bool maperr, uintptr_t ra); + +/** + * 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. + */ +G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, + MMUAccessType access_type, + uintptr_t ra); + #endif diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 815a39503f3..0561c4f6dc7 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -24,6 +24,7 @@ #include "qemu/bitops.h" #include "qemu/rcu.h" #include "exec/cpu_ldst.h" +#include "user/cpu_loop.h" #include "qemu/main-loop.h" #include "user/page-protection.h" #include "exec/page-protection.h" diff --git a/bsd-user/signal.c b/bsd-user/signal.c index edbcd461bfa..b4e1458237a 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" #include "qemu.h" +#include "user/cpu_loop.h" #include "exec/page-protection.h" #include "user/page-protection.h" #include "user/tswap-target.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index a191e9b26f2..087c4d270e4 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -33,6 +33,7 @@ #include "trace.h" #include "signal-common.h" #include "host-signal.h" +#include "user/cpu_loop.h" #include "user/page-protection.h" #include "user/safe-syscall.h" #include "tcg/tcg.h" diff --git a/target/arm/tcg/mte_helper.c b/target/arm/tcg/mte_helper.c index ae037dc9143..846d659ff77 100644 --- a/target/arm/tcg/mte_helper.c +++ b/target/arm/tcg/mte_helper.c @@ -25,6 +25,7 @@ #include "exec/page-protection.h" #ifdef CONFIG_USER_ONLY #include "user/page-protection.h" +#include "user/cpu_loop.h" #endif #include "exec/ram_addr.h" #include "exec/cpu_ldst.h"