From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE9D9606A31C for ; Mon, 30 Nov 2026 18:35:52 +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=ejc2p3C0 Received: by kanga.kvack.org (Postfix) id EA7576B05BB; Mon, 30 Nov 2026 13:35:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E583C6B05BC; Mon, 30 Nov 2026 13:35:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D95F76B05BD; Mon, 30 Nov 2026 13:35:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A9A886B05BB for ; Mon, 30 Nov 2026 13:35:46 -0500 (EST) Received: from smtpin05.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1F28FA89AE for ; Mon, 30 Nov 2026 18:35:46 +0000 (UTC) X-FDA: 85492639092.05.526B81E Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf02.hostedemail.com (Postfix) with ESMTP id 6416880009 for ; Mon, 30 Nov 2026 18:35:44 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ejc2p3C0; spf=pass (imf02.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796063744; b=AgQnYsxjsIF6jcZF61Mvw4vLZcwLHuH7p06B/cekIgyAeFtQOjXfAtnVQEulop182zerQi fjBy41IFcDt/d/qF/UijorlCQENOVvhVMr1VKLVFqDPFHc/lVtJmT22icfWaPA0PgbIz8V 4j1axtn+PqwF1LfZj8db1SUIv0MeOTw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796063744; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dQsqpbLsQx6ENgZffhpLNm+QUY3b9eT28LnvWJV3sf4=; b=PGBXRwyy2FQ5jDdGyLgzH2xqoSyc0tonQWiIfzhF4wWezjFl/srwue2potxahF46EdVg4F bfposQ6dvY0S8yiG1fsxNC4HpFDE2R4hdjkI0jo1fIU0Yqb3sb+x5xhpJUVETdlwRptKgM gCJrIDKoThBpdoWoJ/zmgV4Jj7/QS40= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=ejc2p3C0; spf=pass (imf02.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C2A83405D2; Mon, 30 Nov 2026 18:35:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A5BB1F000C1; Mon, 30 Nov 2026 18:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796063742; bh=dQsqpbLsQx6ENgZffhpLNm+QUY3b9eT28LnvWJV3sf4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ejc2p3C0rFE+fysq6SrLs5oBtQp5ikbmYvOjqWCT+1zL22o5KDqim6XfE4+rhjteb rS4uP63vVlEeBrI5XKglJSRQjNIxNuisgk4eS1MeoFIIHnJh4AEwbiKmiVELX0DQ1o lxDD0HO47CjuhhMVK+skv1P+PZu2jCIPLxQyrGkfrRtvn+JrTd301N5gM3uBelqE/5 bhrTtTq+bdNn7MqN5h6QD/VI589BNiLjQvc+JJQ2EVh52ph5w0eXIyEPan4K0sWoHh 9/6sy5DcfjZI14olKoOLpKjMoOD+VR5oIW689Dh8sCGyXC6cOF3UaNlcUlO1nw7rYt 9CnQQYrGOplng== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 06/23] nitro_enclaves: Retry a command the device asks us to retry Reply-To: sashiko-reviews@lists.linux.dev To: "Alexander Graf" , "Greg Kroah-Hartman" , "Arnd Bergmann" Cc: "The AWS Nitro Enclaves Team" , "Paolo Bonzini" , "Stefano Garzarella" , "Stefan Hajnoczi" , "Marek Szyprowski" , "Robin Murphy" , "Andrew Morton" , "David Hildenbrand" , "Mike Rapoport" , "Jonathan Corbet" , "Shuah Khan" , "Randy Dunlap" , diapop@amazon.com, mancio@amazon.com, mknaust@amazon.com, nh-open-source@amazon.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, linux-mm@kvack.org, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <912dd2023d5151105ccf4629dc7150b28faf166d.1795965038.git.graf@amazon.com> References: <912dd2023d5151105ccf4629dc7150b28faf166d.1795965038.git.graf@amazon.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 18:35:41 +0000 X-Rspam-User: X-Rspamd-Queue-Id: 6416880009 X-Stat-Signature: 1un77n4tysmcwquu4zh91ps4is7bddty X-Rspamd-Server: rspam12 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SP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D7s46+leWOMwbBg+YTeD+8wQy9BMGGhD0bO2ngUQ9FjJFpbEcUkypNcozYWgWspVo8fSl95EW9eRwm3mcC4vYQNdJJp4Je3MdItrZ6L8sAt2HikKvL7xRmh7jBZj5RayxXz9YqLvx4qUPZw/D8yniWg1IuHfsAOxpZUVKkgrA4CyIZR65jWbegKhEzWXK3wbu4T5hBhnh7swDIONGL5klNWZ15EEb7mReICepi8IFnkbmVksBz1nVwwc/iiaxquadkAAHCumABT6PVwDRzA6MPEVlsNlPJ9BpQPRlEKmBhQNqvYjS5nBPzZcncOyBwzgiFpSl0Ln04TPZAHofB3CKFK9liVwmB6CWi4CEmFkbPgof+rTH990Xhm6H/hMFKnGT5iIytaa/ZdlNVvhDVfUYJ3HGL4s1JN4pFzbKxjArQ5w7wrP70HX0ey1O+hUKA2SzXt7QqpOFKt7MshHxwaY/YCYNrz8SW8m7+2YZKEyTD2P8M3vgJgiMmuPG/FpbW3kVbaqPoV8VDJymzPpwYAPxT5HhLF9ql8I22F8uloNnjmY/GqVEuFdzhzHgBChyitz0XXv5WMGJ9scoewZLhzyHARPql8zK76uXfDHF24xpwJQ+7a6r1nM8hZloqwX663vfnEMoXw4/KFd5voHx9jmgGZ1gkLJIe2OmCK1jnrBW2eR75/ZZjhZxTx+PulSyQCd6qxZvIwmdeQM0pOkpPCPb1scojxlbZWMCNtW8LjjDiLhUiuVMGyfMUxS/fyGC3OeaScyZVUcJNO62BY08AldOG4f+c8+ixhrioLAaI0cAG+UzShcDK2wzuoGf7WV0DwW1TRZqdc= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] nitro_enclaves: enclaves_list_mutex held across retry in ne_enclave_release() -- commit 6fed9d92931fd77de6660031a8280950cb317c53 Author: Alexander Graf nitro_enclaves: Retry a command the device asks us to retry This commit adds retry handling with exponential backoff in ne_do_request() when the Nitro Enclaves PCI device replies with -EAGAIN, and converts enclave and list mutex acquisitions in the ioctl and event work paths to mutex_lock_killable(). > diff --git a/drivers/virt/nitro_enclaves/ne_pci_dev.c b/drivers/virt/nitr= o_enclaves/ne_pci_dev.c > index c37777bb95b49..199c3c7f8c42e 100644 > --- a/drivers/virt/nitro_enclaves/ne_pci_dev.c > +++ b/drivers/virt/nitro_enclaves/ne_pci_dev.c [ ... ] > @@ -159,6 +209,27 @@ int ne_do_request(struct pci_dev *pdev, enum ne_pci_= dev_cmd_type cmd_type, > =20 > atomic_set(&ne_pci_dev->cmd_reply_avail, 0); > =20 > + if (cmd_reply->rc =3D=3D -EAGAIN) { > + /* > + * The device answered, so nothing is in flight and another > + * command may go out while this one waits to be sent again. > + */ > + mutex_unlock(&ne_pci_dev->pci_dev_mutex); > + > + if (!deadline) { > + unsigned int budget_msecs =3D ne_cmd_frees_slot(cmd_type) ? > + NE_FREE_TIMEOUT_MSECS : > + NE_CMD_RETRY_TOTAL_MSECS; > + > + deadline =3D jiffies + msecs_to_jiffies(budget_msecs); > + } > + > + msleep(delay_msecs); > + delay_msecs =3D min(delay_msecs * 2, NE_CMD_RETRY_MAX_MSECS); > + > + goto retry; > + } > + > if (cmd_reply->rc < 0) { > rc =3D cmd_reply->rc; > =20 > @@ -221,7 +292,14 @@ static void ne_event_work_handler(struct work_struct= *work) > int rc =3D -EINVAL; > struct slot_info_req slot_info_req =3D {}; > =20 > - mutex_lock(&ne_pci_dev->enclaves_list_mutex); > + /* > + * A release holds these locks for as long as the device takes to free > + * the slot, which can be minutes, so wait killable: that is not > + * reported as a hung task. The worker gets no signal, so the locks do > + * not fail. > + */ > + if (mutex_lock_killable(&ne_pci_dev->enclaves_list_mutex)) > + return; > =20 > /* > * Iterate over all enclaves registered for the Nitro Enclaves > @@ -229,7 +307,8 @@ static void ne_event_work_handler(struct work_struct = *work) > * is corresponding to. > */ > list_for_each_entry(ne_enclave, &ne_pci_dev->enclaves_list, enclave_lis= t_entry) { > - mutex_lock(&ne_enclave->enclave_info_mutex); > + if (mutex_lock_killable(&ne_enclave->enclave_info_mutex)) > + break; [Severity: Medium] Does holding ne_pci_dev->enclaves_list_mutex across ne_enclave_free_slot() in ne_enclave_release() block out-of-band event delivery for all other running enclaves and still trigger hung-task warnings during a slow slot release? drivers/virt/nitro_enclaves/ne_misc_dev.c:ne_enclave_release() { ... mutex_lock(&ne_pci_dev->enclaves_list_mutex); mutex_lock(&ne_enclave->enclave_info_mutex); /* * A slot the device did not free may still run on the memory and the * CPUs of the enclave, so the enclave keeps them. */ rc =3D ne_enclave_free_slot(ne_pci_dev, ne_enclave); if (!rc) ne_pci_dev_remove_enclave_entry(ne_enclave, ne_pci_dev); ... } Although ne_do_request() drops ne_pci_dev->pci_dev_mutex between -EAGAIN retries so other commands can proceed, ne_enclave_release() holds ne_pci_dev->enclaves_list_mutex across the entire ENCLAVE_STOP and SLOT_FREE retry loop (up to 10 minutes per command). While one enclave is waiting for its slot to be scrubbed, ne_event_work_handler() blocks on ne_pci_dev->enclaves_list_mutex and cannot deliver out-of-band events to user space for any other running enclave, and NE_CREATE_VM in ne_ioctl() is similarly blocked before it can issue SLOT_ALLOC. In addition, if a second enclave file descriptor is closed while the first release is retrying for longer than the hung-task timeout, the second ne_enclave_release() call blocks in uninterruptible mutex_lock() on ne_pci_dev->enclaves_list_mutex (and ne_enclave_release() cannot simply use mutex_lock_killable() because it may run from do_exit() with a fatal signal already pending). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1794820000.gi= t.graf@amazon.com?part=3D6