From patchwork Tue Nov 1 14:54:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3023923wru; Tue, 1 Nov 2022 08:02:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YFlul9k2gvejyuQfLFuwtAFfXRGw9n8kN7kRL2L+g3+Kd9BMJgnnz/2G8+rzC9lYn/kh7 X-Received: by 2002:a17:907:a087:b0:7ad:a4c4:873b with SMTP id hu7-20020a170907a08700b007ada4c4873bmr18092875ejc.58.1667314976059; Tue, 01 Nov 2022 08:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314976; cv=none; d=google.com; s=arc-20160816; b=meF137wPb2gbokbVYzDl+gMismcpRjsDlXOZ0WXtx3fyTlLgIRHqOjYf+q4VgcWQxi qniX5G06f596eUzVs2UMElj+Xy9pQOfrVZlxA8cHiHQJPK5s750/gujd/SZr5A2+IUfN T2QG5SiZ0c7SZOps6ICcgeI2l82Qd1fbfF1f8nbxP40XeuL1+E0pqlVSvm/o0NRfp+Fo hXVXfaHaBp8C+I2JMZ9uvqIbzc3b6aSIXLyNRYP/nBGkONYK+8FBz9aYz3DfODtj4tD+ 8H7JinBM5ULvsk9/zDMLV4si1mLkgRvdMmHHDaAJ7MUHeLPPoUXG6Mq+QhlmoQRejFn+ cC6Q== 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=xWVSRzWoozyky4L4lZm5osF5xXKXnRoHIXk4rXDkpYo=; b=YLfWCoSNkKplwpIQmcB4BExpTV95Z3PAfmoiYGVHl73w+uIy0vwNkcEkGIUk095yHV HgZ5pnrikoI/DqGazaEBItT773yxCQQESF7CZjiSgzrugEDIXkP8Go+r+ohVk5uFOxbC 6jlUiWZ2oG6IGyRcFqqo/nQ7u8g5FN3/9D548bj4roHGwxoK98ueTVZrALAB/97GUSab 4JuQPQOZ6vcO5usYlrX6xX3UPjlpnxgjgWaqKHIGs7i+wDLr8XXjnEsY/JvVcDFPArUt Otg4haex8h/0kSwBIkJypYIeLZgVKB3fGs1G956DvnE0/27q2Pir32qINJqOz99hDGcX 2sDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ENfcZy8B; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm10-20020a170907948a00b007ac2daa0b49si12456952ejc.367.2022.11.01.08.02.25; Tue, 01 Nov 2022 08:02: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=ENfcZy8B; 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 S231245AbiKAPBl (ORCPT + 99 others); Tue, 1 Nov 2022 11:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbiKAPBQ (ORCPT ); Tue, 1 Nov 2022 11:01:16 -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 D01D31DDFC for ; Tue, 1 Nov 2022 07:56:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314604; 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=xWVSRzWoozyky4L4lZm5osF5xXKXnRoHIXk4rXDkpYo=; b=ENfcZy8BFDyrhC2Qpb5NqtQ+z3Alnv43W4N3d3gNOOLMt3JMhtfHjL1OWm1WH6l+mqpnrV JyPGxBtNcsq0Ubi86wvcdKaoYqoGNFmp+teJrLWBmjJW/sGVYDO7tXszBiPclMwXAfC8/6 RXCU1hZIJl9dDzbz+r+tevunSkAysgs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-kodqSEUfONK73cKE9maB4Q-1; Tue, 01 Nov 2022 10:56:39 -0400 X-MC-Unique: kodqSEUfONK73cKE9maB4Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BEBA8060AB; Tue, 1 Nov 2022 14:56:18 +0000 (UTC) Received: from ovpn-194-149.brq.redhat.com (ovpn-194-149.brq.redhat.com [10.40.194.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B3CC15BA5; Tue, 1 Nov 2022 14:56:11 +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 v13 35/48] KVM: selftests: Export vm_vaddr_unused_gap() to make it possible to request unmapped ranges Date: Tue, 1 Nov 2022 15:54:13 +0100 Message-Id: <20221101145426.251680-36-vkuznets@redhat.com> In-Reply-To: <20221101145426.251680-1-vkuznets@redhat.com> References: <20221101145426.251680-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748306468374559381?= X-GMAIL-MSGID: =?utf-8?q?1748306468374559381?= 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. Reviewed-by: Sean Christopherson 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 e42a09cd24a0..a34bdf97bf7c 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -383,6 +383,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 29f743086ecc..fdb5836461ab 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1151,8 +1151,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;