[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 37/47] memfd: add hugetlb support
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 37/47] memfd: add hugetlb support |
Date: |
Mon, 5 Feb 2018 20:28:51 +0100 |
From: Marc-André Lureau <address@hidden>
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é Lureau <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
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
-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 flags)
#define MFD_ALLOW_SEALING 0x0002U
#endif
-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 |= MFD_ALLOW_SEALING;
}
+ if (hugetlb) {
+ flags |= MFD_HUGETLB;
+ }
mfd = 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 = qemu_memfd_create(name, size, seals, NULL);
+ int mfd = qemu_memfd_create(name, size, false, seals, NULL);
/* some systems have memfd without sealing */
if (mfd == -1) {
- mfd = qemu_memfd_create(name, size, 0, NULL);
+ mfd = qemu_memfd_create(name, size, false, 0, NULL);
}
if (mfd == -1) {
--
1.8.3.1
- [Qemu-devel] [PULL 27/47] ivshmem: Always remove irqfd notifiers, (continued)
- [Qemu-devel] [PULL 27/47] ivshmem: Always remove irqfd notifiers, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 32/47] cpus: dummy: unregister thread with RCU, exit loop on unplug, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 30/47] cpus: hax: register/unregister thread with RCU, exit loop on unplug, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 31/47] cpus: kvm: unregister thread with RCU, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 26/47] ivshmem: Don't update non-existent MSI routes, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 35/47] cpus: join thread when removing a vCPU, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 34/47] cpus: hvf: unregister thread with RCU, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 33/47] cpus: tcg: unregister thread with RCU, fix exiting of loop on unplug, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 36/47] memfd: add error argument, instead of perror(), Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 38/47] memfd: add hugetlbsize argument, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 37/47] memfd: add hugetlb support,
Paolo Bonzini <=
- [Qemu-devel] [PULL 40/47] tests: keep compiling failing vhost-user tests, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 44/47] Add the Windows Hypervisor Platform accelerator., Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 43/47] tests/test-filter-redirector: move close(), Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 39/47] Add memfd based hostmem, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 41/47] vhost-user-test: make read-guest-mem setup its own qemu, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 42/47] tests: use memfd in vhost-user-test, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 45/47] Add the WHPX vcpu API, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 47/47] Add the WHPX acceleration enlightenments, Paolo Bonzini, 2018/02/05
- [Qemu-devel] [PULL 46/47] Introduce the WHPX impl, Paolo Bonzini, 2018/02/05
- Re: [Qemu-devel] [PULL 00/47] Misc patches for 2018-02-05, Peter Maydell, 2018/02/06