From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6E7802E7BD6; Fri, 2 Oct 2026 12:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790945835; cv=none; b=iBo3nyJGKG+Ykp1S1zTfxnlf4UYbXrDXnUEwqIjbLtH75WBwg4nj/VM9opZ0vHcZnc3KzmbEI/8WRLkNK5EMGsnAfzjWmOxnYlH2xnBA0D3BxvQJbstXCWFmLiqU3cbgflrFL/BkD56MOr/xwncsayzsunH5ukMd/qgcptMUHts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790945835; c=relaxed/simple; bh=ZXwF5qQJEkDqdDJzkSWaEZAvXI4WTxddA3a3t+t/qmI=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=MTZvQCSMXFC2jaXfW9bNUlAdYbe9zNoEzwRvezEvbFmuwEBHuv2tOvX4wRCBDYTOmtN6EagSwxLhFAYXqCjw5HR54DUNl5Tv+ZS+hs7yhHmkAnzxfd8uIsaSG15ljerA8SW8mH7JY3YdFrcjo0byeDEt18pPHTM2KWvkryskQsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WF9LZxrc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WF9LZxrc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 501261F000FF; Fri, 2 Oct 2026 12:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790945834; bh=0UtDxCzSxsK2ku+CA7l+bjB6RPxfD160Qjz44ZIDIe0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=WF9LZxrcVvHu6PW+XOYclk0VVBOQPLtinnNi/jt6r7uTb/njR6uIWn3UAt0/bYaZ0 Q9NbBQDrNX+jztOzQI/FzXzQ60Y3j0ytpRMGVwX6QHBl2Cfn6lwrrSI9kJPHT+wXfy FOuHQou7kYr7Ik6dI3pg9Yb3gUEOc5G8JTCe0zYFCF6obms2czMWJdCUDjHFQFs3Sx mhQNBI1a58YE6LNEHKPfFB3iAsFpD4GshDO648dfYfbM0OVVYsIEExWYMBUUXKsG+b z44pEb8aEHodxNdBXtPqA4CKips1YXXhtTZKdFFgQiq71qwlKk2BL6mOAL2Lbf7gE4 +Mmvv1dpREhiQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xCcp5-0000000GE4t-48QV; Fri, 02 Oct 2026 12:57:12 +0000 Date: Fri, 02 Oct 2026 13:57:11 +0100 Message-ID: <86se2o2rbs.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Suzuki K Poulose , kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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, 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, sudeep.holla@arm.com, jonathan.cameron@oss.qualcomm.com Subject: Re: [PATCH v21 05/23] KVM: arm64: Track the type of VM in kvm_arch In-Reply-To: References: <20261001210703.1597150-1-suzuki.poulose@arm.com> <20261001210703.1597150-6-suzuki.poulose@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, suzuki.poulose@arm.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, 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, 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, sudeep.holla@arm.com, jonathan.cameron@oss.qualcomm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 02 Oct 2026 11:06:52 +0100, Fuad Tabba wrote: > > Hi Suzuki, > > On Thu, 01 Oct 2026 22:06:45 +0100, Suzuki K Poulose > wrote: > [...] > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > [...] > > +#define vcpu_is_protected(vcpu) \ > [...] > > + if (is_nvhe_hyp_code() && \ > > + !is_protected_kvm_enabled()) \ > > + __kvm = kern_hyp_va(__kvm); \ > > On a non-pKVM nVHE host, the hyp callers of this in switch.c and > timer-sr.c now translate vcpu->kvm and load vm_flavor on every guest > entry and exit, where the is_protected_kvm_enabled() check used to > short-circuit. Could they use vcpu_is_protected_pkvm(), and drop the > kern_hyp_va() here? Just to make sure. Is that what you had in mind? diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 7318e3e6a5f36..2a3e6d83682d5 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -217,7 +217,7 @@ static const exit_handler_fn pvm_exit_handlers[] = { static const exit_handler_fn *kvm_get_exit_handler_array(struct kvm_vcpu *vcpu) { - if (unlikely(vcpu_is_protected(vcpu))) + if (unlikely(vcpu_is_protected_pkvm(vcpu))) return pvm_exit_handlers; return hyp_exit_handlers; @@ -238,7 +238,7 @@ static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code) * it. The check below is based on the one in * kvm_arch_vcpu_ioctl_run(). */ - if (unlikely(vcpu_is_protected(vcpu) && vcpu_mode_is_32bit(vcpu))) { + if (unlikely(vcpu_is_protected_pkvm(vcpu) && vcpu_mode_is_32bit(vcpu))) { /* * As we have caught the guest red-handed, decide that it isn't * fit for purpose anymore by making the vcpu invalid. The VMM diff --git a/arch/arm64/kvm/hyp/nvhe/timer-sr.c b/arch/arm64/kvm/hyp/nvhe/timer-sr.c index 9930657169133..17bd1ff621ab6 100644 --- a/arch/arm64/kvm/hyp/nvhe/timer-sr.c +++ b/arch/arm64/kvm/hyp/nvhe/timer-sr.c @@ -48,7 +48,7 @@ void __timer_enable_traps(struct kvm_vcpu *vcpu) * or running a protected VM (we don't offset anything in this case). */ clr = CNTHCTL_EL1PCEN; - if (vcpu_is_protected(vcpu) || + if (vcpu_is_protected_pkvm(vcpu) || !timer_get_offset(vcpu_ptimer(vcpu))) set |= CNTHCTL_EL1PCTEN; else M. -- Without deviation from the norm, progress is not possible.