From patchwork Mon Dec 4 20:35:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10091495 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 1F00860327 for ; Mon, 4 Dec 2017 20:37:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121BB2925F for ; Mon, 4 Dec 2017 20:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07086293F9; Mon, 4 Dec 2017 20:37:14 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A06252925F for ; Mon, 4 Dec 2017 20:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752709AbdLDUhM (ORCPT ); Mon, 4 Dec 2017 15:37:12 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35286 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751436AbdLDUgB (ORCPT ); Mon, 4 Dec 2017 15:36:01 -0500 Received: by mail-wm0-f67.google.com with SMTP id f9so16711558wmh.0 for ; Mon, 04 Dec 2017 12:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=lRmaraAkFVotZnFmOkIUOPaU/TIrZ5gLINwgg3NwmyU=; b=KjaKXnoMgK4h7bteJBMPs5km1kBWT6Qo/9sjZpjtQ4bkQ3KZb8w6Pxvb5jz1FZhAeq QDvXpf0CWDV90bcjpj32cBOvku76BvR8oDlVaUn+4pbkd6gPkt2hX5sNNia+HIALCNYi HDG6ypJdc5E4ld3aSg0w6WsSpSw5bDWGviwpYKyQqJXQ1SFbxCgkmKANieINIoYpyG9y vA04f9I9PhKRJ3nDYnIEq8PN7mdenhCXIvMEA74hG4bqZMTiVbtleGzmqTaIavhYyfPj GhKWWGv5IfJofJI5jIYGO5j4uPMecUeeHuZxPekEmDZrP91if1JINUk4oa3WcRiziKEq 4I4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=lRmaraAkFVotZnFmOkIUOPaU/TIrZ5gLINwgg3NwmyU=; b=rW8O+1GoINO1gTRtjIW3J5kcynmWrRgzkntLoGw8xEw7Cco40Ru/AZE/IPmwHJ/z4o 963JInXcCfuVLOpkc0iPocrZ8XCFNM56zn5OX0+ksMuP5Q87pTPDpr2OWSM7s0nJgY7p GfGb+HyyjEVMadWW882dygDagfLlyeLdeVHG/tPgJAofDVqK4OC/upr5FZFp/+mchgu5 WyAQlJsDAr58XpJbmV8K5dOZNKy8+exglfof0PExlYZgx0aJN8XbKxedj1JYInuGZ+EC BQmN1BRcB3ck1Fhs1C0pdUgr7GNpDLAgdS+IxsM/YhwRuByxXFzb5Pv5+0zv6RHje0Y3 cAqw== X-Gm-Message-State: AJaThX4bKjOWRag+vxMpHOWzisRJI27ltss9Z8f1OiDcqwd30uoZSJpq 0sBFzvodIe19i+13x3xIWwFNbGHFCmhkKA== X-Google-Smtp-Source: AGs4zMaGwXHIMeEzf7tAtQ+e4KLPoKrAmvn3z3AcPAQ5jYr9hj7pR7kkMnWOPKHyPVwcaem5V8fBkw== X-Received: by 10.80.240.80 with SMTP id u16mr32541537edl.5.1512419759694; Mon, 04 Dec 2017 12:35:59 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id k42sm8434943edb.94.2017.12.04.12.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 12:35:59 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Cc: Andrew Jones , Christoffer Dall , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Marc Zyngier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, James Hogan , linux-mips@linux-mips.org, Paul Mackerras , kvm-ppc@vger.kernel.org, Christian Borntraeger , Cornelia Huck , linux-s390@vger.kernel.org Subject: [PATCH v3 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Date: Mon, 4 Dec 2017 21:35:30 +0100 Message-Id: <20171204203538.8370-9-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204203538.8370-1-cdall@kernel.org> References: <20171204203538.8370-1-cdall@kernel.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_mpstate(). Reviewed-by: David Hildenbrand Signed-off-by: Christoffer Dall Reviewed-by: Cornelia Huck --- arch/s390/kvm/kvm-s390.c | 11 +++++++++-- arch/x86/kvm/x86.c | 3 +++ virt/kvm/arm/arm.c | 3 +++ virt/kvm/kvm_main.c | 2 -- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index d95b4f15e52b..396fc3db6d63 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -2836,9 +2836,16 @@ 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; + + vcpu_load(vcpu); + /* 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 a31a80aee0b9..9bf62c336aa5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7440,6 +7440,8 @@ 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) { + vcpu_load(vcpu); + kvm_apic_accept_events(vcpu); if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED && vcpu->arch.pv.pv_unhalted) @@ -7447,6 +7449,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 1f448b208686..a7171701df44 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -381,11 +381,14 @@ 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) { + vcpu_load(vcpu); + 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 19cf2d11f80f..eac3c29697db 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2603,9 +2603,7 @@ static long kvm_vcpu_ioctl(struct file *filp, case KVM_GET_MP_STATE: { struct kvm_mp_state mp_state; - vcpu_load(vcpu); r = kvm_arch_vcpu_ioctl_get_mpstate(vcpu, &mp_state); - vcpu_put(vcpu); if (r) goto out; r = -EFAULT;