From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf2-f13.google.com (mail-lf2-f13.google.com [74.125.229.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70A513254A8 for ; Tue, 22 Sep 2026 14:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.229.205 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087672; cv=none; b=k4eB1OXFBbMKWn3WoBFhDfAFoC/EgHADO4IUPBhI3nuANgpWfD+6NTJSZxl2yQZh1tClCThBgTdSypbDGsj/cYVeAnOdqHuHyVp8Pr8ZWdT1jRqqDKUxaYZrypqEWrWuiouDkNw2ut4FDDpk/i4xGrjEopgvsofjjnA2T2CB1hY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790087672; c=relaxed/simple; bh=OSpr8vZBZSILiOyuY44tAAoQRF+Mre7i03lUP3vPqEw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AxgsC5VxFlKAsdLLakpOHF+KPwyQ1QIE9bXJp9HilAJ8LqPA90WTKtkRjPE2PQZjZh7V/POeZi4Gkj5YcXylt6RaM4VLDqJtlyTQieqai/aq+YQUjryhcZXiOBHLLwreJ7iQ5TN12FVEWeO/jZdqb7D8+JNeTbkSZDKGBrm25QA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=FlcMQpQ1; arc=none smtp.client-ip=74.125.229.205 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FlcMQpQ1" Received: by mail-lf2-f13.google.com with SMTP id 2adb3069b0e04-5b5e4f13d77so4803066e87.0 for ; Tue, 22 Sep 2026 07:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790087668; x=1790692468; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=r0HTz7i0csHEzPxGHorQVXPbwITXujz+YYUQK1Bj5/w=; b=FlcMQpQ1Q+gcuJrY6I6E4XZnUUZ0BkJfL1IuZm026I6gEvDtLx43huuCBnyLLFK3Xh 7p95odqEQbgG5hw3VXn4kLanjnoMOuiBpO/ev7sAfjAYyeJxFBGLiM2amt6uud76f4va rGcDgNWGeIwIQH9ojUOzPVLPXqOFRa0p7oox7P/jYoc84Y7pj9xYbdIbSV9CBEJbHZOk rzM8uvnImqloWs0PRyqG7e4st3lagcaAAQ0zTICKgW52UKxUQ1CKZwLW3dPjkwWMCBVT 2wy+nzbJFcH07rF1Zncl6A9Avo4oUWR47Ni96z6rQ85Ti8HsFhUfl1jkMrx7ow6FuUAI qriw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790087668; x=1790692468; h=in-reply-to:content-disposition:content-type:mime-version :references: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=r0HTz7i0csHEzPxGHorQVXPbwITXujz+YYUQK1Bj5/w=; b=1JzYvBzl/CGvt/KKgN/d29ENtvgi3g8X2rwGSYzTCW3XB3c9984vQZf/FMKK7RB4o7 Z4exPcZqqYyTOLLRbKJXavZsGoBMq3tfWFXUFVfxB5AclXJ1Iq7uxBaMqlpXFViXtxi1 ME4iN96nFjY1GxiJGLWdiCVKCqRXAjgmsv6GK9YWV8DlhzgnpY7292zFMAqymaK4FMQp VRn1RT0N4iSkOlv0YRFjnfTVVOr70cVe2/uZB1wgLZUodbYN5jIht8llGqERM4DP1Usv +mN6hnBWjNjWoLZwb7YC7/hMbzkuc/VwF7Fpr/CCpBBy2yD/4v/jUfQE3cj5l56TlUOO OOEA== X-Forwarded-Encrypted: i=1; AKwUvBx3BACEVNCtxqlAXlcFuyQ5DCsJvokxs1zz3fSsQk4tU+iULxvg+IPFbFezxHIStLLP+kDAq6Vp4yS0/Og=@vger.kernel.org X-Gm-Message-State: AFuF++n/ypTcd9i0t7P3uuVmhGPpM3dxSKgkiuEQfMgaI9Wq1CARS15L AOn/Ew1wHmorNib3FjP8Be/nVmQPu+doD3whO6lPuKsgw7k9qBMkEykzqmopu4oVxw== X-Gm-Gg: AYBFou220YheKoIIPFh8ZmIhCkqL+nrm+TI4Cvnmo1LLDjmG8EraLJPMrRi8fWBBPhx 6yrJYfH1FZcIF3b0jxD/QVzMEUOWk7HvaFNsZQmsNZkwYimnW4VBHv0mRaEPZfUtBKxoBiB8QPm yvoqluysg7vxX20tlapFU6qeGcmTHihHnqCN+EHfN7+ytTucGCE7/ObIPFLJEd0Pbj6PEoOjy1u AJcA0JxnG24MquqaztrT1Y2aGEGCLg7onXiU4nUDyEdtdKrCzD+dwSW5sL3EzxDuVXfAjS2fC7o XcTx7Fd0XcofawYSONrFmh5S/mSvymSrsEdHelF+2IvBtwhk1DBbKFTjEMHlCaFmGfRhC2ytsj4 jUXjllJX8SYp+HP1frRforYgybBYvVitgYWJTrxQTqodXMtcqgMOVyhWbDcE8NM2nWfApCxEJqY ryEayIABEWIBKOqf4titKL5/zyk6MGzbey8S60/vDLiGtdf6salCPRYSbc4UcY6kuqD0Xz1aFU2 CLTAcWcltLhP4HcPjO8QRs5pt6Qs61bvANTQqI4F9iYtLJ0Lqj3AQ== X-Received: by 2002:a05:6512:3e1b:b0:5b6:1a7c:21 with SMTP id 2adb3069b0e04-5b8c184e320mr4889993e87.36.1790087667742; Tue, 22 Sep 2026 07:34:27 -0700 (PDT) Received: from google.com (135.91.155.104.bc.googleusercontent.com. [104.155.91.135]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b8d46e871dsm604660e87.60.2026.09.22.07.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2026 07:34:27 -0700 (PDT) Date: Tue, 22 Sep 2026 15:34:22 +0100 From: Vincent Donnefort To: Fuad Tabba Cc: maz@kernel.org, oupton@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, mark.rutland@arm.com, steven.price@arm.com, qperret@google.com, tabba@google.com Subject: Re: [PATCH v3 04/18] KVM: arm64: Disable steal time for protected VMs Message-ID: References: <20260914113338.159227-1-fuad.tabba@linux.dev> <20260914113338.159227-5-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260914113338.159227-5-fuad.tabba@linux.dev> On Mon, Sep 14, 2026 at 12:33:24PM +0100, Fuad Tabba wrote: > pKVM doesn't support steal time for protected guests, and > KVM_CAP_STEAL_TIME already reads 0 for them on the VM file descriptor, > but kvm_arm_pvtime_supported() doesn't know the VM, so the host still > accepts the KVM_ARM_VCPU_PVTIME_CTRL attribute, whose IPA would point > kvm_update_stolen_time() at the guest's private memory on every vCPU > load. Pass the VM in and return false for a protected one, so the > attribute returns -ENXIO as it does where steal time isn't implemented. > > Signed-off-by: Fuad Tabba Reviewed-by: Vincent Donnefort > --- > arch/arm64/include/asm/kvm_host.h | 2 +- > arch/arm64/kvm/arm.c | 2 +- > arch/arm64/kvm/pvtime.c | 10 +++++----- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 27fe0cd5b2d7a..286489a69dff5 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1346,7 +1346,7 @@ long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu); > gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu); > void kvm_update_stolen_time(struct kvm_vcpu *vcpu); > > -bool kvm_arm_pvtime_supported(void); > +bool kvm_arm_pvtime_supported(struct kvm *kvm); > int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu, > struct kvm_device_attr *attr); > int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu, > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 8b080804bc90b..db36815630790 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -447,7 +447,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > r = system_supports_mte(); > break; > case KVM_CAP_STEAL_TIME: > - r = kvm_arm_pvtime_supported(); > + r = kvm_arm_pvtime_supported(kvm); > break; > case KVM_CAP_ARM_EL1_32BIT: > r = cpus_have_final_cap(ARM64_HAS_32BIT_EL1); > diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c > index 4ceabaa4c30bd..053fe831fa541 100644 > --- a/arch/arm64/kvm/pvtime.c > +++ b/arch/arm64/kvm/pvtime.c > @@ -67,9 +67,9 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu) > return base; > } > > -bool kvm_arm_pvtime_supported(void) > +bool kvm_arm_pvtime_supported(struct kvm *kvm) > { > - return !!sched_info_on(); > + return !!sched_info_on() && (!kvm || !kvm_vm_is_protected(kvm)); > } > > int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu, > @@ -81,7 +81,7 @@ int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu, > int ret = 0; > int idx; > > - if (!kvm_arm_pvtime_supported() || > + if (!kvm_arm_pvtime_supported(kvm) || > attr->attr != KVM_ARM_VCPU_PVTIME_IPA) > return -ENXIO; > > @@ -110,7 +110,7 @@ int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu, > u64 __user *user = (u64 __user *)attr->addr; > u64 ipa; > > - if (!kvm_arm_pvtime_supported() || > + if (!kvm_arm_pvtime_supported(vcpu->kvm) || > attr->attr != KVM_ARM_VCPU_PVTIME_IPA) > return -ENXIO; > > @@ -126,7 +126,7 @@ int kvm_arm_pvtime_has_attr(struct kvm_vcpu *vcpu, > { > switch (attr->attr) { > case KVM_ARM_VCPU_PVTIME_IPA: > - if (kvm_arm_pvtime_supported()) > + if (kvm_arm_pvtime_supported(vcpu->kvm)) > return 0; > } > return -ENXIO; > -- > 2.39.5 > -- Vincent