Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5516501rwb; Wed, 21 Sep 2022 08:48:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5c8UXgKy1liRLw7X8Ecwf8IzmcewOq0wGRB8axgWuTtjvAzNYkyBEDPjnBfunvyWsccBSB X-Received: by 2002:a62:2503:0:b0:538:426a:af11 with SMTP id l3-20020a622503000000b00538426aaf11mr30164533pfl.22.1663775331106; Wed, 21 Sep 2022 08:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663775331; cv=none; d=google.com; s=arc-20160816; b=kj1Ey2I7Rl1vKg4vArW/53rMHHfkdQoElCyjEiHRGeofA6lzokZJfEWwfPRNa+ShVw hdSHQTeyYPWytEndmQa7nD7yWvMEweBIEHp55/a/fCxEKbxMvNgy9U07RaZjWBJcmy3o hQIxAa4M5iT5G8INQwK+7sS3Y2Sg2u+kSsqJNRLJ/s731Es623YNZ/kLKJBraIu4Zi2n 8fOdOPazcCcRvb7GHfPC/UDbIEJsVkHx4sTCFIN0+hXcNEUgNIzPcJHMML9UZR1tZ9V1 oxiamiy0iAXgm4hk2kgkzQSqJi97cLROgh3Z8FGLy0FjlVT9StNrl1V/Q8yGZQ/57Dcj ZWNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S/Eqzsi/PLqUiymEmKzNGInOxseJNuXY/3mYYoCHjg0=; b=0sHnLC9NzFMOOYF88BnYHqflOyJn0yzZGmMi24CykDdY0L5fBwH9Eu8zOicrqh8L72 qJYzYIxpsWZLZrLdT1tq7YI2lWqTmIc/IGo8A/B7Up5J9zkVxf+hHfd5r6hyqixuwPhS 598LQqhpUUJi/o++Ay2X0g0t6ecmcARMRXNaEX7eWQ4Jt93twsBXxnglnFitMrLUOR2Z VpQ3aPKwHSNEzkodNQDJmGJ2doZGij3g4o1ivYFyXYU57zKKEaV+HheXs3X0WmwqCxPH FT2px9hGLPd4K9332fQvCDf+c9uMINYAo/LmZYG9yIDAhfBE6WxhVvO1UfQ3H9LDbjHD DEpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UUUnUPh9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 8-20020a630208000000b004393cb45b20si3349427pgc.683.2022.09.21.08.48.13; Wed, 21 Sep 2022 08:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UUUnUPh9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbiIUP3S (ORCPT + 99 others); Wed, 21 Sep 2022 11:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiIUP2S (ORCPT ); Wed, 21 Sep 2022 11:28:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F20C798C90 for ; Wed, 21 Sep 2022 08:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663773970; 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; bh=S/Eqzsi/PLqUiymEmKzNGInOxseJNuXY/3mYYoCHjg0=; b=UUUnUPh9wyWb7HHoXxuS+Jg96Oja9Tu0su1+pTsQ+n5nl7VyjpI83EYwKlfgDn0GJsMiGA oAYrIKp4fZAI8UyDFVEO1O6li3jkpTSorGy+rMlpsyZXP5rgLACEUVsklDOvpMj37lz5bs F3sl9oPl/16X6K+FAoyt3MWyiRNsuVk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-h6VNZRwDNTebRFgcLzWJyA-1; Wed, 21 Sep 2022 11:25:53 -0400 X-MC-Unique: h6VNZRwDNTebRFgcLzWJyA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D289A294EDD4; Wed, 21 Sep 2022 15:25:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.194.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E59C2166B2A; Wed, 21 Sep 2022 15:25:50 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 28/39] KVM: selftests: Export vm_vaddr_unused_gap() to make it possible to request unmapped ranges Date: Wed, 21 Sep 2022 17:24:25 +0200 Message-Id: <20220921152436.3673454-29-vkuznets@redhat.com> In-Reply-To: <20220921152436.3673454-1-vkuznets@redhat.com> References: <20220921152436.3673454-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, tests can only request a new vaddr range by using vm_vaddr_alloc()/vm_vaddr_alloc_page()/vm_vaddr_alloc_pages() but these functions allocate and map physical pages too. Make it possible to request unmapped range too. Signed-off-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_util.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index 24fde97f6121..fe0ab920b3e7 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -379,6 +379,7 @@ void vm_mem_region_set_flags(struct kvm_vm *vm, uint32_t slot, uint32_t flags); void vm_mem_region_move(struct kvm_vm *vm, uint32_t slot, uint64_t new_gpa); void vm_mem_region_delete(struct kvm_vm *vm, uint32_t slot); struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id); +vm_vaddr_t vm_vaddr_unused_gap(struct kvm_vm *vm, size_t sz, vm_vaddr_t vaddr_min); vm_vaddr_t vm_vaddr_alloc(struct kvm_vm *vm, size_t sz, vm_vaddr_t vaddr_min); vm_vaddr_t vm_vaddr_alloc_pages(struct kvm_vm *vm, int nr_pages); vm_vaddr_t vm_vaddr_alloc_page(struct kvm_vm *vm); diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index ad9e15d4c6a9..9f214d2a14a1 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1109,8 +1109,8 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id) * TEST_ASSERT failure occurs for invalid input or no area of at least * sz unallocated bytes >= vaddr_min is available. */ -static vm_vaddr_t vm_vaddr_unused_gap(struct kvm_vm *vm, size_t sz, - vm_vaddr_t vaddr_min) +vm_vaddr_t vm_vaddr_unused_gap(struct kvm_vm *vm, size_t sz, + vm_vaddr_t vaddr_min) { uint64_t pages = (sz + vm->page_size - 1) >> vm->page_shift; -- 2.37.3