Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp225490iof; Mon, 6 Jun 2022 02:03:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv1dv+xJu2uWbPZCO/nxHBbNU6UGrYCmeiVp4Ov/Mqd+UYrW9GMeqF9uoxblA+DpA62McQ X-Received: by 2002:a62:1784:0:b0:51b:bc40:28a7 with SMTP id 126-20020a621784000000b0051bbc4028a7mr23413978pfx.55.1654506206695; Mon, 06 Jun 2022 02:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654506206; cv=none; d=google.com; s=arc-20160816; b=sgodShjOsc+dbHa0P55dF6rBbl0IyDWx69dvzun2AG4Mu9YMZG4GkM5UjDbHGGwO5H owD0DLfxBoWWCXF1I39GraaOt0gOGP1bBSX7UGYanJeGPpUDWKujjM0hK7g/ywKsAqZl Ly6MR3mTDGutMwpPyyQaG5uzuY1ZLpdvqmnqd0G97TRtnRA78QP28b+feNa2pXub6lnS R/LQVJsRsOWXRxbS3wVF/3XkXHwcMg4Qzm4ULKo7OX9vyssZXvHm4f0knjiW9/JARVJy wkLGzyW1M1IS3nS0v8lULbilOWwCr/hx9mt/O2Y7WxUTOOoHrt8NzbSzwkDxmshbMg3E dmTw== 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=hI5tcymMyNY0x/KbxdPcK+U4n8lHpHeb3PjdglObBsg=; b=WQkNUhxhfdoaRjpl1GiEPh+OOFwSEf+JI++ecxtLLcvaCmpEmAZTPiNy0aTa/x0o96 AzU5NS7KZN2c2lrOXKBzNdtjBGoHs9IWL7cemSv/U2yptI9niMNMDVeuqsavB8p9XbKg r0yvatHELTion/jQzqwLG3Y2xn4wCvHXNZPQ8DRmhUXBbYpbBGablorN5azqqWa+PKZS o7s0w6pyze2fdyFIINm5KjAiOP5YbPSeMtUYDhNNulhtZVXmLl4WqVf6I+aGY4glKw2Z 3LlCJdg2HvhSqsGR4gSXw4HS1wgsFOWzPtRqzok/GC3XfAmLoYjErAcKeL2zu38jQ2ii Ee5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bHpyHzWj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d8-20020a170902b70800b00158f13b4872si18353117pls.7.2022.06.06.02.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 02:03:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bHpyHzWj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 51B038A05E; Mon, 6 Jun 2022 01:40:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbiFFIkT (ORCPT + 99 others); Mon, 6 Jun 2022 04:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbiFFIiN (ORCPT ); Mon, 6 Jun 2022 04:38:13 -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 ESMTP id 5BC5931910 for ; Mon, 6 Jun 2022 01:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654504690; 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=hI5tcymMyNY0x/KbxdPcK+U4n8lHpHeb3PjdglObBsg=; b=bHpyHzWjXsx+fWOV6fWStD/ncKx/WCtkxPdJqDdLA5neM+bMO1bcNLBvD1Xxk7Q/i+PqxH IKfRl9xplm/3n2jD1oi85gJhC4s36w8uSBnZMec9fpmiBlGGCvd96EyiS+TsUTKe9xPDsg 3Sdhgry8uwAedQr8tDkghLAOLCVCcbI= 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-489-42ozNQbpNf6RvnfL7mLLoA-1; Mon, 06 Jun 2022 04:38:07 -0400 X-MC-Unique: 42ozNQbpNf6RvnfL7mLLoA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 906F1381078E; Mon, 6 Jun 2022 08:38:06 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.193.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F8321121314; Mon, 6 Jun 2022 08:38:04 +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 v6 29/38] KVM: selftests: Export vm_vaddr_unused_gap() to make it possible to request unmapped ranges Date: Mon, 6 Jun 2022 10:36:46 +0200 Message-Id: <20220606083655.2014609-30-vkuznets@redhat.com> In-Reply-To: <20220606083655.2014609-1-vkuznets@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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 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 92cef0ffb19e..8273fe93c4f6 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -169,6 +169,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); void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid); +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 936be9c9f870..37df67780787 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1263,8 +1263,8 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid) * 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.35.3