Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1000115rdb; Wed, 24 Jan 2024 01:27:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXdsjFBz4bBbcwhoSM7LKeq694s3f9Ils9NQxMZOP4pUi3OKs5t87OZlDVDedEosP/IWPU X-Received: by 2002:a05:6358:5245:b0:176:3770:ced1 with SMTP id c5-20020a056358524500b001763770ced1mr7363255rwa.56.1706088431264; Wed, 24 Jan 2024 01:27:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706088431; cv=pass; d=google.com; s=arc-20160816; b=V55eZlynpRYjs9kYPCnekmHn/uAlAE0st8JHBiAT6wQpR31RXxXs/jPm4GZC5ZyFMQ IRZqQnMNBiVhJ9MencsPc4Him2+YBPyFQNERJ3flRb2/RXENS8BeeyuzYlalhXITdRlJ 6rLY346Jv4TFkzb0sYE9ODmQwe7MvGtb15Znr04s2ZexKZHZCYqY4uK6UJVJnGNYqNLC aezgaMItN6H1xhb3554ch6U0Zh0KKPToXzoEnSJFM0vpTr2HL4jfzcH2vfUpUxy+vcaf bUibHZfCSBGOyaqOm98I4NL98BbkWoIcjw+BnoRSunqSCKuvEFWL6PhGv4rw14IiVQp2 q/0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SI39RK/rWNckwv2r4B917cux2i/pKiQn7x4kFloCx1A=; fh=6vtHFiII+JmHmUDiBIO85RvBKyJRiy1/HAyQxMav06s=; b=rdYeJa/wnPV76zBQAId+CgYduuGI3gr0bdZ0cZEZ9yF1ggzJJYKOvRaU4EU5l2PdMQ 8KgZpEelv67itLoO+pjlmNe7eT3t8I9jTP/UPumrgUeawVn8ybRO6kRSo0T5Y7G2hXMY viSsYE9K1VuB+zLfbEx+t7b5xhu9lZIh4bpPJpu2n+U3fiolrKIULW2P7RXUBGQ0aXKq BqAQtY2b6wXquaDpjRmatPCIoVeC6p7Za7FKJ6bkV/b5orWNTmfZWeD/J7nbSNm35ipw 94FooWYKZIGDIZ33MaPTFKqglP38vMqKIyTGlReSgdHQA11iXCZ9WoKtR5LOQs872sAf 9+FA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TUJx2hii; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-36676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36676-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 2-20020a630d42000000b005d2014b75b5si2851691pgn.618.2024.01.24.01.27.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 01:27:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=TUJx2hii; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-36676-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36676-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4B5A4B218FA for ; Wed, 24 Jan 2024 09:07:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E72FC17BC6; Wed, 24 Jan 2024 09:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TUJx2hii" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83EA317BB2 for ; Wed, 24 Jan 2024 09:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087259; cv=none; b=atNrPOysGCxeAGs6ivfkdHXLtP28q1Cr1JSguhbCd/P1q4kvE7u90FoiUXdnEISDIpO1IFm0FgxFARFWDaBFUsk7xAYEAFYNCKa3PLDHJhXv3piUfZ4a1MAKiqRJqXINbBvIkjV9EmegZL9ly04fUpE84bqxZYjx+611BXFFpKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706087259; c=relaxed/simple; bh=IXM6p4NQ5xNMIp+I08MpFl/C4xzL887zpVFg7lffNJQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UWAEIycbG7m4aRFI2O4OI+ZZe7kfiXR2cITQHWnoB8013vs6zZGd9rQHU9MbT5Z2AEYU7aHO0p8ZY/jCEARWqN9Cst+ySJcDoOJSg0mIDhGDvSqbUvUAUFWozo1t9U0MfQ1cZDbBsMtBR8HWrY65jjfqV1UBUMa7KXtEFlHonJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TUJx2hii; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40e865bccb4so37345e9.0 for ; Wed, 24 Jan 2024 01:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706087256; x=1706692056; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SI39RK/rWNckwv2r4B917cux2i/pKiQn7x4kFloCx1A=; b=TUJx2hiiFXxEQO9IQO4ITipdfTgUi18peJAvMnVsL8dIUc62kd3gjl7G2/axNg8bNj hbvQknLjtRLLBcscEGmAeRMBuNttn7tAK1jlZrYtTPtOdZP1Mxa6lputKsJ8A756gvmz GQtW+efuCYYLZbKLnU8pSQtDahsa4HOsY8nl3Lv4uJH88Aahjb69eyMF+ZfXpVlOsPUH yEP4EHMTbfVgISteoPGj8rhkK7TlZCy9pAYaYbRP6hTrxXiOhbyNpUppDNJHxo7gdK85 do662d5S31U+q/9doKBYhIgicgVzb5cA7QMZ9s9ihmLeG1V1sdtUqLKM5Aas1cxzrFZG 2VAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706087256; x=1706692056; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SI39RK/rWNckwv2r4B917cux2i/pKiQn7x4kFloCx1A=; b=hktC/D4rTeDFBJmWSA3UwApby5gRpB9xDr2qkJaauaxibjX5aq8r+EEYyS0T0qLjvp 8WQBNZsjWrtq0LeKf6DfkNLHGnQ5/uZU2bz3lsxIESVs2SCz6YUlJoRLvi8N6iBC3pA2 jL1uj0wd8cfZcZub/hF3YAakgmDChhcBQPECAf40mQ5PRnU8jwYbZd+qfkdLaJTI7BDg a15uLWx6zS0HNPgjTBdfkmOLn2p+3m/2Z2R5CXMiy16mTC94GchUYB5InxY1ok1yGKkR RJviK3S2IHKLcALN+JpaKk2jEIllLuh+dgKBIFLezgxxkWbWmTg2bPKWylHjo0TzSZHq sF+A== X-Gm-Message-State: AOJu0YzHptkyMnN05M64uSHYd89AxqKsf5j8Z2GJmh8Jq/vy3UO584Qj gihU+7pNSuP45otepGKw03s+s8oJkTqJPXsb4L+WzrjpdE4VZrZERj1CZgGnUQ== X-Received: by 2002:a05:600c:5107:b0:40e:b963:6076 with SMTP id o7-20020a05600c510700b0040eb9636076mr41367wms.5.1706087255568; Wed, 24 Jan 2024 01:07:35 -0800 (PST) Received: from google.com (185.83.140.34.bc.googleusercontent.com. [34.140.83.185]) by smtp.gmail.com with ESMTPSA id s16-20020a5d5110000000b0033763a9ea2dsm9142555wrt.63.2024.01.24.01.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 01:07:35 -0800 (PST) Date: Wed, 24 Jan 2024 09:07:33 +0000 From: Sebastian Ene To: Oliver Upton Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Fix circular locking dependency Message-ID: References: <20240123164818.1306122-2-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Jan 23, 2024 at 05:35:26PM +0000, Oliver Upton wrote: > On Tue, Jan 23, 2024 at 04:48:19PM +0000, Sebastian Ene wrote: > > The rule inside kvm enforces that the vcpu->mutex is taken *inside* > > kvm->lock. The rule is violated by the pkvm_create_hyp_vm which acquires Hi Oliver, > ^~~~~~~~~~~~~~~~~~ > > nit: always suffix function names with '()' > > > the kvm->lock while already holding the vcpu->mutex lock from > > kvm_vcpu_ioctl. Follow the rule by taking the config lock while getting the > > VM handle and make sure that this is cleaned on VM destroy under the > > same lock. > > It is always better to describe a lock in terms of what data it > protects, the critical section(s) are rather obvious here. > > Avoid the circular locking dependency altogether by protecting the hyp > vm handle with the config_lock, much like we already do for other > forms of VM-scoped data. > > > Signed-off-by: Sebastian Ene > > Cc: stable@vger.kernel.org > > nitpicks aside, this looks fine. > > Reviewed-by: Oliver Upton > Thanks for the suggestions, I updated the comit message and I will push a V2 of the patch with the above and the Reviewed-by tag. Thanks, Seb > -- > Thanks, > Oliver