From patchwork Fri Jun 15 15:47:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10466823 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 593F5600F4 for ; Fri, 15 Jun 2018 15:50:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4351126247 for ; Fri, 15 Jun 2018 15:50:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3730228E02; Fri, 15 Jun 2018 15:50:39 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 C5F3B26247 for ; Fri, 15 Jun 2018 15:50:38 +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=2OaMzp+2ZhmRBblvpwx1uCav59dv3SGCYwL75t8C5pY=; b=W6Q3KuIa5cIuugtsg1L/yixGNK TRpAU4F49BSE07J4W/mQNgf2OhJGZFe0+JF1KRSZoPHwLFh7HpVu2jZ91K+TlzWgY+bnuyS6pATYV FcgLylC87Nk9PUczXDXgDrlY25e20yARORlkTt/pFWy7xIgFxTgQAX+3Z/yFz7dqfi5Sh45TO1KP9 2U41M8fIRLcn7tDkqIKU2ybUE09C+0i0qDOe0XnEGnvn6vpqipFZFwR6GGS8sdQHU9WtRGyEJIGz9 CBVaaLS28WuiDrfRQj/YvV6cNN2NoKD0IUbh38nhx7pviSmfmvbbpr/omCbAtOunhvbMFUbSXB7hx JYOtAeRQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTqzc-0001QF-0z; Fri, 15 Jun 2018 15:50:28 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTqxr-00083J-Jx for linux-arm-kernel@bombadil.infradead.org; Fri, 15 Jun 2018 15:48:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yBx6MwXvaYNqBjPeivo/YxfdPu1iJy32Jx2IdqufCKE=; b=bCamCBOJmSmLWoKUrfk0baZyY 30n1K+Ish1QnmxPQcxIpD7UCaU37rKzwBRULbBfGDJ4tf9SuINlXxQi5rcimrskN5QFhwtFwPB3nb 3HaufMgMP+wLQdzXWjCjNJ3Awr/+G4PpQgZYx+kv+IcBmnvxBURNSKvMNa8jL3pAPjXnH11468w96 61ixQbujGr7oD8EhTrKJsrqNuJDRI1Un2sHKxP9n0721UvGSnAyDG0pxdhrUWxGRs+JwPoWUvdOtV nUKlH+gwxjULrTMTkMANUylB9aoWsX+sorZigNW515CyTek8nONCTGaa25xMpC1sj0HnXEBUBkSMv iUsbZMWJA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTqxo-00063w-8H for linux-arm-kernel@lists.infradead.org; Fri, 15 Jun 2018 15:48:37 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 778E61596; Fri, 15 Jun 2018 08:48:22 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 21DC93F557; Fri, 15 Jun 2018 08:48:20 -0700 (PDT) From: Dave Martin To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 2/4] KVM: arm64: Don't mask softirq with IRQs disabled in vcpu_put() Date: Fri, 15 Jun 2018 16:47:24 +0100 Message-Id: <1529077646-2848-3-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1529077646-2848-1-git-send-email-Dave.Martin@arm.com> References: <1529077646-2848-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180615_114836_409646_60D7053D X-CRM114-Status: GOOD ( 14.09 ) 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: Christoffer Dall , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon , Andre Przywara , linux-arm-kernel@lists.infradead.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 Commit e6b673b ("KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing") introduces a specific helper kvm_arch_vcpu_put_fp() for saving the vcpu FPSIMD state during vcpu_put(). This function uses local_bh_disable()/_enable() to protect the FPSIMD context manipulation from interruption by softirqs. This approach is not correct, because vcpu_put() can be invoked either from the KVM host vcpu thread (when exiting the vcpu run loop), or via a preempt notifier. In the former case, only preemption is disabled. In the latter case, the function is called from inside __schedule(), which means that IRQs are disabled. Use of local_bh_disable()/_enable() with IRQs disabled is considerd an error, resulting in lockdep splats while running VMs if lockdep is enabled. This patch disables IRQs instead of attempting to disable softirqs, avoiding the problem of calling local_bh_enable() with IRQs disabled in the __schedule() path. This creates an additional interrupt blackout during vcpu run loop exit, but this is the rare case and the blackout latency is still less than that of __schedule(). Fixes: e6b673b741ea ("KVM: arm64: Optimise FPSIMD handling to reduce guest/host thrashing") Reported-by: Andre Przywara Signed-off-by: Dave Martin --- Changes since v1: Requested by Marc Zyngier: * Disable IRQs unconditionally instead of attempting to conditionally disable softirqs. This creates an additional interrupt blackout during vcpu run loop exit. This is the rare case, and the blackout latency is still less than that of __schedule(). --- arch/arm64/kvm/fpsimd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index dc6ecfa..f9d0931 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -5,7 +5,7 @@ * Copyright 2018 Arm Limited * Author: Dave Martin */ -#include +#include #include #include #include @@ -92,7 +92,9 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu) */ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu) { - local_bh_disable(); + unsigned long flags; + + local_irq_save(flags); update_thread_flag(TIF_SVE, vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE); @@ -106,5 +108,5 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu) fpsimd_bind_task_to_cpu(); } - local_bh_enable(); + local_irq_restore(flags); }