Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp829347lqb; Fri, 15 Mar 2024 07:36:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZs3OGSPdDcJcmiYoOGlW6ae4Ae8Y/SIIoAtkA5cCEtOKiTSyf2UfYU6SEPD6A3+yj+RaY4GYdmoslgnnSoKS9TL9S2vPZbpTXgTAxGw== X-Google-Smtp-Source: AGHT+IEWDT7A8vYUQN9ThrgjfO+bfIfU1E4EBlBrz1TZE8zhJ08XBxHV9rW5MWgTb40aNqBU97OL X-Received: by 2002:a17:903:24e:b0:1de:de7d:d3a6 with SMTP id j14-20020a170903024e00b001dede7dd3a6mr5642115plh.30.1710513360765; Fri, 15 Mar 2024 07:36:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710513360; cv=pass; d=google.com; s=arc-20160816; b=o7UgtNbqxpsofEBhAdmnWfGT520ORip421tRbdPUhdfDC8XIuWVczSWJ+5fCVWDEsM hC5UTbnBg9qvVD2p+symkTlc2SX0/4oviOcViJFrC7YwxagpyNmJw9peToEaQyOtVdn6 iItKvdneRKFMgLa+OvPZrgL2jsBW7iyWqEqTveMB6A+XTy1rttWPoLkqqGVIih/Tc80g RbNZUl9h/YKUPmGE7qR4OEVcA1pbAn4gLVFoPBHtOdXtup7bTP2qgUnbV8QBJyIuwloP Qp9r3A38SR7V8cMcQK4xeLBECVX18mwRaiNyyqV32IyqbkBjbkpWW4XdCSlFKkrxwaNw 1/dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=SrsZ3sRjJ0cd4TSAU6qFDBULeyMZSqfIVaf6DxKRBJs=; fh=Zmw0uw3wCTyA14szLkkCdMHzt75OC0pePryufZD+oF8=; b=y1oSsnIJJkL59TagOXpK80lHPO/LgNP03lQqYH0bpgx9BIMDx6DEtXFEuBTjuji1d5 qI7zbZy6cmptFuC9KCpF0uFIx93LiBWna3roYYpCWHg50mbDmbX7CubULcu4CNJkzhs3 Hj5vtpT52s74uHKXkkGaluzxAtEWQO2Ny/uFP+JVAPR01jj+5rJilcGkFPbZvKkmdxZn JPsr/o/uSKnLxQPHo+JZOX/xmpiI4bo8cNDlTkcCa/zlB5BWu9TN2fILjI/mks55z2Zx LDZGt/IEqLtYv32uBP03/9kUR2FGOdMd9lX7rER1k0lZchJ8cz2lDwsyrKVmozKV26wD mpeg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BnECXpvA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-104519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c4-20020a170902d48400b001dcfb65e0aasi913578plg.356.2024.03.15.07.36.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 07:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BnECXpvA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-104519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DF0632848E2 for ; Fri, 15 Mar 2024 14:35:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 242F63D0AA; Fri, 15 Mar 2024 14:35:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BnECXpvA" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBD6C26AE3 for ; Fri, 15 Mar 2024 14:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710513319; cv=none; b=PVTsmP7Mbg8atPm43hpxkbKwyZXUbPv1BSC+idpj04OMsTIjt8rtUUIIwQ86eCZfnMzsyGSjIeslGcbBQzxhorCPqmgZql5H2CLKyQeCY3++mJaXhkCIdRaMgXyPwfYjzr2Y/0ypMmEQxhblQSO/9sQwbcJyRVyCu5VpJskgfhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710513319; c=relaxed/simple; bh=Bnp7XWkyPj45TcVE/OTtDC1VSqGlz7YOyH8lcokg3ec=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=n5p+WBx8kdwGPyFUIVRplVYAp0l0DzZMq83TA1DCaLMAfeFSu0Z4yhw05cLtJXcseAO+zOfkqqx151PP0GHqnH3QACuCsBUKGzWboP6J+8OQsNhb8+p+ZRvRjPekKDQdalpVHIDG8LMK3pXbJE91fHQ81mQxa2EpJdp48bXk1rM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BnECXpvA; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710513315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=SrsZ3sRjJ0cd4TSAU6qFDBULeyMZSqfIVaf6DxKRBJs=; b=BnECXpvAxelwjxehlvR/zY2qBNuJep2ebbkXwTGs48igElQuy+odwg/RwpwPWyY2KjYmPS EI22iOHB4PhpQ3ldL9DqzcLhM58RLG9dPTHZTb18PNSGxiqQXwVGmstonjeBDbssdxAcsU gPg8J23P6Hmr8etQ+TJ/yqLlLAhGVXc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-IO3P_mF2M4yxJoySzljqKA-1; Fri, 15 Mar 2024 10:35:13 -0400 X-MC-Unique: IO3P_mF2M4yxJoySzljqKA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86C4E8007A3; Fri, 15 Mar 2024 14:35:13 +0000 (UTC) Received: from intellaptop.redhat.com (unknown [10.22.10.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3FB1C04128; Fri, 15 Mar 2024 14:35:12 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , linux-kselftest@vger.kernel.org, Shuah Khan , Maxim Levitsky Subject: [PATCH] KVM: selftests: fix max_guest_memory_test with more that 256 vCPUs Date: Fri, 15 Mar 2024 10:35:07 -0400 Message-Id: <20240315143507.102629-1-mlevitsk@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 max_guest_memory_test uses ucalls to sync with the host, but it also resets the guest RIP back to its initial value in between tests stages. This makes the guest never reach the code which frees the ucall struct and since a fixed pool of 512 ucall structs is used, the test starts to fail when more that 256 vCPUs are used. Fix that by replacing the manual register reset with a loop in the guest code. Signed-off-by: Maxim Levitsky --- .../testing/selftests/kvm/max_guest_memory_test.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/kvm/max_guest_memory_test.c b/tools/testing/selftests/kvm/max_guest_memory_test.c index 6628dc4dda89f3c..1a6da7389bf1f5b 100644 --- a/tools/testing/selftests/kvm/max_guest_memory_test.c +++ b/tools/testing/selftests/kvm/max_guest_memory_test.c @@ -22,10 +22,11 @@ static void guest_code(uint64_t start_gpa, uint64_t end_gpa, uint64_t stride) { uint64_t gpa; - for (gpa = start_gpa; gpa < end_gpa; gpa += stride) - *((volatile uint64_t *)gpa) = gpa; - - GUEST_DONE(); + for (;;) { + for (gpa = start_gpa; gpa < end_gpa; gpa += stride) + *((volatile uint64_t *)gpa) = gpa; + GUEST_SYNC(0); + } } struct vcpu_info { @@ -55,7 +56,7 @@ static void rendezvous_with_boss(void) static void run_vcpu(struct kvm_vcpu *vcpu) { vcpu_run(vcpu); - TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_DONE); + TEST_ASSERT_EQ(get_ucall(vcpu, NULL), UCALL_SYNC); } static void *vcpu_worker(void *data) @@ -64,17 +65,13 @@ static void *vcpu_worker(void *data) struct kvm_vcpu *vcpu = info->vcpu; struct kvm_vm *vm = vcpu->vm; struct kvm_sregs sregs; - struct kvm_regs regs; vcpu_args_set(vcpu, 3, info->start_gpa, info->end_gpa, vm->page_size); - /* Snapshot regs before the first run. */ - vcpu_regs_get(vcpu, ®s); rendezvous_with_boss(); run_vcpu(vcpu); rendezvous_with_boss(); - vcpu_regs_set(vcpu, ®s); vcpu_sregs_get(vcpu, &sregs); #ifdef __x86_64__ /* Toggle CR0.WP to trigger a MMU context reset. */ -- 2.40.1