From patchwork Thu Jan 16 23:04:34 2025 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: 857942 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:cc8:b0:385:e875:8a9e with SMTP id dq8csp443558wrb; Thu, 16 Jan 2025 15:06:02 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU5b5Y0osQP+TfeZxNyTMA+SCvFSkD5ZUtFCD7JcknaJpUhgjF5HbqkbrkQ7m/wcs3NKKUL0A==@linaro.org X-Google-Smtp-Source: AGHT+IHPhUiw6YkbEV2+4OOS/d6Tn9ulRGtYBhYY/n8DnPDfPX83vtqWjCJJ64GZAILPRHp6pkXL X-Received: by 2002:a05:6214:2aa8:b0:6d4:1ea3:981d with SMTP id 6a1803df08f44-6e1b223031emr10003166d6.43.1737068762214; Thu, 16 Jan 2025 15:06:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1737068762; cv=none; d=google.com; s=arc-20240605; b=TkDsxbiom7lx56aMD2GnPbfbJn9r/BXotV2zeP3MtgcTZ4Qonl0vF3cOycx3EbYvfG +21fIC6a2QevarHE0q3cKKps4btb4MVoHYEP+Df3puzNn/GgrQPvVvDGWpwSPm2E1/1T KPEQRfRsl8whusnhrqTHH8GZ6IlzxTeTIzJ/Y5XlY8g6RXRVRET54IRR9dop/x/cZTHN 4DQq91JDdOTQyOToLE6DBxBwCFDkkaDc9cLExc2eyrAhowvPLL124Joo65C3Rp9xUZbq 0gMcrPakxGYajqe4CI6ChScJbJd/X7txWm3U8BRYSdnh/o/Pan+G9jhprmI7USZgffHU oYTg== 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=nLjAfEesdApASDyVsAST+uy4KXHzjDdggJGXjuSffuw=; fh=7LI32/j37eOXTKcWpmI+N/xqJjGIVJhHv1mu0qpOfNo=; b=H7Sbl42974ZJnIRNvF/UEuUJHeyNeT3gPDrylPbx3ROW9Lvcimg2fk0AsAZ12iJnSn su3RInlM1xwqnHt7hvkul5HFde0r6vlI1KIkKqdp0tPTzfTeG40kYv87te57AeY6TMft FqyFKOLiEn+AswNJp0LTlE/nX/Q6Zee4FsXSxDwzik5diYi7kN7JJzTXKsxSOwehWy6A 4XBnM0GiFewQlX45WgHdOvaev6UIyPgPk7vaCUD+BcGwPz3xqi1KtjTAJyrBsEPcAqV+ d5MQ6yE6O98zzvrP/Eos3w9qP7tpggxUQR4W50uC1viua/1V26iIxvcKLSNqAeGh+Foy rr3Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cd2eACeM; 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 6a1803df08f44-6e1afbfb38fsi10307176d6.66.2025.01.16.15.06.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Jan 2025 15:06:02 -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=cd2eACeM; 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 1tYYuv-0005vn-0o; Thu, 16 Jan 2025 18:04:49 -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 1tYYut-0005vP-3J for qemu-devel@nongnu.org; Thu, 16 Jan 2025 18:04:47 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tYYur-0004xs-Fk for qemu-devel@nongnu.org; Thu, 16 Jan 2025 18:04:46 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-385ddcfc97bso1202166f8f.1 for ; Thu, 16 Jan 2025 15:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737068684; x=1737673484; 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=nLjAfEesdApASDyVsAST+uy4KXHzjDdggJGXjuSffuw=; b=cd2eACeMmBeD5o7k/NuSiehHU/jHI7jfjmz2v0QOB44X3A2HWBC+XQabqTltDVgtx3 ZZYA8KWsoCpU2KoUviauY+TqfGErtzMTirg59OBtlc3EcEAkupAfYa1C20FielgaDKGz 1N563iup0W97wutj5z6U3cIQgolpQxxWBTMHZ0GxC3RYghWMHLDhnEFU6akNqYidicdI FUQwvvmxVJ3WxuBsETniy0m3bLgbwkBAKTA+c0S7/iJEA1mnog03rVNMtvFS0JTgvOrK HCquYQwlnhSua7W8jIxe3JPuXLgsonAwiYf6L46yjS5+4d+wPpso9rg1OaHx/wYudCbo Sxzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737068684; x=1737673484; 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=nLjAfEesdApASDyVsAST+uy4KXHzjDdggJGXjuSffuw=; b=hjmB+T686x6mBvuw5ib/sRW1JTZzCDK8l1xN5ygl8X0RJR19gx0N0tKgUSJiMJWrLk +KFt87BvYCtWu5uLyPVqN7NIvn573B2lDgwDl7+CAABlsXpp5XEvAI9rxmG9aVtJ8nCw omxUqBq5SyJc0PydM27gKqJnTKmLy9GNYXGA23zeZ4cgVm9y4yC72OBXWMtFR+dpZcRz fzDPW1V0ziaOHw6+byfrn7tyQXwSaXW7dBOSFXOD5lshfaPPD5gfTf3RG6TA50XuR0n2 MXblnEaiXP+5ZP5lAUC8u5/PldjcYLNbMRhAh6R4Wemoau3a05S6f2upcb+5OJ2TIKxT +PPQ== X-Gm-Message-State: AOJu0YwbEjMnBPL7CVH7oTZxmYRD9iHrgCkrrs4kRL2yfEomPpzp9mm6 Zqx11u2Br8mdxNfTl4d+sQbGk/k6eovg+VMH/VgiDMBhY02dXBLKye2m18bzQAvMP8LGuzN9eYS sp4k= X-Gm-Gg: ASbGncsYhWzYhs7MlyTnnpDtLbq8kSvCJLAsvq/OFnWnWrrvTrT26yjqZSzdKmAT+MM HLl04cKU2dOfrnzjJFWGHLeyX2VVe1LnTrOIb4tSsdHbSbf3j1xe4MVHZkWgWUDnJaLfinTgYb5 6FC6V4Ht8pGc0Fcnx4GFrpiTPO53YWy0ot0DcUKwNo1H/Nn8SE9NPmox1VJSsZAclAGf7Siy/Vm I07xQPZAZvOG18f1d4lXgm6fECB//sDEpdlyP8DEfro+NDOSgwPuqydp4roG8Y6ZfgL7stwOoyp OZPFplPmmECRGl6voD4nJTComu0TfDY= X-Received: by 2002:a5d:64a1:0:b0:385:f44a:a53 with SMTP id ffacd0b85a97d-38bf5655b07mr267507f8f.4.1737068683638; Thu, 16 Jan 2025 15:04:43 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf327dee3sm922535f8f.86.2025.01.16.15.04.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Jan 2025 15:04:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-arm@nongnu.org, Paolo Bonzini , Daniel Henrique Barboza , Peter Maydell , Richard Henderson Subject: [RFC PATCH 1/2] cpus: Introduce const_cpu_env() and const_env_archcpu() Date: Fri, 17 Jan 2025 00:04:34 +0100 Message-ID: <20250116230435.87580-2-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250116230435.87580-1-philmd@linaro.org> References: <20250116230435.87580-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=philmd@linaro.org; helo=mail-wr1-x430.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 const_cpu_env() is similar to cpu_env() but return a const CPU 'env' state. Same for const_env_archcpu() w.r.t. env_archcpu(). Signed-off-by: Philippe Mathieu-Daudé --- include/exec/cpu-common.h | 5 +++++ include/hw/core/cpu.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index b1d76d69850..f765e97a973 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -250,6 +250,11 @@ static inline ArchCPU *env_archcpu(CPUArchState *env) return (void *)env - sizeof(CPUState); } +static inline const ArchCPU *const_env_archcpu(const CPUArchState *env) +{ + return (const void *)env - sizeof(CPUState); +} + /** * env_cpu_const(env) * @env: The architecture environment diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c3ca0babcb3..ecb31221b26 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -588,6 +588,12 @@ static inline CPUArchState *cpu_env(CPUState *cpu) return (CPUArchState *)(cpu + 1); } +static inline const CPUArchState *const_cpu_env(const CPUState *cpu) +{ + /* We validate that CPUArchState follows CPUState in cpu-all.h. */ + return (const CPUArchState *)(cpu + 1); +} + typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ; extern CPUTailQ cpus_queue;