From patchwork Tue Mar 8 11:10:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 12773525 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 EF86AC433FE for ; Tue, 8 Mar 2022 11:10:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346321AbiCHLLp (ORCPT ); Tue, 8 Mar 2022 06:11:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346336AbiCHLLp (ORCPT ); Tue, 8 Mar 2022 06:11:45 -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 30518457AB; Tue, 8 Mar 2022 03:10:49 -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 C00A4615F4; Tue, 8 Mar 2022 11:10:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2075C340EC; Tue, 8 Mar 2022 11:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646737848; bh=Q2s/iQcTH+SXJFwnKcZFVY44y/cmyFC2fSfRw8SBNqU=; h=From:To:Cc:Subject:Date:From; b=rPpc8qQxwmbbms54yob29DznB7ZZaw77JUfFsFNryOCmsbofkY1WhFN2G65dPQxSR GLIVlzxEPZhvMJDd5tPub/BPBm7ZcjyhF/p+PfI8DBM+aPfjlny7OoSrta2Xs049ln TbZ9fewFAtjh3jtGlo5HIpkvi+sHJjS7Ah86vFbZb0DuFq0cE06qMjsItVLHyGaGdv gZ2zt2N1+H+RNwUDA0tAxeN/K++I7XryUtsdW0bEKIkJzjziFwn414fL+/I4sJvuPy AxVgEfJs4V1oiZDOXMpyFuqUKbfLX50MF82A4hQxdc5XFoCuOdGir2aIDA1ba5GXqg vjjB7qOieyRzw== 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 v2 0/3] MAP_POPULATE for device memory Date: Tue, 8 Mar 2022 13:10:00 +0200 Message-Id: <20220308111003.257351-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 | 9 ++- 6 files changed, 175 insertions(+), 42 deletions(-)