From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7AC4C6FD1C for ; Thu, 23 Mar 2023 22:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9XwKDK0IU5nMbgYTplEO51YjSV2hSHodKInlJJKv4H8=; b=kGcSTdfrT7BKem pCfJLc0pW1ypMOeW7OGUfH1THu2VMSeV90HQRgssbT63kOQR9eEPE9XNRjndO6fDBJyj2HhZNGwg+ zo5GKJCgSoo75CAUa1zKP4PmeCpwCXRYSIss2iJeAuFGyEa1dtKmgVCnJ2tykqQo3QPDIR9GpM7Vu hlkoxRFHz4x3xtFZn+ggfFVXWFdDmL9mW9SshkA+FMgH79cVMiN676G4tmJU3AN9/VnIETp3f76Te RT7bz/Hu7WGz/eOrTC7l5q3LYJo7Vi9nJlMVjw2WEYTZRbqAfmXO9/k3V+ul0JW2jKAySfNXax9L1 sjEj/oEbao0Wn7+ddUxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfTjl-0036xt-14; Thu, 23 Mar 2023 22:48:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfTjd-0036wd-2z for linux-arm-kernel@lists.infradead.org; Thu, 23 Mar 2023 22:48:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 632CD4B3; Thu, 23 Mar 2023 15:49:23 -0700 (PDT) Received: from [192.168.122.164] (U203867.austin.arm.com [10.118.30.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27FE63F766; Thu, 23 Mar 2023 15:48:32 -0700 (PDT) Message-ID: Date: Thu, 23 Mar 2023 17:48:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 0/4] KVM: arm64: Fix vcpu->mutex v. kvm->lock inversion Content-Language: en-US To: Oliver Upton , Marc Zyngier Cc: James Morse , Suzuki K Poulose , kvmarm@lists.linux.dev, Zenghui Yu , linux-arm-kernel@lists.infradead.org, Sean Christopherson References: <20230316211412.2651555-1-oliver.upton@linux.dev> From: Jeremy Linton In-Reply-To: <20230316211412.2651555-1-oliver.upton@linux.dev> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230323_154842_028134_CA737460 X-CRM114-Status: GOOD ( 15.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On 3/16/23 16:14, Oliver Upton wrote: > As it so happens, lock ordering in KVM/arm64 is completely backwards. > There's a significant amount of VM-wide state that needs to be accessed > from the context of a vCPU. Until now, this was accomplished by > acquiring the kvm->lock, but that cannot be nested within vcpu->mutex. > > This series fixes the issue with some fine-grained locking for MP state > and a new, dedicated mutex that can nest with both kvm->lock and > vcpu->mutex. > > Tested with kvmtool and QEMU scaled up to 64 vCPUs on a kernel w/ > lockdep enabled. Applies to kvmarm/next. This set makes the reported lockdep error go away for me, it also appears to complete some basic kernel/kvm testing without error as well. So, Tested-by: Jeremy Linton Thanks, > > v1: http://lore.kernel.org/kvmarm/20230308083947.3760066-1-oliver.upton@linux.dev > > v1 -> v2: > - Add a dedicated lock for serializing writes to MP state > - Inform lockdep of acquisition order at time of VM/vCPU creation > - Plug a race with GIC creation (Sean) > - Use the config_lock in GIC ITS flows as well. There is now a single > (valid) use of kvm->lock when enabling MTE. > > Oliver Upton (4): > KVM: arm64: Avoid vcpu->mutex v. kvm->lock inversion in CPU_ON > KVM: arm64: Avoid lock inversion when setting the VM register width > KVM: arm64: Use config_lock to protect data ordered against KVM_RUN > KVM: arm64: Use config_lock to protect vgic state > > arch/arm64/include/asm/kvm_host.h | 4 ++ > arch/arm64/kvm/arm.c | 45 +++++++++++++++++++---- > arch/arm64/kvm/guest.c | 2 + > arch/arm64/kvm/hypercalls.c | 4 +- > arch/arm64/kvm/pmu-emul.c | 23 +++--------- > arch/arm64/kvm/psci.c | 19 +++++----- > arch/arm64/kvm/reset.c | 16 ++++---- > arch/arm64/kvm/vgic/vgic-debug.c | 8 ++-- > arch/arm64/kvm/vgic/vgic-init.c | 33 ++++++++++------- > arch/arm64/kvm/vgic/vgic-its.c | 29 ++++++--------- > arch/arm64/kvm/vgic/vgic-kvm-device.c | 53 ++++++++++++--------------- > arch/arm64/kvm/vgic/vgic-mmio-v3.c | 4 +- > arch/arm64/kvm/vgic/vgic-mmio.c | 12 +++--- > arch/arm64/kvm/vgic/vgic-v4.c | 11 +++--- > arch/arm64/kvm/vgic/vgic.c | 2 +- > 15 files changed, 146 insertions(+), 119 deletions(-) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel