From patchwork Sun Oct 13 22:12:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 835096 Delivered-To: patch@linaro.org Received: by 2002:adf:b352:0:b0:37d:45d0:187 with SMTP id k18csp1735176wrd; Sun, 13 Oct 2024 15:15:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWR3ZksyMF4g3NifgeGJy/5ExUbSX9VC3wFrb0wlhURXxMzWqcUkPjth/aQxYx3gx0yZvZDVg==@linaro.org X-Google-Smtp-Source: AGHT+IFGY8tZ3c5ZkyZegPoBb2YLcvbftIdR+UDPkOOcSLeiZo0mZ/gFHvI3HQ9aeL6UQaDvv+X8 X-Received: by 2002:a05:620a:170e:b0:7b1:184f:caba with SMTP id af79cd13be357-7b121006418mr1202956085a.40.1728857705334; Sun, 13 Oct 2024 15:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728857705; cv=none; d=google.com; s=arc-20240605; b=fVTpWmK2rX2EYJ+lfFILbjZfKXVWxNIu5c0HPkFkR3JCjH/RgvtGyE28jFsj/MzJwR XS+U9qkT5M0jgj6mo8t0N1e9IBsi/W2gTP91mn6Dy9mhh/HLo4K3PEL496AvvYQG6DDM 0jHyN6OxHPG378p8+rFttF9+Xf+Mup8C5ExnX1DaZYtYFBBUNvCzcyfIIPkOCBdrwrbZ Lp76g9XqCYBwRx+CfmKS13zcg1+OoQjGzJvm964GPwSPMnv4b7MH/kC7/ZEx5a/xOaWk ZoppBxMWrHWeu7DJ6VnGDobhRhWYT8ZIhK8TS6+CDVsr3evkxD39e7q8eleXjARPASk4 U3lA== 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=nYSXn25U/DdvMWs7SvnxnC83hyNQjHsWrN+gaiP3cZI=; fh=o2XzhdKG+B45MJCghEfnYoypmHvLX2hd4SL6yXeiyXI=; b=B8hseT5sy1bKk11Uvzd/+QxLzzWaqzA6WCOj/s/kvpHQRK1Rz7iaNSifxLGMt6MOzO HbPUi6fNvFvLchcH/bu/28F+sfCSb7V40iU+hWnGdtYHuLqsfR1bgLADNv+dEyUq+Awe KysbY9FYGJvPvockHRueKKkyQ96QZF917RrIBL6GWc4sqr4Ex5jrNmPxsEO6LghSn5o7 YuD3l1z9mC3zEWeF8x1QnuPAbbKSmbErg6UYIcHGiuWAqf8EqFLwL4tXne0Uz2bO46bL yuctDn45D6i/IqQTPGCF8Ty6e8TaLrwyxMGXlcQyIrtEmSajOnqoUfp+EIprTPfxv0u4 lhbw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UV4A9fMg; 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 af79cd13be357-7b1149c5e1fsi901740885a.670.2024.10.13.15.15.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 Oct 2024 15:15:05 -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=UV4A9fMg; 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 1t06pP-00076x-UY; Sun, 13 Oct 2024 18:12:43 -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 1t06pN-00075l-Nc for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:41 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t06pL-0000tP-TH for qemu-devel@nongnu.org; Sun, 13 Oct 2024 18:12:41 -0400 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2e28b75dbd6so2583705a91.0 for ; Sun, 13 Oct 2024 15:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728857558; x=1729462358; 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=nYSXn25U/DdvMWs7SvnxnC83hyNQjHsWrN+gaiP3cZI=; b=UV4A9fMgJH/jdrRHSRj8PwGHaoW3ecn5UDdiGCMiutCQ24/5si8HLA44cPyiDPxScT B9Q/3Hy2y2gaOV+WKee6YjWCfKVRm5JRJCUnFQ/YUvKqGF5TurWhO+tVpsq6JKJDoQjX 1JaEdXW3MWeaKv7A7bTh03Ql0BkDlmU1386qiBANR69g50Sfezqzt8VT18/jhmkvOH7V jv6yvzLp6r5bYQTdednxGLGwAsvmiZWhGZsE0tdnaUO2GKRAZsKzmQILrwWbSVkTUTZG cKRd5rzZjBTXxO7d7Gqv5oYvqd/F+GbsToxmiqiejLfMcG5QF0aVWuTO27H4p2/De1o0 20kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728857558; x=1729462358; 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=nYSXn25U/DdvMWs7SvnxnC83hyNQjHsWrN+gaiP3cZI=; b=XhYb1MS/GdrnIiAEsj/s1KJTt5Rf35pQN1mNbIFTDKimXF06gL/GXPsKEy8nIoW2G9 AjqcWDCuQGruWnpt9kKEKWRS2jXtqq+eJikCzCvzS/t/fXldF4U8DOioBrFuoDZegNci C2RtAqDPX5wtScd7fWpmefahJEejf4+b0w4MFW38PLoTpCtxgtPQRVtk2lQyjptJ6yQR ynJgcPjrc+ihJE59lAfNClCKJpPd3PcDzorr2xzb2l04js1ZGnJCeStmgLF9WPLV1uRS o91sbcQUVYzR74850Ae4qkcuYTOLxa+soAdxEG9UWr6oB6/vJT4o6NQQDz+VZthS77/C 0Nfg== X-Gm-Message-State: AOJu0YwPROWWoPLIyrtTO5/n+SYcJWysBR97jufphgyxWlloCGl41TCe WkRmY1Y887TToXlet9IMmItYjPHZUKX03EiNEEmO7udNAw0MNjHtWcyevwZgW+Ed17UeJTML0yS 0 X-Received: by 2002:a17:90b:390a:b0:2e2:af0b:8f2d with SMTP id 98e67ed59e1d1-2e31536de5dmr7803911a91.26.1728857558447; Sun, 13 Oct 2024 15:12:38 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2d5df1eebsm7271958a91.17.2024.10.13.15.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Oct 2024 15:12:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich Subject: [PULL 02/27] include/exec: Introduce env_cpu_const() Date: Sun, 13 Oct 2024 15:12:10 -0700 Message-ID: <20241013221235.1585193-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241013221235.1585193-1-richard.henderson@linaro.org> References: <20241013221235.1585193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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 From: Ilya Leoshkevich It's the same as env_cpu(), but for const objects. Reviewed-by: Richard Henderson Signed-off-by: Ilya Leoshkevich Message-ID: <20240912093012.402366-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- include/exec/cpu-common.h | 13 ++++++++++++- linux-user/elfload.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 2e1b499cb7..638dc806a5 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -238,6 +238,17 @@ static inline ArchCPU *env_archcpu(CPUArchState *env) return (void *)env - sizeof(CPUState); } +/** + * env_cpu_const(env) + * @env: The architecture environment + * + * Return the CPUState associated with the environment. + */ +static inline const CPUState *env_cpu_const(const CPUArchState *env) +{ + return (void *)env - sizeof(CPUState); +} + /** * env_cpu(env) * @env: The architecture environment @@ -246,7 +257,7 @@ static inline ArchCPU *env_archcpu(CPUArchState *env) */ static inline CPUState *env_cpu(CPUArchState *env) { - return (void *)env - sizeof(CPUState); + return (CPUState *)env_cpu_const(env); } #ifndef CONFIG_USER_ONLY diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 52c88a68a9..352960b771 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4314,7 +4314,7 @@ static int wmr_write_region(void *opaque, target_ulong start, */ static int elf_core_dump(int signr, const CPUArchState *env) { - const CPUState *cpu = env_cpu((CPUArchState *)env); + const CPUState *cpu = env_cpu_const(env); const TaskState *ts = (const TaskState *)get_task_state((CPUState *)cpu); struct rlimit dumpsize; CountAndSizeRegions css;