Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp409575rwb; Tue, 4 Oct 2022 05:54:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yiL21V634V1F7hSccGm5RLqIBQnwdRPpNPtzNjh3qkz0vgWQ/2Gc+c6ZT8KNyFpwxI1VE X-Received: by 2002:a05:6a00:198e:b0:541:f85a:6c27 with SMTP id d14-20020a056a00198e00b00541f85a6c27mr27502336pfl.81.1664888053205; Tue, 04 Oct 2022 05:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664888053; cv=none; d=google.com; s=arc-20160816; b=1DFx6DPLdEatc04nTA2JdyxtQhEanB3N8uDDjaufMZLksIZAfKRegQZIrm8/uWTEIe T4uHGw+i6DeaSJmKAJyt59z+CLih4HAIA1iuoFidCTO1ArDACnHQEp9k3FoKRrwhGT0e iowbitNxR/6/p4WAge78tEt/0DL94k/89YfPKu3FxE1XLxx89+OyKhbDnXAED00SFVsJ V3jgxLvnoQ6V+IcBBjQCScVUbZDmrg774j+Zry/T54BgjhlEbPqUa0cieyjzLdLRU9xo Qe2vGQUUfcDNYcFtK+maXvrENy3k+oDBhkx6CyTN8B/wPmIZT1i5dPVaDuMbRNcOg/uw QzLQ== 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=B7rt+ZP9F1qAAB8FT50m0Mx4VizkpmKa3DoF+0Sx+j879A6ZX/jMneGswnd6EUPZdg c3HwI10lH4aVL/sxLnFOdBpSPGsT7dAKMYZhxTlp4FTGtIw+aXBXz6xBq/tJVjpGC7se MP7nhCFcFaab3VLZwQBs6pC54l0iqgNURJvb2i0uiCw5EGL5sSp8oYmgE9+/DU97zx0Z ZIq6/e1q2cua92yqpV6kuou70EqYeSxL7YGgFBNFM/pM3QGVmkldEptAa9TehbeOXNlO F0W5lTogSBFFIKbcmA7gneBtONtdul2K+BukPPIbySFL++B3ZjHxoz9ylcC9UBG45q2G XG5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eCk9ulvP; 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 ls5-20020a17090b350500b001ed40b70436si2730825pjb.155.2022.10.04.05.54.00; Tue, 04 Oct 2022 05:54:13 -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=eCk9ulvP; 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 S230116AbiJDMoN (ORCPT + 99 others); Tue, 4 Oct 2022 08:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbiJDMna (ORCPT ); Tue, 4 Oct 2022 08:43:30 -0400 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 64DAC5EDC7 for ; Tue, 4 Oct 2022 05:42:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887292; 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=eCk9ulvPbo1dzaMvR0cWPirb+N/YBA5IK5jA5RfM1wF2ogP2dJ1wteALcjIop5uN1A+H0q 1awRlYVgI1uvSMeXsqGQW13cTiZI/HzI4POvpM8ZgiA15bZYnD1PkMkOpLI4Cin4jHMCzV EWySASzLwuU6SvO+sEpNTDM4+C9L8O4= 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-102-vuQCNlszOiqO_-63N-YpMQ-1; Tue, 04 Oct 2022 08:41:26 -0400 X-MC-Unique: vuQCNlszOiqO_-63N-YpMQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 36DB5381078A; Tue, 4 Oct 2022 12:41:26 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C6AF7AE5; Tue, 4 Oct 2022 12:41:23 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 35/46] KVM: selftests: Export vm_vaddr_unused_gap() to make it possible to request unmapped ranges Date: Tue, 4 Oct 2022 14:39:45 +0200 Message-Id: <20221004123956.188909-36-vkuznets@redhat.com> In-Reply-To: <20221004123956.188909-1-vkuznets@redhat.com> References: <20221004123956.188909-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.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=ham 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