qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Anton Johansson" <anjo@rev.ng>,
	qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	qemu-arm@nongnu.org, "Peter Xu" <peterx@redhat.com>,
	qemu-riscv@nongnu.org, "David Hildenbrand" <david@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	qemu-s390x@nongnu.org
Subject: Re: [PATCH 22/24] exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h'
Date: Wed, 13 Nov 2024 20:15:57 -0800	[thread overview]
Message-ID: <8fe0b6ea-c467-4194-8a57-969974f446c8@linaro.org> (raw)
In-Reply-To: <20241114011310.3615-23-philmd@linaro.org>

On 11/13/24 17:13, Philippe Mathieu-Daudé wrote:
> Move methods related to the ram_addr_t type to
> the specific "exec/ram_addr.h" header.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   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
>   
> -/* 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 RAMBlock.
> - */
> -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 *dev);
> -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"
>   
>   /**
>    * 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 @@
>   
>   #ifndef CONFIG_USER_ONLY
>   
> +/* 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 RAMBlock.
> + */
> +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 *dev);
> +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);
>   
>   long qemu_minrampagesize(void);
> diff --git a/include/exec/translation-block.h b/include/exec/translation-block.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
>   
>   #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"

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>


  reply	other threads:[~2024-11-14  4:16 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14  1:12 [PATCH 00/24] exec: Build up 'cputlb.h' and 'ram_addr.h' headers Philippe Mathieu-Daudé
2024-11-14  1:12 ` [PATCH 01/24] exec/cpu-all: Include missing 'exec/cpu-defs.h' header Philippe Mathieu-Daudé
2024-11-14  4:09   ` Pierrick Bouvier
2024-11-14  8:29   ` Thomas Huth
2024-11-14 18:11     ` Richard Henderson
2024-11-14  1:12 ` [PATCH 02/24] exec/cpu-defs: Remove unnecessary headers Philippe Mathieu-Daudé
2024-11-14  4:09   ` Pierrick Bouvier
2024-11-14  8:33   ` Thomas Huth
2024-11-14 18:15   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 03/24] exec/translation-block: Include missing 'exec/vaddr.h' header Philippe Mathieu-Daudé
2024-11-14  4:10   ` Pierrick Bouvier
2024-11-14 15:23     ` Philippe Mathieu-Daudé
2024-11-14 17:13       ` Pierrick Bouvier
2024-11-14 18:15   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 04/24] accel/tcg: Include missing 'exec/translation-block.h' header Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 18:23   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 05/24] target/i386/helper: " Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 18:42   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 06/24] target/rx/cpu: " Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 18:43   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 07/24] system/watchpoint: Include missing 'exec/cpu-all.h' header Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 18:53   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 08/24] linux-user/aarch64/mte: Include missing 'user/abitypes.h' header Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 18:59   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 09/24] target/arm/mte: Restrict 'exec/ram_addr.h' to system emulation Philippe Mathieu-Daudé
2024-11-14  4:11   ` Pierrick Bouvier
2024-11-14 19:00   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 10/24] target/arm/cpu: Restrict cpu_untagged_addr() to user emulation Philippe Mathieu-Daudé
2024-11-14  4:12   ` Pierrick Bouvier
2024-11-14 19:03   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 11/24] exec: Introduce 'user/guest-host.h' header Philippe Mathieu-Daudé
2024-11-14  4:12   ` Pierrick Bouvier
2024-11-14 19:14   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 12/24] accel/tcg: Have tlb_vaddr_to_host() use vaddr type Philippe Mathieu-Daudé
2024-11-14  4:12   ` Pierrick Bouvier
2024-11-14 19:16   ` Richard Henderson
2024-11-14  1:12 ` [PATCH 13/24] exec: Declare tlb_reset_dirty*() in 'exec/cputlb.h' Philippe Mathieu-Daudé
2024-11-14  4:12   ` Pierrick Bouvier
2024-11-14 19:19   ` Richard Henderson
2024-11-14 21:05     ` Philippe Mathieu-Daudé
2024-11-14  1:12 ` [PATCH 14/24] exec: Declare tlb_init/destroy() " Philippe Mathieu-Daudé
2024-11-14  4:13   ` Pierrick Bouvier
2024-11-14 19:21   ` Richard Henderson
2024-11-14 21:13     ` Philippe Mathieu-Daudé
2024-11-14  1:13 ` [PATCH 15/24] exec: Declare tlb_set_page_full() " Philippe Mathieu-Daudé
2024-11-14  4:13   ` Pierrick Bouvier
2024-11-14 19:24   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 16/24] exec: Declare tlb_set_page_with_attrs() " Philippe Mathieu-Daudé
2024-11-14  4:13   ` Pierrick Bouvier
2024-11-14  1:13 ` [PATCH 17/24] exec: Declare tlb_set_page() " Philippe Mathieu-Daudé
2024-11-14  4:13   ` Pierrick Bouvier
2024-11-14  1:13 ` [PATCH 18/24] exec: Declare tlb_flush*() " Philippe Mathieu-Daudé
2024-11-14  4:14   ` Pierrick Bouvier
2024-11-14 19:30   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 19/24] exec: Declare tlb_hit*() " Philippe Mathieu-Daudé
2024-11-14  4:14   ` Pierrick Bouvier
2024-11-14 19:37   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 20/24] exec: Declare tlb_vaddr_to_host() " Philippe Mathieu-Daudé
2024-11-14  4:14   ` Pierrick Bouvier
2024-11-14 19:59   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 21/24] exec: Extract CPU physical memory API to 'sysemu/physmem-target.h' Philippe Mathieu-Daudé
2024-11-14  1:17   ` Philippe Mathieu-Daudé
2024-11-14  4:15   ` Pierrick Bouvier
2024-11-14 20:51   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 22/24] exec/cpu-common: Move ram_addr_t related methods to 'exec/ram_addr.h' Philippe Mathieu-Daudé
2024-11-14  4:15   ` Pierrick Bouvier [this message]
2024-11-14 20:47   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 23/24] exec/memory: Move qemu_map_ram_ptr() declaration " Philippe Mathieu-Daudé
2024-11-14  4:16   ` Pierrick Bouvier
2024-11-14 20:48   ` Richard Henderson
2024-11-14  1:13 ` [PATCH 24/24] exec: Move 'ram_addr.h' header under sysemu/ namespace Philippe Mathieu-Daudé
2024-11-14  4:16   ` Pierrick Bouvier
2024-11-14 20:49   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8fe0b6ea-c467-4194-8a57-969974f446c8@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=anjo@rev.ng \
    --cc=david@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).