Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1152739lqj; Mon, 3 Jun 2024 11:43:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYpxEe57mD+KzoOrbUAH1cPJa5EasfsN3Uw3EU40k8ND4ju/iA6jQJkzu4FaAKLq3J1Z8k1yFmM21FZo/Y3QDmQE7iuzWo8VZpQH8jFQ== X-Google-Smtp-Source: AGHT+IFaQXRsAoBJuE1625rg3BApTDPSbP6lhNLQK5FGkGWFu8Y0hNt4SWkNyPnXg4AtAf29MJWb X-Received: by 2002:a05:6359:7c23:b0:192:b048:2942 with SMTP id e5c5f4694b2df-19b490d5c85mr1212324055d.30.1717440190171; Mon, 03 Jun 2024 11:43:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717440190; cv=pass; d=google.com; s=arc-20160816; b=ipxJ/KLvbhZWSrGqkCypYO0IAbKyREZEAVN4uYNtN5A5xo1tfqnn1YFIp28P5HKlTK Vd24JpxvDpgFnMgxh2A39tHAPhZNdHqaekZxYgf45VAsrYoYi5Qdi/XtWy3etsTUlbpZ fh0mvEWaSrNSjbUSyNOTn8Qu/zJ81brH46mP8ss1T0DJkakDPwNzANn1adX1inBNbQMc p1MFIS7tozXbehUG9x0L4ZaLl+U+kqtDEltqN4S4AINdHfjYrNXWQdNj83ff2yQmEufo xSjZnP5SkuXCXOFKYcFl6vYWf3EA/kFb6Jfsne5tffnc8ebIE/mkYg/jp8HP5w/ndcko pKzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:message-id:organization:from :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:references:subject:cc:to :dkim-signature; bh=iCcJnSD/X8BoTO5hGfdYG8ROo2WtS0k1OScHmMIGKNg=; fh=erIkl5I/j27ryTjQPkRM/WKvryOxXi/6izu7Hct7USs=; b=CwB5d2ReZIPtNCrbFurpLSKnhe8VIJVnK7al22zMF3yJeGvGdzeC9JQnjEeNVSoJ7i qcyz5dyHTwW2IwRrS1+eTmcbtZF4hz8XinJTFsre+0upgx5aDFFavvRYe5BpGZ+SzTdC p+gnbneRZonoSWKxG5zfOU/uIq5+CzUwU4m/yAShK4BGkQUBbdqLvmROzebLaRWpYAtI 90QJC1u1bmhFMfK0iB2ns60rQqeutT7hAX+9Lwv6eTi2dAf+NkSGm1ryQrC68iWdr0Gw xEe+jF7I5Drfe2zRlri8rItcqvPr1NDzScK9EbSDUHCI2k8uFFf0z/P9aSOXVMtzPZQz nsqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6VjL6Ws; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-199573-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35d59f2efsi6845057a12.808.2024.06.03.11.43.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:43:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199573-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6VjL6Ws; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-199573-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199573-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C2C3F287761 for ; Mon, 3 Jun 2024 18:43:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BFC913A240; Mon, 3 Jun 2024 18:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="J6VjL6Ws" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 8E7D01CD38; Mon, 3 Jun 2024 18:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717440176; cv=none; b=sn8zkehPlqwXyE0wx7z13zTnsf3xPdyI39JvIN1rHnFF+QjomfQl7ahrQlyCdySjoCP8UKnzveR1DyqgbqGTXsMhyhZyAVMFEikqMEWJeya4c6Y/Hw9WbrzHiztTTdZdw6T1zBiKBAu1RuZa5uPJhm1P2JA+KYzlHTXrxv2JuTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717440176; c=relaxed/simple; bh=XU3+4aIaGjfIeWdhjY6gqQJdX7eZNihH6RIm/Asfw6Y=; h=Content-Type:To:Cc:Subject:References:Date:MIME-Version:From: Message-ID:In-Reply-To; b=YCpFR2qtkg/1O9ZYmb6ZeGoyMUKF2/iYCAcg4xSn7ryR4l3mhfGdDoPNmjUWgorSPdx7Y1lAdMpuysHsukPqdo5s7QkYTvoDjpI0RXyDimyBgT2AT5MzD+9sTWqBopJkHZRDOfbxiOt1gvLrl003628EMlPKAvQWluga7Co5X4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=J6VjL6Ws; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717440175; x=1748976175; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=XU3+4aIaGjfIeWdhjY6gqQJdX7eZNihH6RIm/Asfw6Y=; b=J6VjL6WsI+scU62zfrO/ByNwKqDV4KtBe9buJVwxd5z3bkHAaLv7OPBk S1iS8rzSQkblHtH0i+oWDAqH3roKKadNDTeUshNhdXjgJR1jIV4IiVEL9 u7juZ8qUGONnHMa+dsPJYSZRtdTGMi6cMbLM3va9v4NxZvORoF0TdwQGL L2e+UdySI/0HDsFdCX89VF8p665p7in3G8CY7NS/hObSadFhzsTLG3PCD nYh1NRqC17bIxe6V0fx85W1uKjqTQDxwFkd1veTrrkrI4ND+C6U92mR/N V35X4oA1HyXxEXlo5zI3ZDq9tFr7kh+R9v7UKCBGnH7vEU2wkueR2kXj5 w==; X-CSE-ConnectionGUID: WKVKnG3TTnu2zIeDznSl+w== X-CSE-MsgGUID: E5myC96OQN2i0miwGWAtUw== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="13759907" X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="13759907" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 11:42:54 -0700 X-CSE-ConnectionGUID: AiZY5W62Rzisjdj9sJ4hJQ== X-CSE-MsgGUID: FW+UUMl7TzmrUi3mo8BR/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,212,1712646000"; d="scan'208";a="74450737" Received: from hhuan26-mobl.amr.corp.intel.com ([10.92.17.168]) by smtpauth.intel.com with ESMTP/TLS/AES256-SHA; 03 Jun 2024 11:42:52 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Dmitrii Kuvaiskii" , dave.hansen@linux.intel.com, jarkko@kernel.org, kai.huang@intel.com, reinette.chatre@intel.com, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, "Dave Hansen" Cc: mona.vij@intel.com, kailun.qin@intel.com, stable@vger.kernel.org Subject: Re: [PATCH v3 2/2] x86/sgx: Resolve EREMOVE page vs EAUG page data race References: <20240517110631.3441817-1-dmitrii.kuvaiskii@intel.com> <20240517110631.3441817-3-dmitrii.kuvaiskii@intel.com> <01bb6519-680e-45bf-b8bd-34763658aa17@intel.com> Date: Mon, 03 Jun 2024 13:42:49 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Message-ID: In-Reply-To: <01bb6519-680e-45bf-b8bd-34763658aa17@intel.com> User-Agent: Opera Mail/1.0 (Win32) On Tue, 28 May 2024 11:23:13 -0500, Dave Hansen wrote: > On 5/17/24 04:06, Dmitrii Kuvaiskii wrote: > ... > > First, why is SGX so special here? How is the SGX problem different > than what the core mm code does? > >> --- a/arch/x86/kernel/cpu/sgx/encl.h >> +++ b/arch/x86/kernel/cpu/sgx/encl.h >> @@ -25,6 +25,9 @@ >> /* 'desc' bit marking that the page is being reclaimed. */ >> #define SGX_ENCL_PAGE_BEING_RECLAIMED BIT(3) >> >> +/* 'desc' bit marking that the page is being removed. */ >> +#define SGX_ENCL_PAGE_BEING_REMOVED BIT(2) > > Second, convince me that this _needs_ a new bit. Why can't we just have > a bit that effectively means "return EBUSY if you see this bit when > handling a fault". > IIUC, reclaimer_writing_to_pcmd() also uses SGX_ENCL_PAGE_BEING_RECLAIMED to check if a page is about being reclaimed in order to prevent its VA slot fro being freed. So I think we do need separate bit for EREMOVE which does not write to VA slot? BR Haitao