Re: [PATCH v7] KVM: s390: Add new reset vcpu API

Christian Borntraeger
2020-01-27T08:05:10Z

On 10.01.20 12:45, Janosch Frank wrote:
[...]
> +static void kvm_arch_vcpu_ioctl_clear_reset(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_sync_regs *regs = &vcpu->run->s.regs;
> +
> + /* Clear reset is a superset of the initial reset */
> + kvm_arch_vcpu_ioctl_normal_reset(vcpu);
> +
> + memset(&regs->gprs, 0, sizeof(regs->gprs));

> + /* Will be picked up because of save_fpu_regs() in the initial reset */
> + memset(&current->thread.fpu.vxrs, 0, sizeof(current->thread.fpu.vxrs));

So I checked with a userspace that sets f8(call-saved) to 0x123 during this ioctl.
f8 is 0 afterwards. The guest f8 is also correct, just because QEMU does clear out
its copy of the fprs and syncs that back via synv regs.

So this must be

/* we have not synced the registers from kvm_run to the thread
structure. We must clear out kvm_run*/
memset(&regs->vrs, 0, sizeof(regs->vrs));

> + memset(&regs->acrs, 0, sizeof(regs->acrs));
> +
> + regs->etoken = 0;
> + regs->etoken_extension = 0;
> +
> + memset(&regs->gscb, 0, sizeof(regs->gscb));
[....]