From nobody Mon Feb 9 16:47:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1517860959316194.28701136209258; Mon, 5 Feb 2018 12:02:39 -0800 (PST) Received: from localhost ([::1]:55063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimyM-0001Jd-FT for importer@patchew.org; Mon, 05 Feb 2018 15:02:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eimSc-0004qB-OR for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eimSb-00059S-P8 for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:50 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:43242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eimSb-00058s-HL for qemu-devel@nongnu.org; Mon, 05 Feb 2018 14:29:49 -0500 Received: by mail-wr0-x243.google.com with SMTP id b52so10520999wrd.10 for ; Mon, 05 Feb 2018 11:29:49 -0800 (PST) Received: from 640k.lan ([82.84.122.246]) by smtp.gmail.com with ESMTPSA id g8sm20029891wra.18.2018.02.05.11.29.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 11:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EqCOYwuRO1GjaOjOSLjtoAPpfjqY+gsE9sH7/uNXNGY=; b=X42KynGeViG3kMy1BPwbd8fDNfJwA6QdC6FCyOT6hMvE6DX17seZDJMeYfc9ddAnOf wRY1ZZ7orVK+4+jsJf4Ys2XtE+H6Q3kigd7n1ne87fWLol5dgDZcZMmT1lhYzHSPwIfA Fdz9Z7u5P3Tt7sxJmblCjxEnI8jsXAeh10jwvOrnx+2/aKnSkS3c9QY/3liL3EkQzhjg /aL2J1tq+1p4R3UtFstGxjRqgKM/HyyK9jz0oh77m9MJovApRJ8IQdonNePwmO8aBSmV lUrVv22pdOxetBEVHFWSaOS0DIxrzgS7lgA+Q+LBZcdr48p6LgsglhOzPKNws+O5m2+o N7hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EqCOYwuRO1GjaOjOSLjtoAPpfjqY+gsE9sH7/uNXNGY=; b=WUPV62wwOiOlE5P3FQm3DyVZv4Z0wwTMYXPW/kI920h5sMl+U+FVSN45F0U122FFqL I6cwWDaYhoOZ0ZwgPeLIdFgSyW9fbFn3/oNXH/BHav1eulQVSj9w9gN5+d1i08vqT5cJ CE+7ODUM+LL23jWpxnxNGn6JmxTheWRPzuODTBfxUaYhVGFpetCKO0nrzPPfnAPBCf1v lyG+IOK7XxOdKxTV9er/q0wrsM8C7ljKx1UBi+nbREluGG5NT0MlLZK6FCOdwBuJFalL 4qbVVQtLqhW6/befWjxqlOSZon7bVsQL2nAbX9XlE1IP+vKmcVe0BKOtxs9pUMhbwufd LDhg== X-Gm-Message-State: AKwxytegWuV6lomJEaO51YOLJzaBol32la9G/8CMEYuF4oyt9FufsSXl EpvQxC1/46JucuJGjl1cR+KQ17Gk X-Google-Smtp-Source: AH8x227NOka/rRGV0wqJi+UP9L1Aqv1auw1pl3jQbPeao9DF/72pxube41pkkJPPD+9zPJMMdCnOLQ== X-Received: by 10.223.150.116 with SMTP id c49mr32766062wra.225.1517858988163; Mon, 05 Feb 2018 11:29:48 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Feb 2018 20:28:51 +0100 Message-Id: <1517858941-5538-38-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> References: <1517858941-5538-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PULL 37/47] memfd: add hugetlb support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Marc-Andr=C3=A9 Lureau Linux commit 749df87bd7bee5a79cef073f5d032ddb2b211de8 (v4.14-rc1) added a new flag MFD_HUGETLB to memfd_create() that specify the file to be created resides in the hugetlbfs filesystem. This is the generic hugetlbfs filesystem not associated with any specific mount point. hugetlbfs does not support sealing operations in v4.14, therefore specifying MFD_ALLOW_SEALING with MFD_HUGETLB will result in EINVAL. However, I added sealing support in "[PATCH v3 0/9] memfd: add sealing to hugetlb-backed memory" series, queued in -mm tree for v4.16. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180201132757.23063-3-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/qemu/memfd.h | 4 ++-- util/memfd.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/qemu/memfd.h b/include/qemu/memfd.h index b9d0987..1d3ecc7 100644 --- a/include/qemu/memfd.h +++ b/include/qemu/memfd.h @@ -16,8 +16,8 @@ #define F_SEAL_WRITE 0x0008 /* prevent writes */ #endif =20 -int qemu_memfd_create(const char *name, size_t size, unsigned int seals, - Error **errp); +int qemu_memfd_create(const char *name, size_t size, bool hugetlb, + unsigned int seals, Error **errp); void *qemu_memfd_alloc(const char *name, size_t size, unsigned int seals, int *fd, Error **errp); void qemu_memfd_free(void *ptr, size_t size, int fd); diff --git a/util/memfd.c b/util/memfd.c index 8d27307..7594af7 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -52,7 +52,11 @@ static int memfd_create(const char *name, unsigned int f= lags) #define MFD_ALLOW_SEALING 0x0002U #endif =20 -int qemu_memfd_create(const char *name, size_t size, +#ifndef MFD_HUGETLB +#define MFD_HUGETLB 0x0004U +#endif + +int qemu_memfd_create(const char *name, size_t size, bool hugetlb, unsigned int seals, Error **errp) { #ifdef CONFIG_LINUX @@ -62,6 +66,9 @@ int qemu_memfd_create(const char *name, size_t size, if (seals) { flags |=3D MFD_ALLOW_SEALING; } + if (hugetlb) { + flags |=3D MFD_HUGETLB; + } =20 mfd =3D memfd_create(name, flags); if (mfd < 0) { @@ -97,11 +104,11 @@ void *qemu_memfd_alloc(const char *name, size_t size, = unsigned int seals, int *fd, Error **errp) { void *ptr; - int mfd =3D qemu_memfd_create(name, size, seals, NULL); + int mfd =3D qemu_memfd_create(name, size, false, seals, NULL); =20 /* some systems have memfd without sealing */ if (mfd =3D=3D -1) { - mfd =3D qemu_memfd_create(name, size, 0, NULL); + mfd =3D qemu_memfd_create(name, size, false, 0, NULL); } =20 if (mfd =3D=3D -1) { --=20 1.8.3.1