Re: [PATCH 14/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

[replying to myself]

On Sat, Nov 25, 2017 at 09:57:17PM +0100, Christoffer Dall wrote:
> Move the calls to vcpu_load() and vcpu_put() in to the architecture
> specific implementations of kvm_arch_vcpu_ioctl() which dispatches
> further architecture-specific ioctls on to other functions.
> 
> Some architectures support asynchronous vcpu ioctls which cannot call
> vcpu_load() or take the vcpu->mutex, because that would prevent
> concurrent execution with a running VCPU, which is the intended purpose
> of these ioctls, for example because they inject interrupts.
> 
> We move the checks for these specifics into the architecture code for
> MIPS, S390 and PPC, and it has the added benefit of getting rid of the
> ifdef in the generic dispatcher.
> 
> Signed-off-by: Christoffer Dall <christoffer.dall@xxxxxxxxxx>
> ---
>  arch/mips/kvm/mips.c       | 51 +++++++++++++++++++++++----------------
>  arch/powerpc/kvm/powerpc.c | 15 +++++++-----
>  arch/s390/kvm/kvm-s390.c   | 21 +++++++++-------
>  arch/x86/kvm/x86.c         | 24 ++++++++++++++-----
>  virt/kvm/arm/arm.c         | 60 ++++++++++++++++++++++++++++++++--------------
>  virt/kvm/kvm_main.c        | 15 +-----------
>  6 files changed, 114 insertions(+), 72 deletions(-)
> 

[...]

> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 66e5c2445a87..027a6259c3c4 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -1621,16 +1621,18 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	void __user *argp = (void __user *)arg;
>  	long r;
>  
> -	switch (ioctl) {
> -	case KVM_INTERRUPT: {
> +	if (ioctl == KVM_INTERRUPT) {
>  		struct kvm_interrupt irq;
> -		r = -EFAULT;
>  		if (copy_from_user(&irq, argp, sizeof(irq)))
> -			goto out;
> -		r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
> -		goto out;
> +			return -EFAULT;
> +		return kvm_vcpu_ioctl_interrupt(vcpu, &irq);
>  	}
>  
> +	r = vcpu_load(vcpu);
> +	if (r)
> +		return r;
> +
> +	switch (ioctl) {
>  	case KVM_ENABLE_CAP:
>  	{
>  		struct kvm_enable_cap cap;
> @@ -1670,6 +1672,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>  	}
>  
>  out:
> +	vcpu_put(r);
>  	return r;

This should obviously be
	vcpu_put(vcpu);

Fixed for v2.

Thanks,
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux