Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1183531lqd; Thu, 25 Apr 2024 08:10:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUrxuO24fDR9YvyZaHODGWsxC5SnZ6cslGE4TYzIsQ/lgxTJBPu+4dHnd1Md8SdwujiOtQF5SNnFOVRFjlsrqVASQ08fXqt0dtrFCgMyA== X-Google-Smtp-Source: AGHT+IGl2fOdi9foFZcV4zwgYHabJj/+Va7Rqo7pVTK00VIMfEgmUZ9or0/nvP7gnUKpYBAKnHKw X-Received: by 2002:ae9:f21a:0:b0:78d:67b4:7399 with SMTP id m26-20020ae9f21a000000b0078d67b47399mr5977270qkg.25.1714057808052; Thu, 25 Apr 2024 08:10:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714057808; cv=pass; d=google.com; s=arc-20160816; b=sPOW3wcuqGBPpTP+Cc6DgZXgEv1ROQv/64Huovw16uakj8QBMDbP5c4vJZRo3Khf/X pMJrYCJd1gVCAonzhOqSUQt4RzVDMy3flAKy3fNuAK8sLXgshKWAkBzx3lZcDP6uTVpC y50usaul+bC8eDYcjAEBNb78hE6EQYJvAfsVJDx/OzM7L1XW+7wZ0/rHrqnwk6c2ezb+ tRJ5tD2pbfrMuoCIIE88PiCsWRIgN56EHBT91rLwLot4F4HjheTBAF5I5jfesMaO9q+/ PYnlOqgXxSkIKjAHdnuDUHUrZEetsPbR6ZRJ4PkRWtvsF5GW7k1X0NAfgILHNTYlgfhl 1HdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=m1qzGW4ycfJBkwOtQag42BpB9F1dgLw6AsC1TpSQ/BE=; fh=TszLRhPC8WCUQHjp+f2eHBwwOlZAEvTjxVAr3ulFSC4=; b=jWEtZBCWo96gTUvkU1V16E97dUkabgStvXPl+W7ZbmAAyM/lsjtGF3n0werr4o2dqJ WFiWasCy9uE5yIGBUoZhK9WBZQWoGdbyxTxwSf3VUPBeYaURqh2rVOsVKtY6Ubdy9J3u 52+KTLOFhy68endzAP7U1HY9Z4EsJLWXbzLW13Fy92+mguQ+j3QDYssOHGbKG9GEAM+X 3gO6M6BKNcyK40wxS8ZCcol4gw0c7ixGJJuEWL0OWxNsOJ/Z4Qmv593l6pcv0sDG1/3U ruv3oMIWrVxcuDSH75KR6JS0vKpaq4s0qi9z8WU9i6A/PaPkaM9/Tq2sXP/jmXjExIok 7mOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AeaEXTjc; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-158775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o22-20020a05620a0d5600b0078d68a8cd4csi17414287qkl.18.2024.04.25.08.10.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 08:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AeaEXTjc; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-158775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B62F91C21D93 for ; Thu, 25 Apr 2024 15:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C13DF149E01; Thu, 25 Apr 2024 15:09:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AeaEXTjc" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 B255441C6C for ; Thu, 25 Apr 2024 15:09:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714057793; cv=none; b=j10DD9aPiJPmBxTosJegk0o9cIVvDtD2xH51t2YFbkyVQeOJ5nEybGxWhSFC9kAB8s5tE7W28b6aNRJ2CJxhpOWb/WMKhFlCpwOZhbbIxBT0ZZ7pflklzZtiB9DQbHLiASD/zg/CkAVMTGNgECq63xhwvzgai+yxaBfUBNYGXn4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714057793; c=relaxed/simple; bh=14ynkVWPzNhCtgD+Z9x14gnpSJO5GRO1ma5/65Lnzr4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Y2dlu+z0bomQl+HC6kyTdYvtlJXDf3EU7uQSCGnZnHWK8ZZGp2KrurVTmDWBtEzBlvmgiCGXJfhKHe/hdnyWC9olewO3KPHsKUcc1qmXys4b9O64dC3U7ssC/ykgP7Wfz0aumovo+/oiJavFsIRZsy9owh6IaulIMY+fJnCyyqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AeaEXTjc; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6dbdcfd39so2334734276.2 for ; Thu, 25 Apr 2024 08:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714057791; x=1714662591; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=m1qzGW4ycfJBkwOtQag42BpB9F1dgLw6AsC1TpSQ/BE=; b=AeaEXTjc9NqG4OPHqdShhUsB5Dv2YbD7XkbuvhMgFbjCnfW8WmGN2xW3YNFm3zke2g Ia2R4Ihx8p+uRLU89m5yroYv8d72JXjJT+KrkDQlqRF2li1V3wuyRTvlorp46U6I2JRt KEoo3WEtCaowgbItpK8UATwiqev4BM9ljHyWgwA3v4BK5ZEHbXA6LLq+8V6AG/poINPB O+i11/hGHtDz+pdoSEAw4NclpukoKQjhTV4Xtf+nsZlBTa2zmRtQtd5BjwgnU3n2R9/Z M/on9AGjeHNra0FJq3gFcRq4VzWH/tSllxGvPeuXyiUMbqxshWz14trlzSdGCMfY+u41 UjMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714057791; x=1714662591; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m1qzGW4ycfJBkwOtQag42BpB9F1dgLw6AsC1TpSQ/BE=; b=snkRl7G6EfJwUpSlRV9Wg16Ny4Yg9SStm8jVe2CPRCqKctVHPF7oxjE0m6RpAVgCCE b3n8xiyc8j0g/OOS+7fPWPV+wLZAjBqumlK8OhWVO9hNQS4yNly+L0i8GS/QtoeB3lvG Spa2uptJsPTibj6QScIUZv81wKP4ePtluUmh/UDgLBzM0gF6XDPCEmRsAYaELAgUS+Rg Bd51TcQDP8Y9oID9hqksDgm2tx8WbljCIWSQzXx0jKkqBJzCIyyFrVQ+mdsGxhy5LEll YR9St55jxBAeZaDuHZIG70fYI6TZDBB833C16MvcKg00/pkT2C7+ZK4qy4pNJwuXdMLW 1gFw== X-Forwarded-Encrypted: i=1; AJvYcCXPqauWhfKAcZeyEngEBvDFgmgfWczETfIQ6umql1EX/+MF36MDOD4xBm+s9sS1bbNzoOl7lKqS8hoq44LfHgWqHghBJ1GFzCrqJVzh X-Gm-Message-State: AOJu0YzQUwsYYgSp5UrbHwbXzSUrcWI9PRxPYo6dp0DzI6ZBB6ZkIZ+b ZSVaV6TWIdPQmPS5eXAQTRiVYuowOCrtqvV1AjT/PKOeH4CV3+Az3fzpLbUSIwLQkKwv7oIiwb+ 8Vg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:698a:0:b0:de4:c2d4:e14f with SMTP id e132-20020a25698a000000b00de4c2d4e14fmr1617703ybc.11.1714057790783; Thu, 25 Apr 2024 08:09:50 -0700 (PDT) Date: Thu, 25 Apr 2024 08:09:49 -0700 In-Reply-To: <3848a9ad-07aa-48da-a2b7-264c4a990b5b@linuxfoundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 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> Message-ID: Subject: Re: [PATCH v13 25/35] KVM: selftests: Convert lib's mem regions to KVM_SET_USER_MEMORY_REGION2 From: Sean Christopherson To: Shuah Khan 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?Q?Micka=C3=ABl_Sala=C3=BCn?=" , 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 Content-Type: text/plain; charset="us-ascii" 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. 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)); --