From patchwork Fri Apr 26 19:41:35 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: 792369 Delivered-To: patch@linaro.org Received: by 2002:adf:cc13:0:b0:346:15ad:a2a with SMTP id x19csp626440wrh; Fri, 26 Apr 2024 12:47:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXgualHQl3XtYBXgLycYKW9bdTzNlRG2PgOKNA/EbdtFDgTwCU6hCa2ii+OCEdqrY2DO99bfJmTnXagVvveXI0D X-Google-Smtp-Source: AGHT+IFR/sUn/xbaKULNi+pq/ooAc3Ex1sXg8lZmP0qXulpyfB2Phum7uG13phWk4f7vInPUcsI3 X-Received: by 2002:ac8:5a0a:0:b0:43a:4bb6:e19d with SMTP id n10-20020ac85a0a000000b0043a4bb6e19dmr3754071qta.23.1714160879710; Fri, 26 Apr 2024 12:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714160879; cv=none; d=google.com; s=arc-20160816; b=Rsc7j5XL4qX2ugUYYBvPFAEELq7MupKvnHztAz2Wyc+6+jyYRQs06hzjc4UcL5rp7Y Nh+mIDpOnoyVagbJy2mS2U9/N780QEDVr8njWdFNkvtHcUgWm9ZJ6sAcNJNvNJJE4f5U Raeej3AZfan2QtsmdU0fxNo93mta+3Y0rSya3DTxs7fiRoSNLs6+TGa2rFopd1FaEbyw WxoVyrvH7qEw+7Z2I5xHcGihFuvjYcoClRfSTl7YxL3bEAvl3y5p+bMwX5wD4PfMsMff 0m8FIL5hjinsaIq1ACKc9uCw6Ry2Xojv40X2xLY0bAUvMMFx7OHPuCCP6pEkvyJmhhkS 7hBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=6ledkbh8k2HTuIvDABWBQUBebX3R5+DXtp/0ED5fWzA=; fh=sYHwNYxcKl934eeYBqheGdiV8Hwbu4VfWXOT5e73QAU=; b=gDcD5M0lKUBO/rewvyx3hwV4H3iWrgZrfUf2yh+OFk4RwUMuxpnaOxboV8ziSj4bh8 LE40AI71PgUB8VXT17AXCT5KmPUOlpgWaeUk5Agth0fh5NeQY8Pt6XOwcnohhl2fXzp7 b2vbrGNJwsFDNzTI8AgN3Z5FOdm+zqgMaL+sugICSmJodOkIjGNKwDTgKH8SFtp/NLtH 4NkkZYJuNdrI3gWu4qZTeEhcDsxbRINQhb0JRZTTOC7Ss6vFMThNYkFqCLUHuL9Mh9o6 b8QBa8expeb+ic/plU6K4hmPtl3gRiWNXVwIL/Jyl1SochyjfjKRjN4iEtwwB6BnyUu4 CuGw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YDpF/XGp"; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p20-20020a05622a00d400b00437545f0670si20912865qtw.683.2024.04.26.12.47.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Apr 2024 12:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="YDpF/XGp"; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0RUb-0004Eo-5d; Fri, 26 Apr 2024 15:44:21 -0400 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 1s0RTw-000294-N8 for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:43:41 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0RTq-0003BT-Aj for qemu-devel@nongnu.org; Fri, 26 Apr 2024 15:43:40 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-56e48d0a632so3784688a12.2 for ; Fri, 26 Apr 2024 12:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714160612; x=1714765412; 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=6ledkbh8k2HTuIvDABWBQUBebX3R5+DXtp/0ED5fWzA=; b=YDpF/XGp+M9BknmM5aeV92FaUZY+j0g8hSbONhONijwA12TaFNGex9mLxFfQAe5G9c ySMduJHjAuLN2zvjLpb31xn3EvxD4IZ59qD5Q+sp7IMTVb+PHVjqUW7aFyyBuxKlKS5H ASYC88Imx1YX0chAvDG86J72dZkm88ts54BVookVk+QAAeXLyh+aQmNqEmNw34lV4Jlt EewiQ6aM+A4UZ/FTweCiEwary/pKV5jyNujNpl4Eb2UVtWgjzZFcwh90Ymn/cE5B7c3i A/ikPaD3i7J7Ivf4o5sPLr8nACNlsg2ih+7ZvYUroFnPiZxNXVERfxuyeM1dPAtbaK7A ugpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714160612; x=1714765412; 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=6ledkbh8k2HTuIvDABWBQUBebX3R5+DXtp/0ED5fWzA=; b=NOhwacle6J+1KWRSHPTrK0GKftefyWGOrIFWKrQHGxHaBi9jEHlBLHbnJjSmAIr6so RkUd23MeoA00FxUV/CIDLdTrAwN+6bqrRqdNMcw1vm9rPJyDmWzLFSY7X2LQ1USTBb3D HvrORUjcaKi+KoMuun9iYjVzUrCpKkRzilMRi68Ag93F7J24+HZsUrtYiib+GV+0akjC kVkw5AHTuNhzhofgJCDRRis1Hot465Js13p7NgK0PEuZ/Uhomy0209nH8o+OvwqsuSzu GKR6/yr59aWoMHtIrG3kTYb60KF6YYWiqUE11zUNB8vBTgrkZsYu/S8kTEew3Sopoa8t KrxA== X-Gm-Message-State: AOJu0YzK2Aa47RrZH9GDtGf6Sm66Lr5jYImJbUvC297ybw6S8YZF6I1P 6b8Lj6EN64VqhNTp+XHEqY78vv5A3NeBsSpahpKwzVEMmFPl8TN6L7F/CT5ceOulJmx/zf4L0/+ p0d8= X-Received: by 2002:aa7:cb8c:0:b0:572:637b:c7e1 with SMTP id r12-20020aa7cb8c000000b00572637bc7e1mr1039807edt.21.1714160612244; Fri, 26 Apr 2024 12:43:32 -0700 (PDT) Received: from m1x-phil.lan (aul93-h02-176-184-11-147.dsl.sta.abo.bbox.fr. [176.184.11.147]) by smtp.gmail.com with ESMTPSA id be12-20020a0564021a2c00b0056bf7f92346sm10310057edb.50.2024.04.26.12.43.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Apr 2024 12:43:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini , Riku Voipio Subject: [PULL 15/38] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Date: Fri, 26 Apr 2024 21:41:35 +0200 Message-ID: <20240426194200.43723-16-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240426194200.43723-1-philmd@linaro.org> References: <20240426194200.43723-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=philmd@linaro.org; helo=mail-ed1-x531.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org set_helper_retaddr() is only used in accel/tcg/user-exec.c. clear_helper_retaddr() is only used in accel/tcg/cpu-exec.c and accel/tcg/user-exec.c. No need to expose their definitions to all user-emulation files including "exec/cpu_ldst.h", move them to a new "user-retaddr.h" header (restricted to accel/tcg/). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20231211212003.21686-19-philmd@linaro.org> --- accel/tcg/user-retaddr.h | 28 ++++++++++++++++++++++++++++ include/exec/cpu_ldst.h | 28 ++-------------------------- accel/tcg/cpu-exec.c | 3 +++ accel/tcg/user-exec.c | 1 + 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 accel/tcg/user-retaddr.h diff --git a/accel/tcg/user-retaddr.h b/accel/tcg/user-retaddr.h new file mode 100644 index 0000000000..e0f57e1994 --- /dev/null +++ b/accel/tcg/user-retaddr.h @@ -0,0 +1,28 @@ +#ifndef ACCEL_TCG_USER_RETADDR_H +#define ACCEL_TCG_USER_RETADDR_H + +#include "qemu/atomic.h" + +extern __thread uintptr_t helper_retaddr; + +static inline void set_helper_retaddr(uintptr_t ra) +{ + helper_retaddr = ra; + /* + * Ensure that this write is visible to the SIGSEGV handler that + * may be invoked due to a subsequent invalid memory operation. + */ + signal_barrier(); +} + +static inline void clear_helper_retaddr(void) +{ + /* + * Ensure that previous memory operations have succeeded before + * removing the data visible to the signal handler. + */ + signal_barrier(); + helper_retaddr = 0; +} + +#endif diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index eb8f3f0595..82690d3947 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -300,31 +300,7 @@ Int128 cpu_atomic_cmpxchgo_be_mmu(CPUArchState *env, abi_ptr addr, Int128 cmpv, Int128 newv, MemOpIdx oi, uintptr_t retaddr); -#if defined(CONFIG_USER_ONLY) - -extern __thread uintptr_t helper_retaddr; - -static inline void set_helper_retaddr(uintptr_t ra) -{ - helper_retaddr = ra; - /* - * Ensure that this write is visible to the SIGSEGV handler that - * may be invoked due to a subsequent invalid memory operation. - */ - signal_barrier(); -} - -static inline void clear_helper_retaddr(void) -{ - /* - * Ensure that previous memory operations have succeeded before - * removing the data visible to the signal handler. - */ - signal_barrier(); - helper_retaddr = 0; -} - -#else +#if !defined(CONFIG_USER_ONLY) #include "tcg/oversized-guest.h" @@ -376,7 +352,7 @@ static inline CPUTLBEntry *tlb_entry(CPUState *cpu, uintptr_t mmu_idx, return &cpu->neg.tlb.f[mmu_idx].table[tlb_index(cpu, mmu_idx, addr)]; } -#endif /* defined(CONFIG_USER_ONLY) */ +#endif /* !defined(CONFIG_USER_ONLY) */ #if TARGET_BIG_ENDIAN # define cpu_lduw_data cpu_lduw_be_data diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 5c70748060..225e5fbd3e 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -41,6 +41,9 @@ #include "tb-context.h" #include "internal-common.h" #include "internal-target.h" +#if defined(CONFIG_USER_ONLY) +#include "user-retaddr.h" +#endif /* -icount align implementation. */ diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 3cac3a78c4..1c621477ad 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -31,6 +31,7 @@ #include "tcg/tcg-ldst.h" #include "internal-common.h" #include "internal-target.h" +#include "user-retaddr.h" __thread uintptr_t helper_retaddr;