From patchwork Wed May 23 07:02:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10420539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D02B160327 for ; Wed, 23 May 2018 07:49:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0C0928DBA for ; Wed, 23 May 2018 07:49:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B592328EAC; Wed, 23 May 2018 07:49:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5587328DBA for ; Wed, 23 May 2018 07:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754479AbeEWHs6 (ORCPT ); Wed, 23 May 2018 03:48:58 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38459 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754501AbeEWHsZ (ORCPT ); Wed, 23 May 2018 03:48:25 -0400 Received: by mail-pf0-f193.google.com with SMTP id o76-v6so10072643pfi.5; Wed, 23 May 2018 00:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EFLZOJy1G5yhrClJTNyV3OBDskYj3PqhJZNirmxcU/o=; b=APgvwvpasbkWyKIy5bJTJXNxCzQznSwJL3WMjWYEC5tunvdlH5kpveWg76RrlgI4Vx INAGzIuBGq4iHiDD35w9RJ+MhCypIzX1YOETSG5sFZb4muIK/SON3RhSrInH9QZJCIJw Aixc9xJ6lCt1m/DOjcELIcmf6BjH24IQ9/z5LGl7cW4MIYUg8UZbW/1h2pUwiCM4/tIt L10ib7AKp3WQA/pNXRtjgZo7JOCTpFtMaxuU1gPevr/bQse8+ETPh725KxPqo+ReQycM 4EAq7wnN8gExFFJ1SkfD73Uyv6QzGVgYWUhqt99Qf3IcEUaxaWMRmkjkl/1Qolqroov+ fDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EFLZOJy1G5yhrClJTNyV3OBDskYj3PqhJZNirmxcU/o=; b=SoEUCpk0hnXU+aSIRzn7aP6tYRIlqxfjNK1FzBwGJFly95/FsULb+lZ5Ip6R3Ab3C1 sJJB5Hhrz5FKrwEZNbbK9Sd96QI1YPrh7JyXWHMhL6xFTHXNbn9jChTSuqmIypqzHevW rI2TJR/7fHiUTkxf65Wo2OT7zeWcpN0MJxFN5b6GLdk1xCnDlFZ5pWch5x8o1qJPl/6H lbtm2SdL1tkRRRbTCOZKRWIR058BuZ8AjhZB+xSJoV1t+My+Hy2fvwGgf/zvSu1dBXIT Hbd/P99z5p8kV6QLiDCBk3mj9wFnaQIyfL23N2SlXGK2cwaGKh2kj/FWw69B4OXuE1KK hFaQ== X-Gm-Message-State: ALKqPwebvDOHGok6/cH3TeNml1b8NAxxkTt5CwTPgZAoT0eW7FPUbh3x GgpIS70COPpqZPijdsCuN84= X-Google-Smtp-Source: AB8JxZqdf776X0CVXi6leBbabc3LgvQzAfRnALZ2TieFH2pyIQSJ5Bdz9smo5OZ02tSbBsYkfz4VIg== X-Received: by 2002:a62:3c10:: with SMTP id j16-v6mr1808176pfa.7.1527061705146; Wed, 23 May 2018 00:48:25 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([112.73.0.89]) by smtp.gmail.com with ESMTPSA id a4-v6sm39079171pfj.19.2018.05.23.00.48.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 May 2018 00:48:24 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org Cc: Paul Mackerras , kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Simon Guo Subject: [PATCH v4 26/29] KVM: PPC: move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl Date: Wed, 23 May 2018 15:02:09 +0800 Message-Id: <1527058932-7434-27-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527058932-7434-1-git-send-email-wei.guo.simon@gmail.com> References: <1527058932-7434-1-git-send-email-wei.guo.simon@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Guo Although we already have kvm_arch_vcpu_async_ioctl() which doesn't require ioctl to load vcpu, the sync ioctl code need to be cleaned up when CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL is not configured. This patch moves vcpu_load/vcpu_put down to each ioctl switch case so that each ioctl can decide to do vcpu_load/vcpu_put or not independently. Signed-off-by: Simon Guo --- arch/powerpc/kvm/powerpc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index 1fa5bbe..c9098ff 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1783,16 +1783,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp, void __user *argp = (void __user *)arg; long r; - vcpu_load(vcpu); - switch (ioctl) { case KVM_ENABLE_CAP: { struct kvm_enable_cap cap; r = -EFAULT; + vcpu_load(vcpu); if (copy_from_user(&cap, argp, sizeof(cap))) goto out; r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); + vcpu_put(vcpu); break; } @@ -1801,12 +1801,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp, { struct kvm_one_reg reg; r = -EFAULT; + vcpu_load(vcpu); if (copy_from_user(®, argp, sizeof(reg))) goto out; if (ioctl == KVM_SET_ONE_REG) r = kvm_vcpu_ioctl_set_one_reg(vcpu, ®); else r = kvm_vcpu_ioctl_get_one_reg(vcpu, ®); + vcpu_put(vcpu); break; } @@ -1814,9 +1816,11 @@ long kvm_arch_vcpu_ioctl(struct file *filp, case KVM_DIRTY_TLB: { struct kvm_dirty_tlb dirty; r = -EFAULT; + vcpu_load(vcpu); if (copy_from_user(&dirty, argp, sizeof(dirty))) goto out; r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty); + vcpu_put(vcpu); break; } #endif @@ -1825,7 +1829,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, } out: - vcpu_put(vcpu); return r; }