Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3154331pxp; Tue, 8 Mar 2022 08:40:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmaxCM0KFcDD09WQn0i2GugvteBnKkttoOfemxpSkjYGQ96/viLW3P6xaGut9pvsA7knGJ X-Received: by 2002:a17:906:6a0f:b0:6d7:1021:2bd2 with SMTP id qw15-20020a1709066a0f00b006d710212bd2mr14934650ejc.395.1646757645025; Tue, 08 Mar 2022 08:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646757645; cv=none; d=google.com; s=arc-20160816; b=wkRsZzy7SY8drrXQjiTTOOxyS9JV13VtpGywiL1FTbdg9MWJpShpD4BfrsrZ5pXQ1n zX6wehALZGKRTJ20QecQJJU8A8fErYH9KTUade38NTleJAfK8BfK7fVxegK/bJBdmutX gvrWuSkTOs//RjL1wI3+V8IS5Kau2fEtr0vdodJQWGgNO+prijMmJeoGT/o9M5gXfHIw dVLNH4IslmkN3JEF6de6oJ1Y2N1zsUurhPW0kg7LtB7VU9Nj13n1s185hGI3xbgH6s+q u7f8RvP+Fm4qHZidFqoQSzG+jIhRdQ+k2nlt8dqdpUxlm3vleU6/XupNpf6I6lkLFiOi YAhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7uixxFOVFohxt+a1eTEHpCs6rEyknQSZKs4PTbxVpRg=; b=iSdl1dzBUmXnrNC6iICKsFlPDyOmF84Womp4FnQ+P8zMzKVPe+2oOJmSw0S1rF8NTG e4yUP7my4l0RLs6bPjodsqD0nxqWhO+hH9eyGZoFKXNKz29tx7BMXsCBQJyFdx9aAMgQ ZzsePeoxa/oihfBajJvEb3L6dd1PPfGN9DH2I8/Ee2wQpHckfKHf40U8u+ocVv0WrFBC o7Aw1ky9O5lCYx5nsG7n+NXk14KFlfO8riNu06/5df4+XOGplis18N6utPYAgJkG70vE XxvVNyD9W3FVsQLNuXSp0vD/QyQutRHfmViWNRJfTGYM3rE6x0+9T2EOWWv3aAEfqXal UW+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WuKoSqjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020aa7dc4f000000b004160656a9easi8064235edu.303.2022.03.08.08.40.21; Tue, 08 Mar 2022 08:40:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WuKoSqjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239177AbiCGQSh (ORCPT + 99 others); Mon, 7 Mar 2022 11:18:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244075AbiCGQSf (ORCPT ); Mon, 7 Mar 2022 11:18:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AF5465C2; Mon, 7 Mar 2022 08:17:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B9A260C53; Mon, 7 Mar 2022 16:17:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD9DDC340E9; Mon, 7 Mar 2022 16:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646669860; bh=Ow0qlJFv8Ai59R6SHq7SYcAd/WZ7HKl8y68xRyfOxi4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WuKoSqjhMqktUxl46K8ouMyuOIiXymZ2HjoZbPuOghcZie5K3+EVDsY3WOmi5DFQJ 2kSKhUsaVelRDLZRnVg7WF8c7nHebO9+ZThCKAFWorgAPUiIfF+CD1demP0pR7ti+y xFP3jtJL4kaufTDt12aTMdlYxuA9SF6bXNpbLwXWk7tjSgi0nMa1P/DK7bCQB851ZU Cc4AXxEmFN3o8UA9q/HKTJB5MchFo4iRbXEejhaBFq/7xrOBnpzaKT/lDUok9xsbZ7 5g87SlzJkSDEAAzbYvFHH2kRCUT8iHg3tOCV/Pqb1FCFcV66hPW9+/fhGou/9nudSR W9dA2Vo/K9FFA== Date: Mon, 7 Mar 2022 18:16:59 +0200 From: Jarkko Sakkinen To: Reinette Chatre Cc: dave.hansen@linux.intel.com, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, seanjc@google.com, kai.huang@intel.com, cathy.zhang@intel.com, cedric.xing@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 19/32] x86/sgx: Support adding of pages to an initialized enclave Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 07, 2022 at 04:45:41PM -0800, Reinette Chatre wrote: > + encl_page = kzalloc(sizeof(*encl_page), GFP_KERNEL); > + if (!encl_page) > + return VM_FAULT_OOM; > + > + encl_page->desc = addr; > + encl_page->encl = encl; > + > + /* > + * Adding a regular page that is architecturally allowed to only > + * be created with RW permissions. > + * TBD: Interface with user space policy to support max permissions > + * of RWX. > + */ > + prot = PROT_READ | PROT_WRITE; > + encl_page->vm_run_prot_bits = calc_vm_prot_bits(prot, 0); > + encl_page->vm_max_prot_bits = encl_page->vm_run_prot_bits; You should use sgx_encl_page_alloc() here and not reinvent wheel. I wrote a patch that exports it: https://lore.kernel.org/linux-sgx/20220306053211.135762-3-jarkko@kernel.org/T/#u BR, Jarkko