Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2159439rdf; Mon, 6 Nov 2023 06:27:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJvAmkiM09iGnHAvwzGPVpGWORSh7GInC2xhLJE4K40QC5i9p89cXkqjzayu7SNlhJS1Qm X-Received: by 2002:a05:6a21:7185:b0:180:def9:20e1 with SMTP id wq5-20020a056a21718500b00180def920e1mr26642357pzb.22.1699280873326; Mon, 06 Nov 2023 06:27:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699280873; cv=none; d=google.com; s=arc-20160816; b=fp0q7CG/1wt5LqJfYyJbcrEywzR8KehxzOwIqEN9JN/ttYIPH/zYv5fxJy/DiEXE1l olL9NPhoSH70zj+0D7UH4f8ERrpiKlmya66YLvkjRW91PD4fLjwnuhpqkqTsZw9ivdSf /ibpdQbAJh0ZwnVdPHGi/aO3xLjkoH05e/xccT6Eu79Vzgs65DYAxY8cgdil8eRoxnx8 Bv77Gygb4raS1vmJqpeOak64H4WBp+6lDZU79yVy3cNxrDpUgho+rTz/L7/JFPM+HHmt e1/1PEdrcXHgKsLn3AJxRc+fT+XDtC4Jf8LawNdJs+dmRnq1xW9kZaRlw9yAfR+WyPXV VlkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:autocrypt :from:references:cc:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=EQEY0yLpyjybbnIksSuJ4Z5QD7aeTkworRxg3pV8noA=; fh=xeYfUkXmrbmJuvT7HIyFwcfGyAI14QUDqFE5ILCFqbU=; b=l7upRDHtGR3jKgLvqB6he+DMInOP9DWZ64Qo7EBoFB0iNTl2DK4qMnAuL+bPI5t+WH R3kOJTd4yGcV6QVvamZ9Cr4y7Lj7v7hiFhTSkra37kmi4AN/PWU+sRXqgVfdjvPUGvdR AHmlvxMMobiFFYqwG7boSKzrxdQtf+hev6C9ZBkw7dZXHGGiI/E9rFskdTMksLjobu7Y 3iZQXP/ro2dldJ3E0QE7NLBVclF97aO3Fbg9ItO6C5GfMBb4iCd4NqpJPMdQtUHjhp1R /Xak1IPb4cjFxg+Bt/6aWkn/mG1H95DtL6Kzx+ZVklNcq2lnUct1mufGlW9N7Sqt5icn J4Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CZbuNZFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id by20-20020a056a02059400b005b99bfe3301si8997680pgb.462.2023.11.06.06.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:27:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CZbuNZFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 01228803A51C; Mon, 6 Nov 2023 06:27:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231685AbjKFO1j (ORCPT + 99 others); Mon, 6 Nov 2023 09:27:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbjKFO1i (ORCPT ); Mon, 6 Nov 2023 09:27:38 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E89100 for ; Mon, 6 Nov 2023 06:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699280811; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=EQEY0yLpyjybbnIksSuJ4Z5QD7aeTkworRxg3pV8noA=; b=CZbuNZFplBMR7BrTUPa4pK7U+nftOAf1HDw9V2kHPyncpkIrSPeXuy4KmYpqcCMhRUJauc nawCVH0FBKTM2rx2k0nWTSH16m6QlbaGTSl4iJmAL1fQk/Qi+eseLVcHMEsjP//v7IZoKn zphHSHFGR0SNYFZsSTMjR8pxnXi3GJA= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-apziV4U5NlK1sBW3VuyduQ-1; Mon, 06 Nov 2023 09:26:49 -0500 X-MC-Unique: apziV4U5NlK1sBW3VuyduQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2c6f3cd892cso44722641fa.3 for ; Mon, 06 Nov 2023 06:26:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699280808; x=1699885608; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EQEY0yLpyjybbnIksSuJ4Z5QD7aeTkworRxg3pV8noA=; b=FGisMgDVb3YQ8incgQy6Wd6XT6KD9rLgYmeI180475ZB4yW0P+j7GkDa+K2aZwL4nP nc7bxpPXkX3c6waQzfgkjWB7TUdsYH94ht0YO+akuGrB5KHQnoG+KIIqxsxGkQmBewHi SsSHK9Zdfry7Wycm1e6OjS/UCl+NEUVcVAxcMgZeX81dQH0hcpQYc/hYGEl4+0VfA/zz W6zAxuvq8JE02CeVlmLoKFy1LMBSNASof5ALrbzAbQvwF6itmFtwQwDUAX27lBLvorP/ ODh/7JlDj0jggMAsCpoUnnxdbiLrVTmlNfWZge6/OZQXa4XzYzLH3pwCOvSqpAMa9MXm 7Trg== X-Gm-Message-State: AOJu0YygynsDyPmNlnM8PcRr2zN4XFfnJSoD2uXsrTcH1Ti1sjhjWOqq Udm58MB2+Q1Nn9WdORMft6Yu9ek/FOllmdaqaLx00phzZM7ISZ53s8/q2xbfJ+0tnLa/SnFiePx VdSzZ4AehT7jWs6XX6SoNdSn1 X-Received: by 2002:a2e:b953:0:b0:2c5:2d02:ed14 with SMTP id 19-20020a2eb953000000b002c52d02ed14mr21572252ljs.23.1699280808180; Mon, 06 Nov 2023 06:26:48 -0800 (PST) X-Received: by 2002:a2e:b953:0:b0:2c5:2d02:ed14 with SMTP id 19-20020a2eb953000000b002c52d02ed14mr21572194ljs.23.1699280807790; Mon, 06 Nov 2023 06:26:47 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.googlemail.com with ESMTPSA id l41-20020a05600c1d2900b004083a105f27sm12541348wms.26.2023.11.06.06.26.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Nov 2023 06:26:47 -0800 (PST) Message-ID: Date: Mon, 6 Nov 2023 15:26:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 31/34] KVM: selftests: Expand set_memory_region_test to validate guest_memfd() Content-Language: en-US To: 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?B?TWlja2HDq2wgU2FsYcO8?= =?UTF-8?Q?n?= , Vlastimil Babka , Vishal Annapurve , Ackerley Tng , Maciej Szmigiero , David Hildenbrand , Quentin Perret , Michael Roth , Wang , Liam Merwick , Isaku Yamahata , "Kirill A. Shutemov" References: <20231105163040.14904-1-pbonzini@redhat.com> <20231105163040.14904-32-pbonzini@redhat.com> From: Paolo Bonzini Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZun3jh+U6Z9wNGLKQ0kSFyjN38gMqU1SfP+TUNQepFHb/Gc0E2 CxXPkIBTvYY+ZPkoTh5xF9oS1jqI8iRLzouzF8yXs3QjQIZ2SfuCxSVwlV65jotcjD2FTN04 hVopm9llFijNZpVIOGUTqzM4U55sdsCcZUluWM6x4HSOdw5F5Utxfp1wOjD/v92Lrax0hjiX DResHSt48q+8FrZzY+AUbkUS+Jm34qjswdrgsC5uxeVcLkBgWLmov2kMaMROT0YmFY6A3m1S P/kXmHDXxhe23gKb3dgwxUTpENDBGcfEzrzilWueOeUWiOcWuFOed/C3SyijBx3Av/lbCsHU Vx6pMycNTdzU1BuAroB+Y3mNEuW56Yd44jlInzG2UOwt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+6MlSSJMOFnYUCCL77bucx9uImI5nX24PIlqT+zasVEEVGSRF m8dgkcJDB7Tps0IkNrUi4yof3B3shR+vMY3i3Ip0e41zKx0CvlAhMOo6otaHmcxr35sWq1Jk tLkbn3wG+fPQCVudJJECvVQ//UAthSSEklA50QtD2sBkmQ14ZryEyTHQ+E42K3j2IUmOLriF dNr9NvE1QGmGyIcbw2NIVEBOK/GWxkS5+dmxM2iD4Jdaf2nSn3jlHjEXoPwpMs0KZsgdU0pP JQzMUMwmB1wM8JxovFlPYrhNT9MAEQEAAcLBMwQYAQIACQUCVEJx7gIbDAAKCRB+FRAMzTZp sadRDqCctLmYICZu4GSnie4lKXl+HqlLanpVMOoFNnWs9oRP47MbE2wv8OaYh5pNR9VVgyhD OG0AU7oidG36OeUlrFDTfnPYYSF/mPCxHttosyt8O5kabxnIPv2URuAxDByz+iVbL+RjKaGM GDph56ZTswlx75nZVtIukqzLAQ5fa8OALSGum0cFi4ptZUOhDNz1onz61klD6z3MODi0sBZN Aj6guB2L/+2ZwElZEeRBERRd/uommlYuToAXfNRdUwrwl9gRMiA0WSyTb190zneRRDfpSK5d usXnM/O+kr3Dm+Ui+UioPf6wgbn3T0o6I5BhVhs4h4hWmIW7iNhPjX1iybXfmb1gAFfjtHfL xRUr64svXpyfJMScIQtBAm0ihWPltXkyITA92ngCmPdHa6M1hMh4RDX+Jf1fiWubzp1voAg0 JBrdmNZSQDz0iKmSrx8xkoXYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: <20231105163040.14904-32-pbonzini@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 06:27:50 -0800 (PST) On 11/5/23 17:30, Paolo Bonzini wrote: > From: Chao Peng > > Expand set_memory_region_test to exercise various positive and negative > testcases for private memory. > > - Non-guest_memfd() file descriptor for private memory > - guest_memfd() from different VM > - Overlapping bindings > - Unaligned bindings This needs a small fixup: diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index e4d2cd9218b2..1b58f943562f 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -819,6 +819,7 @@ static inline struct kvm_vm *vm_create_barebones(void) return ____vm_create(VM_SHAPE_DEFAULT); } +#ifdef __x86_64__ static inline struct kvm_vm *vm_create_barebones_protected_vm(void) { const struct vm_shape shape = { @@ -828,6 +829,7 @@ static inline struct kvm_vm *vm_create_barebones_protected_vm(void) return ____vm_create(shape); } +#endif static inline struct kvm_vm *vm_create(uint32_t nr_runnable_vcpus) { diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index 1891774eb6d4..302c7a46955b 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -386,6 +386,7 @@ static void test_add_max_memory_regions(void) } +#ifdef __x86_64__ static void test_invalid_guest_memfd(struct kvm_vm *vm, int memfd, size_t offset, const char *msg) { @@ -476,14 +477,13 @@ static void test_add_overlapping_private_memory_regions(void) close(memfd); kvm_vm_free(vm); } +#endif int main(int argc, char *argv[]) { #ifdef __x86_64__ int i, loops; -#endif -#ifdef __x86_64__ /* * FIXME: the zero-memslot test fails on aarch64 and s390x because * KVM_RUN fails with ENOEXEC or EFAULT. @@ -493,6 +493,7 @@ int main(int argc, char *argv[]) test_add_max_memory_regions(); +#ifdef __x86_64__ if (kvm_has_cap(KVM_CAP_GUEST_MEMFD) && (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_VM))) { test_add_private_memory_region(); @@ -501,7 +502,6 @@ int main(int argc, char *argv[]) pr_info("Skipping tests for KVM_MEM_GUEST_MEMFD memory regions\n"); } -#ifdef __x86_64__ if (argc > 1) loops = atoi_positive("Number of iterations", argv[1]); else in order to compile successfully on non-x86 platforms.