From nobody Sat Nov 23 20:01:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1731547148; cv=none; d=zohomail.com; s=zohoarc; b=I7PRHHRwoj8mTi38rFaKPITFqEgAyZpfEBGTP6p6ebLAlIxRARYZxq2cRN2pFYK2tNEqqQhdOAzEwt8dWJlZBFj5Kc/xOxhxw4XgDNwsBNRZaABBzybbdSJPwOSX676LG9aYUj0Wh/vynBXY4pecszCBqyFb1dBa0wzrdK9BL+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731547148; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dJnPLBXDUWt9APABFP9RtiuQUlaLpT6eHtJy+a+Whyg=; b=RU+b9O8nf8jy4kJ13DH7QDp8ZQmsZD2Qt+DFUrnSdrDCew/ku8odffclJ55MH5DkR7Rrc5Zp/wwCx2wRNrEmscG9Tronr5+vnx0b//HW0POVGwqMIraqlmLcxmWYtTq6fHKfw3yCnL+0jr4SmvlersuFip7zhXLMRKoLX1y2Nw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731547148407803.0733956096574; Wed, 13 Nov 2024 17:19:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBOTS-00044B-Al; Wed, 13 Nov 2024 20:16:42 -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 1tBOT0-0002VS-IQ for qemu-devel@nongnu.org; Wed, 13 Nov 2024 20:16:16 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBOSx-00031y-Sq for qemu-devel@nongnu.org; Wed, 13 Nov 2024 20:16:14 -0500 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-431616c23b5so205305e9.0 for ; Wed, 13 Nov 2024 17:16:10 -0800 (PST) Received: from localhost.localdomain ([176.187.209.238]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432da280018sm4774385e9.26.2024.11.13.17.16.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 13 Nov 2024 17:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731546969; x=1732151769; 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=dJnPLBXDUWt9APABFP9RtiuQUlaLpT6eHtJy+a+Whyg=; b=qSC2iR3FZXQ9xvcsI53Cva0/uYAFxHj+GyOAmpyHInvli7a3m+TRmBsokfSUeheQD6 5pBBDLn+iRIGWrq4mHs24modnt7mMF8QtnlDY1ALgRaHcgt3z2EFGBYDOvpD+NEXgqZ8 v9fxuS1RSgwfz6k4y6wzk5Aq/iiFZ5OuopnyrGOxuItaqa/Gd7agNItE9Xgdv3sKOi9s GGuZZUCNG40cuOSKjVsw4GOKU4zpQ+KcOhL47kr7MQaE/JR0rA4GuXIPfRxhoQgptGm4 4R3pA07Pw8BoPwOQc5cejTOwPkvZpeqxqP+R/N59rNViHh+Z+JNlbAMrJiqmv9kjh+oy 5hkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731546969; x=1732151769; 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=dJnPLBXDUWt9APABFP9RtiuQUlaLpT6eHtJy+a+Whyg=; b=qzRadUCaYawoPH7HmJPN2dl0lxKD8sMJmVVRWEOMOZ0Du8FrH5bo/Qhcessv14AWJ8 VT7M/GeTkK2XwZua5BsLSgdBeBYx++o+Xs18NViUpY7kksegtRThfsQ5DYbtmj3jqQOS gj0diBgVKwRUQ9e2q1HRvqi2fJ3zyzhADvakT7rTmRqMKlc3juqk4nuW2msE3G+irXWZ Ta7k3PZ3FhxmfeLXPDeZ6V7DI/Kj+hfsdI13E2cdrPoUgEjPRibzvPQR2XIionvm2WuX 0h3ObfCii7Abl4ej8EOemabrAZH81w3p+yv/XzbpUTOy21yRyfB7SFW1v+GGWqWWtue5 41Qg== X-Forwarded-Encrypted: i=1; AJvYcCUStxbJ5Q53DcXNf3lxQ5YPMb29vfJS6H8ypYnu0Wqvbz8Y+Zu9i/bTklyvVePSY//30OEcXuu7Zqke@nongnu.org X-Gm-Message-State: AOJu0YwSKlxS391guXvV1spxOCNm4LtpX99xNzFDEeFt9YxtfxMXD/E0 RHzsNQ4VU0kPttJvc2kyblFjF63QqUHwINo1MmPuH2/edLiIl+PDs6u5x7nzQ9Gpan1O1NACxdZ y X-Google-Smtp-Source: AGHT+IFNRYI+6+k6hzZD/Oqm3sK6NGybQN7v5rJRv2V4XIRC72YBhh+g6R+IRQke+T79tc6rz4+9zg== X-Received: by 2002:a05:600c:4fc5:b0:431:55f3:d34e with SMTP id 5b1f17b1804b1-432d9761bdcmr12005115e9.15.1731546969598; Wed, 13 Nov 2024 17:16:09 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Paolo Bonzini , Richard Henderson , Anton Johansson , qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, Thomas Huth , qemu-arm@nongnu.org, Peter Xu , Pierrick Bouvier , qemu-riscv@nongnu.org, David Hildenbrand , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 22/24] exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h' Date: Thu, 14 Nov 2024 02:13:07 +0100 Message-ID: <20241114011310.3615-23-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114011310.3615-1-philmd@linaro.org> References: <20241114011310.3615-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1731547150115116600 Move methods related to the ram_addr_t type to the specific "exec/ram_addr.h" header. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/exec/cpu-common.h | 56 +------------------------------- include/exec/ram_addr.h | 56 ++++++++++++++++++++++++++++++++ include/exec/translation-block.h | 2 +- 3 files changed, 58 insertions(+), 56 deletions(-) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 638dc806a5..b790202c56 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -54,61 +54,7 @@ enum device_endian { #define DEVICE_HOST_ENDIAN DEVICE_LITTLE_ENDIAN #endif =20 -/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND) -typedef uint64_t ram_addr_t; -# define RAM_ADDR_MAX UINT64_MAX -# define RAM_ADDR_FMT "%" PRIx64 -#else -typedef uintptr_t ram_addr_t; -# define RAM_ADDR_MAX UINTPTR_MAX -# define RAM_ADDR_FMT "%" PRIxPTR -#endif - -/* memory API */ - -void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); -/* This should not be used by devices. */ -ram_addr_t qemu_ram_addr_from_host(void *ptr); -ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); -RAMBlock *qemu_ram_block_by_name(const char *name); - -/* - * Translates a host ptr back to a RAMBlock and an offset in that RAMBlock. - * - * @ptr: The host pointer to translate. - * @round_offset: Whether to round the result offset down to a target page - * @offset: Will be set to the offset within the returned RAMBlock. - * - * Returns: RAMBlock (or NULL if not found) - * - * By the time this function returns, the returned pointer is not protected - * by RCU anymore. If the caller is not within an RCU critical section and - * does not hold the BQL, it must have other means of protecting the - * pointer, such as a reference to the memory region that owns the RAMBloc= k. - */ -RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, - ram_addr_t *offset); -ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host); -void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *de= v); -void qemu_ram_unset_idstr(RAMBlock *block); -const char *qemu_ram_get_idstr(RAMBlock *rb); -void *qemu_ram_get_host_addr(RAMBlock *rb); -ram_addr_t qemu_ram_get_offset(RAMBlock *rb); -ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); -ram_addr_t qemu_ram_get_max_length(RAMBlock *rb); -bool qemu_ram_is_shared(RAMBlock *rb); -bool qemu_ram_is_noreserve(RAMBlock *rb); -bool qemu_ram_is_uf_zeroable(RAMBlock *rb); -void qemu_ram_set_uf_zeroable(RAMBlock *rb); -bool qemu_ram_is_migratable(RAMBlock *rb); -void qemu_ram_set_migratable(RAMBlock *rb); -void qemu_ram_unset_migratable(RAMBlock *rb); -bool qemu_ram_is_named_file(RAMBlock *rb); -int qemu_ram_get_fd(RAMBlock *rb); - -size_t qemu_ram_pagesize(RAMBlock *block); -size_t qemu_ram_pagesize_largest(void); +#include "exec/ram_addr.h" =20 /** * cpu_address_space_init: diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 80f6dc7564..e0620ddb03 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -21,6 +21,62 @@ =20 #ifndef CONFIG_USER_ONLY =20 +/* address in the RAM (different from a physical address) */ +#if defined(CONFIG_XEN_BACKEND) +typedef uint64_t ram_addr_t; +# define RAM_ADDR_MAX UINT64_MAX +# define RAM_ADDR_FMT "%" PRIx64 +#else +typedef uintptr_t ram_addr_t; +# define RAM_ADDR_MAX UINTPTR_MAX +# define RAM_ADDR_FMT "%" PRIxPTR +#endif + +/* memory API */ + +void qemu_ram_remap(ram_addr_t addr, ram_addr_t length); +/* This should not be used by devices. */ +ram_addr_t qemu_ram_addr_from_host(void *ptr); +ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr); +RAMBlock *qemu_ram_block_by_name(const char *name); + +/* + * Translates a host ptr back to a RAMBlock and an offset in that RAMBlock. + * + * @ptr: The host pointer to translate. + * @round_offset: Whether to round the result offset down to a target page + * @offset: Will be set to the offset within the returned RAMBlock. + * + * Returns: RAMBlock (or NULL if not found) + * + * By the time this function returns, the returned pointer is not protected + * by RCU anymore. If the caller is not within an RCU critical section and + * does not hold the BQL, it must have other means of protecting the + * pointer, such as a reference to the memory region that owns the RAMBloc= k. + */ +RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, + ram_addr_t *offset); +ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host); +void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *de= v); +void qemu_ram_unset_idstr(RAMBlock *block); +const char *qemu_ram_get_idstr(RAMBlock *rb); +void *qemu_ram_get_host_addr(RAMBlock *rb); +ram_addr_t qemu_ram_get_offset(RAMBlock *rb); +ram_addr_t qemu_ram_get_used_length(RAMBlock *rb); +ram_addr_t qemu_ram_get_max_length(RAMBlock *rb); +bool qemu_ram_is_shared(RAMBlock *rb); +bool qemu_ram_is_noreserve(RAMBlock *rb); +bool qemu_ram_is_uf_zeroable(RAMBlock *rb); +void qemu_ram_set_uf_zeroable(RAMBlock *rb); +bool qemu_ram_is_migratable(RAMBlock *rb); +void qemu_ram_set_migratable(RAMBlock *rb); +void qemu_ram_unset_migratable(RAMBlock *rb); +bool qemu_ram_is_named_file(RAMBlock *rb); +int qemu_ram_get_fd(RAMBlock *rb); + +size_t qemu_ram_pagesize(RAMBlock *block); +size_t qemu_ram_pagesize_largest(void); + bool ramblock_is_pmem(RAMBlock *rb); =20 long qemu_minrampagesize(void); diff --git a/include/exec/translation-block.h b/include/exec/translation-bl= ock.h index b99afb0077..9c4757882c 100644 --- a/include/exec/translation-block.h +++ b/include/exec/translation-block.h @@ -8,7 +8,7 @@ #define EXEC_TRANSLATION_BLOCK_H =20 #include "qemu/thread.h" -#include "exec/cpu-common.h" +#include "exec/ram_addr.h" #include "exec/vaddr.h" #ifdef CONFIG_USER_ONLY #include "qemu/interval-tree.h" --=20 2.45.2