From patchwork Tue Feb 27 17:52:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: simon X-Patchwork-Id: 10245931 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 729ED60362 for ; Tue, 27 Feb 2018 18:02:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 633A728A44 for ; Tue, 27 Feb 2018 18:02:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5816428A47; Tue, 27 Feb 2018 18:02:05 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 EC06428A44 for ; Tue, 27 Feb 2018 18:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751856AbeB0SCC (ORCPT ); Tue, 27 Feb 2018 13:02:02 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:45914 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbeB0SBm (ORCPT ); Tue, 27 Feb 2018 13:01:42 -0500 Received: by mail-pl0-f66.google.com with SMTP id v9-v6so9828547plp.12; Tue, 27 Feb 2018 10:01:42 -0800 (PST) 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=nZQ8blA5IjL26Hg0aI9D7Rwq9a8csgTQLqqC2kfFuSY=; b=ZOf4oyaKxlM56iuoxyK0U3G5nJefz6hxqfGqpF0/2HaKvtrkwXmF05bZu6KNZE/U7+ vRBKX6aqF0nfRfpwqf2Gq6aRYNzaLZNqbtOywc6cnr5Ibkirqku5bVwr/bKr1QMUG0uU TnKYD3oB8OnoT6dsv8luXrHTgOE6Q4qwcWrs59F5GuXRROdh/AfzAx+E+bDNOVbth6f/ VgO9ZKAV/U+f1v/x00GTchtMLAkP7mmeoAPvUossrILeWTNkrxiivrd4EWN4MuUzieU2 UcUBpqSojMWDQ9UgsnGuN9CBfP5ZUtkPo2qom79WHV/cUrIGIgquZmsKbeh8Sq0q3lBl lRdQ== 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=nZQ8blA5IjL26Hg0aI9D7Rwq9a8csgTQLqqC2kfFuSY=; b=gj9Y6auhpWginEyRmpRpQQyHtrvmr7AlsKdJlOapkQV3X674eGUcsIo1iy29EmBavr tBn7KPONfMmIw/EbDqQUtdfO3Zk+FSDEPAwuKvc3gRRjd/rKPw1dSd81mLhISTtQyioG 7nAqdUIlBm0uNK9AX4r9+3A6+ww6dozbjRjc74zdEZx8owYR80OVCfxfVe2I/V7C5uSv XCDjSu/1iRg7ldnFOZEo8ZcsC9NZmfokzqAcwpKyULkzI4snvYHu4u+hon3iEnG0+Blr Alu5bfZaNshFJySn4E0fKsmuQzOcTohBff0IMGRXPHQaAdhN/aA1a4a/yWS5p+3t4pyg Zr9g== X-Gm-Message-State: APf1xPAbEq7z08ToYgu/J5MPaHixn+Ox0QP9NvTcWRhw4X3yTxhFiUXt lgUWcAU5VvwDsGKfBq7tR50= X-Google-Smtp-Source: AG47ELurLxj6J+QNPvmTY2pkHFVqoXd1W9D2x5Yd1X/ykREtRnQBK8sdDdzjp5OsAuQ97Bu7PwiRmw== X-Received: by 2002:a17:902:407:: with SMTP id 7-v6mr2274420ple.9.1519754501961; Tue, 27 Feb 2018 10:01:41 -0800 (PST) Received: from simonLocalRHEL7.x64 ([101.80.181.226]) by smtp.gmail.com with ESMTPSA id m83sm24360910pfk.107.2018.02.27.10.01.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 10:01:41 -0800 (PST) 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 v2 26/30] KVM: PPC: move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl Date: Wed, 28 Feb 2018 01:52:34 +0800 Message-Id: <1519753958-11756-16-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1519753958-11756-1-git-send-email-wei.guo.simon@gmail.com> References: <1519753958-11756-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 2d10314..cf3effd 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c @@ -1629,16 +1629,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; } @@ -1647,12 +1647,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; } @@ -1660,9 +1662,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 @@ -1671,7 +1675,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, } out: - vcpu_put(vcpu); return r; }