From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F6AC4708B for ; Wed, 4 May 2022 23:07:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384970AbiEDXIW (ORCPT ); Wed, 4 May 2022 19:08:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380040AbiEDXCF (ORCPT ); Wed, 4 May 2022 19:02:05 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B845A087 for ; Wed, 4 May 2022 15:53:42 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id r9-20020a655089000000b003c612b48014so158779pgp.18 for ; Wed, 04 May 2022 15:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=hThR3eXvdbL6PIPwsArk6NS/Y6ItR8JxmYPs055HfNQ=; b=HZvGef4wMTUUww0ii1QoiwMBQSBC/Pvw3CoC72aul1ExRfDQ2K5By8y4/GGBcgJaeN owaaHAG/e7rStRrir9ExqsMKk4ynjLGKLmJaW5Z/6z+xjstjP5ZbhJ3Kb6wDVrH9QauE DkJedMIVsKGVgA4gID4rx3C4DyKI6MUL7S3Bffz5GU/1jUw6uYENZeYMnZJcSD1FBHxo uqhvPCUHKfzKn25stT7tccHRDWctknK2xDWQEGGvAoVl9rL2byoPoQ07LbFg5Ho4zHpN PGa+qnQwevzHvvolT3qf93eqYFEuuCX9mYdLStjxrXePI+/05RKJk2pFbAaGb7yOggAB V58A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=hThR3eXvdbL6PIPwsArk6NS/Y6ItR8JxmYPs055HfNQ=; b=kGsfdXV2RyJ7n2bVcD/F88iQ+PUa4IYbxSOCoOCHMr6KPpW3uRb45D6JnIJ/BE0xK9 NROYxUHLtEBe68CJ9tYfyCB4OZSCuFBUZQlr8B3Kv5AWGw00ppw7J7fUQZptuVagJxPB 5N7yDBeFDtcpzeLeD3rNlTjjr1XTF77AcBKoX+lrW9Te0scGkSXcZPwdZbLMR7PmsQPw wKe1rxDLvNtcBVxKH/uum6quGhaEVNcCk1t/1v1XXtVA2uAVLTlu03raOmAtNTvADGXG jwGHRImmID9/d0f+LGMpZwVyqplkqmNcYzrFKBAwHyytMDKoX1/C6n0fI6wpWs6YjQ6t 6/Tw== X-Gm-Message-State: AOAM530TwTY7GP4BsM+kbmx+kH1I4Ig9NkX/dqErYvFNnREE6qJ70GA6 ZBfzIIfgeyoTSXOyi2JMsMdOnvQefLQ= X-Google-Smtp-Source: ABdhPJwgHLHvRfb8WYuIp2kW1pjw/YQRzjjh1gfBOLY12cy5NstVGLntHtlD+eVhWnvP5CGghG3yOhajnck= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:d487:b0:15e:a0a4:69e3 with SMTP id c7-20020a170902d48700b0015ea0a469e3mr18832343plg.155.1651704791544; Wed, 04 May 2022 15:53:11 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 4 May 2022 22:49:14 +0000 In-Reply-To: <20220504224914.1654036-1-seanjc@google.com> Message-Id: <20220504224914.1654036-129-seanjc@google.com> Mime-Version: 1.0 References: <20220504224914.1654036-1-seanjc@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH 128/128] KVM: selftests: Drop DEFAULT_GUEST_PHY_PAGES, open code the magic number From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vitaly Kuznetsov , Andrew Jones , David Matlack , Ben Gardon , Oliver Upton , Sean Christopherson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove DEFAULT_GUEST_PHY_PAGES and open code the magic number (with a comment) in vm_nr_pages_required(). Exposing DEFAULT_GUEST_PHY_PAGES to tests was a symptom of the VM creation APIs not cleanly supporting tests that create runnable vCPUs, but can't do so immediately. Now that tests don't have to manually compute the amount of memory needed for basic operation, make it harder for tests to do things that should be handled by the framework, i.e. force developers to improve the framework instead of hacking around flaws in individual tests. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/kvm_util_base.h | 1 - tools/testing/selftests/kvm/lib/kvm_util.c | 8 +++++++- 2 files changed, 7 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 527f63a30668..d30f8e0612af 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -100,7 +100,6 @@ memslot2region(struct kvm_vm *vm, uint32_t memslot); #define KVM_UTIL_MIN_VADDR 0x2000 #define KVM_GUEST_PAGE_TABLE_MIN_PADDR 0x180000 -#define DEFAULT_GUEST_PHY_PAGES 512 #define DEFAULT_GUEST_STACK_VADDR_MIN 0xab6000 #define DEFAULT_STACK_PGS 5 diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index f4bd4d7559b9..a0c8333d1bf6 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -274,7 +274,13 @@ static uint64_t vm_nr_pages_required(uint32_t nr_runnable_vcpus, "nr_vcpus = %d too large for host, max-vcpus = %d", nr_runnable_vcpus, kvm_check_cap(KVM_CAP_MAX_VCPUS)); - nr_pages = DEFAULT_GUEST_PHY_PAGES; + /* + * Arbitrarily allocate 512 pages (2mb when page size is 4kb) for the + * test code and other per-VM assets that will be loaded into memslot0. + */ + nr_pages = 512; + + /* Account for the per-vCPU stacks on behalf of the test. */ nr_pages += nr_runnable_vcpus * DEFAULT_STACK_PGS; /* -- 2.36.0.464.gb9c8b46e94-goog