From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE46B3C0A1A for ; Wed, 23 Sep 2026 16:48:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790182106; cv=none; b=JLAej3OJehDEwOyN/LALe9Upn/uVZBZN3OGcRzluxvTQYTJ2kyZtUlrRidWSnNnhnG6VIHiLWN+NJUH2jOZ85d/djP/86s10/jJbe/OJu42qiu8Sn648VTzJr52OLV0e3xCBZ3FQ0sEL6DbDngW/sp8b7cuPBgF++s8env0MUJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790182106; c=relaxed/simple; bh=CGiWjTmGXAl6+wWuNY52mdjGBRHixUk9gnSMpBDzaVU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=klppqahd3CsIgYAHQZ9ybbP9GAwWCQa/G9pIqgXlWzMXqG1kY+oX5Bo9dsnryQSuTEER1ZBL9Eb6QwBQZE4k1sm9A3JeDM4tw7VJJdAP+EqFRWeapN4i6ppWjdaoWju+SRhYUchmup01A3DQIqxBTrn+YnyveZ6zaQju4DPJ6jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=HwURI9u8; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=L9cqnxOO; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="HwURI9u8"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="L9cqnxOO" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68NGThd32470172 for ; Wed, 23 Sep 2026 16:48:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 4GGpD9bCLKwKljw9siihHkGdhbEHAKmKaI5FQZgKfS0=; b=HwURI9u8gOqsxzop D+O0P9O7uAoodVx8vvTnFSrFFdCFGgLgCpPcV8vhfjlglXwwOTzGnkKFaxkC/ZBE KzXKfya286vL+1P9N8JySDE3wy6BG/elusP9Fgzp2Cw60YVKuxkWrkOedA1JBIiH 4MnTe3LupfJ5deFFxg2KXb528bKGtmwd3T3Q1YvyHb2T/DQceHMfTevWrE0DhQ+w wWdGCRmLV+pIlJ7nEdfZ5XCYUCjXDDzqeBrWD3zhxcQcyRNajCmY3qyEyaEgcAyA pyuKK0MX4yCYcvIuF+liPrfF9DrP7C9sn5MGqHusXYj5hCZr4UKG0Cm5Rv6IJhnx oo5Wdw== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gvfjv0xuu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 16:48:23 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-39e087a17dfso1506004a91.3 for ; Wed, 23 Sep 2026 09:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790182103; x=1790786903; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4GGpD9bCLKwKljw9siihHkGdhbEHAKmKaI5FQZgKfS0=; b=L9cqnxOOhqsgDxZvuZA4BcWxa16QFCgKjIyCT6QMuLQo1Odo6QSDxb0b8R4Y1hV3cb I1JkVEeDPxH0u9KFGxQNWlHHg1KfIDerzxK/tPfxYs7E2/zXZazunAWJYFFcCTaa5d8E Ansc61zaub6a1LsIWWsMNdE3BinkRO+0N6WTkuJ98fhysHRWXUqD2AGVkyTj5IAsNl5m Zi8RYK8lAedK5OwNynpfSwwtIYKKigS98LpygE1cEqGljz/Vn6bAOzbtHeru30Kd73cF QDnCt5qEKgTpKkk/jiHoIwmvogTeJU79qRxRWzyxxRVBhA09k6bUPbejRZwQ0uEMNeGq /PgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790182103; x=1790786903; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4GGpD9bCLKwKljw9siihHkGdhbEHAKmKaI5FQZgKfS0=; b=JcplQSfSDo1YN4dPA3IQRTalubBd+NVmRX8pwv4L25drNmnU6JPrT7sCr4N39wuBsa rEBpVvpJ3vWsUAvHgEc5G/e5HJUUTKgTyuEq9wNFs6pI0rkQU+qJ5mLW8LLgPoBXETXf G93ynVCF50RhRb3gWCzwyTmIB0sRJgCk5vQwQ3NUSkI/bEl2DN0677z0UBPqW3s+fHSN QG5MOxqaRSNy4wS68oaHOj4XrnG8zptrPF+CEb83yq5JYWdQCQTXxqTovt4qvvrv/Op/ aoe0KsjWx+ktOy/+YuglNgSGSOJrGxMQjU2myXOqfP+J6YAb8fEp52McmfvCI5dbf/x3 7gqA== X-Gm-Message-State: AFuF++mTXrgrlfiX5i0fCf3mF7fKtSP6RtSF/XcKLajfzsPvKHpPUTkB vyC0aaXJyLuzHzN5DJQycwKgz/QxCU8bXzbmKtjAqFYwcHblG8AP4r56m/nHQlTAu0c+V46LfKZ fxTlnag5LmOcPrDnyVVGHqZppwQulIHYzTOrtSE64KJBz4mwbGLlm/7Y= X-Gm-Gg: AYBFou1l8KJbJ9mp+BSe8dpGGY/YPWr1w0+zjZ+utfK0Ddrb67YeS6kNDsaNgoYBi4k M3XNjZW1tJMGg2m3buj96rGIejfAaJRvc4vo73dOTWRuHM/0IJk8ipJ4Q1wOmMhBPrha2Uj9mOP BYiTt8IIr/EV5JBv+4y9iS9Xm7YfN212R537pZI3QfRhBYejeqWAYSFEv4UKg5u+AIPGawapOOD uhEmVDdOT15pCcEtwIdXvsBGp6fCTdx1p2eKFWTT/kOqCur/TbmHDyNAnH1+fTq77bBCDHxRgbd pqH6JiexRAHNKN32Qq26Fvh1/W3oG+Bc6Ib5D5XnnGZQyIInTcQm3ChjOCoLF+7wefdOHvbZOM7 i666OxX0i1tEcf6Kb41bcVu1SX4LYjLcXEMifVIyui/1tU9gydRTR/A== X-Received: by 2002:a17:90b:390d:b0:398:bacb:1137 with SMTP id 98e67ed59e1d1-3a07e54a8e2mr3129862a91.19.1790182102982; Wed, 23 Sep 2026 09:48:22 -0700 (PDT) X-Received: by 2002:a17:90b:390d:b0:398:bacb:1137 with SMTP id 98e67ed59e1d1-3a07e54a8e2mr3129824a91.19.1790182102520; Wed, 23 Sep 2026 09:48:22 -0700 (PDT) Received: from localhost (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a096b8753csm10943a91.0.2026.09.23.09.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:48:21 -0700 (PDT) Date: Wed, 23 Sep 2026 09:48:15 -0700 From: Jonathan Cameron To: Suzuki K Poulose Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, maz@kernel.org, will@kernel.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, steven.price@arm.com, aneesh.kumar@kernel.org, oupton@kernel.org, gshan@redhat.com, joey.gouly@arm.com, tabba@google.com, yuzenghui@huawei.com, linux-coco@lists.linux.dev, gankulkarni@os.amperecomputing.com, sdonthineni@nvidia.com, alpergun@google.com, fj0570is@fujitsu.com, WeiLin.Chang@arm.com, lpieralisi@kernel.org, enju.kohei@fujitsu.com Subject: Re: [PATCH v19 01/20] KVM: arm64: protected VM: Handle user writes to CNTVCT_EL0/CNTPCT_EL0 Message-ID: <20260923094815.000026eb@oss.qualcomm.com> In-Reply-To: <528f3c4a-723f-47ad-a387-6e6a4179c96a@arm.com> References: <20260920212845.707-1-suzuki.poulose@arm.com> <20260920212845.707-2-suzuki.poulose@arm.com> <20260922122542.00006868@oss.qualcomm.com> <528f3c4a-723f-47ad-a387-6e6a4179c96a@arm.com> Organization: Qualcomm X-Mailer: Claws Mail 4.4.0 (GTK 3.24.51; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIzMDA2NiBTYWx0ZWRfX7s/qTeZ+Yhxr nepDLtDlqWg669VsONroEv06WoiDp+Ln20+Ik45WgaNaLZVRYvP36omAilxw3e0V10cNjvsAwKk nKFDTPJ3+7Qayx77bXFebK4w4OxT/NnfSZoBfQxfHCMfHXnEG7kxfOAYkW/sQ3VygFXCPvd8jH6 owuxvRNoed9pNpqMUubIjJ6HuT8l9RGvfWDlnmZJgPQI5EYShZrPtNj3ZLU7veHWL8IV79AWvIS p+de/hIUqf9Uf5IFHumB7e99hiPH5pyPu2SqP605UDbl7AfGyjsoXaroNcrG9/JdbgrRt1nYelt jLSkProB3eQ7sdDGlAYk6cIqLI2mkQoMVfZyVBF1X90wp3e9vRIW7PhacxWyKvOO0y4YTUWZnuC 7FYMOBxixLkv+t7N6QUSYQe2yLIE9tLV0XLILImXNf/zKNNR97jDqBAJvBMYS7pBrHzdYWLFOnB jb8AuO8G2vq+iywNNOA== X-Authority-Analysis: v=2.4 cv=aIxlOr9m c=1 sm=1 tr=0 ts=6ab402d7 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=kj9zAlcOel0A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=7CQSdrXTAAAA:8 a=iHHI45kYt6FPp7tEAR8A:9 a=CjuIK1q_8ugA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 a=a-qgeE7W1pNrGK8U0ZQC:22 X-Proofpoint-GUID: jrx4vF5IdZku20yH2LUBBNRI5nmlrRah X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIzMDA2NiBTYWx0ZWRfX/UR0yr8WK+UZ VoW2QAzwelzW8xSFBTU6eJFwVGaYJ4uOBIDNMFQT0NyKAUO9kF8lH7uJZH2zwto0cxCUMt1iWfz DDvwV52XWyD/zZJeWdBYgX/5mbgEWfk= X-Proofpoint-ORIG-GUID: jrx4vF5IdZku20yH2LUBBNRI5nmlrRah X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-23_06,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230066 On Tue, 22 Sep 2026 22:53:48 +0100 Suzuki K Poulose wrote: > On 22/09/2026 20:25, Jonathan Cameron wrote: > > On Sun, 20 Sep 2026 22:28:26 +0100 > > Suzuki K Poulose wrote: > > > > Hi Suzuki, > > > >> Protected VMs doesn't allow setting offsets for virtual and phyiscal > > > > physical > > > >> counters, as the offset is always fixed to 0. The VM ioclt is filtered > > > > ioctl > > > >> out based on the cap. However we don't prevent the userspace from trying > >> to write to the CNTVCT/CNTPCT registers. This would lead to KVM triggering > >> a WARN() in timer_set_offset() as the vm_offset pointer is set to NULL. > >> > >> Fix this by always "fixing" the timer offsets to 0 and marking that the > >> timer offset is set in the kvm->arch.flags at KVM init time for protected > >> VMs. A userspace writing to the CNT*CT_EL0 would observe success, without > >> any real effect. This was chosen over preventing the writes to these > >> registers and returning -EPERM. > > > > Why? I don't mind the decision but telling us what was chosen is something > > we can see in the code - patch description should give us the stuff we > > can't see. > > I have modified the paragraph to : > > "Fix this by always "fixing" the timer offsets to 0 and marking that the > timer offset is set in the kvm->arch.flags at KVM init time for > protected VMs. This prevents the access to the VM specific vm_offset at > low cost. A userspace writing to the CNT*CT_EL0 would observe success, > without any real effect. This is cleaner over spilling *_is_protected()" cleaner than spilling. Snag is over spill is a whole different thing and got me wondering what was over spilling! Otherwise that works nicely. Thanks!