From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53A76189F3B; Mon, 19 May 2025 17:48:59 +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=1747676941; cv=none; b=rOrdGkCo7581ocLVkd7pyJ1iq+QGuPPC33JRKIpLUFOkYc0WvXApZtHmWE/MluOtr/nleknkPhY6pX1im4DJQCvHlgeyj5sqHim26eeVn7AV9SbhCmwAJs/mzm9Foae/rVJmRd17kn0nvHhFmPOasON/KDEhVzusqv6gBMHA0Qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747676941; c=relaxed/simple; bh=VZD7KJH98460RHVflDeZoOG37d286qHkE5BrcmtWmXc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iMGqgX9C2DwqHxZDph1ZuXP3yysXQYztYSLfFVj1+c4hFUDgnpKLfaG0a885gnN2QAqK2hMB2AY0fkcO8CF64yU+t/6ugjYWTIWAT1R7Oa+f1RJ2nBKHMfB5WMXk2RwBGboWQR6O746eCOc0/7HVLzSkGAXfiCvMX0oJQCRYxx0= 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 74F0115A1; Mon, 19 May 2025 10:48:45 -0700 (PDT) Received: from [10.57.50.157] (unknown [10.57.50.157]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 441CF3F673; Mon, 19 May 2025 10:48:55 -0700 (PDT) Message-ID: <9a09a3fe-c91c-457f-b6da-9fccbf98e649@arm.com> Date: Mon, 19 May 2025 18:48:54 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v8 21/43] KVM: arm64: Handle realm VCPU load Content-Language: en-GB To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , 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" References: <20250416134208.383984-1-steven.price@arm.com> <20250416134208.383984-22-steven.price@arm.com> From: Suzuki K Poulose In-Reply-To: <20250416134208.383984-22-steven.price@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 16/04/2025 14:41, Steven Price wrote: > When loading a realm VCPU much of the work is handled by the RMM so only > some of the actions are required. Rearrange kvm_arch_vcpu_load() > slightly so we can bail out early for a realm guest. > > Signed-off-by: Steven Price > Reviewed-by: Gavin Shan > --- > arch/arm64/kvm/arm.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index cf707130ef66..08d5e0d76749 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -644,10 +644,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) I think we use the pkvm hook to skip to the nommu goto, to avoid the VMID allocation and context flush. > kvm_timer_vcpu_load(vcpu); > kvm_vgic_load(vcpu); > kvm_vcpu_load_debug(vcpu); > - if (has_vhe()) > - kvm_vcpu_load_vhe(vcpu); > - kvm_arch_vcpu_load_fp(vcpu); > - kvm_vcpu_pmu_restore_guest(vcpu); > if (kvm_arm_is_pvtime_enabled(&vcpu->arch)) > kvm_make_request(KVM_REQ_RECORD_STEAL, vcpu); We could also move thise pvtime to the bottom too ? > > @@ -671,6 +667,15 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > &vcpu->arch.vgic_cpu.vgic_v3); > } > > + /* No additional state needs to be loaded on Realmed VMs */ > + if (vcpu_is_rec(vcpu)) > + return; > + > + if (has_vhe()) > + kvm_vcpu_load_vhe(vcpu); > + kvm_arch_vcpu_load_fp(vcpu); > + kvm_vcpu_pmu_restore_guest(vcpu); > + With the above addressed: Reviewed-by: Suzuki K Poulose > if (!cpumask_test_cpu(cpu, vcpu->kvm->arch.supported_cpus)) > vcpu_set_on_unsupported_cpu(vcpu); > }