From patchwork Wed Nov 29 16:41:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10082831 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 6E90360311 for ; Wed, 29 Nov 2017 16:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56789283F9 for ; Wed, 29 Nov 2017 16:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B59028578; Wed, 29 Nov 2017 16:45:12 +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 D8CB929A3A for ; Wed, 29 Nov 2017 16:45:11 +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=ehgePnKQZhTSTEBiphZK+wWrxk6EAEXb5dbBkA+z9p4=; b=N36xhj5Nr+8a5K6a7ePWA/HDp2 RCrE4MPblg/djHpF+mojQhR1Xxo29MoqnMknqljzDtUFHa7X/DrPPPY1aMTNGqoaNOo68FFs1FUKQ hatVdq0qiG2Q84Py0GK97VBe/VY9JOk8kCkWFJuKofTxxxZ4fss0MIrytLJ2P82OGs4hNk+90+Hdj REZkIYr9nQODNH2UFPgOdQlZum82fPz1ac6nTo50oMuHjHKMb7lKRf4XU2PrpYFl0wqK9pqGfCMgf j6OXH3GfsWQj63TjQsQynoFUkkcMBchWXE9wy81qkgiokTApfqbe7fkXUyI5SJpW1sZKZ7Fv0rKz8 FlkaHZ9Q==; 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 1eK5Tw-0007ub-2Z; Wed, 29 Nov 2017 16:45:08 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK5Qp-0004Vk-B1 for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 16:42:03 +0000 Received: by mail-wr0-x243.google.com with SMTP id q9so3975218wre.7 for ; Wed, 29 Nov 2017 08:41:34 -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=CZPnP6nGssexHqRuGMm7Nw54fNn3j2sNXvS0KdU9Vuo=; b=N4lc+1TZ4IuA94W0xVQkItJ9hkWjsMe7X1qFj282paEauSldcq7uwimNtQjdrE8y9A pk9cxbHmMRTwyMeHEKe1PQlVOSDK6IcKvbMTS6KKfM0t+pt8BT2wg5tzRbH9W2YttYkr Ktepx0k5Am9tnRF0ZU06q/Uvd8j9SPQkA28SI= 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=CZPnP6nGssexHqRuGMm7Nw54fNn3j2sNXvS0KdU9Vuo=; b=N0QNHG16Gqa64apZiNbKUEjSOE1jXgb5Y2EF9sfbyzlSiRksJOAqRLd7+l20pj6vvs l688h+twd6GTJueX0GrBQGqfMpYbUgqxABUrWnPIyP4j2zpNYWrRtPqLK5EF/1EdSBP4 KttQ4suq8SrQEmO8tizdY/1KvBJvTgOsxqJmfD4H1Xh+xVqa1JZbfPd0IeXXUEStNBE9 gE6D50y16hsAqRnbezQP5KNCFjSvsjmEcL4391IT+HWN/7dW9lI8eaK+LpVQjoeAMovw lgBwz9qGeyql16m0W1nlmHgCobwLyr8I8Hw2/mex1lhcNvEkXoBbcYPuYniI3psciFW7 8MBw== X-Gm-Message-State: AJaThX4g88OuJLwSZo7kRUkagj9KuPJvReHkMFvzsrIOLj7NUOXmPQcK o/TLaa5B0yq0Kt7PDefLpuaPcQ== X-Google-Smtp-Source: AGs4zMZtutc7gal9/VY5Igy84dOd0GGM9MySY12GMSde5kHkdTZl62fPX0BE31Dd0sb0E41oxoQFkQ== X-Received: by 10.223.188.81 with SMTP id a17mr2862652wrh.146.1511973692836; Wed, 29 Nov 2017 08:41:32 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id e71sm2080765wma.13.2017.11.29.08.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 08:41:32 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v2 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate Date: Wed, 29 Nov 2017 17:41:08 +0100 Message-Id: <20171129164116.16167-9-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171129164116.16167-1-christoffer.dall@linaro.org> References: <20171129164116.16167-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171129_084155_927173_B0C65F5B X-CRM114-Status: GOOD ( 12.85 ) 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 Reviewed-by: David Hildenbrand --- 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 d95b4f1..396fc3d 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 a31a80a..9bf62c3 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 1f448b2..a717170 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 19cf2d1..eac3c29 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;