From patchwork Fri Mar 7 18:56:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 871233 Delivered-To: patch@linaro.org Received: by 2002:a5d:64c8:0:b0:38f:210b:807b with SMTP id f8csp915537wri; Fri, 7 Mar 2025 10:57:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWHMj/xwlr1JJ8gsKGPSooKJWxLUhA5xZ54k841qao+MOZI5HVTHQ5uIimd1ND3mx6qYeNd+A==@linaro.org X-Google-Smtp-Source: AGHT+IGERcLY1bE0Wezct7rU/UYn/Ueqkve4VQYLqSom+CeySG3nh59UwE3/HeWtVYotueo4Ozs6 X-Received: by 2002:ac8:7fcd:0:b0:474:fb51:b58f with SMTP id d75a77b69052e-476109b34c4mr64587191cf.30.1741373862136; Fri, 07 Mar 2025 10:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1741373862; cv=none; d=google.com; s=arc-20240605; b=GEvJhy0Jfqs2vTRq0Nfro86ztyjIHmsD3Ry1Qy0ygGOCgqfL7nGGIba0Il7BSxWbY2 UbscL4XLIK5mdrE93jOcxT40B6DEmHJ3/9TJti1QLJShp2dHZnK+U1hhV6A/4vpHHMw+ pikD+W44lcQQyLz5YYswU4Eo6++ZjtV+V8Zu8FkJi9xc3ATlTNiW7A388y5XOe4pt6+1 0ojtaHhj58FZBBDf2yWAZhHRPfd49cy69qBsxu54HWug1K/jVBE4W3xqnbTr/ZOmf4S9 dh8S0gW5nFWFUkl3MXXSfgBNEczZRjFWscrWJxXbZyLBsG7y6Nc7W1ECkD7HyBQYXSzj jEiw== 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=RytMCD0LlZ8TULuAO+TyiQ/M0TGfjDPA2CE/B7x8fYg=; fh=ycigHkwOPieh2u5PmcA89sNk/qPD1ZkdDlL8Mchfvw8=; b=Ws2G0yc96eOIjn2DXxGrdPAqOB8OoYaBhnaNV3BbvGGNWqlr6D/Q9npSzuDq134pzz wCam/P43nCrZA7PrnG4xdujx+Sw31+z+UF7JjdABZ/fAnJ/7IVVcgqE7odAqYIP3IP9P uuV+PpP96M5yQqF5umpAncFzw48f0eFNCzR8Xnp7iXTd/fnuWh10j5Yeh5cEGiCoMC/y TrOMGSIJdol5nePm6EYelsFqsBvMHsBJzyUeTs4BCV+nJuDcgVjhT6aC6D6cjq0Wy5sS S/HXL7+ydVteVo+M18KUOq0u7bdgknACsESS+OZRtpgcDP+lkcp5YBQRpDz6LDzwMYmz z4ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eRjIM7YL; 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-4751db3c393si37823201cf.495.2025.03.07.10.57.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Mar 2025 10:57:42 -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=eRjIM7YL; 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 1tqcsc-0007Ww-Hv; Fri, 07 Mar 2025 13:57:06 -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 1tqcsX-0007US-FR for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:57:01 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tqcsV-0007oZ-HW for qemu-devel@nongnu.org; Fri, 07 Mar 2025 13:57:01 -0500 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2ff087762bbso3426749a91.3 for ; Fri, 07 Mar 2025 10:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741373818; x=1741978618; 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=RytMCD0LlZ8TULuAO+TyiQ/M0TGfjDPA2CE/B7x8fYg=; b=eRjIM7YLZBgFKoD48CopjteZE+NKJUCbVxUn6Nideg0MKEfs41ZHYRjbU3XnHd2sAe 5KFvZdIQ9LT6+902mwaSSuHqhg12oUkV9fs2zsttb3jCGVwu4oyv4E6egrBX25VVBnrg h32JE8necZfpJxc0mUA5uixp/WoIW6uMnv/1kUQ1hjA5lOlZhQ0aTz8yIvtLsor0zJwf UbBpBeW3qRwctUhW23zQxF9z08ZL2fG4IWG+eKX8Loesm9kbyCosr4eRJtmHIb3fotug MIFhUV3klnSBKHjqsH4OlFMP+fgJM1vAes4fzqWcN90qkQvSl0f6rTUJ0AugEjU+xnLR eJ2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741373818; x=1741978618; 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=RytMCD0LlZ8TULuAO+TyiQ/M0TGfjDPA2CE/B7x8fYg=; b=XgEFgcgpqoYDktbpabQUs/Pb6j1g//Z5Xbov8eLoB0Zt3cNv/6HV1weygUfwVKaa4h c6qLhIg+RRY6WMUar5SgteW8+pcfD6zzLAv1sE+ZO0wECuv5zcVqrULo4tAdgKGmpB3R JXhu9i67io3s7lAqmXMvrFvGyyWyH5fzmQXW60Rbc2xPsnAv0oEbQorq8l8v+ZHUR6v4 3fRp3MJJ2uRCrnvTjiPeTR6pmm16J5NkvQ0+mHc5axv0+Pq8wG9jL3R2v40oiMcgdvst F87PelKf1rlrV5S1jr3JD0/qUAdAygcHI5RBCA9gPyFWplSVocEzHkga4rZV2z26TCI8 EOjg== X-Gm-Message-State: AOJu0Yzz5hCe1TT+NdZJ+8Mqg1c8HP1chqlZZDzT5uH8Zkbkn51+yAvc 5tRenc5Br0ViuHaivVJoK2a6tqbzFxXgEwQTFvuF4FlU5+HIgM3ShWf+3TJAPLVRifLsec2EqB3 h X-Gm-Gg: ASbGnctFAKui2lskGfXOzOHIdPwbmjAwnLguxPkfc3PrPXqOSV7Tlpb8HAogS41rZ2h 7xWbAfCCDQxYSK7a8oXUtYB7DqK4VwXnVF25k4StCSm07rxFmpZ5/8UT1Dz+YcJ8JA2ogKcsPrQ aKgR5Ee5BwMI7BWb0F0ShdK+5w4h9x0eFQmy+UF5Hx+HPVWGag6BSxEimk5VbtOjem+WtQow8s9 RaE+7fbuo0/tdTQ1CfGUU8vjyU3o76K/TU/uniCkcqFjI4sSxNHsmbGp0QHATxJvqXZJbQhTlg7 Eel9UG1j2cKIKR4KwQVl//gWLrfLnX6H+9W8w4l5sYglmj6HzbHh7sNhEvNUXQJ0sIPB7y0go/Z H X-Received: by 2002:a17:90b:52c3:b0:2fe:b77a:2eab with SMTP id 98e67ed59e1d1-2ff7cf26f00mr6164815a91.32.1741373817883; Fri, 07 Mar 2025 10:56:57 -0800 (PST) Received: from stoup.. (174-21-74-48.tukw.qwest.net. [174.21.74.48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ff693534f8sm3391917a91.17.2025.03.07.10.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Mar 2025 10:56:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH 14/16] include/exec: Split out helper-getpc.h Date: Fri, 7 Mar 2025 10:56:43 -0800 Message-ID: <20250307185645.970034-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307185645.970034-1-richard.henderson@linaro.org> References: <20250307185645.970034-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 Split out GETPC and GETPC_ADJ to a target-independent header. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- include/exec/exec-all.h | 19 +------------------ include/exec/helper-getpc.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 include/exec/helper-getpc.h diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index a758b7a843..22a99ca502 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -26,6 +26,7 @@ #endif #include "exec/mmu-access-type.h" #include "exec/translation-block.h" +#include "exec/helper-getpc.h" #if defined(CONFIG_TCG) @@ -177,24 +178,6 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t last); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); -/* GETPC is the true target of the return instruction that we'll execute. */ -#if defined(CONFIG_TCG_INTERPRETER) -extern __thread uintptr_t tci_tb_ptr; -# define GETPC() tci_tb_ptr -#else -# define GETPC() \ - ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) -#endif - -/* The true return address will often point to a host insn that is part of - the next translated guest insn. Adjust the address backward to point to - the middle of the call insn. Subtracting one would do the job except for - several compressed mode architectures (arm, mips) which set the low bit - to indicate the compressed mode; subtracting two works around that. It - is also the case that there are no host isas that contain a call insn - smaller than 4 bytes, so we don't worry about special-casing this. */ -#define GETPC_ADJ 2 - #if !defined(CONFIG_USER_ONLY) /** diff --git a/include/exec/helper-getpc.h b/include/exec/helper-getpc.h new file mode 100644 index 0000000000..1c8bd72c11 --- /dev/null +++ b/include/exec/helper-getpc.h @@ -0,0 +1,31 @@ +/* + * Get host pc for helper unwinding. + * + * Copyright (c) 2003 Fabrice Bellard + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef HELPER_GETPC_H +#define HELPER_GETPC_H + +/* GETPC is the true target of the return instruction that we'll execute. */ +#if defined(CONFIG_TCG_INTERPRETER) +extern __thread uintptr_t tci_tb_ptr; +# define GETPC() tci_tb_ptr +#else +# define GETPC() \ + ((uintptr_t)__builtin_extract_return_addr(__builtin_return_address(0))) +#endif + +/* + * The true return address will often point to a host insn that is part of + * the next translated guest insn. Adjust the address backward to point to + * the middle of the call insn. Subtracting one would do the job except for + * several compressed mode architectures (arm, mips) which set the low bit + * to indicate the compressed mode; subtracting two works around that. It + * is also the case that there are no host isas that contain a call insn + * smaller than 4 bytes, so we don't worry about special-casing this. + */ +#define GETPC_ADJ 2 + +#endif /* HELPER_GETPC_H */