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 CA72E3932FF; Thu, 16 Jul 2026 10:38:28 +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=1784198312; cv=none; b=GP6y4dZRumFX5HREG7YdWsH/oQ7A759Za3zmibF1wsIpSeeiJ+BeD1NvvzAXb1rwNZMv74b2YoQL6HqASoAabNKrEq75blhy4DLkUwLvl2lpJYtFP0JAVyvpyRK25epuH9PBN1DqR+yn+MK79m1uYg2wNDu24v70EvLt9oaUwtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784198312; c=relaxed/simple; bh=eatil/BgWzzUzjknYQO/rfLqqSuIy87cjTAYJwTkPlQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LqSYSI2zl0TNaMzTzLCNp13CinVWu3fCAqb9AFHqphxj0InNOKAzDH/YHFY/7hXe1sgnyoIcW90j1HuM4sMlyI2ZsRX+JazBHlos5GIeVdGYdxHQzZ19ZO7HQRliVPW6xCf45HXex4RwfpI2dYXbNC4w+y3+MuOeNp4NFdr6S7c= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ObQrMAPv; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ObQrMAPv" 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 CFAA4339; Thu, 16 Jul 2026 03:38:23 -0700 (PDT) Received: from [10.2.197.99] (ewhatever.cambridge.arm.com [10.2.197.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD1F93F93E; Thu, 16 Jul 2026 03:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784198308; bh=eatil/BgWzzUzjknYQO/rfLqqSuIy87cjTAYJwTkPlQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ObQrMAPvENDnI4UYljIfKi3c66d6yFzXc7APc/4AQnh2Kjf2K++w7kUQv6jonhB8I mdp93z/QHSDFwC0OMjyGWN6bOymarLt2VrW2G/qD/QIHo9y6u5q/JbpaV4eOtrx9or Su+SguHT78PMEtpDRzFEF2a5FR92VMwEVK8VzgcY= Message-ID: <609440c1-7bdc-4f43-9b16-23521ca96394@arm.com> Date: Thu, 16 Jul 2026 11:38:21 +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 v15 25/37] KVM: arm64: CCA: Handle Realm PSCI requests 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" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo Pieralisi References: <20260715142841.80544-1-steven.price@arm.com> <20260715142841.80544-26-steven.price@arm.com> Content-Language: en-US From: Suzuki K Poulose In-Reply-To: <20260715142841.80544-26-steven.price@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 15/07/2026 15:28, Steven Price wrote: > Some PSCI commands cause a REC exit and the host has to call > RMI_PSCI_COMPLETE to provide the status value to return to the guest. > > Co-developed-by: Suzuki K Poulose > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > --- > Changes since v14: > * Dropped the support for providing the target REC for a PSCI call (as > per v2.0-bet2 spec). > Changes since v13: > * The ioctl KVM_ARM_VCPU_RMI_PSCI_COMPLETE has gone. The RMI call is > made automatically just before entering the REC again. > Changes since v12: > * Change return code for non-realms to -ENXIO to better represent that > the ioctl is invalid for non-realms (checkpatch is insistent that > "ENOSYS means 'invalid syscall nr' and nothing else"). > Changes since v11: > * RMM->RMI renaming. > Changes since v6: > * Use vcpu_is_rec() rather than kvm_is_realm(vcpu->kvm). > * Minor renaming/formatting fixes. > --- > arch/arm64/include/asm/kvm_rmi.h | 2 ++ > arch/arm64/kvm/psci.c | 14 ++++++++++++ > arch/arm64/kvm/rmi.c | 38 ++++++++++++++++++++++++++++++++ > 3 files changed, 54 insertions(+) > > diff --git a/arch/arm64/include/asm/kvm_rmi.h b/arch/arm64/include/asm/kvm_rmi.h > index 718c7128a3c3..a9bb9aabee5d 100644 > --- a/arch/arm64/include/asm/kvm_rmi.h > +++ b/arch/arm64/include/asm/kvm_rmi.h > @@ -120,6 +120,8 @@ int realm_map_ipa(struct kvm *kvm, phys_addr_t ipa, > enum kvm_pgtable_prot prot, > struct kvm_mmu_memory_cache *memcache); > > +int realm_psci_complete(struct kvm_vcpu *source, unsigned long status); > + > static inline bool kvm_realm_is_private_address(struct realm *realm, > unsigned long addr) > { > diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c > index 3b5dbe9a0a0e..b0983ee416a2 100644 > --- a/arch/arm64/kvm/psci.c > +++ b/arch/arm64/kvm/psci.c > @@ -142,6 +142,20 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) > /* Ignore other bits of target affinity */ > target_affinity &= target_affinity_mask; > > + if (vcpu_is_rec(vcpu)) { > + struct kvm_vcpu *target_vcpu; > + > + /* RMM supports only zero affinity level */ > + if (lowest_affinity_level != 0) > + return PSCI_RET_INVALID_PARAMS; > + > + target_vcpu = kvm_mpidr_to_vcpu(kvm, target_affinity); > + if (!target_vcpu) > + return PSCI_RET_INVALID_PARAMS; > + > + return PSCI_RET_SUCCESS; > + } > + We don't have to deal with AFFINITY_INFO anymore with the RMM maintaining the MPIDR to REC mapping. This can be removed. Otherwise looks good to me. Suzuki > /* > * If one or more VCPU matching target affinity are running > * then ON else OFF > diff --git a/arch/arm64/kvm/rmi.c b/arch/arm64/kvm/rmi.c > index 31effae067c8..8fb6403893e8 100644 > --- a/arch/arm64/kvm/rmi.c > +++ b/arch/arm64/kvm/rmi.c > @@ -3,6 +3,7 @@ > * Copyright (C) 2023-2026 ARM Ltd. > */ > > +#include > #include > > #include > @@ -119,6 +120,18 @@ static void free_rtt(phys_addr_t phys) > kvm_account_pgtable_pages(phys_to_virt(phys), -1); > } > > +int realm_psci_complete(struct kvm_vcpu *source, unsigned long status) > +{ > + int ret; > + > + ret = rmi_psci_complete(virt_to_phys(source->arch.rec.rec_page), > + status); > + if (ret) > + return -ENXIO; > + > + return 0; > +} > + > static int realm_rtt_create(struct realm *realm, > unsigned long addr, > int level, > @@ -1115,6 +1128,28 @@ static void kvm_complete_ripas_change(struct kvm_vcpu *vcpu) > rec->run->exit.ripas_base = base; > } > > +static void kvm_rec_complete_psci(struct kvm_vcpu *vcpu) > +{ > + struct rec_run *run = vcpu->arch.rec.run; > + unsigned long status = PSCI_RET_DENIED; > + unsigned long ret = vcpu_get_reg(vcpu, 0); > + > + switch (run->exit.gprs[0]) { > + case PSCI_0_2_FN64_CPU_ON: { > + if (ret != PSCI_RET_SUCCESS && > + ret != PSCI_RET_ALREADY_ON) > + status = PSCI_RET_DENIED; > + else > + status = PSCI_RET_SUCCESS; > + break; > + } > + default: > + return; > + } > + > + realm_psci_complete(vcpu, status); > +} > + > /* > * kvm_rec_pre_enter - Complete operations before entering a REC > * > @@ -1139,6 +1174,9 @@ int kvm_rec_pre_enter(struct kvm_vcpu *vcpu) > for (int i = 0; i < REC_RUN_GPRS; i++) > rec->run->enter.gprs[i] = vcpu_get_reg(vcpu, i); > break; > + case RMI_EXIT_PSCI: > + kvm_rec_complete_psci(vcpu); > + break; > case RMI_EXIT_RIPAS_CHANGE: > kvm_complete_ripas_change(vcpu); > break;