qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kohei Tokunaga <ktokunaga.mail@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P . Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	ktokunaga.mail@gmail.com
Subject: [PATCH 2/5] include: define vaddr based on TCG_VADDR_BITS
Date: Fri, 23 May 2025 00:17:27 +0900	[thread overview]
Message-ID: <7e749b8c93fc15ceb042eef95e49ac27cc917e75.1747922170.git.ktokunaga.mail@gmail.com> (raw)
In-Reply-To: <cover.1747922170.git.ktokunaga.mail@gmail.com>

This commit defines vaddr based on TCG_VADDR_BITS. For non-wasm hosts,
TCG_VADDR_BITS maches the pointer size, so this change preserves the
original behaviour.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
---
 include/exec/helper-head.h.inc |  9 +++++----
 include/exec/vaddr.h           | 28 +++++++++++++++++++---------
 include/tcg/tcg.h              |  6 +++---
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/include/exec/helper-head.h.inc b/include/exec/helper-head.h.inc
index 5b248fd713..cbeb7bc371 100644
--- a/include/exec/helper-head.h.inc
+++ b/include/exec/helper-head.h.inc
@@ -58,16 +58,17 @@
 # define dh_ctype_tl target_ulong
 #endif /* COMPILING_PER_TARGET */
 
-#if __SIZEOF_POINTER__ == 4
+#if TCG_VADDR_BITS == 32
 # define dh_alias_vaddr i32
 # define dh_typecode_vaddr dh_typecode_i32
-#elif __SIZEOF_POINTER__ == 8
+# define dh_ctype_vaddr uint32_t
+#elif TCG_VADDR_BITS == 64
 # define dh_alias_vaddr i64
 # define dh_typecode_vaddr dh_typecode_i64
+# define dh_ctype_vaddr uint64_t
 #else
 # error "sizeof pointer is different from {4,8}"
-#endif /* __SIZEOF_POINTER__ */
-# define dh_ctype_vaddr uintptr_t
+#endif /* TCG_VADDR_BITS */
 
 /* We can't use glue() here because it falls foul of C preprocessor
    recursive expansion rules.  */
diff --git a/include/exec/vaddr.h b/include/exec/vaddr.h
index 28bec632fb..ff6184a31e 100644
--- a/include/exec/vaddr.h
+++ b/include/exec/vaddr.h
@@ -6,15 +6,25 @@
 /**
  * vaddr:
  * Type wide enough to contain any #target_ulong virtual address.
- * We do not support 64-bit guest on 32-host and detect at configure time.
- * Therefore, a host pointer width will always fit a guest pointer.
  */
-typedef uintptr_t vaddr;
-#define VADDR_PRId PRIdPTR
-#define VADDR_PRIu PRIuPTR
-#define VADDR_PRIo PRIoPTR
-#define VADDR_PRIx PRIxPTR
-#define VADDR_PRIX PRIXPTR
-#define VADDR_MAX UINTPTR_MAX
+#if TCG_VADDR_BITS == 32
+typedef uint32_t vaddr;
+#define VADDR_PRId PRId32
+#define VADDR_PRIu PRIu32
+#define VADDR_PRIo PRIo32
+#define VADDR_PRIx PRIx32
+#define VADDR_PRIX PRIX32
+#define VADDR_MAX UINT32_MAX
+#elif TCG_VADDR_BITS == 64
+typedef uint64_t vaddr;
+#define VADDR_PRId PRId64
+#define VADDR_PRIu PRIu64
+#define VADDR_PRIo PRIo64
+#define VADDR_PRIx PRIx64
+#define VADDR_PRIX PRIX64
+#define VADDR_MAX UINT64_MAX
+#else
+#error Unknown pointer size
+#endif
 
 #endif
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 3fa5a7aed2..256a7b059c 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -218,13 +218,13 @@ typedef struct TCGv_ptr_d *TCGv_ptr;
 typedef struct TCGv_vec_d *TCGv_vec;
 typedef TCGv_ptr TCGv_env;
 
-#if __SIZEOF_POINTER__ == 4
+#if TCG_VADDR_BITS == 32
 typedef TCGv_i32 TCGv_vaddr;
-#elif __SIZEOF_POINTER__ == 8
+#elif TCG_VADDR_BITS == 64
 typedef TCGv_i64 TCGv_vaddr;
 #else
 # error "sizeof pointer is different from {4,8}"
-#endif /* __SIZEOF_POINTER__ */
+#endif /* TCG_VADDR_BITS */
 
 /* call flags */
 /* Helper does not read globals (either directly or through an exception). It
-- 
2.43.0



  parent reply	other threads:[~2025-05-22 15:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22 15:17 [PATCH 0/5] Enable QEMU TCI to run 64bit guests on browsers Kohei Tokunaga
2025-05-22 15:17 ` [PATCH 1/5] meson.build: add TCG_VADDR_BITS for defining the vaddr size Kohei Tokunaga
2025-05-22 15:17 ` Kohei Tokunaga [this message]
2025-05-22 15:17 ` [PATCH 3/5] tlb: specify address field size based on TCG_VADDR_BITS Kohei Tokunaga
2025-05-22 15:17 ` [PATCH 4/5] tci: define TCG_TARGET_REG_BITS " Kohei Tokunaga
2025-05-22 15:17 ` [PATCH 5/5] tci: use tcg_target_ulong when retrieving the pool data Kohei Tokunaga
2025-06-03  2:41 ` [PATCH 0/5] Enable QEMU TCI to run 64bit guests on browsers Kohei Tokunaga

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=7e749b8c93fc15ceb042eef95e49ac27cc917e75.1747922170.git.ktokunaga.mail@gmail.com \
    --to=ktokunaga.mail@gmail.com \
    --cc=berrange@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /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).