[PATCH v7 21/23] KVM: s390: arm64: Implement vCPU IOCTLs
Janosch Frank
frankja at linux.ibm.com
Thu Sep 3 06:27:16 PDT 2026
On 8/31/26 4:47 PM, Steffen Eiden wrote:
> Implement all required vCPU (arch) IOCTLs.
>
> Co-developed-by: Andreas Grapentin <gra at linux.ibm.com>
> Signed-off-by: Andreas Grapentin <gra at linux.ibm.com>
> Co-developed-by: Nina Schoetterl-Glausch <nsg at linux.ibm.com>
> Signed-off-by: Nina Schoetterl-Glausch <nsg at linux.ibm.com>
> Signed-off-by: Steffen Eiden <seiden at linux.ibm.com>
> ---
[...]
> +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_timing_enter_irqoff();
> + guest_state_enter_irqoff();
> + local_irq_enable();
> +
> + sae_block->icptr = 0;
We already do that in the function below, no?
If possible I'd like to avoid setting ictpr here.
> +
> + sae64a(sae_block);
> +
> + local_irq_disable();
> + guest_state_exit_irqoff();
> + guest_timing_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();
> +
> + kvm_vcpu_srcu_read_lock(vcpu);
> +
> + ret = 1;
> + do {
> + if (signal_pending(current)) {
> + kvm_run->exit_reason = KVM_EXIT_INTR;
> + ret = -EINTR;
> + break;
> + }
> +
> + if (need_resched())
> + schedule();
> +
> + if (ret > 0)
> + ret = check_vcpu_requests(vcpu);
> +
> + vcpu->arch.sae_block.icptr = 0;
Here
> +
> + smp_store_mb(vcpu->mode, IN_GUEST_MODE);
> +
> + if (kvm_request_pending(vcpu)) {
> + vcpu->mode = OUTSIDE_GUEST_MODE;
> + continue;
> + }
> +
> + kvm_vcpu_srcu_read_unlock(vcpu);
> +
> + arm_vcpu_run(vcpu);
> +
> + vcpu->mode = OUTSIDE_GUEST_MODE;
> +
> + kvm_vcpu_srcu_read_lock(vcpu);
> +
> + ret = handle_exit(vcpu);
ARM increases stat.exits here and since you copied the stat fields over
we could do that too.
General question to the ARM maintainers:
We'll be adding more stat fields in the very soon future.
Are you fine with us adding them under any name or should we prefix them
so it's clear they exist because of our architecture / implementation
and will likely never be added to ARM KVM?
In the past we've added a lot of stats and I'd expect us to at least add
stats for every intercept reason.
> +
> + } while (ret > 0);
> +
> + kvm_vcpu_srcu_read_unlock(vcpu);
> +
> + kvm_sigset_deactivate(vcpu);
> +out:
> + if (unlikely(vcpu_get_flag(vcpu, INCREMENT_PC)))
> + adjust_pc(vcpu);
> +
> + save_vx_regs(vcpu->arch.ctxt.vregs);
> + kernel_fpu_end(&fpu_save, KERNEL_FPC | KERNEL_VXR);
> + vcpu_put(vcpu);
> +
> + return ret;
> +}
More information about the linux-arm-kernel
mailing list