Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1073002rwb; Thu, 18 Aug 2022 18:31:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6DmiNXM2Nch9CZzTsSKihuz7KpcdD7xNtvo0xvdtmTG3gsriNx6x5hK7EXb7MkKTxjLghU X-Received: by 2002:a17:90a:4a01:b0:1fa:a153:7b5a with SMTP id e1-20020a17090a4a0100b001faa1537b5amr11739122pjh.72.1660872682242; Thu, 18 Aug 2022 18:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660872682; cv=none; d=google.com; s=arc-20160816; b=zrfjCIDzQVyrZUEdR3mW1v9n2DveJ79YVXJoVwP4NkT+FGNygsJ7DZBU1cb0wN0QMi DvuY7CXSlqK3m2nM3MEzIT8G62EwuCFB0UXjuhho1gR8OKysKI5en/1ETmJppayMxPSc b2Cwg5hXYYkVPzycpkGe4knQrAWXg2gy8uPpicoQlkEST+WML5Qg+0/X1qxx+Cw4gYeK haVjFODACj+flfPReBsbE+TfkJeeJdU5ll6ENQGwQem0nuxky0GNgP4KoXBczyTj2ks0 O0n3K7nbyNQMHk9v8jIf0YZUtCXmoVgKrE4p3FFfIHv5z56EbTEgnf1vE+vrBvAxDk/r GgXw== 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=WXZV61jfgDNJXnq5uwdk9hoJi8yzuP+++eERMshJ/0Q=; b=LUZQ+zpEBPUOydq0vn58iLTQZqoBwuXObrQoEYQ23BkTDmDnWEyX/zYBRotoTlivno 2H9X3+ygfX/eXcDz54NDC0hmeeohpgV31wwggeLonb+ZuImu3EwPy40vpITf2TizsLxT YnjGdJdxwMLlEpJ5bMnkdGrrSMmENQu+vqZnbyMaJC/dIGD4fd1h5/j5bzJPQA7tBjuk jIXYFF7gz8tE8gyZ0Er0+JSb42HjzxlkyZEBRUJJkxEQ+LQcskiMnvrBzoevkMNyw4bR n5gWoypM3PX9+cMe0gksnBH39z90Al78hldwvAlstpDXFWjoVUXEY/YkyDggGpFRVd50 UdcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MWCaV9fG; 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 s37-20020a635265000000b0041ad92b654fsi2782348pgl.185.2022.08.18.18.31.10; Thu, 18 Aug 2022 18:31:22 -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=MWCaV9fG; 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 S1344131AbiHSA5N (ORCPT + 99 others); Thu, 18 Aug 2022 20:57:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239026AbiHSA5J (ORCPT ); Thu, 18 Aug 2022 20:57:09 -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 ESMTPS id E6B3DDF0AB for ; Thu, 18 Aug 2022 17:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660870626; 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=WXZV61jfgDNJXnq5uwdk9hoJi8yzuP+++eERMshJ/0Q=; b=MWCaV9fGWio1MopK4E1juVAqoE/jNaBgTVOB74WbfyMybfsxgrmpJFaY8l5eDs5/cWpl+5 D+dRYHqgqosb1OpEgwgryvBBTT2/W4fpHuA9YdKUzwMSC+Vrxgz6+307Skt0VxuwUs1OUM e1AAnEEdam34tP/KOdmH3lcjlx3rVSA= 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-321-VilcA4G8OhCHa0uI9An1Eg-1; Thu, 18 Aug 2022 20:57:01 -0400 X-MC-Unique: VilcA4G8OhCHa0uI9An1Eg-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 D3A3C185A7B2; Fri, 19 Aug 2022 00:56:58 +0000 (UTC) Received: from gshan.redhat.com (vpn2-54-16.bne.redhat.com [10.64.54.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09C02C15BB8; Fri, 19 Aug 2022 00:56:49 +0000 (UTC) From: Gavin Shan To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, peterx@redhat.com, pbonzini@redhat.com, corbet@lwn.net, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, seanjc@google.com, drjones@redhat.com, dmatlack@google.com, bgardon@google.com, ricarkol@google.com, zhenyzha@redhat.com, shan.gavin@gmail.com Subject: [PATCH v1 2/5] KVM: selftests: Use host page size to map ring buffer in dirty_log_test Date: Fri, 19 Aug 2022 08:55:58 +0800 Message-Id: <20220819005601.198436-3-gshan@redhat.com> In-Reply-To: <20220819005601.198436-1-gshan@redhat.com> References: <20220819005601.198436-1-gshan@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-2.8 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,T_SCC_BODY_TEXT_LINE 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 In vcpu_map_dirty_ring(), the guest's page size is used to figure out the offset in the virtual area. It works fine when we have same page size on host and guest. However, it fails when the page sizes on host and guest are different, like below error messages indicates. Actually, the offset should be figured out according to host's page size. Otherwise, the virtual area associated with the ring buffer can't be identified by host. # ./dirty_log_test -M dirty-ring -m 7 Setting log mode to: 'dirty-ring' Test iterations: 32, interval: 10 (ms) Testing guest mode: PA-bits:40, VA-bits:48, 64K pages guest physical test memory offset: 0xffbffc0000 vcpu stops because vcpu is kicked out... Notifying vcpu to continue vcpu continues now. ==== Test Assertion Failure ==== lib/kvm_util.c:1477: addr == MAP_FAILED pid=9000 tid=9000 errno=0 - Success 1 0x0000000000405f5b: vcpu_map_dirty_ring at kvm_util.c:1477 2 0x0000000000402ebb: dirty_ring_collect_dirty_pages at dirty_log_test.c:349 3 0x00000000004029b3: log_mode_collect_dirty_pages at dirty_log_test.c:478 4 (inlined by) run_test at dirty_log_test.c:778 5 (inlined by) run_test at dirty_log_test.c:691 6 0x0000000000403a57: for_each_guest_mode at guest_modes.c:105 7 0x0000000000401ccf: main at dirty_log_test.c:921 8 0x0000ffffb06ec79b: ?? ??:0 9 0x0000ffffb06ec86b: ?? ??:0 10 0x0000000000401def: _start at ??:? Dirty ring mapped private Fix the issue by using host's page size to map the ring buffer. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 9889fe0d8919..4e823cbe6b48 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1464,7 +1464,7 @@ struct kvm_reg_list *vcpu_get_reg_list(struct kvm_vcpu *vcpu) void *vcpu_map_dirty_ring(struct kvm_vcpu *vcpu) { - uint32_t page_size = vcpu->vm->page_size; + uint32_t page_size = getpagesize(); uint32_t size = vcpu->vm->dirty_ring_size; TEST_ASSERT(size > 0, "Should enable dirty ring first"); -- 2.23.0