Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1235528lqd; Thu, 25 Apr 2024 09:23:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQxNaBo6/ByL34CHV23C+S9Aq3YD0dqowiJJkzVieQne/GU5SFhdQNqltm84ArQ/o8nDK+/qVESqJJR3DztItt9ec414daqnn+yk6eYA== X-Google-Smtp-Source: AGHT+IH0pWIZR0CQ9pfNH5KwxUFksVWZeLIVycmBUSKpPcEdFzqH51Q9epj3vhHT7t+fdIbC+Mgg X-Received: by 2002:a17:906:2544:b0:a58:9485:3156 with SMTP id j4-20020a170906254400b00a5894853156mr146157ejb.50.1714062183279; Thu, 25 Apr 2024 09:23:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714062183; cv=pass; d=google.com; s=arc-20160816; b=f+N0ObZHU6DzSJ4MS4tgiioZBU1KqETKMC1VmYVS/6d6QCJ1xEy0T7Leq+gwRjy04x EeWHIHSFENt64pakX9vhd27U9/CdaBOea/u5h3sycOsPta5tLETXvzYRlyCMgXnNe+5o J3ohVg7uSkkUF1Gu46Gwy/TqOp8c8KGnip8EXkxN3Df9rCZJCgXdHZSoWsGzRrG5n4BN 0VLjuMEtom+b+uzr+PbvSkUt2lXsiDHTlvoN4Bk2egfvx5Q+KVBS8BNxwsywsXcyx8Au Dl82wk+PefVg7TN96wrxRK2ZWp3FWvWVyeygbSYF2K3otennVdBDW5Pr3bF2WBlVe7dv TUeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=tZwpXS/k0DYed9wD5OBUEJ5ypdpSnZbheBH2rdFMtPA=; fh=PL5AicnrypCBXMmdqGcVYkQ08nMgrv8lvdr2K74A2qY=; b=l/I8FpsZ2rr2zEME6CgHodZfj9DZi9L8JZ8C/zrPu0kly+EcwoTucfGcB5UzLCTn3j 8zqL09gYV8ZGNFknwvGDV0J865qFA9bfluqykYaRri2FpUvI0rT6zgYmYpYC+ABDcgBW o7eoJMShsqmE+4ZN98M/V64fsf78F6pkTZJ/ca8AMiw7AW31j7x7C1Y25iuB5SLb3xlt 5IGNh/HnCc0B42bS4KO+NCUk+UOeuur4MyTh1j7T+g2kMmQW07M/QLXMLf8LMQPmxF9A Mpx1kzn8An5/rSzfn0Ik17liUdcoVL2blh/yGkXWDDqedkEhTD8/tIAjdnbYoXZN7o/z FZHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=bTW2y76Y; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-158889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ce10-20020a170906b24a00b00a588fa9a2c5si2666314ejb.328.2024.04.25.09.23.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 09:23:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=bTW2y76Y; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-158889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D547E1F23ABA for ; Thu, 25 Apr 2024 16:23:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5639114D70A; Thu, 25 Apr 2024 16:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bTW2y76Y" Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1CD514D6F6 for ; Thu, 25 Apr 2024 16:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714062150; cv=none; b=kFUkumIYpynsXKQDSGsk8Gfozl3LEEqMXFgL8Xgx4eTau5MqDecwaW6n5sw4L/F+DkSnInUJgeqnhVGuVYNLeo9wivlZPk40FVg7iNwfeQBsYUKorFnXHzcJhFTqYjm20MqMAi0e5NMXPaMSmbduN4tjEI9WW8HzMwzc+hDAlZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714062150; c=relaxed/simple; bh=MDAUkdPnGzKG6chVud66+86ptfSgJ9KB44HVfsQFna8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k4vTgvLqRFkkbzX8A1DZ+Otif4i8xeJcRWH6MdVXrzhaIjvpPXEeSQLvt3syBVN1hNg2trd2+FMwAScbqA0wlFsMh13A0WaQ66ju+d+7+aReNtuIgLAbdBVwSDlrA7H6TNbPDJX67js6qadvcFHyOK7+lFKhAD8dhLvJHFukNf0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bTW2y76Y; arc=none smtp.client-ip=209.85.166.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-io1-f47.google.com with SMTP id ca18e2360f4ac-7d6b362115eso8732439f.0 for ; Thu, 25 Apr 2024 09:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1714062148; x=1714666948; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=tZwpXS/k0DYed9wD5OBUEJ5ypdpSnZbheBH2rdFMtPA=; b=bTW2y76YgHaHc6KB1MhvC43eovk1JFB7R42GEEGwApT83OWEkcKfjVabJ7hyn1Ynp4 qJ7pNAz8/i958EUH0F77Z/ph+LeZvTa6ubMMyFG1THOi28/zeaGWwtAPDfz1DiGvDTg8 23QFIGZ8H8MnIu9Q6nTps/dMHb/bierZgVkYE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714062148; x=1714666948; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tZwpXS/k0DYed9wD5OBUEJ5ypdpSnZbheBH2rdFMtPA=; b=VUxdnVgUQxwLCPGGc03oEw479hvY8D4uH5aXoi9TSwODR7Z7PCt/M71aBxaE7O5G2d wI61Bt2iKzDHKwW+wJJRvBdaL6WLtz1GiaK9Bwvn+vvYA655Y5mXVzRiUwVPIvOjSd/E a8vfEw2g+DwjaUYvDInEi9WHto1ZUU28CIkoVlLCHphX/DPegeuINk8byo1C4byzFhBb X+BXPYvrz+7HS91F3HAp5V2oI+n8JEuiO4p3PgrafTtDKkPYKPlBC5k93ruvSDaxQiOw wVgnbjGTK0oZWaqNRoZhPbZQByKKrKqwyNIpF5xV6eglRYl/JYc4o8l5RAZvveJSWvUS QD9w== X-Forwarded-Encrypted: i=1; AJvYcCVKI/A09PhAUlH1IBZ1GAevkrJrHCea8HlS1N1Oc62u2Clv4h8TmsnAVcDLKkXMV5jyWTQbSoxbvYvJTdbUkcNi6JZ6XFanBOgJUNSU X-Gm-Message-State: AOJu0Ywz18oL3eKrjwrf71P1Peymg6/TA3jjgrJeOujQO3BgITZljaX0 VMWfbXBFnLIP9iItFKPWm6dTjEvhUDwMBLNvnQfIXJTTmLn63gZWvdLK2WgoZRE= X-Received: by 2002:a6b:ea07:0:b0:7da:cdf3:7bec with SMTP id m7-20020a6bea07000000b007dacdf37becmr160971ioc.1.1714062147803; Thu, 25 Apr 2024 09:22:27 -0700 (PDT) Received: from [192.168.43.82] ([223.185.79.208]) by smtp.gmail.com with ESMTPSA id m2-20020a638c02000000b005e857e39b10sm13196097pgd.56.2024.04.25.09.22.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Apr 2024 09:22:27 -0700 (PDT) Message-ID: <763ee03a-817d-4833-b42f-e5b4bd25dc7f@linuxfoundation.org> Date: Thu, 25 Apr 2024 10:22:11 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v13 25/35] KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2 To: Sean Christopherson Cc: Dan Carpenter , Shuah Khan , Greg Kroah-Hartman , Paolo Bonzini , Marc Zyngier , Oliver Upton , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , "Matthew Wilcox (Oracle)" , Andrew Morton , 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" , Naresh Kamboju , Anders Roxell , Benjamin Copeland , Shuah Khan References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-26-seanjc@google.com> <69ae0694-8ca3-402c-b864-99b500b24f5d@moroto.mountain> <3848a9ad-07aa-48da-a2b7-264c4a990b5b@linuxfoundation.org> Content-Language: en-US From: Shuah Khan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/25/24 09:09, Sean Christopherson wrote: > On Thu, Apr 25, 2024, Shuah Khan wrote: >> On 4/25/24 08:12, Dan Carpenter wrote: >>> On Fri, Oct 27, 2023 at 11:22:07AM -0700, Sean Christopherson wrote: >>>> Use KVM_SET_USER_MEMORY_REGION2 throughout KVM's selftests library so that >>>> support for guest private memory can be added without needing an entirely >>>> separate set of helpers. >>>> >>>> Note, this obviously makes selftests backwards-incompatible with older KVM >>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>>> versions from this point forward. >>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >>> >>> Is there a way we could disable the tests on older kernels instead of >>> making them fail? Check uname or something? There is probably a >>> standard way to do this... It's these tests which fail. >> >> They shouldn't fail - the tests should be skipped on older kernels. > > Ah, that makes sense. Except for a few outliers that aren't all that interesting, > all KVM selftests create memslots, so I'm tempted to just make it a hard requirement > to spare us headache, e.g. > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index b2262b5fad9e..4b2038b1f11f 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -2306,6 +2306,9 @@ void __attribute((constructor)) kvm_selftest_init(void) > /* Tell stdout not to buffer its content. */ > setbuf(stdout, NULL); > > + __TEST_REQUIRE(kvm_has_cap(KVM_CAP_USER_MEMORY2), > + "KVM selftests from v6.8+ require KVM_SET_USER_MEMORY_REGION2"); > + > kvm_selftest_arch_init(); > } > > -- > > but it's also easy enough to be more precise and skip only those that actually > create memslots. This is approach is what is recommended in kselfest document. Rubn as many tests as possible and skip the ones that can't be run due to unmet dependencies. > > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index b2262b5fad9e..b21152adf448 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -944,6 +944,9 @@ int __vm_set_user_memory_region2(struct kvm_vm *vm, uint32_t slot, uint32_t flag > .guest_memfd_offset = guest_memfd_offset, > }; > > + __TEST_REQUIRE(kvm_has_cap(KVM_CAP_USER_MEMORY2), > + "KVM selftests from v6.8+ require KVM_SET_USER_MEMORY_REGION2"); > + > return ioctl(vm->fd, KVM_SET_USER_MEMORY_REGION2, ®ion); > } > > @@ -970,6 +973,9 @@ void vm_mem_add(struct kvm_vm *vm, enum vm_mem_backing_src_type src_type, > size_t mem_size = npages * vm->page_size; > size_t alignment; > > + __TEST_REQUIRE(kvm_has_cap(KVM_CAP_USER_MEMORY2), > + "KVM selftests from v6.8+ require KVM_SET_USER_MEMORY_REGION2"); > + > TEST_ASSERT(vm_adjust_num_guest_pages(vm->mode, npages) == npages, > "Number of guest pages is not compatible with the host. " > "Try npages=%d", vm_adjust_num_guest_pages(vm->mode, npages)); > -- thanks, -- Shuah