From: Steven Price <steven.price@arm.com>
To: Fuad Tabba <tabba@google.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
James Morse <james.morse@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Zenghui Yu <yuzenghui@huawei.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Christoffer Dall <christoffer.dall@arm.com>,
linux-coco@lists.linux.dev,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>,
Gavin Shan <gshan@redhat.com>,
Shanker Donthineni <sdonthineni@nvidia.com>,
Alper Gun <alpergun@google.com>,
"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
Emi Kisanuki <fj0570is@fujitsu.com>,
Vishal Annapurve <vannapurve@google.com>,
WeiLin.Chang@arm.com, Lorenzo Pieralisi <lpieralisi@kernel.org>,
Kohei Enju <enju.kohei@fujitsu.com>
Subject: Re: [PATCH v3 02/11] KVM: arm64: CCA: Introduce Realms
Date: Wed, 18 Nov 2026 16:12:57 +0000 [thread overview]
Message-ID: <a36b5c53-5148-4b08-b399-ae64b1ad8707@arm.com> (raw)
In-Reply-To: <CA+EHjTwfp8p7uwP2LXEqSmTwL6ZHuDCYbvMie_Wr_30xJwfO6A@mail.gmail.com>
On 17/11/2026 14:07, Fuad Tabba wrote:
> On Mon, 16 Nov 2026 16:43:48 +0000, Steven Price <steven.price@arm.com> wrote:
> [...]
>> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> [...]
>> @@ -1571,31 +1576,39 @@ struct kvm *kvm_arch_alloc_vm(void);
>>
>> #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS_RANGE
>>
>> -#ifdef __KVM_NVHE_HYPERVISOR__
>> +#define kvm_vm_is_protected(kvm) ((kvm)->arch.vm_flavor >= __VM_PROTECTED)
>>
>> -#define kvm_vm_is_protected(kvm) \
>> - (is_protected_kvm_enabled() && ((kvm)->arch.vm_flavor == VM_PROTECTED_PKVM))
>> +#ifdef __KVM_NVHE_HYPERVISOR__
>> /*
>> * Accessing vcpu->kvm from nVHE hyp stub is tricky, as we need to convert the
>> * pointer to the hyp VA. With pKVM, the nVHE code runs with the hyp_vcpu,
>> - * which is populated correctly and is gated on is_protected_kvm_enabled().
>> + * which is populated correctly. Always vcpu_is_protected_pkvm(), which is
>> + * gated on is_protected_kvm_enabled().
>> */
>> -#define vcpu_is_protected(vcpu) \
>> +#define vcpu_is_protected(vcpu) BUILD_BUG_ON(1)
>> +#else
>> +#define vcpu_is_protected(vcpu) kvm_vm_is_protected((vcpu)->kvm)
>> +#endif
>> +
>> +#define kvm_vm_is_protected_pkvm(kvm) \
>> + (is_protected_kvm_enabled() && ((kvm)->arch.vm_flavor == VM_PROTECTED_PKVM))
>> +
>> +/*
>> + * Rely on is_protected_kvm_enabled() check in kvm_vm_is_protected_pkvm() to
>> + * make sure the vcpu->kvm is always valid VA in the context
>> + */
>> +#define vcpu_is_protected_pkvm(vcpu) \
>> ({ \
>> struct kvm *__kvm = READ_ONCE((vcpu)->kvm); \
>> \
>> - (__kvm && kvm_vm_is_protected(__kvm)); \
>> + (__kvm && kvm_vm_is_protected_pkvm(__kvm)); \
>> })
>>
>> -#else
>> -
>> -#define kvm_vm_is_protected(kvm) ((kvm)->arch.vm_flavor >= __VM_PROTECTED)
>> -#define vcpu_is_protected(vcpu) kvm_vm_is_protected((vcpu)->kvm)
>
> This brings back the _pkvm variants that Marc asked to drop in the
> plumbing series [1]. In the nVHE hyp code, kvm_vm_is_protected() and
> vcpu_is_protected() already mean pKVM-protected, so I think the hyp
> side can stay as it is.
>
> At EL1, the pKVM-only checks that a Realm vCPU also reaches are in
> kvm_arm_vcpu_power_off() and kvm_psci_vcpu_on(). Could they check
> vm_flavor == VM_PROTECTED_PKVM directly?
Ah, yes that should work better. Thanks for the suggestion.
>> +#define kvm_vm_is_realm(kvm) ((kvm)->arch.vm_flavor == VM_REALM)
>> +#define vcpu_is_rec(vcpu) kvm_vm_is_realm((vcpu)->kvm)
>
> vcpu_is_rec() isn't used anywhere in this series. Could it be dropped?
Yep, I can move it after this series.
> [...]
>> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> [...]
>> @@ -906,7 +907,8 @@ static bool kvm_arm_vcpu_suspended(struct kvm_vcpu *vcpu)
>> /* Only the guest's CPU_ON may start a vCPU EL2 holds powered off. */
>> bool kvm_pkvm_vcpu_is_powered_off(struct kvm_vcpu *vcpu)
>> {
>> - return READ_ONCE(vcpu->arch.mp_state.mp_state) == KVM_MP_STATE_UNINITIALIZED;
>> + return vcpu_is_protected_pkvm(vcpu) &&
>> + READ_ONCE(vcpu->arch.mp_state.mp_state) == KVM_MP_STATE_UNINITIALIZED;
>
> Only a pVM's vCPU can be in KVM_MP_STATE_UNINITIALIZED, so is this needed?
I guess not. I'll drop this change.
Thanks,
Steve
> Cheers,
> /fuad
>
> [1] https://lore.kernel.org/all/86pkxs2npx.wl-maz@kernel.org/
next prev parent reply other threads:[~2026-11-18 16:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:43 [PATCH v3 00/11] KVM: arm64: CCA: Prepare Realm memory management Steven Price
2026-11-16 16:43 ` [PATCH v3 01/11] KVM: arm64: guest_memfd: Check mmap support when preparing memslot Steven Price
2026-11-17 14:05 ` Fuad Tabba
2026-11-18 10:34 ` Suzuki K Poulose
2026-11-18 11:14 ` Steven Price
2026-11-18 12:04 ` Suzuki K Poulose
2026-11-18 15:18 ` Steven Price
2026-11-16 16:43 ` [PATCH v3 02/11] KVM: arm64: CCA: Introduce Realms Steven Price
2026-11-17 14:07 ` Fuad Tabba
2026-11-18 16:12 ` Steven Price [this message]
2026-11-16 16:43 ` [PATCH v3 03/11] KVM: arm64: Handle attributes in stage2_unmap_range Steven Price
2026-11-17 14:16 ` Fuad Tabba
2026-11-18 16:12 ` Steven Price
2026-11-16 16:43 ` [PATCH v3 04/11] KVM: arm64: CCA: Add basic infrastructure for creating a realm Steven Price
2026-11-16 16:43 ` [PATCH v3 05/11] KVM: arm64: CCA: Tear down RTTs Steven Price
2026-11-16 16:43 ` [PATCH v3 06/11] KVM: arm64: CCA: Add Realm RTT mapping and invalidation helpers Steven Price
2026-11-16 16:43 ` [PATCH v3 07/11] KVM: Allow architectures to reject memslot changes before invalidation Steven Price
2026-11-17 14:31 ` Fuad Tabba
2026-11-16 16:43 ` [PATCH v3 08/11] KVM: arm64: CCA: Prevent memslot modifications after Realm creation Steven Price
2026-11-17 14:42 ` Fuad Tabba
2026-11-16 16:43 ` [PATCH v3 09/11] KVM: arm64: CCA: Support runtime faulting of memory Steven Price
2026-11-16 16:43 ` [PATCH v3 10/11] KVM: arm64: Dispatch stage-2 destruction by VM flavor Steven Price
2026-11-17 15:02 ` Fuad Tabba
2026-11-16 16:43 ` [PATCH v3 11/11] KVM: arm64: CCA: Add Realm stage-2 MMU operations Steven Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a36b5c53-5148-4b08-b399-ae64b1ad8707@arm.com \
--to=steven.price@arm.com \
--cc=WeiLin.Chang@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=alpergun@google.com \
--cc=aneesh.kumar@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@arm.com \
--cc=enju.kohei@fujitsu.com \
--cc=fj0570is@fujitsu.com \
--cc=gankulkarni@os.amperecomputing.com \
--cc=gshan@redhat.com \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=sdonthineni@nvidia.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=vannapurve@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®