From patchwork Tue Mar 8 11:28:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 12773543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 963EBC433FE for ; Tue, 8 Mar 2022 11:29:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 129288D0003; Tue, 8 Mar 2022 06:29:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B2218D0001; Tue, 8 Mar 2022 06:29:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBCF28D0003; Tue, 8 Mar 2022 06:29:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id DC8B28D0001 for ; Tue, 8 Mar 2022 06:29:16 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8A89C82A17FF for ; Tue, 8 Mar 2022 11:29:16 +0000 (UTC) X-FDA: 79220997912.18.CE3C1F7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 1AB064000A for ; Tue, 8 Mar 2022 11:29:15 +0000 (UTC) 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 3FF036115A; Tue, 8 Mar 2022 11:29:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50F59C340EC; Tue, 8 Mar 2022 11:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646738954; bh=nbU7mIeF1Dy+lDixzqyrU78B2yr27pHjzue9SkRm4Hk=; h=From:To:Cc:Subject:Date:From; b=tL8aqieZSys2aIh27sli7QGG4YOp1+MeuG7B+WlabZhSCARn1d40Fww91RNulXxbV QRMgvY+phO2KgcfPNAqHn7Jp4BhtvWBM1p9C0PAKMi4WcnFQe92Lp9o1KgC/pm0gIT WvosfQBi/2LlWpfilPsVLi5JAeHxs+/qH6ydPwPmeumValKveILma8vRRrvV8Ir0lX Vuc4k/ZnVN/vurAahkm4J42plgXSW3RF2fvB5b1Vf0dVyyCPsgRr973ujFAw46L3RF u+Zrfgx3jsx91nDlx+TQOB0zeJeCbPbU8xzfSNXlghvxGcsIBEmE+78VEOKHtDLIiu NUbTxe5QWV2Nw== From: Jarkko Sakkinen To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: Dave Hansen , Nathaniel McCallum , Reinette Chatre , Alexander Viro , linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Jarkko Sakkinen Subject: [PATCH RFC v3 0/3] MAP_POPULATE for device memory Date: Tue, 8 Mar 2022 13:28:30 +0200 Message-Id: <20220308112833.262805-1-jarkko@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1AB064000A X-Stat-Signature: u3s7kdptmjyqjoy6pgsfjpygjnaeo4se Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tL8aqieZ; spf=pass (imf01.hostedemail.com: domain of jarkko@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-HE-Tag: 1646738955-445423 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: SGX is weird. SGX memory is managed outside the core mm. It doesn't have a 'struct page' and get_user_pages() doesn't work on it. Its VMAs are marked with VM_IO. So, none of the existing methods for avoiding page faults work on SGX memory. This patch set essentially helps extend existing "normal RAM" kernel ABIs to work for avoiding faults for SGX too. SGX users want to enjoy all of the benefits of a delayed allocation policy (better resource use, overcommit, NUMA affinity) but without the cost of millions of faults. Jarkko Sakkinen (3): mm: Add f_op->populate() for populating memory outside of core mm x86/sgx: Export sgx_encl_page_alloc() x86/sgx: Implement EAUG population with MAP_POPULATE arch/x86/kernel/cpu/sgx/driver.c | 128 +++++++++++++++++++++++++++++++ arch/x86/kernel/cpu/sgx/encl.c | 38 +++++++++ arch/x86/kernel/cpu/sgx/encl.h | 3 + arch/x86/kernel/cpu/sgx/ioctl.c | 38 --------- include/linux/fs.h | 1 + mm/gup.c | 11 ++- 6 files changed, 178 insertions(+), 41 deletions(-)