From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-riscv@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"Thomas Huth" <thuth@redhat.com>
Subject: [PATCH 18/22] target/s390x: Get cpu first addr space with cpu_get_address_space()
Date: Wed, 1 Oct 2025 17:05:23 +0200 [thread overview]
Message-ID: <20251001150529.14122-19-philmd@linaro.org> (raw)
In-Reply-To: <20251001150529.14122-1-philmd@linaro.org>
In order to remove the convenient CPUState::as field, access
the vcpu first address space using the cpu_get_address_space()
helper.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/s390x/cpu-system.c | 4 +++-
target/s390x/mmu_helper.c | 9 +++++----
target/s390x/tcg/excp_helper.c | 10 ++++++----
target/s390x/tcg/mem_helper.c | 6 ++++--
4 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/target/s390x/cpu-system.c b/target/s390x/cpu-system.c
index f3a9ffb2a27..948dd7bc133 100644
--- a/target/s390x/cpu-system.c
+++ b/target/s390x/cpu-system.c
@@ -63,7 +63,9 @@ static void s390_cpu_load_normal(CPUState *s)
uint64_t spsw;
if (!s390_is_pv()) {
- spsw = ldq_phys(s->as, 0);
+ AddressSpace *as = cpu_get_address_space(s, 0);
+
+ spsw = ldq_phys(as, 0);
cpu->env.psw.mask = spsw & PSW_MASK_SHORT_CTRL;
/*
* Invert short psw indication, so SIE will report a specification
diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index 4e2f31dc763..358d5463a0a 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -42,9 +42,10 @@ static void trigger_access_exception(CPUS390XState *env, uint32_t type,
if (kvm_enabled()) {
kvm_s390_access_exception(cpu, type, tec);
} else {
- CPUState *cs = env_cpu(env);
if (type != PGM_ADDRESSING) {
- stq_phys(cs->as, env->psa + offsetof(LowCore, trans_exc_code), tec);
+ AddressSpace *as = cpu_get_address_space(env_cpu(env), 0);
+
+ stq_phys(as, env->psa + offsetof(LowCore, trans_exc_code), tec);
}
trigger_pgm_exception(env, type);
}
@@ -106,7 +107,7 @@ bool mmu_absolute_addr_valid(target_ulong addr, bool is_write)
static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
uint64_t *entry)
{
- CPUState *cs = env_cpu(env);
+ AddressSpace *as = cpu_get_address_space(env_cpu(env), 0);
/*
* According to the PoP, these table addresses are "unpredictably real
@@ -115,7 +116,7 @@ static inline bool read_table_entry(CPUS390XState *env, hwaddr gaddr,
*
* We treat them as absolute addresses and don't wrap them.
*/
- if (unlikely(address_space_read(cs->as, gaddr, MEMTXATTRS_UNSPECIFIED,
+ if (unlikely(address_space_read(as, gaddr, MEMTXATTRS_UNSPECIFIED,
entry, sizeof(*entry)) !=
MEMTX_OK)) {
return false;
diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c
index 4c7faeee82b..1db159be131 100644
--- a/target/s390x/tcg/excp_helper.c
+++ b/target/s390x/tcg/excp_helper.c
@@ -53,7 +53,7 @@ G_NORETURN void tcg_s390_data_exception(CPUS390XState *env, uint32_t dxc,
g_assert(dxc <= 0xff);
#if !defined(CONFIG_USER_ONLY)
/* Store the DXC into the lowcore */
- stl_phys(env_cpu(env)->as,
+ stl_phys(cpu_get_address_space(env_cpu(env), 0),
env->psa + offsetof(LowCore, data_exc_code), dxc);
#endif
@@ -70,7 +70,7 @@ G_NORETURN void tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc,
g_assert(vxc <= 0xff);
#if !defined(CONFIG_USER_ONLY)
/* Always store the VXC into the lowcore, without AFP it is undefined */
- stl_phys(env_cpu(env)->as,
+ stl_phys(cpu_get_address_space(env_cpu(env), 0),
env->psa + offsetof(LowCore, data_exc_code), vxc);
#endif
@@ -639,10 +639,12 @@ void monitor_event(CPUS390XState *env,
uint64_t monitor_code,
uint8_t monitor_class, uintptr_t ra)
{
+ AddressSpace *as = cpu_get_address_space(env_cpu(env), 0);
+
/* Store the Monitor Code and the Monitor Class Number into the lowcore */
- stq_phys(env_cpu(env)->as,
+ stq_phys(as,
env->psa + offsetof(LowCore, monitor_code), monitor_code);
- stw_phys(env_cpu(env)->as,
+ stw_phys(as,
env->psa + offsetof(LowCore, mon_class_num), monitor_class);
tcg_s390_program_interrupt(env, PGM_MONITOR, ra);
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index f1acb1618f7..962f31d4cdb 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -957,12 +957,14 @@ uint32_t HELPER(mvpg)(CPUS390XState *env, uint64_t r0, uint32_t r1, uint32_t r2)
return 0; /* data moved */
inject_exc:
#if !defined(CONFIG_USER_ONLY)
+ AddressSpace *as = cpu_get_address_space(env_cpu(env), 0);
+
if (exc != PGM_ADDRESSING) {
- stq_phys(env_cpu(env)->as, env->psa + offsetof(LowCore, trans_exc_code),
+ stq_phys(as, env->psa + offsetof(LowCore, trans_exc_code),
env->tlb_fill_tec);
}
if (exc == PGM_PAGE_TRANS) {
- stb_phys(env_cpu(env)->as, env->psa + offsetof(LowCore, op_access_id),
+ stb_phys(as, env->psa + offsetof(LowCore, op_access_id),
r1 << 4 | r2);
}
#endif
--
2.51.0
next prev parent reply other threads:[~2025-10-01 15:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 15:05 [PATCH 00/22] hw/core/cpu: Remove @CPUState::as field Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 01/22] system/qtest: Use &address_space_memory for first vCPU address space Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 02/22] disas/disas-mon: Get cpu first addr space with cpu_get_address_space() Philippe Mathieu-Daudé
2025-10-01 15:34 ` BALATON Zoltan
2025-10-01 15:05 ` [PATCH 03/22] monitor/hmp-cmds: " Philippe Mathieu-Daudé
2025-10-01 15:35 ` BALATON Zoltan
2025-10-01 16:23 ` Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 04/22] hw/core/loader: " Philippe Mathieu-Daudé
2025-10-01 15:08 ` Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 05/22] hw/ppc: " Philippe Mathieu-Daudé
2025-10-01 15:23 ` Miles Glenn
2025-10-01 15:05 ` [PATCH 06/22] hw/m86k: " Philippe Mathieu-Daudé
2025-10-18 5:52 ` Thomas Huth
2025-10-01 15:05 ` [PATCH 07/22] target/xtensa: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 08/22] target/riscv: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 09/22] semihosting: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 10/22] target/alpha: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 11/22] target/arm: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 12/22] target/hppa: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 13/22] target/i386: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 14/22] target/loongarch: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 15/22] target/m68k: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 16/22] target/microblaze: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 17/22] target/ppc: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` Philippe Mathieu-Daudé [this message]
2025-10-01 15:05 ` [PATCH 19/22] target/sparc: " Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 20/22] hw/core/cpu: Remove @CPUState::as field Philippe Mathieu-Daudé
2025-10-01 15:05 ` [PATCH 21/22] exec/cpu: Declare cpu_memory_rw_debug() in 'hw/core/cpu.h' and document Philippe Mathieu-Daudé
2025-10-06 19:08 ` Philippe Mathieu-Daudé
2025-10-08 16:25 ` Zhao Liu
2025-10-01 15:05 ` [PATCH 22/22] target/sparc: Reduce inclusions of 'exec/cpu-common.h' Philippe Mathieu-Daudé
2025-10-01 15:39 ` [PATCH 00/22] hw/core/cpu: Remove @CPUState::as field BALATON Zoltan
2025-10-01 16:08 ` Peter Maydell
2025-10-01 16:35 ` Richard Henderson
2025-10-01 16:42 ` Philippe Mathieu-Daudé
2025-10-01 18:38 ` Philippe Mathieu-Daudé
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=20251001150529.14122-19-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=david@redhat.com \
--cc=iii@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=pierrick.bouvier@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).