From patchwork Fri Oct 27 18:22:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13438960 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B243C25B70 for ; Fri, 27 Oct 2023 18:23:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E02B80029; Fri, 27 Oct 2023 14:23:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 891F280018; Fri, 27 Oct 2023 14:23:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 696D780029; Fri, 27 Oct 2023 14:23:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 51F8880018 for ; Fri, 27 Oct 2023 14:23:36 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2F617A0749 for ; Fri, 27 Oct 2023 18:23:36 +0000 (UTC) X-FDA: 81392064432.22.587B084 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf14.hostedemail.com (Postfix) with ESMTP id 619BC100019 for ; Fri, 27 Oct 2023 18:23:34 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3okaymEj; spf=pass (imf14.hostedemail.com: domain of 3JQA8ZQYKCEY0mivrkowwotm.kwutqv25-uus3iks.wzo@flex--seanjc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3JQA8ZQYKCEY0mivrkowwotm.kwutqv25-uus3iks.wzo@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698431014; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Gf3qZUfKxr1l5xs4a4PCSuBn/K/kT1FM/O66ERGfDAo=; b=hAt6x1Gs5HrWikK6d/jnQDoqjNYRLBH9wHWMTQihHCuvBq8p+1TjsH/HMfwxv+/3mTWDmm 7wsoaBKAW3pxffskSkb+lc9Q6ZRMICm/GwmctS/k1FpePOb81C8GyyY/lxCPMkmu+y0weT PHiRnzzNON6bRFHeNGZh10Z8XJJ4Taw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698431014; a=rsa-sha256; cv=none; b=S7w1rz+M41NZsnSYq0bTPFhu8Mqz/PrN/QWdmqXPvAfV6wcz9Zkp3sd1GrJkSNqGAAwEkn EchLMIDDCV3KEyUqF72STA/8YkteaGVa4HdTsAZ9aEGCpUFgjnb2dUvTOMv6VP8ko/0CRX VD1oGMNxXlNf4dptGEO38iQx56oQ+k0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=3okaymEj; spf=pass (imf14.hostedemail.com: domain of 3JQA8ZQYKCEY0mivrkowwotm.kwutqv25-uus3iks.wzo@flex--seanjc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3JQA8ZQYKCEY0mivrkowwotm.kwutqv25-uus3iks.wzo@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-da0631f977bso1909293276.2 for ; Fri, 27 Oct 2023 11:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698431013; x=1699035813; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=Gf3qZUfKxr1l5xs4a4PCSuBn/K/kT1FM/O66ERGfDAo=; b=3okaymEjoP8D37VMkv9pIDuv05UiXNOAsngo5I3SlcP9++HIIIcSMWIyp9EJe6ITlC YdcmQIfb3MzP+25r9m+JAIpmkIa6ZSNe7MO0tT0/qD7MvosS8eb1DiJfdC8yACiggKXc P/xfdji1S5K6xTJVOTgszDxYHj/jW2uHKCDrJaAxKKHnnm6l5rWh0wKIn8v1/mcO2bpo VjAEuumgPLiQCF+J7OTfebUagfQf71iKyAgmivS9bu5Hsks3+j6/0KTQeOBN05QO7NkM X/r7ik4auYpo6qrWCb4KMHEK3gG4jLg+PDxCBcfadE5kUGaanUPtcqJz10WTEDqltPQA hNog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698431013; x=1699035813; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Gf3qZUfKxr1l5xs4a4PCSuBn/K/kT1FM/O66ERGfDAo=; b=nOHDOSP3nCPRBtcYOM8vbCWwnL4Veh7chA8/47DD7RvjZgD7SIPzNPk7E+rBqHGTqz UUmZmeCZbWBxgqfgcix3GR8pYEy8jFnluTI0Lb5G2Wo4qK0iwJBb0SXfbp1mL1bUMd0v FznDP5qC9BoMNfAddcUL8W0kVwQRqqEOiSiew/SPsAjIwfvteODCrXZi9JqW/8W0XiE3 GFZPhm44FbDWu2+iXaQ66nZmaKEqrAPt3MXEND9JGysAvZMexroNQeYyQWkFFDnHK9HP JqRnmZ9L1EX8wo2/1/aozrnTEFTw6oF295K4EP7SchT7kfovzYgw/iL0vaYNTycP6w0b NWNQ== X-Gm-Message-State: AOJu0Yx/3RC4ZGI0YMbdoTDvOBl566WsdF4ZCNvcQ0+yJqF84Ghyqt9D 0ZrXlTimmfmlQ5O2p9VJ4T0T9e6mvrw= X-Google-Smtp-Source: AGHT+IFvLwrndU5RN7JLgZaUSfmAls7MFUJfuK8Cz4IhpSWC48U7qmoJK4uE/MrHKdWeSCjIUJubQh1tXXM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:aa47:0:b0:d9a:d272:ee58 with SMTP id s65-20020a25aa47000000b00d9ad272ee58mr68414ybi.9.1698431013458; Fri, 27 Oct 2023 11:23:33 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 27 Oct 2023 11:22:16 -0700 In-Reply-To: <20231027182217.3615211-1-seanjc@google.com> Mime-Version: 1.0 References: <20231027182217.3615211-1-seanjc@google.com> X-Mailer: git-send-email 2.42.0.820.g83a721a137-goog Message-ID: <20231027182217.3615211-35-seanjc@google.com> Subject: [PATCH v13 34/35] KVM: selftests: Add basic selftest for guest_memfd() From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Sean Christopherson , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Xu Yilun , Chao Peng , Fuad Tabba , Jarkko Sakkinen , Anish Moorthy , David Matlack , Yu Zhang , Isaku Yamahata , " =?utf-8?q?Micka=C3=ABl_Sala?= =?utf-8?q?=C3=BCn?= " , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A . Shutemov" X-Rspamd-Queue-Id: 619BC100019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: edbb4x3exgph4hrxfhki3wrrzky9t5ty X-HE-Tag: 1698431014-304913 X-HE-Meta: U2FsdGVkX1/LcYR6Uw11QRgPW5r7t1jWf50dXYoZ3Lk7keTxnljkIc8t/cz6jXMLUrKWyUDFk+Fypmvs5Imqz5WkzPpzeBJgB1h1ySFti7SnbCUhaAmbrpddAqLSzKhoWmMcQgCSASGwCbydrJmXSljThmRSsB758iMSs5rr2oQ+scf8SjDsHEfYFPC4oNCVvEplcAfAKUNajbk8mCWMMYebO/BP6uVRkd7+vuuXeGxwe0tv8UTUsiyiQ9btutBuypRwi7lFiriCrHhh9qTHx/eV07jJnXPehhj9ceS8QAYsV37g8L6Ff8NLbpX9cRKIrwR/xqndG4NWk0ynbzfYdV76lRY9ZCu66/enH4g+8NQSy4KPh76ml5aSRU/+UuEJUjdXBaFM49a/mCqpzjvdScxIuyJ1QRj363j/zyPJHS+r5Mnr5VqwOTetbXc2bqANLJfwLOmu6+Vj71F1sLmWPk1FdAWTMjy5T5js5fSDdqPzeQVNzXrRIX2b/a81wG7QZJpy4jn9FK7SMN+TCK5UsSQCL7MhRj41gCaqzP7PKx1e2r3TKj3y4zZVYIOh70lfx9fLsb34A0XeU6k5EJKfuMoyeJ+BAgBEM8axx5Vpql1rgYTCxgMJM4DyhwGhCltMc30FPSdUVq7qhZo8iz45ih9gWWryqAMsV4UT6nTLx+4gx5wuaxH4+eJpIU4O98T5nb/sZ6t6HN+M+klecuUvd1KfCnz0NDz9I6sbR/tsI+SjhBB0pX5aRSF12lqUS2reTrLTvX+n0oPBb8OoHIqTGRGcAN6Rgq6cfsN/xuIcZ0ZhZOKkj3AgH8wmoV+4rywNqRlUvvUtV5veB5724l/8e3Uh/vdZ19NkfZrCyGPjQTmtqGqh+Iv71XIyybKho34jerncfe5m738991fJ0vmKDdHGxs3zLLn0mjCxzZt998l9XaizbNjecI12xjKtR8CLah59CXCwwZFmsJuApPh RYZSuMko Ez8QArlK526Y29XN7Ye6JpW98gkNNq5jQdyqjr/+q9dlx+R84tR3kucGQYyaX+qkSMzHdjJeQAij0whDVGVUZTqQP6pOYBju2qDPs4UVYuEG7zWA+X06Z4rPDizWo0BlE7cJ0QfW7kFLSFFPfuLqcNlQdhh8IGtBDu2T0QcpqCQJs6c6wtsCI70iy9hPfQx4oc5cYbVtJL0IKYCb9rSgccIsVrPwNoIsTJ7N+9f1LlJibdzF8NeQgUG4cIvHeggz3J6jhRMQALbPXPqyDVRzrv1AoMGQv0OoNxmk9P8ZBmKrM0lC93rLZ6TUeg9a539koLjc8FcUx/TPH4DL6vW/+f90xhfApbFvTdVwNRx/ID7Khget3AIUqT23lfjEeoSUrp+tiTO6+toLeX/y6UCY9fvu0s6YuVUs3O8Kzn7csPzWioXy9hvnIvOz6H6g2GvH9DeLqyD6zbAqLeXr5dJv5dWgFQXL6zYYW0ieDaszCOno95A/Pg1A1as4iB0TNdDFQNz18DqqNoDp/DEfERP+5RODq6+UMPcoZNKi5ShpqfI9ZOmsjShXWkzS3f/2RullBJjEwgpUAkJmR8+/jPU2cs+K/zqBwyx2e4gSmKKFirp3Tx4j2NdkxP8ShyX5XMbgFeWCAYM0qjCdIjT/YXuP2LUKoulqGrEAncbSeWnwXPuS06XCGqrheVyQTXGD1EDZFn2EOE71lpjIvmJ9cBSeEGo9UG3b5iIR9o17S4iQR+q64Ks6Y550WYoZASayiWbIrWuiciA4PmF/CGg71s1CUHyaoCk0UHX6hl3w/qrNF7dXN2YogPNSqqN1Deu/FBzbWsrT15MoyoviunMnyK1nZHS8uHpch6oMO07AHv1JDieC0GN8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Chao Peng Add a selftest to verify the basic functionality of guest_memfd(): + file descriptor created with the guest_memfd() ioctl does not allow read/write/mmap operations + file size and block size as returned from fstat are as expected + fallocate on the fd checks that offset/length on fallocate(FALLOC_FL_PUNCH_HOLE) should be page aligned + invalid inputs (misaligned size, invalid flags) are rejected + file size and inode are unique (the innocuous-sounding anon_inode_getfile() backs all files with a single inode...) Signed-off-by: Chao Peng Co-developed-by: Ackerley Tng Signed-off-by: Ackerley Tng Co-developed-by: Paolo Bonzini Signed-off-by: Paolo Bonzini Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/Makefile | 1 + .../testing/selftests/kvm/guest_memfd_test.c | 221 ++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 tools/testing/selftests/kvm/guest_memfd_test.c diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index b709a52d5cdb..2b1ef809d73a 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -124,6 +124,7 @@ TEST_GEN_PROGS_x86_64 += access_tracking_perf_test TEST_GEN_PROGS_x86_64 += demand_paging_test TEST_GEN_PROGS_x86_64 += dirty_log_test TEST_GEN_PROGS_x86_64 += dirty_log_perf_test +TEST_GEN_PROGS_x86_64 += guest_memfd_test TEST_GEN_PROGS_x86_64 += guest_print_test TEST_GEN_PROGS_x86_64 += hardware_disable_test TEST_GEN_PROGS_x86_64 += kvm_create_max_vcpus diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c new file mode 100644 index 000000000000..c15de9852316 --- /dev/null +++ b/tools/testing/selftests/kvm/guest_memfd_test.c @@ -0,0 +1,221 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright Intel Corporation, 2023 + * + * Author: Chao Peng + */ + +#define _GNU_SOURCE +#include "test_util.h" +#include "kvm_util_base.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static void test_file_read_write(int fd) +{ + char buf[64]; + + TEST_ASSERT(read(fd, buf, sizeof(buf)) < 0, + "read on a guest_mem fd should fail"); + TEST_ASSERT(write(fd, buf, sizeof(buf)) < 0, + "write on a guest_mem fd should fail"); + TEST_ASSERT(pread(fd, buf, sizeof(buf), 0) < 0, + "pread on a guest_mem fd should fail"); + TEST_ASSERT(pwrite(fd, buf, sizeof(buf), 0) < 0, + "pwrite on a guest_mem fd should fail"); +} + +static void test_mmap(int fd, size_t page_size) +{ + char *mem; + + mem = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + TEST_ASSERT_EQ(mem, MAP_FAILED); +} + +static void test_file_size(int fd, size_t page_size, size_t total_size) +{ + struct stat sb; + int ret; + + ret = fstat(fd, &sb); + TEST_ASSERT(!ret, "fstat should succeed"); + TEST_ASSERT_EQ(sb.st_size, total_size); + TEST_ASSERT_EQ(sb.st_blksize, page_size); +} + +static void test_fallocate(int fd, size_t page_size, size_t total_size) +{ + int ret; + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, total_size); + TEST_ASSERT(!ret, "fallocate with aligned offset and size should succeed"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + page_size - 1, page_size); + TEST_ASSERT(ret, "fallocate with unaligned offset should fail"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, total_size, page_size); + TEST_ASSERT(ret, "fallocate beginning at total_size should fail"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, total_size + page_size, page_size); + TEST_ASSERT(ret, "fallocate beginning after total_size should fail"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + total_size, page_size); + TEST_ASSERT(!ret, "fallocate(PUNCH_HOLE) at total_size should succeed"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + total_size + page_size, page_size); + TEST_ASSERT(!ret, "fallocate(PUNCH_HOLE) after total_size should succeed"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + page_size, page_size - 1); + TEST_ASSERT(ret, "fallocate with unaligned size should fail"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + page_size, page_size); + TEST_ASSERT(!ret, "fallocate(PUNCH_HOLE) with aligned offset and size should succeed"); + + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE, page_size, page_size); + TEST_ASSERT(!ret, "fallocate to restore punched hole should succeed"); +} + +static void test_invalid_punch_hole(int fd, size_t page_size, size_t total_size) +{ + struct { + off_t offset; + off_t len; + } testcases[] = { + {0, 1}, + {0, page_size - 1}, + {0, page_size + 1}, + + {1, 1}, + {1, page_size - 1}, + {1, page_size}, + {1, page_size + 1}, + + {page_size, 1}, + {page_size, page_size - 1}, + {page_size, page_size + 1}, + }; + int ret, i; + + for (i = 0; i < ARRAY_SIZE(testcases); i++) { + ret = fallocate(fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, + testcases[i].offset, testcases[i].len); + TEST_ASSERT(ret == -1 && errno == EINVAL, + "PUNCH_HOLE with !PAGE_SIZE offset (%lx) and/or length (%lx) should fail", + testcases[i].offset, testcases[i].len); + } +} + +static void test_create_guest_memfd_invalid(struct kvm_vm *vm) +{ + uint64_t valid_flags = 0; + size_t page_size = getpagesize(); + uint64_t flag; + size_t size; + int fd; + + for (size = 1; size < page_size; size++) { + fd = __vm_create_guest_memfd(vm, size, 0); + TEST_ASSERT(fd == -1 && errno == EINVAL, + "guest_memfd() with non-page-aligned page size '0x%lx' should fail with EINVAL", + size); + } + + if (thp_configured()) { + for (size = page_size * 2; size < get_trans_hugepagesz(); size += page_size) { + fd = __vm_create_guest_memfd(vm, size, KVM_GUEST_MEMFD_ALLOW_HUGEPAGE); + TEST_ASSERT(fd == -1 && errno == EINVAL, + "guest_memfd() with non-hugepage-aligned page size '0x%lx' should fail with EINVAL", + size); + } + + valid_flags = KVM_GUEST_MEMFD_ALLOW_HUGEPAGE; + } + + for (flag = 1; flag; flag <<= 1) { + uint64_t bit; + + if (flag & valid_flags) + continue; + + fd = __vm_create_guest_memfd(vm, page_size, flag); + TEST_ASSERT(fd == -1 && errno == EINVAL, + "guest_memfd() with flag '0x%lx' should fail with EINVAL", + flag); + + for_each_set_bit(bit, &valid_flags, 64) { + fd = __vm_create_guest_memfd(vm, page_size, flag | BIT_ULL(bit)); + TEST_ASSERT(fd == -1 && errno == EINVAL, + "guest_memfd() with flags '0x%llx' should fail with EINVAL", + flag | BIT_ULL(bit)); + } + } +} + +static void test_create_guest_memfd_multiple(struct kvm_vm *vm) +{ + int fd1, fd2, ret; + struct stat st1, st2; + + fd1 = __vm_create_guest_memfd(vm, 4096, 0); + TEST_ASSERT(fd1 != -1, "memfd creation should succeed"); + + ret = fstat(fd1, &st1); + TEST_ASSERT(ret != -1, "memfd fstat should succeed"); + TEST_ASSERT(st1.st_size == 4096, "memfd st_size should match requested size"); + + fd2 = __vm_create_guest_memfd(vm, 8192, 0); + TEST_ASSERT(fd2 != -1, "memfd creation should succeed"); + + ret = fstat(fd2, &st2); + TEST_ASSERT(ret != -1, "memfd fstat should succeed"); + TEST_ASSERT(st2.st_size == 8192, "second memfd st_size should match requested size"); + + ret = fstat(fd1, &st1); + TEST_ASSERT(ret != -1, "memfd fstat should succeed"); + TEST_ASSERT(st1.st_size == 4096, "first memfd st_size should still match requested size"); + TEST_ASSERT(st1.st_ino != st2.st_ino, "different memfd should have different inode numbers"); +} + +int main(int argc, char *argv[]) +{ + size_t page_size; + size_t total_size; + int fd; + struct kvm_vm *vm; + + TEST_REQUIRE(kvm_has_cap(KVM_CAP_GUEST_MEMFD)); + + page_size = getpagesize(); + total_size = page_size * 4; + + vm = vm_create_barebones(); + + test_create_guest_memfd_invalid(vm); + test_create_guest_memfd_multiple(vm); + + fd = vm_create_guest_memfd(vm, total_size, 0); + + test_file_read_write(fd); + test_mmap(fd, page_size); + test_file_size(fd, page_size, total_size); + test_fallocate(fd, page_size, total_size); + test_invalid_punch_hole(fd, page_size, total_size); + + close(fd); +}