From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796559579; b=GkOXIjK3JsAYIYUu6oSjuzDy2/Iix6guPuh+kYCtgjkVAk1YOkZFQIdvw6nGuptvfjVe k2/HjPS0rSjX7rAue2FhxpTdEwypbs3fMAW6y6+dmEiNTN5KXM2NlCYbvflmmGakVfzyz lVRZsesfcaljjNB3zoXTTcFb+G+lKsYjfhOhAUWDVC83L66MSCq/09rp1JDdKgNawCDHN 3r8YzwihIsHcNDRLwlIBn6dBuM29r32S6t3vRlmue6rAdDGslemV+kLxkLxMHwomE+kmg usmFC65UBim4gFML8RffRva3H1BO0XRaeDw/WU9mda+OOiQjLqQKZcBfQp+YF8uaHug== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796559579; h=Received:DKIM-Signature:X-Mailer:From:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; bh=bMLL0DCg9Y+GbBlPcooBX2rG6tGy+kE6d9hr/p6f23I=; b=yytlUCDm0lBDnYK1YenPinUkMFU9shPQ+xgbL/zl1fB+BSH3Ps4ZpX5Q0Vy5WI459/l4 ig//t+JmpuMhtN6h8odWMXBSlM7NVS/8hZIqAT2bK3FQUaa2a6PQNUhxf+AiH1fzc8dsn GcybV81j95en6bTIdbURvrbHXF+G4P6StttqA6H6M5JrjJSYISOKUwKMO86KOC0UjlCzw v5SqcAHviTXvSDf1qXmZ0L5Sa4EaB07+dhzLWgfq8qwAqLX9quFg5Ci758XRC7cUZdAHF FPQqiCm3YxmZaZQW9+R+RSht0v68P0CacltvkHo2G9cXuEXFGzDDSdWJ7rDaX0HnPyg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gpMA1w8R; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74A62606A31F; Sun, 6 Dec 2026 12:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gpMA1w8R Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCD371F00A07; Sun, 6 Dec 2026 12:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796559579; bh=bMLL0DCg9Y+GbBlPcooBX2rG6tGy+kE6d9hr/p6f23I=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=gpMA1w8R7DBPnDTKMGqNSiqKMfQOljqXav5QeVqus7POPx+Cwx6PeSBQwiSyLaIUg A6DT85PbjVREL0ivQofoB7rZ0W9EbF2DDh+H9NZUdHJxYZGiS7Zt4eivnHgDH4ud3c Eyf2j/gX7MfjNwMl280zpbjGkfeIDtTOaaq5OKLyKoxEaP0yMoFdhask4R6u69Yh/C gJFPUlEO6OxLlLztKWjhBLb1ccW0h/HqWSaipOaWo4vpNTLXa/49RiLL7J3VyAe3Rc EdfPwiPhwrssbrMFQ38Jf/5uNIYpe7qklq6jrg0OicsuCuHpLS3xiINJofb0KKyDGa FYs1K5x8Y2G5g== X-Mailer: emacs 31.1 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Jason Gunthorpe Cc: Jiri Pirko , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, david.quigley@intel.com, lukas@wunner.de, ksinyuk@kernel.org, rodrigo.vivi@intel.com, cedric.xing@intel.com, sameo@meta.com, drdeeglaze@gmail.com, James.Bottomley@hansenpartnership.com, aik@amd.com, jpiotrowski@nvidia.com, qinkun@google.com, pgonda@google.com, jic23@kernel.org, alistair.francis@wdc.com, ankita@nvidia.com, suzuki.poulose@arm.com, kas@kernel.org, rick.p.edgecombe@intel.com, elena.reshetova@intel.com, dave.hansen@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, peter.fang@intel.com, jarkko@kernel.org, zohar@linux.ibm.com, yeoreum.yun@arm.com, dave.jiang@intel.com, nik.borisov@suse.com, sergii.dmytruk@3mdeb.com Subject: Re: [PATCH RFC v2 3/9] attestation: Prepare provider and instance core In-Reply-To: <20261204172102.GJ1074888@ziepe.ca> References: <20261113160838.2512652-1-jiri@resnulli.us> <20261113160838.2512652-4-jiri@resnulli.us> <20261204172102.GJ1074888@ziepe.ca> Date: Sun, 06 Dec 2026 17:49:25 +0530 Message-ID: X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain Jason Gunthorpe writes: > On Fri, Dec 04, 2026 at 01:27:41PM +0530, Aneesh Kumar K.V wrote: >> Could we also avoid taking ctlv->registration_lock in ctlv_device_add() >> and ctlv_publish()? TSM drivers may call attestation_register() while >> holding their own locks. For CCA, registration holds pci_tsm_rwsem, so >> taking registration_lock here introduces this dependency: >> >> pci_tsm_rwsem -> ctlv->registration_lock >> >> CTLV operations hold registration_lock while invoking callbacks, and >> those callbacks may need to acquire pci_tsm_rwsem, creating the reverse >> dependency. >> >> I think we should preserve this lock ordering: >> >> ctlv->registration_lock -> pci_tsm_rwsem >> >> and avoid taking registration_lock during ctlv_publish() and >> ctlv_device_add(). > > That doesn't seem like tsm is using its locks right. Lets not create > another rtnl_lock :\ > I have been reworking the TSM locking. The simplified scheme removes pci_tsm_rwsem and separates association lookup from operation state: - pci_dev::tsm_lock protects lookup/replacement of pci_dev::tsm and taking an association reference. - pci_tsm::lock is a per-association mutex protecting connection and session state, including disconnecting and the usage counts. - arm_rmm_pdev::lock protects the firmware PDEV state and shared communication buffers. Connect still holds pci_tsm::lock while running the backend connect callback and registering attestation. This serializes connect against disconnect and operations on the newly installed association. Attestation registration calls attestation_register(), which in turn calls ctlv_device_add() and ctlv_publish(). Later, SPDM start, evidence acceptance, and end run with ctlv::registration_lock held for read. For the CCA host, these take: ctlv::registration_lock (read) -> attestation_dev::lock -> pci_tsm::lock -> arm_rmm_pdev::lock pci_tsm::lock is needed here to serialize session transitions against disconnect. In particular, start must check the connection state and take a connection_users reference under that mutex. Taking registration_lock during registration would still reverse the lock order above: pci_tsm::lock -> ctlv::registration_lock -aneesh