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: 10091523 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 A93CC60327 for ; Mon, 4 Dec 2017 20:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B94729428 for ; Mon, 4 Dec 2017 20:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9078129441; Mon, 4 Dec 2017 20:40:52 +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 6AAC829426 for ; Mon, 4 Dec 2017 20:40:51 +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=bO4vlZ5ihPtFrvWh00U2pDeKrBzI2//oR+s/YQmhb5Y=; b=PL1IjyXl3hLUD8DLXIbD7Q2on9 UnmkeVqX3R4oVmg3jRZdYGMVeJeCAgQlwU0owbmVBjrX26Ydb63z75bhq4z2ptubIxqBxo9JxopHk LFhHK8ha5vSgpd0R4VJSXRdkOwGr0efPIqfdgsJ67jIBKKkl5DgpNLY2xQVC4vd2eoUzfqomzUFye XZGlLCslf+UqOUxLmuXPfQlJ+SDb332mrzRJyc32jZ8Jd/38kdp74zATjjgSOeiuAlKZIGzFphez1 eaeZ651xxJhYToXqGOr9ku3YhKSG07Az6793/ahftyjWYpoQ7nlSNup3fukXxOJDX9tj/CP1FjOCo M/BSfcJw==; 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 1eLxXf-0003Qj-Ao; Mon, 04 Dec 2017 20:40:43 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLxTN-0006C3-PB for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 20:36:26 +0000 Received: by mail-wm0-x244.google.com with SMTP id i11so16608913wmf.4 for ; Mon, 04 Dec 2017 12:36:01 -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=JYN5LxG1IhME4gEb8s8qe97Z1vZVEiOkokb35u7oyNmOemkIrbQPgO9rbDp9LS3+p5 09PukhRva65xSVTE8YpTNUeYiagj2jTJwv9KFbF/nKTEANaj5BRr5TW4Vc6zx+rIfXN4 luGLjFJ6KT6NsczPRxLRtmOJaX7u2QV+6XMuVA3aMCz1duoWwCjwMuoXDpPyx1F5yefj 7Hf7J2h2STLG9NfGyl5rSpN/c2oiGD9UKIG0DwQlRo/RziSf+RXne6fhc9bgtmSoMO/Q c67vfiMPwJRxNTwu9qttuNVz4jDbUJbwUODqlqvhcwzK5jhWUI6/Uc2NzvPa/fpxTchK ULdg== X-Gm-Message-State: AJaThX5px1IOtFMtKJIhVGGkQfhoG8y+IarCcCXAyRRcqBax+6pievYW KPwHCnmZzieRA0TmwpVjioIhTSj2bYBzpQ== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171204_123618_343065_6F679DE9 X-CRM114-Status: GOOD ( 12.15 ) 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 , kvm-ppc@vger.kernel.org, Paul Mackerras , Christian Borntraeger , 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 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;