From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88BDDA0032; Fri, 24 Jun 2022 15:20:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E53364281A; Fri, 24 Jun 2022 15:20:11 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 751B3427FF; Fri, 24 Jun 2022 15:20:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S8ry3pkyG94axVbYg8u+du2iSCaWT/EYoWozGO3PkAv4cXOnbwQ20y1Ea/TN4sIXulyJmcnaGZBTDSHy8M1NhFRaHqPVkDkxHx3J6x+bFbbISFXLkJAXEEy74tm85c6jaY7LGi/G+3kYsuDzKfswvMxbyu6SB0HOrY7QwiCaGiev6jbyjDh5PWYNMXbKljnqCcKAqp++B61aWByXGV69SbHyHEJ4At+G3Wzg+FeJfITXk/7l2g7LMBhuR3mvGkXTfu8DkZvgQBgEqUZQXqcVJ4KmELr+FoluzUmGYYnmVVOrR0QTBg03SoJxnDYOk4ElsHJJ1p7rPiHgS7LvilVOFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U4msrMAQU92meE/sFeXI/O5QCaosiY3t88aWFdFbG6c=; b=MZblL+gQ8Ow4fPsUUdbs/zjJ2QOoIpzgTLTyw54+nBC4BkJvEJUbMUP1PSPQ4oPIX5Yz2+WLEd5BAVnn0ww10tVFKDFhq0C9+7GCItEUx9Qh8LTFzFHLehdquspsSOuCcdEr8O5XpujQ3o1IU4lFopF1qlqZIkaWXCHFB7/CckWIG0as+aBw20rpixG1kDLjrAHUtpEU8frP8gQwJxkAoiiPm5yrQm2q2OzX60Oq9uzLnZocDZjxwgteb6XZSFcU2EydPEu6FXtjEjqJQC/F1CjNKq2je9CkFwzQpalnA+fG90UOMbuoVHcfLHynH+QIe1jLkJPoyKfPoyvil/jEfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U4msrMAQU92meE/sFeXI/O5QCaosiY3t88aWFdFbG6c=; b=KY+rC6S0cZUBFiLsZt3wV4KeyNdhdFJyGQEchz71DcMEoXvj/rCygSJy9FFdv14eSSocQxpspmSATHU9LzzO1y88NNVP8NvVaZ3uWeW9XbrsFPt8iS8StGhJfmer411qGgPUn6tvsxtjYWi9CiXClyrbUDSl13htSYgvuf4E2nECopTUt4KRWCm+jEjtNhkwduJlyGgcyZV1YuE9rBhLxgA/SZEMkEYZyOnoeHHlwlQxnZB9c2djRCpIVkjb9eHGf/vy6eoKjdpgV6JgcLWetFPukflcD76nr30/Ab2y/efY3HmiYT+T9kp6v6ZJAAOrF9+202M4Ozaz9teB+i2KSQ== Received: from BN6PR19CA0061.namprd19.prod.outlook.com (2603:10b6:404:e3::23) by DM6PR12MB4811.namprd12.prod.outlook.com (2603:10b6:5:1fb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.19; Fri, 24 Jun 2022 13:20:06 +0000 Received: from BN8NAM11FT048.eop-nam11.prod.protection.outlook.com (2603:10b6:404:e3:cafe::47) by BN6PR19CA0061.outlook.office365.com (2603:10b6:404:e3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17 via Frontend Transport; Fri, 24 Jun 2022 13:20:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT048.mail.protection.outlook.com (10.13.177.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5373.15 via Frontend Transport; Fri, 24 Jun 2022 13:20:06 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 24 Jun 2022 13:20:04 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 24 Jun 2022 06:20:04 -0700 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 24 Jun 2022 06:20:03 -0700 From: Dmitry Kozlyuk To: CC: , Bruce Richardson , "Anatoly Burakov" Subject: [PATCH v4 3/5] doc: give specific instructions for running as non-root Date: Fri, 24 Jun 2022 16:19:54 +0300 Message-ID: <20220624131956.75160-4-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220624131956.75160-1-dkozlyuk@nvidia.com> References: <20220624084817.63145-1-dkozlyuk@nvidia.com> <20220624131956.75160-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17599129-e2f5-478e-a897-08da55e44174 X-MS-TrafficTypeDiagnostic: DM6PR12MB4811:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?GyfvHAn/ohSCi8VPMEse/DHxq+2RKlq9FtldjWWu+CkEAKi9zMwvU5N5zkcn?= =?us-ascii?Q?/AZKCs0gOcTJUY8FVOR7h+7AoKreUyKd9EQDL/IushLh9tXpR5alpe8sfvdB?= =?us-ascii?Q?9VfRvg6eRooKotbo9GcrJLbeydkExMhsjn04XnUN9UAedTMhP0IOPRy5ecBP?= =?us-ascii?Q?nxdlk9IVy6gOI5vuZ51brGWbASwyWHn1sMTXuhug5JvVdu0J7QZi5DhtzyfN?= =?us-ascii?Q?VHpp7RqfFTffWccj9I3wot85Z5bXH14wcf7F3lf9SWffvhoC7Q60+S+m6JAf?= =?us-ascii?Q?my8yusfr/ODNmEGNAXwNah2p3Nf0Q9vxJrVH6HoJT0Sf7scVG18wJraMAUSB?= =?us-ascii?Q?u25a3RNuAuxFjp06WGlCM+rvW90HIoSh7G6eOVVsS+ErWbifbyd/rSLoq0Wl?= =?us-ascii?Q?ftk4aCqxxdyQzsTam/opLpambgpfXCMJpCPP2lEqQH6BxQY8y2Q+GxDpqkQq?= =?us-ascii?Q?iEjyt/JMnEpB/Ze7qbUFDCS0qLCPyYVf9EdiHIjh0FV0BJVUfTPgFsIgiH3y?= =?us-ascii?Q?0+794cUTZiDZUudSnBwWRvtg4L4hPKrjqTcdBptnlme89/LGZpfqWifqEYD8?= =?us-ascii?Q?ynhYSi0eQMKmG8Ov58TKAdGKKosO8LufiT1iKuL8a56+eC6JrUi2XmFV4/t3?= =?us-ascii?Q?eHw1qZEBhe7MFVIo3vj45nZp03Xidz2z1xHiw/RJij3MNsbdBR5/9Xu1tkmv?= =?us-ascii?Q?G8PBjYpIUSaiyPzSAVaS15KbnOR203wtsnz/TQBeVwO3sjKVvC5+BcBBZ/Ae?= =?us-ascii?Q?F7f03vcZ3jsr5/VC3kYhPm+xuRnLcHHBI9v0kLu1WrEOTGiWKT+66WBuDDJi?= =?us-ascii?Q?/PttLc+D6NhXVvZyYiRsllRanBWHD5l7keVnK58Reu+yvv6B4ZWeE4HPMZwq?= =?us-ascii?Q?8qiDDqLPVCnCqN9FhK0qja/rB67ns2BDqst3G0u7cRuVcvehZdHrKA0JzOys?= =?us-ascii?Q?KiMfrfzUHAw1zbxBDeTbGQ=3D=3D?= X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(346002)(396003)(376002)(136003)(39860400002)(40470700004)(36840700001)(46966006)(2906002)(54906003)(83380400001)(82740400003)(81166007)(478600001)(40480700001)(86362001)(8676002)(36860700001)(7696005)(5660300002)(356005)(55016003)(70206006)(70586007)(8936002)(2616005)(47076005)(426003)(6286002)(6666004)(40460700003)(36756003)(186003)(4326008)(1076003)(336012)(26005)(82310400005)(41300700001)(6916009)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2022 13:20:06.3696 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17599129-e2f5-478e-a897-08da55e44174 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT048.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4811 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The guide to run DPDK applications as non-root in Linux did not provide specific instructions to configure the required access and did not explain why each bit is needed. The latter is important because running as non-root is one of the ways to tighten security and grant minimal permissions. Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Bruce Richardson --- doc/guides/linux_gsg/enable_func.rst | 90 +++++++++++++------ .../prog_guide/env_abstraction_layer.rst | 2 + 2 files changed, 65 insertions(+), 27 deletions(-) diff --git a/doc/guides/linux_gsg/enable_func.rst b/doc/guides/linux_gsg/enable_func.rst index 1df3ab0255..b15bfb2f9f 100644 --- a/doc/guides/linux_gsg/enable_func.rst +++ b/doc/guides/linux_gsg/enable_func.rst @@ -13,13 +13,64 @@ Enabling Additional Functionality Running DPDK Applications Without Root Privileges ------------------------------------------------- -In order to run DPDK as non-root, the following Linux filesystem objects' -permissions should be adjusted to ensure that the Linux account being used to -run the DPDK application has access to them: +The following sections describe generic requirements and configuration +for running DPDK applications as non-root. +There may be additional requirements documented for some drivers. -* All directories which serve as hugepage mount points, for example, ``/dev/hugepages`` +Hugepages +~~~~~~~~~ -* If the HPET is to be used, ``/dev/hpet`` +Hugepages must be reserved as root before running the application as non-root, +for example:: + + sudo dpdk-hugepages.py --reserve 1G + +If multi-process is not required, running with ``--in-memory`` +bypasses the need to access hugepage mount point and files within it. +Otherwise, hugepage directory must be made accessible +for writing to the unprivileged user. +A good way for managing multiple applications using hugepages +is to mount the filesystem with group permissions +and add a supplementary group to each application or container. + +One option is to use the script provided by this project:: + + export HUGEDIR=$HOME/huge-1G + mkdir -p $HUGEDIR + sudo dpdk-hugepages.py --mount --directory $HUGEDIR --user `id -u` --group `id -g` + +In production environment, the OS can manage mount points +(`systemd example `_). + +The ``hugetlb`` filesystem has additional options to guarantee or limit +the amount of memory that is possible to allocate using the mount point. +Refer to the `documentation `_. + +.. note:: + + Using ``vfio-pci`` kernel driver, if applicable, can eliminate the need + for physical addresses and therefore eliminate the permission requirements + described below. + +If the driver requires using physical addresses (PA), +the executable file must be granted additional capabilities: + +* ``SYS_ADMIN`` to read ``/proc/self/pagemaps`` +* ``IPC_LOCK`` to lock hugepages in memory + +.. code-block:: console + + setcap cap_ipc_lock,cap_sys_admin+ep + +If physical addresses are not accessible, +the following message will appear during EAL initialization:: + + EAL: rte_mem_virt2phy(): cannot open /proc/self/pagemap: Permission denied + +It is harmless in case PA are not needed. + +Resource Limits +~~~~~~~~~~~~~~~ When running as non-root user, there may be some additional resource limits that are imposed by the system. Specifically, the following resource limits may @@ -34,8 +85,13 @@ need to be adjusted in order to ensure normal DPDK operation: The above limits can usually be adjusted by editing ``/etc/security/limits.conf`` file, and rebooting. -Additionally, depending on which kernel driver is in use, the relevant -resources also should be accessible by the user running the DPDK application. +See `Hugepage Mapping `_ +section to learn how these limits affect EAL. + +Device Control +~~~~~~~~~~~~~~ + +If the HPET is to be used, ``/dev/hpet`` permissions must be adjusted. For ``vfio-pci`` kernel driver, the following Linux file system objects' permissions should be adjusted: @@ -45,26 +101,6 @@ permissions should be adjusted: * The directories under ``/dev/vfio`` that correspond to IOMMU group numbers of devices intended to be used by DPDK, for example, ``/dev/vfio/50`` -.. note:: - - The instructions below will allow running DPDK with ``igb_uio`` or - ``uio_pci_generic`` drivers as non-root with older Linux kernel versions. - However, since version 4.0, the kernel does not allow unprivileged processes - to read the physical address information from the pagemaps file, making it - impossible for those processes to be used by non-privileged users. In such - cases, using the VFIO driver is recommended. - -For ``igb_uio`` or ``uio_pci_generic`` kernel drivers, the following Linux file -system objects' permissions should be adjusted: - -* The userspace-io device files in ``/dev``, for example, ``/dev/uio0``, ``/dev/uio1``, and so on - -* The userspace-io sysfs config and resource files, for example for ``uio0``:: - - /sys/class/uio/uio0/device/config - /sys/class/uio/uio0/device/resource* - - Power Management and Power Saving Functionality ----------------------------------------------- diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 5f0748fba1..70fa099d30 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -228,6 +228,8 @@ Normally, these options do not need to be changed. can later be mapped into that preallocated VA space (if dynamic memory mode is enabled), and can optionally be mapped into it at startup. +.. _hugepage_mapping: + Hugepage Mapping ^^^^^^^^^^^^^^^^ -- 2.25.1