From patchwork Wed Apr 17 18:27:58 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: 789321 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp172794wrm; Wed, 17 Apr 2024 11:29:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuwSOqaCEGV3Jl1V+Nl2uQ/6Un5JMzDOEobWo3diaTJfvNvvWGvWdkqW7IbkMwNkRgzSlDf8UgRtz2vZXZT48u X-Google-Smtp-Source: AGHT+IHIW93F/s1ar83tZGwxuiaqV5Nogp8gDG7xKEtdGWwXas2bD9PMvASIc2mkL+SNdeAHuAZc X-Received: by 2002:a05:690c:f8e:b0:618:1ce6:b618 with SMTP id df14-20020a05690c0f8e00b006181ce6b618mr132749ywb.12.1713378587417; Wed, 17 Apr 2024 11:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713378587; cv=none; d=google.com; s=arc-20160816; b=Ow7ppHbzj43DUVw/D9ZHppfampQikUAHE+q5rIXqr9aJJcs7PuZqQO5GRlNJx1jWaI P/WbkyCtsT2vhE3K3JLia5UBnmWRw1a+O1JAYW05EuKhTUrhIGHit1dVP6IFMbL8o2y8 ePGMsT4kuaz3ZQX77UNebgYJf59bjvSQIGR1CcC5Wb6QMVpSobTJzOupGLXb6AGSh8SK h1PaB+qHaHgMHDQC9UDb1i8VFWZKJDefVOOmB/1+0LH9HqCyE0e0rhkTuIXXJWYgoL67 OweK+K/sTfAHbnMvLimgb+PfP6TtO3ukA28y/vEMSdFeKcfzAggEwbf1tT0SGbk1MFND IPag== 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=ZshIaCnSYMR+iOE/aqIWZYs6swUMEabN3Qo8HFzzTJI=; fh=ZXDWg7hKG7Hj19AbRuutTLw+Zvn/B9RsGUUw/YagpFI=; b=LBzdDmVuB36OpDP21FtCCGOcKMeejv5hWxJ/PLzqg26zjDacyFrO8mvTWx9n3x/Gmd E7oCMqiEt0Si7DDCciCamSgw4apC0oIOQkAxwzaW6JfL9cqPblyhSVxPWw1Zgf6utz6s 18DStFdVGvPuPp2hrGenB+t6cY8LApEqsJRAmjVcPamd1T9tzZWkR1EwmH4waGa5f3mp QyjMSDtjX6w6FSl4ssYQ77JyJ8uk/9Wxb9mLGpSylzB1YaVwBU+sGXFBArDGBQ6xrub5 QSSnOiFr8bfB+BMOzCi4Yf9rAaOugXoQ7C4qoU/PqOx2laUMAqQOfdalxr9795eXyQFB kjSA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDtWhC1d; 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 ey12-20020a0562140b6c00b0069b6afaf166si11406369qvb.131.2024.04.17.11.29.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Apr 2024 11:29:47 -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=bDtWhC1d; 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 1rxA2C-0001vT-CS; Wed, 17 Apr 2024 14:29:28 -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 1rxA2A-0001uJ-Po for qemu-devel@nongnu.org; Wed, 17 Apr 2024 14:29:26 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxA28-0003Vy-NL for qemu-devel@nongnu.org; Wed, 17 Apr 2024 14:29:26 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-418d1edcd4cso356145e9.1 for ; Wed, 17 Apr 2024 11:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713378563; x=1713983363; 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=ZshIaCnSYMR+iOE/aqIWZYs6swUMEabN3Qo8HFzzTJI=; b=bDtWhC1dbHTPHP686fHaNQU/xP48nLlKYqIScmeWRbACTCGQxwMysLkUGO1UNbDVLh CCpZgaJ4tmMhcUrm3dQ+RvE1xcirQOtN6zZj7Uxv+AN7IWHZ/llNkXMQeS2+kVRBk7uR kISLigrT0Jlo8cBnDlvHQ9Pvmqd2Lq9d10kyc1sqnMjoTxq/pApuhZtRRDFlNi2U4C4x Px7cQvtdLGzoc+pQbRUf96APMowdDnTMj3MLL+2Owx6HhakXKMsCNbzNBrKjOzGAIV3v gJAZhTB6NeqF7J/TrVnRcng9e1QdN8DiNsOFpoQNNhvyBpp4SHYHQMj2Ozmb57Ksygnk MPyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713378563; x=1713983363; 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=ZshIaCnSYMR+iOE/aqIWZYs6swUMEabN3Qo8HFzzTJI=; b=STyzvS2hosqTrutKodamOUCPKz1NRR/68NBV8yYERmsg7ZtykrlXQpxnXTViBFvLtL 9zKasUBmtVDeNtJ722flRtP2+vpTIIiuqvuvMSQd+czhoyNhm63YdbdUN5hVhNtK9bsZ UHJ0a/hC1hcq/bqxfX/NWGV59oF7atri4EdCQzHo/TL9o/Jzlkd6w0a5WjSWlat3ZpYc EOu3OAqoE9ywLd4mfgDgyOh5DXKOE3E69AiUUyWCNH96wj32Qn8j9tf9amQ6JvCwFdBE k2/OJWbgCLP4ClpNBalp+J4CfQP5shWcYoTSJP+1pLuNDcrXW6dUHIZA8+TglB18ZRKQ 2tYw== X-Gm-Message-State: AOJu0YzMEtsNc32Rblty/aPOQBloh+7C3NctMwI7Jfpl44kwgBc58GPP SfV1s4ugRPbbodONINorU8HHVLZQr4kG8bnxFtAf3dDXFIx6KuQyMnCeb6k9fxHBovVUvc9nUJj P X-Received: by 2002:a05:600c:45c6:b0:416:3317:5951 with SMTP id s6-20020a05600c45c600b0041633175951mr292871wmo.6.1713378562840; Wed, 17 Apr 2024 11:29:22 -0700 (PDT) Received: from m1x-phil.lan ([176.187.201.23]) by smtp.gmail.com with ESMTPSA id g3-20020a05600c310300b00417bab31bd2sm3900751wmo.26.2024.04.17.11.29.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 11:29:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= Subject: [PATCH 13/21] accel/tcg: Un-inline retaddr helpers to 'user-retaddr.h' Date: Wed, 17 Apr 2024 20:27:58 +0200 Message-ID: <20240417182806.69446-14-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240417182806.69446-1-philmd@linaro.org> References: <20240417182806.69446-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 set_helper_retaddr() is only used in accel/tcg/user-exec.c. clear_helper_retaddr() is only used in accel/tcg/user-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;