qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Wei Liu <liuwe@linux.microsoft.com>
Subject: [PULL 19/34] target/i386/hvf: provide and use simulate_{wrmsr, rdmsr} in emul_ops
Date: Wed, 23 Apr 2025 11:40:49 +0200	[thread overview]
Message-ID: <20250423094105.40692-20-pbonzini@redhat.com> (raw)
In-Reply-To: <20250423094105.40692-1-pbonzini@redhat.com>

From: Wei Liu <liuwe@linux.microsoft.com>

Change the first argument's type to be CPUState to match other hooks.

Signed-off-by: Wei Liu <liuwe@linux.microsoft.com>
Link: https://lore.kernel.org/r/1741377325-28175-8-git-send-email-liuwe@linux.microsoft.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/hvf/hvf-i386.h |  4 ++--
 target/i386/hvf/x86_emu.h  |  2 ++
 target/i386/hvf/hvf.c      | 18 ++++++++++--------
 target/i386/hvf/x86_emu.c  |  4 ++--
 4 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h
index 044ad236ae8..8c42ae6b013 100644
--- a/target/i386/hvf/hvf-i386.h
+++ b/target/i386/hvf/hvf-i386.h
@@ -19,8 +19,8 @@
 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, int reg);
 
 void hvf_handle_io(CPUState *, uint16_t, void *, int, int, int);
-void hvf_simulate_rdmsr(CPUX86State *env);
-void hvf_simulate_wrmsr(CPUX86State *env);
+void hvf_simulate_rdmsr(CPUState *cpu);
+void hvf_simulate_wrmsr(CPUState *cpu);
 
 /* Host specific functions */
 int hvf_inject_interrupt(CPUArchState *env, int vector);
diff --git a/target/i386/hvf/x86_emu.h b/target/i386/hvf/x86_emu.h
index 107c1f1ac86..555b567e2c7 100644
--- a/target/i386/hvf/x86_emu.h
+++ b/target/i386/hvf/x86_emu.h
@@ -30,6 +30,8 @@ struct x86_emul_ops {
                                     enum X86Seg seg);
     void (*handle_io)(CPUState *cpu, uint16_t port, void *data, int direction,
                       int size, int count);
+    void (*simulate_rdmsr)(CPUState *cs);
+    void (*simulate_wrmsr)(CPUState *cs);
 };
 
 extern const struct x86_emul_ops *emul_ops;
diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
index e4f48a79fb7..8c31d2e0cf7 100644
--- a/target/i386/hvf/hvf.c
+++ b/target/i386/hvf/hvf.c
@@ -252,6 +252,8 @@ static const struct x86_emul_ops hvf_x86_emul_ops = {
     .write_mem = hvf_write_mem,
     .read_segment_descriptor = hvf_read_segment_descriptor,
     .handle_io = hvf_handle_io,
+    .simulate_rdmsr = hvf_simulate_rdmsr,
+    .simulate_wrmsr = hvf_simulate_wrmsr,
 };
 
 int hvf_arch_init_vcpu(CPUState *cpu)
@@ -506,10 +508,10 @@ void hvf_store_regs(CPUState *cs)
     macvm_set_rip(cs, env->eip);
 }
 
-void hvf_simulate_rdmsr(CPUX86State *env)
+void hvf_simulate_rdmsr(CPUState *cs)
 {
-    X86CPU *cpu = env_archcpu(env);
-    CPUState *cs = env_cpu(env);
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
     uint32_t msr = ECX(env);
     uint64_t val = 0;
 
@@ -611,10 +613,10 @@ void hvf_simulate_rdmsr(CPUX86State *env)
     RDX(env) = (uint32_t)(val >> 32);
 }
 
-void hvf_simulate_wrmsr(CPUX86State *env)
+void hvf_simulate_wrmsr(CPUState *cs)
 {
-    X86CPU *cpu = env_archcpu(env);
-    CPUState *cs = env_cpu(env);
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
     uint32_t msr = ECX(env);
     uint64_t data = ((uint64_t)EDX(env) << 32) | EAX(env);
 
@@ -900,9 +902,9 @@ int hvf_vcpu_exec(CPUState *cpu)
         {
             hvf_load_regs(cpu);
             if (exit_reason == EXIT_REASON_RDMSR) {
-                hvf_simulate_rdmsr(env);
+                hvf_simulate_rdmsr(cpu);
             } else {
-                hvf_simulate_wrmsr(env);
+                hvf_simulate_wrmsr(cpu);
             }
             env->eip += ins_len;
             hvf_store_regs(cpu);
diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c
index 3ff41c35d89..aec7a8a3fa8 100644
--- a/target/i386/hvf/x86_emu.c
+++ b/target/i386/hvf/x86_emu.c
@@ -672,13 +672,13 @@ void x86_emul_raise_exception(CPUX86State *env, int exception_index, int error_c
 
 static void exec_rdmsr(CPUX86State *env, struct x86_decode *decode)
 {
-    hvf_simulate_rdmsr(env);
+    emul_ops->simulate_rdmsr(env_cpu(env));
     env->eip += decode->len;
 }
 
 static void exec_wrmsr(CPUX86State *env, struct x86_decode *decode)
 {
-    hvf_simulate_wrmsr(env);
+    emul_ops->simulate_wrmsr(env_cpu(env));
     env->eip += decode->len;
 }
 
-- 
2.49.0



  parent reply	other threads:[~2025-04-23  9:43 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23  9:40 [PULL 00/34] i386, Rust, SCSI changes for 2025-04-23 Paolo Bonzini
2025-04-23  9:40 ` [PULL 01/34] scsi: add conversion from ENODEV to sense Paolo Bonzini
2025-04-23  9:40 ` [PULL 02/34] target/i386: Fix model number of Zhaoxin YongFeng vCPU template Paolo Bonzini
2025-04-23  9:40 ` [PULL 03/34] target/i386: Reset parked vCPUs together with the online ones Paolo Bonzini
2025-04-23  9:40 ` [PULL 04/34] target/i386/hvf: fix lflags_to_rflags Paolo Bonzini
2025-04-23  9:40 ` [PULL 05/34] target/i386: special case ADC/SBB x,0 and SBB x,x Paolo Bonzini
2025-04-23  9:40 ` [PULL 06/34] target/i386: tcg: remove tmp0 and tmp4 from SHLD/SHRD Paolo Bonzini
2025-04-23  9:40 ` [PULL 07/34] target/i386: tcg: remove subf from SHLD/SHRD expansion Paolo Bonzini
2025-04-23  9:40 ` [PULL 08/34] target/i386: tcg: remove tmp0 Paolo Bonzini
2025-04-23  9:40 ` [PULL 09/34] target/i386: tcg: remove some more uses of temporaries Paolo Bonzini
2025-04-23  9:40 ` [PULL 10/34] target/i386: tcg: simplify computation of AF after INC/DEC Paolo Bonzini
2025-04-23  9:40 ` [PULL 11/34] target/i386: emulate: microoptimize and explain ADD_COUT_VEC/SUB_COUT_VEC Paolo Bonzini
2025-04-23  9:40 ` [PULL 12/34] target/i386: tcg: use cout to commonize add/adc/sub/sbb cases Paolo Bonzini
2025-04-23  9:40 ` [PULL 13/34] target/i386/hvf: introduce x86_emul_ops Paolo Bonzini
2025-04-23  9:40 ` [PULL 14/34] target/i386/hvf: remove HVF specific calls from x86_decode.c Paolo Bonzini
2025-04-23  9:40 ` [PULL 15/34] target/i386/hvf: provide and use handle_io in emul_ops Paolo Bonzini
2025-04-23  9:40 ` [PULL 16/34] target/i386: rename hvf_mmio_buf to emu_mmio_buf Paolo Bonzini
2025-04-23  9:40 ` [PULL 17/34] target/i386/hvf: use emul_ops->read_mem in x86_emu.c Paolo Bonzini
2025-04-23  9:40 ` [PULL 18/34] target/i386/hvf: provide and use write_mem in emul_ops Paolo Bonzini
2025-04-23  9:40 ` Paolo Bonzini [this message]
2025-04-23  9:40 ` [PULL 20/34] target/i386: rename lazy flags field and its type Paolo Bonzini
2025-04-23  9:40 ` [PULL 21/34] target/i386/hvf: drop unused headers Paolo Bonzini
2025-04-23  9:40 ` [PULL 22/34] target/i386/hvf: rename some include guards Paolo Bonzini
2025-04-23  9:40 ` [PULL 23/34] target/i386: add a directory for x86 instruction emulator Paolo Bonzini
2025-04-23  9:40 ` [PULL 24/34] target/i386/emulate: add a panic.h Paolo Bonzini
2025-04-23  9:40 ` [PULL 25/34] target/i386: move x86 instruction emulator out of hvf Paolo Bonzini
2025-04-23  9:40 ` [PULL 26/34] MAINTAINERS: add an entry for the x86 instruction emulator Paolo Bonzini
2025-04-23  9:40 ` [PULL 27/34] target/i386/emulate: remove flags_mask Paolo Bonzini
2025-04-23  9:40 ` [PULL 28/34] i386/cpu: Consolidate the helper to get Host's vendor Paolo Bonzini
2025-04-23  9:40 ` [PULL 29/34] rust/hpet: convert num_timers to u8 type Paolo Bonzini
2025-04-23  9:41 ` [PULL 30/34] rust/hpet: convert HPETTimer index " Paolo Bonzini
2025-04-23  9:41 ` [PULL 31/34] rust/hpet: Fix a clippy error Paolo Bonzini
2025-04-23  9:41 ` [PULL 32/34] rust/vmstate_test: Fix typo in test_vmstate_macro_array_of_pointer_wrapped() Paolo Bonzini
2025-04-23  9:41 ` [PULL 33/34] rust/hw/char/pl011: Extract extract DR read logic into separate function Paolo Bonzini
2025-04-23  9:41 ` [PULL 34/34] rust/hw/char/pl011: Extract DR write " Paolo Bonzini
2025-04-23 17:58 ` [PULL 00/34] i386, Rust, SCSI changes for 2025-04-23 Stefan Hajnoczi

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=20250423094105.40692-20-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=liuwe@linux.microsoft.com \
    --cc=qemu-devel@nongnu.org \
    /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).