Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp369236imn; Wed, 3 Aug 2022 07:21:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uFcWVVtwPBPNyb0JsstXEH2Nr8deEpctpoqJIZS6i9Ef9tv3iZO5pgwQmUF7cpTQO9tEKG X-Received: by 2002:a63:4042:0:b0:411:bbfe:e736 with SMTP id n63-20020a634042000000b00411bbfee736mr21437996pga.1.1659536516799; Wed, 03 Aug 2022 07:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659536516; cv=none; d=google.com; s=arc-20160816; b=c35D11PEVRuXdIWQHx1sb4eMpDmJC/hR/rIPx3gr4N3dhE2EWBrhtJgG6zCz9MlEdj u9zSgwFf9AXDPc6ScBcFOXxgknJ3H1PXFts8T2zy2jbPuF5y/hCk3ilI/1fb4rDb2hS3 +tLiNr4NJQfATVw7d9Igd4CyjfFY2G1L34LdTEXUOM7AVDCHQPEhZPCFHcXxyhCzdUyA jKONjExk5FQznc3nvQ1V11ixrwLzZ9kcoZc3BqK/WCAe7VaBoqZQgdjtERm+dyWuxHUT WYVBiQMoV+13OtfouAkcJJn28kbWrqNhTcWyn4knC4D56kxx17pVb7kmniFbw/GZwaj9 qyqg== 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=auZBeA8QvjN6YbS0w7HcVEj/mml7S1v4u6NjrdyFJOo=; b=LM90brYQjYx4kPHhLrby4HKIbd91VqYq7qoKoVy+Cg/VpPqxmpOt11IKvtX75KFXIe EevlcwubaVCT8Tm+Xr786lF1rEbvd6ZEqoy/pNOxsFWUdiWriaKBUUk77mXKpF5COdZm D+1fKhuaFp/b4uSAdEmZZv513OOkzkj+42wxSmofxq+SWQDQJUQqq9MkWaePQUWtbth1 9WWiPDjr9i6E3NDhpuAmGinb75boB63g5hLKO1V+D870K7oPmrkSZEgvGM1n7AuA0NS4 8VsF8X6XfgD80mMl+tgeIb3d6nTW05z97R6TxBxKCjqlRRWCkKVgCpeDRW3a5/euRN/Z O1VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tv+BS1Vf; 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 cj6-20020a056a00298600b0052dccbf4079si5933485pfb.220.2022.08.03.07.21.40; Wed, 03 Aug 2022 07:21:56 -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=Tv+BS1Vf; 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 S238412AbiHCNsU (ORCPT + 99 others); Wed, 3 Aug 2022 09:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238449AbiHCNrs (ORCPT ); Wed, 3 Aug 2022 09:47:48 -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 97F0740BD3 for ; Wed, 3 Aug 2022 06:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659534404; 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=auZBeA8QvjN6YbS0w7HcVEj/mml7S1v4u6NjrdyFJOo=; b=Tv+BS1Vf+LRZHjjGDlTP7lMV3HnN8H6/z0cj+h225QVIiw64+CewtIIrBXCCtXIyTN9rTY F10+QUzZz6yiBRxoEoQ0Jhk6ql+j6Eu4NnyNLD6FmfV4oFkflSmvy+CMKOHJmBximpSOAx CGH++/fPvwxd5XEhPSSuoe+Wrey3zQo= 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-297-E0fC-QBDNsmt7YBpaRqr7g-1; Wed, 03 Aug 2022 09:46:43 -0400 X-MC-Unique: E0fC-QBDNsmt7YBpaRqr7g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93EDD280EE2C; Wed, 3 Aug 2022 13:46:42 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E61C141510F; Wed, 3 Aug 2022 13:46:40 +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 v9 29/40] KVM: selftests: Export vm_vaddr_unused_gap() to make it possible to request unmapped ranges Date: Wed, 3 Aug 2022 15:46:39 +0200 Message-Id: <20220803134639.399461-1-vkuznets@redhat.com> In-Reply-To: <20220803134110.397885-1-vkuznets@redhat.com> References: <20220803134110.397885-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-3.4 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=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.35.3