From nobody Sat Oct 11 08:22:10 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDB182DFA24; Wed, 11 Jun 2025 10:50:33 +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=1749639035; cv=none; b=u+0aLfVCwS5KJJ9ssgiY/m1d3EF/3AFAnFlHNrPGV94WvREilXTCRvRHw5VCPMIE07aNhbBaf/UHEELW4BCRwUpOPebpvxEvoeSds8/+Boa3UNh2P8Kdr9wk4eb+ocgaBuOkkFiltaUpZswdlNG98YJg2LPVEqzEfdEBfrEYqCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749639035; c=relaxed/simple; bh=Apb/xu9E+9pm+16MyIqbm+LkJBFoTz315KqB8LlE5Fk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M41DRcq92oFvrtaHJRXlc6LjVV4oQrjnmLdWswzucx3WaZt+ia/03oOXlC8F8abLANskYq8a4+nJRyT4qN3poVQ36yMFEFWsmdeNjLW8t2YcXMRhWyNcaQnjpxV48PgBBJd1eV999XrZaoBoQ21FyIYYPnSgT1ajiAY/KRCSHFI= 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 B8AAD1688; Wed, 11 Jun 2025 03:50:13 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.67.107]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 19ED63F673; Wed, 11 Jun 2025 03:50:29 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki Subject: [PATCH v9 25/43] arm64: Don't expose stolen time for realm guests Date: Wed, 11 Jun 2025 11:48:22 +0100 Message-ID: <20250611104844.245235-26-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250611104844.245235-1-steven.price@arm.com> References: <20250611104844.245235-1-steven.price@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" It doesn't make much sense as a realm guest wouldn't want to trust the host. It will also need some extra work to ensure that KVM will only attempt to write into a shared memory region. So for now just disable it. Reviewed-by: Suzuki K Poulose Reviewed-by: Gavin Shan Signed-off-by: Steven Price --- Changes since v7: * Update the documentation to add a note about stolen time being unavailable in a realm. --- Documentation/virt/kvm/api.rst | 3 +++ arch/arm64/kvm/arm.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index 0049d67fe38f..83843c2f755d 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8907,6 +8907,9 @@ is supported, than the other should as well and vice = versa. For arm64 see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL". For x86 see Documentation/virt/kvm/x86/msr.rst "MSR_KVM_STEAL_TIME". =20 +Note that steal time accounting is not available when a guest is running +within a Arm CCA realm (machine type KVM_VM_TYPE_ARM_REALM). + 8.25 KVM_CAP_S390_DIAG318 ------------------------- =20 diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 5502997b7354..4eb229b6c315 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -396,7 +396,10 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long= ext) r =3D system_supports_mte(); break; case KVM_CAP_STEAL_TIME: - r =3D kvm_arm_pvtime_supported(); + if (kvm_is_realm(kvm)) + r =3D 0; + else + r =3D kvm_arm_pvtime_supported(); break; case KVM_CAP_ARM_EL1_32BIT: r =3D cpus_have_final_cap(ARM64_HAS_32BIT_EL1); --=20 2.43.0