Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54B65CA5FB3 for ; Thu, 1 Oct 2026 10:53:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xCEPM-0005ej-06; Thu, 01 Oct 2026 06:53:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xCEPH-0005dX-Gm; Thu, 01 Oct 2026 06:52:55 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xCEPF-0002P4-S8; Thu, 01 Oct 2026 06:52:55 -0400 Received: from localhost (unknown [131.107.1.165]) by linux.microsoft.com (Postfix) with ESMTPSA id 6E80020B716A; Thu, 1 Oct 2026 03:51:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6E80020B716A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1790851918; bh=37MszlWbJzj+NlQUVtLNagGvC4NXZtVf/7aP5kBq1SA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MwnWGZGZi08SR9BGkm6ZFg9Atrq9TMT1EL/oOCWIzQEcV9zjiG96mExkX1acDhxdl awh/CYBP2WestHS7bSd30g319q7bRO7IXsi01tPMsbOr5Z1xJ5hM+I4DLDxt2Jo0sb ARsNzE8dTd9CA6OuYIeThsVMZA9RjqAYTecqemag= From: Aastha Rawat Date: Thu, 01 Oct 2026 10:52:48 +0000 Subject: [PATCH v6 03/14] accel/mshv: make MSHV migration initialization arch-specific MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261001-mshv_accel_arm64_supp-v6-3-aefe5e76a0e3@linux.microsoft.com> References: <20261001-mshv_accel_arm64_supp-v6-0-aefe5e76a0e3@linux.microsoft.com> In-Reply-To: <20261001-mshv_accel_arm64_supp-v6-0-aefe5e76a0e3@linux.microsoft.com> To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , =?utf-8?q?Doru_Bl=C3=A2nzeanu?= , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Pierrick Bouvier , Peter Maydell , Anirudh Rayabharam , Aastha Rawat , qemu-arm@nongnu.org, Alexander Graf , Pedro Barbuda , Mohamed Mediouni , "Michael S. Tsirkin" , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Mailer: b4 0.15.1 Received-SPF: pass client-ip=13.77.154.182; envelope-from=aastharawat@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org x86 specific migration handlers currently live in common MSHV code. Move these handlers into x86 backend and add a generic architecture migration initialization hook. ARM MSHV live migration support is not added yet, this will allow ARM to add an empty initialization hook. Signed-off-by: Aastha Rawat --- accel/mshv/mshv-all.c | 35 ++++------------------------------- include/system/mshv_int.h | 1 + target/i386/mshv/mshv-all.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 860f511fcba..efe19a39140 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -60,30 +60,6 @@ static int init_mshv(int *mshv_fd) return 0; } -static int mshv_load_cleanup(void *opaque) -{ - CPUState *cpu; - int ret; - - ret = mshv_arch_set_partition_msrs(first_cpu); - if (ret < 0) { - error_report("Failed to set partition MSRs: %s", strerror(-ret)); - return -1; - } - - CPU_FOREACH(cpu) { - ret = mshv_arch_set_mp_state(cpu); - if (ret < 0) { - error_report("Failed to set mp state for vCPU %d: %s", - cpu->cpu_index, strerror(-ret)); - return -1; - } - } - - return 0; -} - - static int get_host_partition_property(int mshv_fd, uint32_t property_code, uint64_t *value) { @@ -519,10 +495,6 @@ static int mshv_init_vcpu(CPUState *cpu) return 0; } -static SaveVMHandlers savevm_mshv = { - .load_cleanup = mshv_load_cleanup, -}; - static int mshv_init(AccelState *as, MachineState *ms) { MshvState *s; @@ -574,9 +546,10 @@ static int mshv_init(AccelState *as, MachineState *ms) 0, "mshv-memory"); memory_listener_register(&mshv_io_listener, &address_space_io); - register_savevm_live("mshv", 0, 1, &savevm_mshv, s); - - mshv_clock_init(); + ret = mshv_arch_migration_init(s); + if (ret < 0) { + return ret; + } return 0; } diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 0e68365c63f..31d2f4381c7 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -109,6 +109,7 @@ void mshv_arch_disable_partition_proc_features( int mshv_arch_accel_init(AccelState *as, MachineState *ms, int mshv_fd); int mshv_arch_post_init_vm(int vm_fd); void mshv_setup_hvcall_args(AccelCPUState *state); +int mshv_arch_migration_init(MshvState *s); int mshv_get_vp_state(int cpu_fd, struct mshv_get_set_vp_state *state); int mshv_set_vp_state(int cpu_fd, const struct mshv_get_set_vp_state *state); typedef struct mshv_root_hvcall mshv_root_hvcall; diff --git a/target/i386/mshv/mshv-all.c b/target/i386/mshv/mshv-all.c index f0b43aa86f1..968fe2a4494 100644 --- a/target/i386/mshv/mshv-all.c +++ b/target/i386/mshv/mshv-all.c @@ -78,3 +78,37 @@ int mshv_arch_post_init_vm(int vm_fd) return ret; } + +static int mshv_load_cleanup(void *opaque) +{ + CPUState *cpu; + int ret; + + ret = mshv_arch_set_partition_msrs(first_cpu); + if (ret < 0) { + error_report("Failed to set partition MSRs: %s", strerror(-ret)); + return -1; + } + + CPU_FOREACH(cpu) { + ret = mshv_arch_set_mp_state(cpu); + if (ret < 0) { + error_report("Failed to set mp state for vCPU %d: %s", + cpu->cpu_index, strerror(-ret)); + return -1; + } + } + + return 0; +} + +static SaveVMHandlers savevm_mshv = { + .load_cleanup = mshv_load_cleanup, +}; + +int mshv_arch_migration_init(MshvState *s) +{ + register_savevm_live("mshv", 0, 1, &savevm_mshv, s); + mshv_clock_init(); + return 0; +} -- 2.45.4