{"id":842657,"url":"http://patchwork.ozlabs.org/api/patches/842657/?format=json","web_url":"http://patchwork.ozlabs.org/project/kvm-ppc/patch/20171129164116.16167-16-christoffer.dall@linaro.org/","project":{"id":23,"url":"http://patchwork.ozlabs.org/api/projects/23/?format=json","name":"KVM PowerPC development","link_name":"kvm-ppc","list_id":"kvm-ppc.vger.kernel.org","list_email":"kvm-ppc@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171129164116.16167-16-christoffer.dall@linaro.org>","list_archive_url":null,"date":"2017-11-29T16:41:15","name":"[v2,15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bdd2c9a7535bacf71c71cc9282f7357d31860649","submitter":{"id":26352,"url":"http://patchwork.ozlabs.org/api/people/26352/?format=json","name":"Christoffer Dall","email":"christoffer.dall@linaro.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/kvm-ppc/patch/20171129164116.16167-16-christoffer.dall@linaro.org/mbox/","series":[{"id":15778,"url":"http://patchwork.ozlabs.org/api/series/15778/?format=json","web_url":"http://patchwork.ozlabs.org/project/kvm-ppc/list/?series=15778","date":"2017-11-29T16:41:00","name":"Move vcpu_load and vcpu_put calls to arch code","version":2,"mbox":"http://patchwork.ozlabs.org/series/15778/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/842657/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/842657/checks/","tags":{},"related":[],"headers":{"Return-Path":"<kvm-ppc-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=kvm-ppc-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"RMToeji0\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yn5sg2b2Lz9t9j\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 30 Nov 2017 03:41:59 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S933213AbdK2Ql5 (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tWed, 29 Nov 2017 11:41:57 -0500","from mail-wr0-f195.google.com ([209.85.128.195]:41076 \"EHLO\n\tmail-wr0-f195.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S933784AbdK2Qlq (ORCPT\n\t<rfc822;kvm-ppc@vger.kernel.org>); Wed, 29 Nov 2017 11:41:46 -0500","by mail-wr0-f195.google.com with SMTP id z18so3978834wrb.8\n\tfor <kvm-ppc@vger.kernel.org>; Wed, 29 Nov 2017 08:41:45 -0800 (PST)","from localhost.localdomain (x50d2404e.cust.hiper.dk.\n\t[80.210.64.78]) by smtp.gmail.com with ESMTPSA id\n\te71sm2080765wma.13.2017.11.29.08.41.43\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 29 Nov 2017 08:41:43 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=SMAMCHKSC1HcI/GbmUe7V6halIvCVXcjhvzl4oipgAs=;\n\tb=RMToeji08XwRVgbkZaS+cH6tIJWPo7MmHK4OK3EVuLjylKkQamKAoG5NasiVcOGioG\n\tI2CIq9BsF9/o15Zs2zgZl7n99F6UR5i+vCUu2muKHETwdU0PEjYd84NjEQxh/ZbfQ2JZ\n\t5UBub6+u3JSyl4u6xjBUAkIKuQPp9M/QopRKQ=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=SMAMCHKSC1HcI/GbmUe7V6halIvCVXcjhvzl4oipgAs=;\n\tb=HWhktpIjz46rP6RE/H4z1FQQ0ctPytCjWnXpwq5XecUGfygcvF7dGTL0xKQKMA8fbN\n\t/pKlmt7MvCZWFnGiC+7Phpmd61rP7nKtoKpUhc81n/AbEL8RAkkd5d1d41t1RzD4DH+8\n\tNooUyjfRJLYTqZd6KfO9GOddUg+HriFEhDz+BHMtiARJz4SEIu4Prxlo6lf7CzIkxLeB\n\tvr3F8X6yGZcla37Br1UNr5mB6Fy1TbGR1csd8jvqhtxc3iruVYkBvuUVQBBqwWLauJ7m\n\t6vSl4s2I4FtcX8Q7o0O8iwDKSIJOh9++QTPAntomEfNqSWbuinQm9l9MISgVA6lZdsnu\n\twFLQ==","X-Gm-Message-State":"AJaThX5/+8qLbNjZIk1AgRg1mVDorwcbbY+FFWs9NJJ3CJzzqg4s+RuQ\n\tcnvM2DrzIvBHxjmNCuS6ewB5zA==","X-Google-Smtp-Source":"AGs4zMYVc8nZoRG5cuuoZN1HaIpzmLYSjJUtDuN39WyFPmFdQwf2cXDAWWBIO8D4oUShK5GUlZMYEw==","X-Received":"by 10.223.190.2 with SMTP id n2mr2954077wrh.44.1511973704899;\n\tWed, 29 Nov 2017 08:41:44 -0800 (PST)","From":"Christoffer Dall <christoffer.dall@linaro.org>","To":"kvm@vger.kernel.org","Cc":"Andrew Jones <drjones@redhat.com>, Christoffer Dall\n\t<christoffer.dall@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>,\n\t=?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= <rkrcmar@redhat.com>,\n\tMarc Zyngier <marc.zyngier@arm.com>, kvmarm@lists.cs.columbia.edu,\n\tlinux-arm-kernel@lists.infradead.org, James Hogan <jhogan@kernel.org>,\n\tlinux-mips@linux-mips.org, Alexander Graf <agraf@suse.com>,\n\tkvm-ppc@vger.kernel.org, \n\tChristian Borntraeger <borntraeger@de.ibm.com>, Cornelia Huck\n\t<cohuck@redhat.com>, linux-s390@vger.kernel.org","Subject":"[PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu\n\tioctls 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>","Sender":"kvm-ppc-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<kvm-ppc.vger.kernel.org>","X-Mailing-List":"kvm-ppc@vger.kernel.org"},"content":"Calling vcpu_load() registers preempt notifiers for this vcpu and calls\nkvm_arch_vcpu_load().  The latter will soon be doing a lot of heavy\nlifting on arm/arm64 and will try to do things such as enabling the\nvirtual timer and setting us up to handle interrupts from the timer\nhardware.\n\nLoading state onto hardware registers and enabling hardware to signal\ninterrupts can be problematic when we're not actually about to run the\nVCPU, because it makes it difficult to establish the right context when\nhandling interrupts from the timer, and it makes the register access\ncode difficult to reason about.\n\nLuckily, now when we call vcpu_load in each ioctl implementation, we can\nsimply remove the call from the non-KVM_RUN vcpu ioctls, and our\nkvm_arch_vcpu_load() is only used for loading vcpu content to the\nphysical CPU when we're actually going to run the vcpu.\n\nSigned-off-by: Christoffer Dall <christoffer.dall@linaro.org>\n---\n arch/arm64/kvm/guest.c | 3 ---\n virt/kvm/arm/arm.c     | 9 ---------\n 2 files changed, 12 deletions(-)","diff":"diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c\nindex d7e3299..959e50d 100644\n--- a/arch/arm64/kvm/guest.c\n+++ b/arch/arm64/kvm/guest.c\n@@ -363,8 +363,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,\n {\n \tint ret = 0;\n \n-\tvcpu_load(vcpu);\n-\n \ttrace_kvm_set_guest_debug(vcpu, dbg->control);\n \n \tif (dbg->control & ~KVM_GUESTDBG_VALID_MASK) {\n@@ -386,7 +384,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,\n \t}\n \n out:\n-\tvcpu_put(vcpu);\n \treturn ret;\n }\n \ndiff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c\nindex 8223c59..a760ef1 100644\n--- a/virt/kvm/arm/arm.c\n+++ b/virt/kvm/arm/arm.c\n@@ -381,14 +381,11 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu)\n int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,\n \t\t\t\t    struct kvm_mp_state *mp_state)\n {\n-\tvcpu_load(vcpu);\n-\n \tif (vcpu->arch.power_off)\n \t\tmp_state->mp_state = KVM_MP_STATE_STOPPED;\n \telse\n \t\tmp_state->mp_state = KVM_MP_STATE_RUNNABLE;\n \n-\tvcpu_put(vcpu);\n \treturn 0;\n }\n \n@@ -397,8 +394,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,\n {\n \tint ret = 0;\n \n-\tvcpu_load(vcpu);\n-\n \tswitch (mp_state->mp_state) {\n \tcase KVM_MP_STATE_RUNNABLE:\n \t\tvcpu->arch.power_off = false;\n@@ -410,7 +405,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,\n \t\tret = -EINVAL;\n \t}\n \n-\tvcpu_put(vcpu);\n \treturn ret;\n }\n \n@@ -1003,8 +997,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,\n \tstruct kvm_device_attr attr;\n \tlong r;\n \n-\tvcpu_load(vcpu);\n-\n \tswitch (ioctl) {\n \tcase KVM_ARM_VCPU_INIT: {\n \t\tstruct kvm_vcpu_init init;\n@@ -1081,7 +1073,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp,\n \t\tr = -EINVAL;\n \t}\n \n-\tvcpu_put(vcpu);\n \treturn r;\n }\n \n","prefixes":["v2","15/16"]}