Re: [PATCH v4 25/27] KVM: s390: arm64: Implement vCPU IOCTLs
From: Marc Zyngier
Date: Wed Jul 08 2026 - 06:44:13 EST
On Mon, 06 Jul 2026 09:52:25 +0100,
Steffen Eiden <seiden@xxxxxxxxxxxxx> wrote:
>
> +static void adjust_pc(struct kvm_vcpu *vcpu)
> +{
> + if (vcpu_get_flag(vcpu, INCREMENT_PC)) {
> + kvm_skip_instr(vcpu);
> + vcpu_clear_flag(vcpu, INCREMENT_PC);
> + }
> +}
Can you clarify the semantics of adjust_pc() here? arm64 also deals
with exceptions in the same code, and I wonder how you deal with this.
> +
> +static void arm_vcpu_run(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_sae_block *sae_block = &vcpu->arch.sae_block;
> +
> + adjust_pc(vcpu);
> +
> + local_irq_disable();
> + guest_enter_irqoff();
> + local_irq_enable();
> +
> + sae_block->icptr = 0;
> +
> + sae64a(sae_block);
> +
> + local_irq_disable();
> + guest_exit_irqoff();
> + local_irq_enable();
> +}
> +
> +/** kvm_arch_vcpu_ioctl_run() - run arm64 vCPU
> + *
> + * Execute arm64 guest instructions using SAE.
> + *
> + * Returns:
> + * 1 enter the guest (should not be observed by userspace)
> + * 0 exit to userspace
> + * < 0 exit to userspace, where the return value indicates n error
> + *
> + *
> + */
> +int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
> +{
> + DECLARE_KERNEL_FPU_ONSTACK32(fpu_save);
> + struct kvm_run *kvm_run = vcpu->run;
> + int ret;
> +
> + if (kvm_run->exit_reason == KVM_EXIT_MMIO) {
> + ret = kvm_handle_mmio_return(vcpu);
> + if (ret <= 0)
> + return ret;
> + }
> +
> + vcpu_load(vcpu);
> +
> + kernel_fpu_begin(&fpu_save, KERNEL_FPC | KERNEL_VXR);
> + load_vx_regs((vcpu->arch.ctxt.vregs));
> +
> + if (!vcpu->wants_to_run) {
> + ret = -EINTR;
> + goto out;
> + }
> +
> + kvm_sigset_activate(vcpu);
> +
> + might_fault();
> +
> + ret = 1;
> + do {
> + if (signal_pending(current)) {
> + kvm_run->exit_reason = KVM_EXIT_INTR;
> + ret = -EINTR;
> + continue;
> + }
> +
> + if (need_resched())
> + schedule();
> +
> + if (ret > 0)
> + ret = check_vcpu_requests(vcpu);
> +
> + vcpu->arch.sae_block.icptr = 0;
> +
> + arm_vcpu_run(vcpu);
> +
> + ret = handle_exit(vcpu);
> +
> + } while (ret > 0);
> +
> + kvm_sigset_deactivate(vcpu);
> +out:
> + if (unlikely(vcpu_get_flag(vcpu, INCREMENT_PC)))
> + adjust_pc(vcpu);
arm64 has the following statements:
if (unlikely(vcpu_get_flag(vcpu, PENDING_EXCEPTION) ||
vcpu_get_flag(vcpu, INCREMENT_PC)))
kvm_call_hyp(__kvm_adjust_pc, vcpu);
It isn't clear to me why you can afford not to deal with pending
exceptions when returning to userspace.
Thanks,
M.
--
Jazz isn't dead. It just smells funny.