Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp357910lqd; Wed, 24 Apr 2024 04:51:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxcnVKaw54m7rGdtZMtmd/70F4MqSntele+oSndq0FxGO9DEiIiJ68fkPN16qdjiPCtQocx5+HlCVqD6pLMK5mNSHu//5WNXunSUf4xw== X-Google-Smtp-Source: AGHT+IGSOdNQ5EGHpGqGss8p3wzxkuPyVNKPFIxEmnLaPzGSzBqZRM4Yy/4mg1ktP4t0frFwSPVD X-Received: by 2002:a05:6359:2781:b0:186:c06f:437c with SMTP id ly1-20020a056359278100b00186c06f437cmr1884513rwb.14.1713959480741; Wed, 24 Apr 2024 04:51:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713959480; cv=pass; d=google.com; s=arc-20160816; b=GHt7WTt7ZFoezHKF1J3lvFCMFO2STWTXH9ey6RTdDjmviEmZpgkTWPulsNa9pSGcCg 6hTQV7YFte2wwvYKtuTHKi06hk4bxRCtX11Wfc7fmUeu074j4a6d6gF7rdH+3qi2WSAy Q0naKV8WIWmnaOtjPAwX7szFAj2UnxrXCoU63SNmbWZElSLlE59e4cL6/dj3I6tL+mf1 pB/U6n4e8BiiIaVxvunw18mxW0DmXduWGHGRrhMlUDI5FfiKEdm1RiqvYpocmAoi3YES hKNQCLJSZJhVmRvTXGCl5Gm3dasiP5hJ7SIrAj1Wwtvdp6oifL3Hvqn5IQs0HlBu5uLp SS9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=ozLjALREGz/5ADpN3UYpLtAQzZ6fw/RdnvorAJ09Wvs=; fh=nwVppg+DAxwn7Vf4YoETWcHOIBcw4X02TbfiCdb2bz4=; b=jceIjuOckggNPD7k19SatqHxAuK3XfqW1OsOYeiN2doMUw7+Ymrg0Agvg/k6VKS2Md DUUgR7nwvO69gMZAzfr3sDXHqHN2eTpMd/cfaOWd17efX5szMjr3fik1CCz/GjpTVbnb GXWUpAAQ66nmh9FzDSMxWKeDSW64awHXrI+Qgt+wr51IslJzhdOJ8er/5Xbs5NHQQgSN 6HzIwReTfYV6vhupskQmqzQMbQCBfalj9GsxYjnnSwU91TIAy91Yh8ypMuSmS0MBlza6 hTzBVOnFQW2ddeAiRsw4JGAf+8g7zi4/8sgFsSHPrBVnRyLG0J6nzuYZLiTwmKMsxI35 camQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=p+8hKg66; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-156818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w16-20020a05622a135000b0043a3195c77csi267467qtk.222.2024.04.24.04.51.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 04:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@antgroup.com header.s=default header.b=p+8hKg66; arc=pass (i=1 spf=pass spfdomain=antgroup.com dkim=pass dkdomain=antgroup.com dmarc=pass fromdomain=antgroup.com); spf=pass (google.com: domain of linux-kernel+bounces-156818-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156818-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F6A61C2326B for ; Wed, 24 Apr 2024 11:51:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA75415AAAF; Wed, 24 Apr 2024 11:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="p+8hKg66" Received: from out0-217.mail.aliyun.com (out0-217.mail.aliyun.com [140.205.0.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C40015A4A1; Wed, 24 Apr 2024 11:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713959474; cv=none; b=i3vtW9Vr2VeP2TfQZTuCEiH43/K9Nke72wa1+YbIq7hREJxILOHU4Je+cDENDbDTFQIBQici9EmpbaHZVfHvUTHIJyqvSF09chxT9TailzC7RmkcvUtEfeGJeCzgvLvGyvgqgiPBKW0jbqYh2YpWDEqgjOBWqNidhicuxL1UwBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713959474; c=relaxed/simple; bh=0ASRLrYLM+eWKri3S7N5mLSo2FArHC34RbVnFY+i0/E=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=GxAAQZvNhxvc9pMC0jxxtzgV1R/vkg0N1tgK0/sYTQ4kf7701Kij9x7OkeExPuVjbfj7y41JCFQfOc5ZOhUOpimGJhByRiAnmD6K9/mQ95w2bY6VKOw86VuS+oMs7BA/WaqZQxlcnDy2u+9lNJ2rmQOz2qRsSqzO+dAGc82AlYA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=p+8hKg66; arc=none smtp.client-ip=140.205.0.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1713959461; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To; bh=ozLjALREGz/5ADpN3UYpLtAQzZ6fw/RdnvorAJ09Wvs=; b=p+8hKg662XSAiXfqhEmzDCY2U7PhfXxYzfW60nkIBPk8RBXQa8T2/lqT83A4nGF/hUUB4cSumO5Xim0YCFUTh8fIRKaTeSda7pr+Aer8kJJy9f4xpIghsO1Lh/27C2VYvkOahrM9tkcr86qaR7hvMS3DctJZR1W3Vcy8GpGV0WU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047211;MF=zhubojun.zbj@antgroup.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---.XKLmvlB_1713959460; Received: from smtpclient.apple(mailfrom:zhubojun.zbj@antgroup.com fp:SMTPD_---.XKLmvlB_1713959460) by smtp.aliyun-inc.com; Wed, 24 Apr 2024 19:51:00 +0800 Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.100.2.1.4\)) Subject: Re: [RFC PATCH 1/1] x86/sgx: Explicitly give up the CPU in EDMM's ioctl() to avoid softlockup From: "Bojun Zhu" In-Reply-To: Date: Wed, 24 Apr 2024 19:50:49 +0800 Cc: "=?UTF-8?B?SHVhbmcsIEthaQ==?=" , "linux-sgx@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dave.hansen@linux.intel.com" , "=?UTF-8?B?5YiY5Y+MKOi9qeWxuSk=?=" , "=?UTF-8?B?Q2hhdHJlLCBSZWluZXR0ZQ==?=" , "Bojun Zhu" Content-Transfer-Encoding: quoted-printable Message-Id: References: <20240423092550.59297-1-zhubojun.zbj@antgroup.com> <20240423092550.59297-2-zhubojun.zbj@antgroup.com> <02fe00c3b10e4476d500ad7a34024b7eae5e3c97.camel@intel.com> <85dfbebc-a2d5-4828-b3b9-f929cd6e30cf@antgroup.com> To: Jarkko Sakkinen X-Mailer: Apple Mail (2.3774.100.2.1.4) Hi Jarkko, > On Apr 24, 2024, at 18:42, Jarkko Sakkinen wrote: >=20 > On Wed Apr 24, 2024 at 10:02 AM EEST, Jarkko Sakkinen wrote: >> On Wed Apr 24, 2024 at 9:46 AM EEST, Bojun Zhu wrote: >>> Based on the the discussion among you, Jarkko and Reinette, >>> I will keep the need_resched() and wrap the logic in using = sgx_resched(), >>> as suggested by Jarkko. >>=20 >> Sounds like a plan :-) >=20 > In sgx_ioc_enclave_add_pages() "if (!c)" check might cause possibly > some confusion. >=20 > Reason for it is that in "transaction sense" the operation can > be only meaningfully restarted when no pages have not been added > as MRENCLAVE checksum cannot be reset. >=20 > BR, Jarkko >=20 Thanks for your reminder. According to the SGX hardware specification, similar to "ADD PAGES=E2=80=9D= , the operations in "MODT PAGEs=E2=80=9D and "REMOVE PAGEs(at = runtime)=E2=80=9D =20 can be only meaningfully restarted when no page has been handled. For the following code in sgx_ioc_enclave_add_pages(): ```c if (signal_pending(current)) { if (!c) ret =3D -ERESTARTSYS; break; } ``` I still have some questions: It seems that the variable "ret" is set to 0 if there is **some** EPC = pages have been=20 added when interrupted by signal(Supposed that sgx_encl_add_page()=20 always returns successfully). Shall we set the return value as "-EINTR" if the context is interrupted = by=20 signal when some EPC pages have been added? (BTW, return values contain -EINTR as shown in = https://elixir.bootlin.com/linux/latest/source/arch/x86/kernel/cpu/sgx/ioc= tl.c#L402) Please correct me if misunderstood it. Regards, Bojun=