From nobody Wed Dec 17 15:59:48 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C84F42FC875; Tue, 30 Sep 2025 10:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759228333; cv=none; b=gUMq82f9HQks1gV4liiX4RIEJoofQ2rArA7BmI7D161RfUrI3J64i/A/6fuMGp8Kj/bZiJtBzQtFOQ5J1tnFwwIcO85oiyQisI7ZdX7PMwjkgIjwfDitphrtG/0Sd3DkPdrTXnYuB6siSSInQljbXaCSFZS31MOovFPU9ge9+eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759228333; c=relaxed/simple; bh=QwmzwrU0DndkFRCTtb3aUeansxkTK7ugdY5cxMSKME8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qw8bipHDlR18aIhdlZ8srdkqsU8GAnA07qd1sE1CNkLPqhYocDivah4akHPVUnSXb8/ziBYic75wulcE+jiai3XoluuXuhUsUCgMcF0YvvRQqRzeFUrOQp1C7U1GVe48CTEwFmfC4W4rTaBfnxOOqWBY2X61qKJ0FgKBntH0ZJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 887572681; Tue, 30 Sep 2025 03:32:02 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E0D53F66E; Tue, 30 Sep 2025 03:32:09 -0700 (PDT) From: Suzuki K Poulose To: kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org, oliver.upton@linux.dev, maz@kernel.org, alexandru.elisei@arm.com, aneesh.kumar@kernel.org, steven.price@arm.com, tabba@google.com, Suzuki K Poulose Subject: [PATCH kvmtool v4 06/15] arm64: Use KVM_SET_MP_STATE ioctl to power off non-boot vCPUs Date: Tue, 30 Sep 2025 11:31:21 +0100 Message-ID: <20250930103130.197534-8-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930103130.197534-1-suzuki.poulose@arm.com> References: <20250930103130.197534-1-suzuki.poulose@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oliver Upton Using the POWER_OFF flag in kvm_vcpu_init gets in the way of resetting a vCPU in response to a PSCI CPU_ON call, for obvious reasons. Drop the flag in favor of using the KVM_SET_MP_STATE call for non-boot vCPUs. Signed-off-by: Oliver Upton Signed-off-by: Suzuki K Poulose --- arm64/kvm-cpu.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arm64/kvm-cpu.c b/arm64/kvm-cpu.c index 3d914112..c7286484 100644 --- a/arm64/kvm-cpu.c +++ b/arm64/kvm-cpu.c @@ -143,10 +143,6 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, un= signed long cpu_id) if (vcpu->kvm_run =3D=3D MAP_FAILED) die("unable to mmap vcpu fd"); =20 - /* VCPU 0 is the boot CPU, the others start in a poweroff state. */ - if (cpu_id > 0) - vcpu_init.features[0] |=3D (1UL << KVM_ARM_VCPU_POWER_OFF); - /* Set KVM_ARM_VCPU_PSCI_0_2 if available */ if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) { vcpu_init.features[0] |=3D (1UL << KVM_ARM_VCPU_PSCI_0_2); @@ -201,6 +197,16 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, un= signed long cpu_id) if (err || target->init(vcpu)) die("Unable to initialise vcpu"); =20 + /* VCPU 0 is the boot CPU, the others start in a poweroff state. */ + if (cpu_id > 0) { + struct kvm_mp_state mp_state =3D { + .mp_state =3D KVM_MP_STATE_STOPPED, + }; + + if (ioctl(vcpu->vcpu_fd, KVM_SET_MP_STATE, &mp_state)) + die_perror("KVM_SET_MP_STATE failed"); + } + coalesced_offset =3D ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_COALESCED_MMIO); if (coalesced_offset) --=20 2.43.0