From patchwork Wed Nov 29 16:41:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10082839 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 AC06860311 for ; Wed, 29 Nov 2017 16:46:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 404E129B41 for ; Wed, 29 Nov 2017 16:46:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351EF29B57; Wed, 29 Nov 2017 16:46:40 +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 A796429B41 for ; Wed, 29 Nov 2017 16:46:39 +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=a0wrmhzAQH68TBkhLNXIebCfJ8oYJSfKDJuO7854TaQ=; b=CeZiZlKETtQT4e7jXSWj9+85py AME1yQPIbtUeq00kveR8ON9lS9eKZuGahiqBFL783yKQ6cjm8OQHVz+pVnJ6YKiB7SShAYAiy7fer Zao9SgfxCjs4hlF+ZL+Slq1vhPGcLHkw097d+HfweYHDgxYgYp2nFzwSSMKhXmK9RPapG2PigmbPt jlKa75LZFdfHNLtY98W+KFOTQCaaa1MXjp+OrZ7vhWax+XpJNTDPka7qN/SutexhFoPJQwE/2JzTa 3Ziq0CJDAb9dAwOygVj7JkH8nKU3VXdw7C25855htJqO4F8Br2GYpwJFAIzJlFaMCTVCUs3Xw+XRb Hs7tJDCg==; 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 1eK5VN-0002Pi-LT; Wed, 29 Nov 2017 16:46:37 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eK5R0-0004gp-At for linux-arm-kernel@lists.infradead.org; Wed, 29 Nov 2017 16:42:15 +0000 Received: by mail-wr0-x242.google.com with SMTP id q9so3975857wre.7 for ; Wed, 29 Nov 2017 08:41:46 -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=SMAMCHKSC1HcI/GbmUe7V6halIvCVXcjhvzl4oipgAs=; b=RMToeji08XwRVgbkZaS+cH6tIJWPo7MmHK4OK3EVuLjylKkQamKAoG5NasiVcOGioG I2CIq9BsF9/o15Zs2zgZl7n99F6UR5i+vCUu2muKHETwdU0PEjYd84NjEQxh/ZbfQ2JZ 5UBub6+u3JSyl4u6xjBUAkIKuQPp9M/QopRKQ= 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=SMAMCHKSC1HcI/GbmUe7V6halIvCVXcjhvzl4oipgAs=; b=BayZsu0dKKZOlRW7AZL1+ghrh5nOpMzDet33Yl44OJrgVzRwQUGi15PHsKFA0Cwlgy IPLX6V3r1SOw/EY+odYViApaU/50hkR4d6RfGmtJjagheP1bP57kdGn5MSNQ38J4px+A BuwmodNy7Fr3K6UxS2Ong7wX2kXItiBplaDOIREh0TeqTC/H3eeqmrB+rdilYKQIBS4W +o5HHTvIdJtEKRrnmOwRru4F90YkxkdwOMp8CDmNUWZenoD7qupR6lWzU5G5sE5gy0Eo KXc2TqmQYICNc1D4cUosi7FfxGXtuPfbl5KQkhQdfXpcitnHU/Z+YCK/lDMi9iZIxCT3 Uv7g== X-Gm-Message-State: AJaThX47ofIJS5HmrKUm/1nN4SdjGbu7sUrR7ql+GP89HkAqvcYgf75M /Pk2pmEgB9hgOWitBHmzo7xrkQ== X-Google-Smtp-Source: AGs4zMYVc8nZoRG5cuuoZN1HaIpzmLYSjJUtDuN39WyFPmFdQwf2cXDAWWBIO8D4oUShK5GUlZMYEw== X-Received: by 10.223.190.2 with SMTP id n2mr2954077wrh.44.1511973704899; Wed, 29 Nov 2017 08:41:44 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Nov 2017 08:41:43 -0800 (PST) From: Christoffer Dall To: kvm@vger.kernel.org Subject: [PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Date: Wed, 29 Nov 2017 17:41:15 +0100 Message-Id: <20171129164116.16167-16-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_084206_747475_E5F4BBBE X-CRM114-Status: GOOD ( 13.38 ) 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 Calling vcpu_load() registers preempt notifiers for this vcpu and calls kvm_arch_vcpu_load(). The latter will soon be doing a lot of heavy lifting on arm/arm64 and will try to do things such as enabling the virtual timer and setting us up to handle interrupts from the timer hardware. Loading state onto hardware registers and enabling hardware to signal interrupts can be problematic when we're not actually about to run the VCPU, because it makes it difficult to establish the right context when handling interrupts from the timer, and it makes the register access code difficult to reason about. Luckily, now when we call vcpu_load in each ioctl implementation, we can simply remove the call from the non-KVM_RUN vcpu ioctls, and our kvm_arch_vcpu_load() is only used for loading vcpu content to the physical CPU when we're actually going to run the vcpu. Signed-off-by: Christoffer Dall --- arch/arm64/kvm/guest.c | 3 --- virt/kvm/arm/arm.c | 9 --------- 2 files changed, 12 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index d7e3299..959e50d 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -363,8 +363,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, { int ret = 0; - vcpu_load(vcpu); - trace_kvm_set_guest_debug(vcpu, dbg->control); if (dbg->control & ~KVM_GUESTDBG_VALID_MASK) { @@ -386,7 +384,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, } out: - vcpu_put(vcpu); return ret; } diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 8223c59..a760ef1 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -381,14 +381,11 @@ 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; } @@ -397,8 +394,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, { int ret = 0; - vcpu_load(vcpu); - switch (mp_state->mp_state) { case KVM_MP_STATE_RUNNABLE: vcpu->arch.power_off = false; @@ -410,7 +405,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, ret = -EINVAL; } - vcpu_put(vcpu); return ret; } @@ -1003,8 +997,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, struct kvm_device_attr attr; long r; - vcpu_load(vcpu); - switch (ioctl) { case KVM_ARM_VCPU_INIT: { struct kvm_vcpu_init init; @@ -1081,7 +1073,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, r = -EINVAL; } - vcpu_put(vcpu); return r; }