From patchwork Wed Oct 9 15:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13828718 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA1DFCEE32A for ; Wed, 9 Oct 2024 16:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BR1gG58gw5F7E+LpSzoPu+wX+wiyja7ptJ1fl5K+zYE=; b=UILT+3Yw8eRrpHWswVbPa0RFK5 ifs28gT3R/cQmrXRlhhk3+pfdAZmdZnSm5EUUB/IEyytMJywqGwSek3APDPb6ClYkCwD5+4DlnRcG 9OITZiUW3eRTLx6YbcrjuwPNOtl3mN7aHTZhH6FVEhHvqWgVAA5oz4zHFCcn1GWKmCbqi5blpexq4 H0eJBKXsTem6Ir7N/XB2Lml/Yw5/qH4NLCs4xrBFYpZ/RpUkhrF+5lKzEYwV8JeeFpEdOTHkNYsxG jdfG+dCEuF/v+chZMdkJL5lEjFCrU9YStbb4/3fVehjhc1qUwoLLFjvNxVj3kWPwHxjouqP8HTENB YPyKiVbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syZB5-00000009rav-36tR; Wed, 09 Oct 2024 16:04:43 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syYx3-00000009o9e-3TmM for linux-arm-kernel@lists.infradead.org; Wed, 09 Oct 2024 15:50:15 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e28c3fb4c84so5475469276.3 for ; Wed, 09 Oct 2024 08:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728489012; x=1729093812; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=BR1gG58gw5F7E+LpSzoPu+wX+wiyja7ptJ1fl5K+zYE=; b=pQGIZ8/ItOX1aLlfzAYEKKw0hseHlQKP7bZ4BB/xdCVUeF+Q3nKQCVbfV6pIhe9LP+ aKVr1xFsMH461/3W4I4k5rw76xRannLf1ITyH8tp5ztNK1A7EqZ9//0/s72xKzu2DYZK xxP9/iUVA9vxVxDVkIU0DWlkW2P5UGz9Ma6rjdiCCDTQM6KhJmrFJJ3jqp9NYm4d3yTk GwwqYxpt+nolONzBi0Z8wsuuvS0ahC+i9ymgKfVxnY8vWBYHmUYu8l4VGianNrVc4j+Y Kgl4V4+6Q+GSgwW0BCY/KVUB4CQYkKg5MJg32Ujl7eEh2ZQDIalosLV5ynJs3OiZrPI0 pTyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728489012; x=1729093812; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BR1gG58gw5F7E+LpSzoPu+wX+wiyja7ptJ1fl5K+zYE=; b=Vvq+30MNrGERlL0ddMndNV2wBJr4GL4zahYBKBLL8mqQygk/pKVj9nTEKZtG+xomDl 9Vlj2abAf67b6Rg5Q7ZZJYmWZcsafGbr5iy2fj3+mSXqYyGp0FtdlJOEJ3uHgSkrJNyD gTj1nuA9vm18t6JtfpGUtmq+4wMxrHFMsDH9x6fBXUmxs0VKERb7pN0fs6gCOaVzgZOK 0K1ML+CrzL7hEvwyWoKUyShsQ7nnUUg1FSg+CutF794OZhUrWEfNwX8e/arJTTraGQ2f DutZUlcoKkG5l4ij1/t/iyrkbKtcNyV3Ly83gUTZsPDXYEkBGGxdilvKyS2S3H0Y+OM0 MElQ== X-Gm-Message-State: AOJu0YwSklfj3ETVaXbnZN+Pp4VHVBcLrUgjIMkuV5s7tJMcvs9W/acc yumAQZej6pI9kOQPy7lmFFRZjowPkVza1bxpKyv8uzT/ZA/sqwrZch2U0oRkVnivgKRWy3qBQhq 6Dw== X-Google-Smtp-Source: AGHT+IHLwQuTuSKn2K83jzMORxhmnJG2QJIDSetKispH+vrqgQjqJfiOQ3+gOO6ZQgZWYqSyd9aEi5B6J6c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a25:6948:0:b0:e29:6a6:ed83 with SMTP id 3f1490d57ef6-e2906a6f043mr903276.11.1728489011277; Wed, 09 Oct 2024 08:50:11 -0700 (PDT) Date: Wed, 9 Oct 2024 08:49:47 -0700 In-Reply-To: <20241009154953.1073471-1-seanjc@google.com> Mime-Version: 1.0 References: <20241009154953.1073471-1-seanjc@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241009154953.1073471-9-seanjc@google.com> Subject: [PATCH v3 08/14] KVM: selftests: Compute number of extra pages needed in mmu_stress_test From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Sean Christopherson , Andrew Jones , James Houghton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241009_085013_903822_374E5ADD X-CRM114-Status: GOOD ( 10.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Create mmu_stress_tests's VM with the correct number of extra pages needed to map all of memory in the guest. The bug hasn't been noticed before as the test currently runs only on x86, which maps guest memory with 1GiB pages, i.e. doesn't need much memory in the guest for page tables. Reviewed-by: James Houghton Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/mmu_stress_test.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/mmu_stress_test.c b/tools/testing/selftests/kvm/mmu_stress_test.c index 847da23ec1b1..5467b12f5903 100644 --- a/tools/testing/selftests/kvm/mmu_stress_test.c +++ b/tools/testing/selftests/kvm/mmu_stress_test.c @@ -209,7 +209,13 @@ int main(int argc, char *argv[]) vcpus = malloc(nr_vcpus * sizeof(*vcpus)); TEST_ASSERT(vcpus, "Failed to allocate vCPU array"); - vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); + vm = __vm_create_with_vcpus(VM_SHAPE_DEFAULT, nr_vcpus, +#ifdef __x86_64__ + max_mem / SZ_1G, +#else + max_mem / vm_guest_mode_params[VM_MODE_DEFAULT].page_size, +#endif + guest_code, vcpus); max_gpa = vm->max_gfn << vm->page_shift; TEST_ASSERT(max_gpa > (4 * slot_size), "MAXPHYADDR <4gb ");