[PATCH] whpx: i386: only do partition reset when exposed

Mohamed Mediouni posted 1 patch 3 days, 12 hours ago
target/i386/whpx/whpx-all.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] whpx: i386: only do partition reset when exposed
Posted by Mohamed Mediouni 3 days, 12 hours ago
WHvResetPartition is not exposed before Windows 11 and
Windows Server 2025.

It is also not exposed on Server 2022, which passes the
legacy OS check otherwise.

As such, gate it behind availabilty of WHvResetPartition.

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4908
---
 target/i386/whpx/whpx-all.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index df1c772eb3..6c6af6c4d5 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -530,7 +530,8 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel level)
     assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
 
     /* Assumes that cpu_synchronize_all_post_reset() runs cpu 0 first. */
-    if (level == WHPX_LEVEL_RESET_STATE && cpu->cpu_index == 0) {
+    if (whp_dispatch.WHvResetPartition &&
+        level == WHPX_LEVEL_RESET_STATE && cpu->cpu_index == 0) {
         hr = whp_dispatch.WHvResetPartition(whpx->partition);
         if (FAILED(hr)) {
             error_report("WHPX: Failed to reset partition, hr=%08lx", hr);
-- 
2.54.0 (Apple Git-157)
Re: [PATCH] whpx: i386: only do partition reset when exposed
Posted by Mohamed Mediouni 3 days, 12 hours ago

> On 19. Nov 2026, at 16:39, Mohamed Mediouni <mohamed@unpredictable.fr> wrote:
> 
> WHvResetPartition is not exposed before Windows 11 and
> Windows Server 2025.
> 
> It is also not exposed on Server 2022, which passes the
> legacy OS check otherwise.
> 
> As such, gate it behind availabilty of WHvResetPartition.
> 
> Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4908
Fixes: 6275714a ("target/i386/whpx: handle processor reset”)

> ---
> target/i386/whpx/whpx-all.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
> index df1c772eb3..6c6af6c4d5 100644
> --- a/target/i386/whpx/whpx-all.c
> +++ b/target/i386/whpx/whpx-all.c
> @@ -530,7 +530,8 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel level)
>     assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu));
> 
>     /* Assumes that cpu_synchronize_all_post_reset() runs cpu 0 first. */
> -    if (level == WHPX_LEVEL_RESET_STATE && cpu->cpu_index == 0) {
> +    if (whp_dispatch.WHvResetPartition &&
> +        level == WHPX_LEVEL_RESET_STATE && cpu->cpu_index == 0) {
>         hr = whp_dispatch.WHvResetPartition(whpx->partition);
>         if (FAILED(hr)) {
>             error_report("WHPX: Failed to reset partition, hr=%08lx", hr);
> -- 
> 2.54.0 (Apple Git-157)
> 
>