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: 12773547 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 906A1C433F5 for ; Tue, 8 Mar 2022 11:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232487AbiCHLaM (ORCPT ); Tue, 8 Mar 2022 06:30:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232182AbiCHLaL (ORCPT ); Tue, 8 Mar 2022 06:30:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5562340EC; Tue, 8 Mar 2022 03:29:15 -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 3FF2E6165E; 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 Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org 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(-)