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 F1F14C74A5B for ; Thu, 23 Mar 2023 19:19:04 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v5dobmY/VR/Cn10f+0q74Eodbkc9aEmjbaA8+86F8Sw=; b=c7+JF1OOW4LzNP lxqGMjsocYHN4eS420z3CjQyIa+ncqm6RPHcBNH48BvWTaDl4ZQdKX7NYap+Q9r5qTYnyTcDS43et GafQUZ8XCsMgzwV9/2ARIH9+R1UfJS5FaLWdrl6kWg6WwgtN1Buw/srP4O/QJRgyI9s8llZGxZ5ZA oCTAPJqP+KbmXrkMFB/QaCYPVK/hiQGv+VPL/gFw9IGnmF30z1eJQP5zXZYX9ErNRjrKs4z43W/Zi VQFDvRlWjKAeKsv1hcfnguBs4OuqjPAXxdTe3tUVJOwIJhPA+MGfvWYetGlT2EulbnMK3pAxCzEYd LfqTyBtKulz1+NevNkPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfQS2-002oi6-2k; Thu, 23 Mar 2023 19:18:18 +0000 Received: from out-7.mta0.migadu.com ([2001:41d0:1004:224b::7]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfQRy-002oh6-0e for linux-arm-kernel@lists.infradead.org; Thu, 23 Mar 2023 19:18:17 +0000 Date: Thu, 23 Mar 2023 19:18:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1679599088; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Gq2VTw21n2omjdhvRhnFDBiQfxeSYLTO49OoqEo41EY=; b=DZJNKHS+yUGO40Mjt1t7faQDYJUOEMoi2a1+sFNNNPjV7lad0fxqOy63uTqrmCStZzGBIV HKfEf6PunGdNMVs20YxidESSVr39qJb7ZMn4fwRO2/85K1IC2Zr/Yce1n8W+Q371cI05QI CA7eZXpxvl2Ulr3XnqNtZcOocF100gQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: James Morse , Suzuki K Poulose , kvmarm@lists.linux.dev, Zenghui Yu , linux-arm-kernel@lists.infradead.org, Sean Christopherson Subject: Re: [PATCH v2 4/4] KVM: arm64: Use config_lock to protect vgic state Message-ID: References: <20230316211412.2651555-1-oliver.upton@linux.dev> <20230316211412.2651555-5-oliver.upton@linux.dev> <87o7olgfjs.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87o7olgfjs.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230323_121816_433196_52931B66 X-CRM114-Status: GOOD ( 15.04 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Mar 22, 2023 at 12:02:15PM +0000, Marc Zyngier wrote: > On Thu, 16 Mar 2023 21:14:12 +0000, > Oliver Upton wrote: [...] > > --- a/arch/arm64/kvm/vgic/vgic-its.c > > +++ b/arch/arm64/kvm/vgic/vgic-its.c > > @@ -2043,7 +2043,10 @@ static int vgic_its_attr_regs_access(struct kvm_device *dev, > > if (offset & align) > > return -EINVAL; > > > > - mutex_lock(&dev->kvm->lock); > > + if (!lock_all_vcpus(dev->kvm)) > > + return -EBUSY; > > + > > + mutex_lock(&dev->kvm->arch.config_lock); > > Huh, that's fishy. The whole "lock the VM and the lock the individual > vcpus" is there to prevent a concurrent creation of a vcpu while we're > doing stuff that affects them all. Allowing a new vcpu to come online > while this sequence is happening is ... unexpected. > > Why do we need to drop this initial lock? I'd expect them to be > completely cumulative. Urgh.. Yes, you're right. I'll go with kvm->lock -> lock_all_vcpus() -> kvm->config_lock in the next spin to guard against the vCPU creation race. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel