From patchwork Fri Jan 12 12:07:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10160407 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 DB6A5602D8 for ; Fri, 12 Jan 2018 12:08:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE0A728870 for ; Fri, 12 Jan 2018 12:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2F35289D0; Fri, 12 Jan 2018 12:08:25 +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 02C2F28870 for ; Fri, 12 Jan 2018 12:08:25 +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=UuQy7ER1HxcGWZrnpxI/15D/CqLD2jIn6I744uxyQsU=; b=R4qBPE/4upawmfsxa955RleFAc 4Tnu846pTiFg93pRs85+M/gq0g6n4mPNqWF6wkEtSi8D0oyrUnI5pVVCapAwjQ8+1ENOvD1qg3m9a ImXHUV5xLQ+cPevrL0O4Y5GNe1stUWPbrNSRyHDLcCwDQLdztAr7J/sXRsWbPn9Ck42Ej9gOU6jch J2kw3sr/jgiDEoc9zTjJ7a4Fn/eTrZdjybnc69189tE1doTptbl7zDAtmh8prv6bNVVrFQPTQoGX+ BfrVOL79DAD5U6wkqY4hq1MKHs1uWHKp3x23kglIKPL3Q6gY+A+PWZVofP2c/piiA5MzVICrhGwBf ciP/vQ5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZy8F-0000XS-PL; Fri, 12 Jan 2018 12:08:23 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZy7w-0008Cz-0A for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:08:05 +0000 Received: by mail-wm0-x243.google.com with SMTP id b141so11736952wme.1 for ; Fri, 12 Jan 2018 04:07:53 -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=uL8ZhLcCHIHL7h/64NA3AxQhXk+y1q/7tfPN+EHdXmM=; b=S7xf0hQLEwndx4LgE43876HNVuSLOd3aykxC++icdVYfG8zd4ETZ3wN2L0vNLyABim ZY1S2FC1MFREr/NtVGBATe0hbZGYFQk7eYMthgjGMED5at359GwA2608u5EpAF8/008w 3rTt3XTMbUynBZ9JQud1SVGtgMHU0Ngp7mzlg= 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=uL8ZhLcCHIHL7h/64NA3AxQhXk+y1q/7tfPN+EHdXmM=; b=rMTOKMcBgC4Pv/rW1cevxxCx+l1A0xwNGwOt19Yzb6F/om/Jv67BGdE1ojtm7BGgPC 44xQ8y67DcVL5TuvksbBFZesd8h9SFSI32ps4iqwK/PYWsGzACRop0VqYiqdbx2bxX/t 4GTxS34AU6/jWRj1MRbjl1ADbGl7nCeWjmsw+kmSXY2IXbEt30COxy+qmQLA49pIk+75 SsW/ES0I7Rv7a+zgvI9YXOk3xoG9SJSXn4yc2+0dHYNMLA8eJni9QESZuEB736qMRW4p nLu3joqbu0qygcFixpbvEOEHJzC2NhNXWgndOTYtWqfWjFNuXIabwiwgJSErbpGjWrJ1 VZLA== X-Gm-Message-State: AKwxyte2Z8zQX2gMvLKvJuAg1GqkGq2jzqVQA8Q95qbDiL11Utjfm0dF aB4x2AIChGn7x7Bj/e8TMMZ3OA== X-Google-Smtp-Source: ACJfBotV8gZS76Pa48E3h3XmtB2DxWBidfvkgWutbL17rklmxfZqUh744cL9nXXH3mdluujfsxT5iA== X-Received: by 10.80.243.13 with SMTP id p13mr16995074edm.186.1515758872214; Fri, 12 Jan 2018 04:07:52 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f16sm13489705edj.65.2018.01.12.04.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:07:51 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 01/41] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Date: Fri, 12 Jan 2018 13:07:07 +0100 Message-Id: <20180112120747.27999-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180112120747.27999-1-christoffer.dall@linaro.org> References: <20180112120747.27999-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_040804_088421_E84E0E44 X-CRM114-Status: GOOD ( 12.65 ) 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: Marc Zyngier , Andrew Jones , Christoffer Dall , Shih-Wei Li , kvm@vger.kernel.org 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 Reviewed-by: Julien Grall --- 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 d7e3299a7734..959e50d2588c 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 7a6ce4830cc5..5e3c149a6e28 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -383,14 +383,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; } @@ -399,8 +396,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; @@ -412,7 +407,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, ret = -EINVAL; } - vcpu_put(vcpu); return ret; } @@ -1028,8 +1022,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; @@ -1106,7 +1098,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, r = -EINVAL; } - vcpu_put(vcpu); return r; }