Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp3470857lkm; Tue, 21 Sep 2021 16:57:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzudoThyQJPXyOKMomIYj1H8LxMpwMNGr3Khf2NYnY7gpbZ+6DB1D6OzJYA5lSwKKHSETGM X-Received: by 2002:a92:c5c9:: with SMTP id s9mr23141851ilt.56.1632268637534; Tue, 21 Sep 2021 16:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632268637; cv=none; d=google.com; s=arc-20160816; b=1FZ1SYLJUhDFYQ3hyh0lS+0rF1GiiOGH2zO9E1rSWqTKwRZoPuoDIVLEQfC8hh8r0r Ed2IRIV66A5xwtwMPAlqQhy5FgkUtpvgFwO2rPvfRN7X36QerIXNzLk1l5HepT7bCIq3 6LH8BvoxksxOjUu/ZssFvC3U+E40GXRFiysOoLqbyDEn7Wd93QsHnDFzDHJ4oLRm9zlB 1+prJxYP/L+M9u/K28UjS2/hzoSnlt27kSF+psLsYDsoD57cbfC51jZQC4W42D1IMsFW ZwJElHPYJB4HqF8bRSif8X2Gc3+H979vuL2S3GEwLMQlKBsuYRjt1u4mKVXE0O/smz5L Rj2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=bzFogdDLD0SZfic4L2pBf5UfwWRv/wRYQkeTHZI48Eo=; b=HKJ9pJ/1K3IeqTe9XbYEDhuALUSn+ltbKEMGrwaSytNXnRLiAXqkFW4Q2EiylmJ+W+ KS6AoYzsccm8wSZ82RWjGo/rlhCjg/3yMbNRrBWUlhT97NdgundhvzMo07udbRsEbTEi 1xqsrF1xjaUXObpw2232PeRLB2N0HPnf0I7ZkDmXaN+slHspBcgBqXcqj+IBaErWBwoa Bu6fC/x1T+bpREPB6Qj84hUGNx5NeXLFNc78KhrIM/riUYsO2bDsCi8dqRtVUNDTYKzs DKcbkhfSH6Ykru6n/etIwsk0443lXxyNm+Tifk6ebihMsxO16xS0VSEe5J24MKgJ61ph y4ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k5/YG+yI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si627360iof.105.2021.09.21.16.56.41; Tue, 21 Sep 2021 16:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k5/YG+yI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235366AbhIUV3u (ORCPT + 99 others); Tue, 21 Sep 2021 17:29:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235066AbhIUV3r (ORCPT ); Tue, 21 Sep 2021 17:29:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6885560E05; Tue, 21 Sep 2021 21:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632259698; bh=u5KDp5z7CNOMtmug5vUpsYUjL+QlsT/yr8SkHYUNkzA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=k5/YG+yIhh+2Lmbf7o19vG38h1Ui+/ljTE8INnNZUhwDqxRBEaKYNGqz4ovOw2qC6 oW0K574xRPFLgi6j7219P63O7HYnSLn+J4ER9euN7lliQZKglCHW13+OMIrfmd3CFr HHKTkvDLZFueAOZsNP6wwOWlr6FyTApV4NHsK/lfJa49eF2m8S699Y/ZYHVOwhwdtK puOJB6MSGQmkw7cTiME9Fp8D7hVJ5ZObWvmueFr7vGvlqZ3P0Z1c/NEo9XypkQkxd0 4ZYXP9p6xLS12/zTcnhNl1VS4N0us1PEu/e7H5zmrbvocDsRUV2yXEUes8jbWHt91J pBDQPbTK+dH5A== Message-ID: Subject: Re: [PATCH v5 1/7] x86/sgx: Provide indication of life-cycle of EPC pages From: Jarkko Sakkinen To: Tony Luck , Sean Christopherson , Dave Hansen Cc: Cathy Zhang , linux-sgx@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Date: Wed, 22 Sep 2021 00:28:16 +0300 In-Reply-To: <20210917213836.175138-2-tony.luck@intel.com> References: <20210827195543.1667168-1-tony.luck@intel.com> <20210917213836.175138-1-tony.luck@intel.com> <20210917213836.175138-2-tony.luck@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-09-17 at 14:38 -0700, Tony Luck wrote: > SGX EPC pages go through the following life cycle: >=20 > DIRTY ---> FREE ---> IN-USE --\ > ^ | > \-----------------/ >=20 > Recovery action for poison for a DIRTY or FREE page is simple. Just > make sure never to allocate the page. IN-USE pages need some extra > handling. >=20 > It would be good to use the sgx_epc_page->owner field as an indicator > of where an EPC page is currently in that cycle (owner !=3D NULL means > the EPC page is IN-USE). But there is one caller, sgx_alloc_va_page(), > that calls with NULL. >=20 > Since there are multiple uses of the "owner" field with different types > change the sgx_epc_page structure to define an anonymous union with > each of the uses explicitly called out. But it's still always a pointer. And not only that, but two alternative fields in that union have *exactly* = the same type, so it's kind of artifically representing the problem more comple= x than it really is. I'm not just getting, why all this complexity, and not a few casts instead? I neither get the rename of "owner" to "private". It serves very little val= ue. I'm not saying that "owner" is best name ever but it's not *that* confusing either. That I'm sure that it is definitely not very productive to rename i= t. Also there was still this "dirty". We could use ((void *)-1), which was als= o suggested for earlier revisions. /Jarkko