From patchwork Sat Nov 25 20:57:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10075167 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 6179D60383 for ; Sat, 25 Nov 2017 21:00:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5121228F53 for ; Sat, 25 Nov 2017 21:00:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4343728F69; Sat, 25 Nov 2017 21:00:32 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C2CA128F53 for ; Sat, 25 Nov 2017 21:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=b408rqFeQwqCOrzYTxoMRKiJmLq49DkZDXj9cSPb+Bo=; b=KpWt6h5fuPeqMB2SoNeQjGXd1F 1hu7sMI+cHw0WDqMLyDiZKKiIXgQizivDfT148mNK+WzHuC4kveLr7aqpKqZFQtQA/Bgv45NPBye7 ZrhxrRaL7sRJZGGdKTdAEo6xHdjvP5ly4JK7ZuA1Fcpkb+GYeKuCDt3faut+0C2IaQRd2m9fwoSAh arFU7hcu+Uu3f4YtIpl2iofPAh+3qGJyV0kTu9B/OV1187jEn/wZ/hluQx2OtbAKn4mEKZqaC6NoM JiCeE7qUn/kexIkM93L9csLzO3W/QaUeMYsGT4fNu7BEMOAJBA8liho2lvGYtxQIassTx4mJ43LF3 0DI5lg4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eIhYt-0000Lu-3c; Sat, 25 Nov 2017 21:00:31 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eIhWB-00059f-Dq for linux-arm-kernel@lists.infradead.org; Sat, 25 Nov 2017 20:57:55 +0000 Received: by mail-wr0-x241.google.com with SMTP id y42so23043728wrd.3 for ; Sat, 25 Nov 2017 12:57:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6IFBzjgEr22DUAF1SgjokiML2Oq/bb3KXNMGvCdaxVA=; b=c/1nKChPnRPfGwaH/OhQWxQQaY1TL6rwrhvobEwSSfy7ey2PN4Kml3r32Wk83AuMDu ybiwa2WOWMBHJltG7EatXFPYIlSS+9a0OGqY2w2M/+K1r2Gj22HmW0WAbfiVD52xfRj1 8tZvov9WvcA4eKhE+iG6jpzCmyYSPnFQveaeI= 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=6IFBzjgEr22DUAF1SgjokiML2Oq/bb3KXNMGvCdaxVA=; b=EUdCFYytKGWWvEW4aSM3l0OiTbgSH/r3DiNk77Ao2HCjaUnoYVgOIzEO+sRYKeVagE O14/uWhua7ZPRE05Iy5O2kXorRT1QaPxITXEN7lddoVe+kJlJ3SoCog03pIZyiAtCeFU Ty3Vle0GjIxfq09a/ENOc6cXE+sIskohKL61zYG4HKQeSgaGwbzyXIFBv6aG4DOt3/xy rhaaRGHUzpTMsWT/X/hBvZt8wLz4RTFZ36g0soFFxj3hn6nNWzwZCKAoNuDzOy4rOv22 l7/JQEF2O2x/DCnHp0KK+hvfNAAJOSgj0sTW96R9zBtO9/hZ22O5mHCD5lG4kPLm0guM 30FQ== X-Gm-Message-State: AJaThX7/iaLkKguua475FjajYRBgNJAZNznSfEWkmjIsbdyt+oZ2DCSJ uNS7Xlp1+r/zc+kZkcAhyLnSug== X-Google-Smtp-Source: AGs4zMbbWO1URsTuHDQ0XIoN07qbqUsnsunu6cpxJfR9gqQ18lBKx3Ezk0fBxRvSbkBxQvnpv+meGQ== X-Received: by 10.223.151.49 with SMTP id r46mr30309902wrb.238.1511643445218; Sat, 25 Nov 2017 12:57:25 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id z37sm15157577wrc.31.2017.11.25.12.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Nov 2017 12:57:24 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH 08/15] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Date: Sat, 25 Nov 2017 21:57:11 +0100 Message-Id: <20171125205718.7731-9-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171125205718.7731-1-christoffer.dall@linaro.org> References: <20171125205718.7731-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171125_125744_181219_8C16C5E4 X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Andrew Jones , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , James Hogan , Cornelia Huck , Christian Borntraeger , kvm-ppc@vger.kernel.org, Alexander Graf , linux-arm-kernel@lists.infradead.org, Paolo Bonzini , linux-s390@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_mpstate(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 13 +++++++++++-- arch/x86/kvm/x86.c | 7 +++++++ virt/kvm/arm/arm.c | 7 +++++++ virt/kvm/kvm_main.c | 4 ---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 51569cc97a07..ccaf5088b73e 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2853,9 +2853,18 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, struct kvm_mp_state *mp_state) { + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + /* CHECK_STOP and LOAD are not supported yet */ - return is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED : - KVM_MP_STATE_OPERATING; + ret = is_vcpu_stopped(vcpu) ? KVM_MP_STATE_STOPPED : + KVM_MP_STATE_OPERATING; + + vcpu_put(vcpu); + return ret; } int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1a701a2f25a3..71f0572a4e4a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7426,6 +7426,12 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, struct kvm_mp_state *mp_state) { + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + kvm_apic_accept_events(vcpu); if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED && vcpu->arch.pv.pv_unhalted) @@ -7433,6 +7439,7 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, else mp_state->mp_state = vcpu->arch.mp_state; + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 54d9aa533df9..4f36e6dd4d5e 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -381,11 +381,18 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, struct kvm_mp_state *mp_state) { + int ret; + + ret = vcpu_load(vcpu); + if (ret) + return ret; + if (vcpu->arch.power_off) mp_state->mp_state = KVM_MP_STATE_STOPPED; else mp_state->mp_state = KVM_MP_STATE_RUNNABLE; + vcpu_put(vcpu); return 0; } diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index f68f45e64967..8b7c821e0244 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2611,11 +2611,7 @@ static long kvm_vcpu_ioctl(struct file *filp, case KVM_GET_MP_STATE: { struct kvm_mp_state mp_state; - r = vcpu_load(vcpu); - if (r) - goto out; r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;