From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 696DAC001B0 for ; Mon, 7 Aug 2023 23:20:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: References:List-Owner; bh=U/JNBm+bghvDNInGsGHW4Wf6k5WCoqXQLCsoyyBiCQY=; b=0x2 OMZcBtJi35iwl8mnRSUtV97r8ss3kNXEOTYeDr4HIgE8rYPbAFAWqEK1Z6nDhh5QxdXlKMskB8h1V wly+ezbhhvTW4/UF276ZZMaPJljd7OouZJQQZ2coSP4UFM6Y/RO+01Dgl/MCV4l4UMDCmf3JZsbDh owbTQ8KfQIWcmk7HbtemRirqYJwxKvFb3kQ/abmuah38hJSa3Rz8OLYE/ZdBYijl8ZiY7TOX4ig2y 9itV3tju9IRcRD+Lzk0uUx0VSvvPBO2YvSGj6qF72mjPAtoAj+0zh9Vhv4uML4K58oiuOtN0Jmbdb ynocdFnzQ7sTkPkoEeVn3V1Rk/OiQuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qT9WP-001BvA-0n; Mon, 07 Aug 2023 23:20:21 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qT9WL-001Bt4-1n for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2023 23:20:18 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58473c4f629so58837527b3.1 for ; Mon, 07 Aug 2023 16:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691450416; x=1692055216; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date:from:to :cc:subject:date:message-id:reply-to; bh=1Ut/hDJ+qFMS0sDMssVLi/Qh1tossNoTViyk+Sv5I6I=; b=OnbGVA8IPnrsdTREsUm581mRdehgXJT0uL+ALPcn3gfxErJrXCtKmSomsOKaQATGMh f0VvgjqMIW5HLukSt/TZqta9FHSpbW8xuPg/WJY9Y8dBtzBXk68FxKvGTf0SBMt/xuPE yb72/yaLEWHxd2i86q/oL/iyLDDk998ORMSoUHaZduqRHpQmcSBeRXdyojnyjv3Pm4Gp 0hyU2N4jgt9pJV3/SHK5m7Gafo6teeA6CAaXNJJ1Z5NngK3Yas1VVpJwsDY8b342oTWb +N+E2aHGEdoYFXjyTrvdzsHzrQ8RpCJH9Ba/1//rKN61ZJdF3SLJ42ybI7Ydk3RiGWfT qyWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691450416; x=1692055216; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Ut/hDJ+qFMS0sDMssVLi/Qh1tossNoTViyk+Sv5I6I=; b=MXIXhXVckVNZg62EetAaTYJPgOqdDyoMeocXeMrdpAgPFeKEZYCxMnQcp12lB2gnT8 Z0tKsMfQrUqUTvf4SeUShn9s/k/QWTY/ud+39i9RqVzmN2MQuFCnIxIQ0bXfOfUJmu/N 2mi5BkqXX1in4JiSt0PkQTRgqzG3KuJVpjJeJo6/8ZvOY6Ax1iBwuQcEV9tQ8GoXMUEq pBuGKE11F9hMNkchCL48aM1ZUwhWegQkYNtQWv/mvCQVsCfd8nN8NtKxgqucv9xh93Ly mKIjr6lT4BXw34sy+qmwoSMvqI7BtOvH0V/J2IiWx9o6X+4kCdaGv33AV6shl0PslefH He8w== X-Gm-Message-State: AOJu0YxBRvMgydVZBEnA4qrvv3QH1pXjuPiK0qy402liJ/cTwhXKXAB5 Zn1ryuWeWF9B5jIUMG5X9FogUWxD853DrxqcLg== X-Google-Smtp-Source: AGHT+IGdVk9oJYWbSpXuFj0KYecexGvmGzQrsUIUE7DdG+7VjOx16xy0jF3toasrtnWqbigopnLRYvJP03sO+CW+ag== X-Received: from ackerleytng-ctop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:13f8]) (user=ackerleytng job=sendgmr) by 2002:a81:af45:0:b0:581:7b58:5e70 with SMTP id x5-20020a81af45000000b005817b585e70mr85942ywj.5.1691450416406; Mon, 07 Aug 2023 16:20:16 -0700 (PDT) Date: Mon, 07 Aug 2023 23:20:15 +0000 In-Reply-To: <20230718234512.1690985-29-seanjc@google.com> (message from Sean Christopherson on Tue, 18 Jul 2023 16:45:11 -0700) Mime-Version: 1.0 Message-ID: Subject: Re: [RFC PATCH v11 28/29] KVM: selftests: Add basic selftest for guest_memfd() From: Ackerley Tng To: Sean Christopherson Cc: pbonzini@redhat.com, maz@kernel.org, oliver.upton@linux.dev, chenhuacai@kernel.org, mpe@ellerman.id.au, anup@brainfault.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, seanjc@google.com, willy@infradead.org, akpm@linux-foundation.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, 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-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, chao.p.peng@linux.intel.com, tabba@google.com, jarkko@kernel.org, yu.c.zhang@linux.intel.com, vannapurve@google.com, mail@maciej.szmigiero.name, vbabka@suse.cz, david@redhat.com, qperret@google.com, michael.roth@amd.com, wei.w.wang@intel.com, liam.merwick@oracle.com, isaku.yamahata@gmail.com, kirill.shutemov@linux.intel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230807_162017_622413_34CF843F X-CRM114-Status: GOOD ( 11.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Sean Christopherson writes: > 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 > > > + > +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 at total_size should fail"); This should be 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"); > +} > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel