From: "Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Doru Blânzeanu" <dblanzeanu@linux.microsoft.com>,
"Magnus Kulke" <magnuskulke@linux.microsoft.com>,
"Wei Liu" <wei.liu@kernel.org>,
"Magnus Kulke" <magnuskulke@microsoft.com>,
"Doru Blânzeanu" <dblanzeanu@microsoft.com>,
"Wei Liu" <liuwe@microsoft.com>
Subject: [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers
Date: Wed, 8 Jul 2026 01:16:44 +0300 [thread overview]
Message-ID: <20260707221645.24557-5-dblanzeanu@linux.microsoft.com> (raw)
In-Reply-To: <20260707221645.24557-1-dblanzeanu@linux.microsoft.com>
Update `store_regs` to use the register page when it is mmapped and
valid to set registers.
Remove the ioctl based register retrieval and fail in case the register
page is not correctly set or valid.
Fixes: 80c7f8e9cd
Signed-off-by: Doru Blânzeanu <dblanzeanu@linux.microsoft.com>
---
target/i386/mshv/mshv-cpu.c | 48 +++++++++++++------------------------
1 file changed, 17 insertions(+), 31 deletions(-)
diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c
index 9ec5c19c67..8a59a0b40e 100644
--- a/target/i386/mshv/mshv-cpu.c
+++ b/target/i386/mshv/mshv-cpu.c
@@ -448,7 +448,7 @@ static int set_standard_regs(const CPUState *cpu)
return 0;
}
-static void mshv_set_standard_regs_vp_page(CPUState *cpu)
+static void set_standard_regs_vp_page(CPUState *cpu)
{
X86CPU *x86cpu = X86_CPU(cpu);
CPUX86State *env = &x86cpu->env;
@@ -478,29 +478,26 @@ static void mshv_set_standard_regs_vp_page(CPUState *cpu)
| (1u << HV_X64_REGISTER_CLASS_FLAGS);
}
-static int store_regs(CPUState *cpu)
+static void store_regs(CPUState *cpu)
{
X86CPU *x86cpu = X86_CPU(cpu);
CPUX86State *env = &x86cpu->env;
- int ret;
- /* Use register vp page to optimize registers access */
- if (env->regs_page && env->regs_page->isvalid != 0) {
- mshv_set_standard_regs_vp_page(cpu);
- } else {
- ret = set_standard_regs(cpu);
- if (ret < 0) {
- return ret;
- }
+ /* Check register page pointer and abort if in unexpected state */
+ if (!env->regs_page) {
+ error_report(
+ "store regs: register page not set for vcpu %d",
+ cpu->cpu_index);
+ abort();
}
-
- ret = set_special_regs(cpu);
- if (ret < 0) {
- error_report("Failed to store speical registers");
- return ret;
+ if (env->regs_page->isvalid == 0) {
+ error_report(
+ "store regs: register page invalid for vcpu %d",
+ cpu->cpu_index);
+ abort();
}
- return 0;
+ set_standard_regs_vp_page(cpu);
}
static void populate_standard_regs(const hv_register_assoc *assocs,
@@ -1518,14 +1515,13 @@ static int set_memory_info(const struct hyperv_message *msg,
return 0;
}
-static int emulate_instruction(CPUState *cpu,
+static void emulate_instruction(CPUState *cpu,
const uint8_t *insn_bytes, size_t insn_len,
uint64_t gva, uint64_t gpa)
{
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env = &x86_cpu->env;
struct x86_decode decode = { 0 };
- int ret;
x86_insn_stream stream = { .bytes = insn_bytes, .len = insn_len };
load_regs(cpu);
@@ -1533,13 +1529,7 @@ static int emulate_instruction(CPUState *cpu,
decode_instruction_stream(env, &decode, &stream);
exec_instruction(env, &decode);
- ret = store_regs(cpu);
- if (ret < 0) {
- error_report("failed to store registers");
- return -1;
- }
-
- return 0;
+ store_regs(cpu);
}
static int handle_mmio(CPUState *cpu, const struct hyperv_message *msg,
@@ -1575,13 +1565,9 @@ static int handle_mmio(CPUState *cpu, const struct hyperv_message *msg,
instruction_bytes = info.instruction_bytes;
- ret = emulate_instruction(cpu, instruction_bytes, insn_len,
+ emulate_instruction(cpu, instruction_bytes, insn_len,
info.guest_virtual_address,
info.guest_physical_address);
- if (ret < 0) {
- error_report("failed to emulate mmio");
- return -1;
- }
*exit_reason = MshvVmExitIgnore;
--
2.53.0
next prev parent reply other threads:[~2026-07-07 22:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 22:16 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07 22:16 ` [PATCH 1/5] include/hw/hyperv: move hv_vp_register_page struct definition Doru Blânzeanu
2026-07-08 16:36 ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 2/5] target/i386/mshv: abort when hv_vp_register_page setup fails Doru Blânzeanu
2026-07-08 16:37 ` Magnus Kulke
2026-07-08 16:38 ` Magnus Kulke
2026-07-07 22:16 ` [PATCH 3/5] target/i386/mshv: remove fallback for register page get registers Doru Blânzeanu
2026-07-08 16:49 ` Magnus Kulke
2026-07-07 22:16 ` Doru Blânzeanu [this message]
2026-07-08 16:44 ` [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers Magnus Kulke
2026-07-07 22:16 ` [PATCH 5/5] target/i386/mshv: fix pio handlers clobbering device-modified registers Doru Blânzeanu
2026-07-08 16:50 ` Magnus Kulke
-- strict thread matches above, loose matches on Subject: below --
2026-07-07 8:25 [PATCH 0/5] Fix register page use for guests using mshv accel Doru Blânzeanu
2026-07-07 8:25 ` [PATCH 4/5] target/i386/mshv: remove fallback for register page set registers Doru Blânzeanu
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=20260707221645.24557-5-dblanzeanu@linux.microsoft.com \
--to=dblanzeanu@linux.microsoft.com \
--cc=dblanzeanu@microsoft.com \
--cc=liuwe@microsoft.com \
--cc=magnuskulke@linux.microsoft.com \
--cc=magnuskulke@microsoft.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wei.liu@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.