From nobody Wed Dec 17 07:30:53 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5C441F418B; Wed, 16 Apr 2025 13:45:26 +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=1744811129; cv=none; b=FRe9VKGDrUqXdvrUr56qm+XY4PPkePOBuxwq9OBWTW8cOO7wGWpr5SsH2nWlWap4Ni5c80+p0TCUSxX0gIYKnmFhwwvZpAGQegvckeAlzf9Qc4rDJKaH7LRlGPpD6psBMfvUG2Su21ywKoEfl3KhGW6YqmQQw4AA1Ag8j/xirRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744811129; c=relaxed/simple; bh=mUT4vDoRTYM9gKOE2Of2g3XtD04WAdss/HL1xVBMSuk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UNq7VQ5qTtsrT5w2XBHW72d8aqmkSfdfM9hsU95sAl3caCO9takfFl5WjH8SM+MBW46tSaeWq6mDhz0SzLq7Aag7RdtCdgvmruEeeGMH58EcfHOATNtcavoVRLL71PWvwzhj+C1YrkeS+LicMRo4v6U+XioOQkJCZofaJNo95oE= 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 CDD6E1692; Wed, 16 Apr 2025 06:45:23 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.90.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 75BFE3F59E; Wed, 16 Apr 2025 06:45:21 -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" Subject: [PATCH v8 25/43] arm64: Don't expose stolen time for realm guests Date: Wed, 16 Apr 2025 14:41:47 +0100 Message-ID: <20250416134208.383984-26-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250416134208.383984-1-steven.price@arm.com> References: <20250416134208.383984-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 54ae0b98030e..f91b35128748 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -8684,6 +8684,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 cacdc10d2a6b..97c5efbe47a6 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