From: Oliver Upton <oliver.upton@linux.dev>
To: Fuad Tabba <tabba@google.com>
Cc: kvmarm@lists.linux.dev, maz@kernel.org, catalin.marinas@arm.com,
joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com,
will@kernel.org
Subject: Re: [PATCH v1 1/4] KVM: arm64: Move pkvm_vcpu_init_traps() to init_pkvm_hyp_vcpu()
Date: Tue, 15 Oct 2024 00:37:45 -0700 [thread overview]
Message-ID: <Zw4byVfZngXV19ni@linux.dev> (raw)
In-Reply-To: <20241014102413.4092725-2-tabba@google.com>
On Mon, Oct 14, 2024 at 11:24:09AM +0100, Fuad Tabba wrote:
> Move pkvm_vcpu_init_traps() to the initialization of the
> hypervisor's vcpu state in init_pkvm_hyp_vcpu(), and remove the
> associated hypercall.
>
> In protected mode, traps need to be initialized whenever a VCPU
> is initialized anyway, and not only for protected VMs. This also
> saves an unnecessary hypercall.
>
> Signed-off-by: Fuad Tabba <tabba@google.com>
> ---
> arch/arm64/include/asm/kvm_asm.h | 1 -
> arch/arm64/kvm/arm.c | 8 --------
> arch/arm64/kvm/hyp/include/nvhe/trap_handler.h | 2 --
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 8 --------
> arch/arm64/kvm/hyp/nvhe/pkvm.c | 4 +++-
> 5 files changed, 3 insertions(+), 20 deletions(-)
>
> diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
> index b36a3b6cc011..7f7866d2bfc2 100644
> --- a/arch/arm64/include/asm/kvm_asm.h
> +++ b/arch/arm64/include/asm/kvm_asm.h
> @@ -76,7 +76,6 @@ enum __kvm_host_smccc_func {
> __KVM_HOST_SMCCC_FUNC___kvm_timer_set_cntvoff,
> __KVM_HOST_SMCCC_FUNC___vgic_v3_save_vmcr_aprs,
> __KVM_HOST_SMCCC_FUNC___vgic_v3_restore_vmcr_aprs,
> - __KVM_HOST_SMCCC_FUNC___pkvm_vcpu_init_traps,
> __KVM_HOST_SMCCC_FUNC___pkvm_init_vm,
> __KVM_HOST_SMCCC_FUNC___pkvm_init_vcpu,
> __KVM_HOST_SMCCC_FUNC___pkvm_teardown_vm,
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index a0d01c46e408..ece934bb4531 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -856,14 +856,6 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
> static_branch_inc(&userspace_irqchip_in_use);
> }
>
> - /*
> - * Initialize traps for protected VMs.
> - * NOTE: Move to run in EL2 directly, rather than via a hypercall, once
> - * the code is in place for first run initialization at EL2.
> - */
> - if (kvm_vm_is_protected(kvm))
> - kvm_call_hyp_nvhe(__pkvm_vcpu_init_traps, vcpu);
> -
Can we instead get rid of this hypercall by implementing the one-time
late initialization as the comment suggests?
It'd be great if the feature configuration for non-protected and
protected VMs is done in a similar way, and that is userspace changes to
the ID registers before KVM_RUN.
So we need this sort of 'late' initialization for that behavior to work.
--
Thanks,
Oliver
next prev parent reply other threads:[~2024-10-15 7:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 10:24 [PATCH v1 0/4] KVM: arm64: Fix initialization of trap register values in pKVM Fuad Tabba
2024-10-14 10:24 ` [PATCH v1 1/4] KVM: arm64: Move pkvm_vcpu_init_traps() to init_pkvm_hyp_vcpu() Fuad Tabba
2024-10-15 7:37 ` Oliver Upton [this message]
2024-10-15 8:22 ` Fuad Tabba
2024-10-15 8:30 ` Oliver Upton
2024-10-15 9:35 ` Fuad Tabba
2024-10-14 10:24 ` [PATCH v1 2/4] KVM: arm64: Refactor kvm_vcpu_enable_ptrauth() for hyp use Fuad Tabba
2024-10-14 10:24 ` [PATCH v1 3/4] KVM: arm64: Initialize the hypervisor's VM state at EL2 Fuad Tabba
2024-10-14 10:24 ` [PATCH v1 4/4] KVM: arm64: Initialize trap register values in hyp in pKVM Fuad Tabba
2024-10-15 7:57 ` Oliver Upton
2024-10-15 8:19 ` Fuad Tabba
2024-10-15 8:22 ` Oliver Upton
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=Zw4byVfZngXV19ni@linux.dev \
--to=oliver.upton@linux.dev \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tabba@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.