From patchwork Fri Dec 9 01:53:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 31581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp529289wrr; Thu, 8 Dec 2022 17:56:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf6wrs5KJbUe493JvWUR4p6pyhceU5xwOFezActQNNOf5GJgaPQ6yhKqPKa9NjD/WW3Jl89G X-Received: by 2002:a05:6402:e98:b0:45c:835c:eab1 with SMTP id h24-20020a0564020e9800b0045c835ceab1mr3752732eda.31.1670550972089; Thu, 08 Dec 2022 17:56:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670550972; cv=none; d=google.com; s=arc-20160816; b=HGKpb35ZVa1ABbsCmPO8DGjU/mzfxNJ+GG0lfbLgn9faeHeR+sNSZO3VEVbpuf/oWv juMMzlx4GWrS6vhzhZ6v03BAN1oUWtCWU6AfJKI/YpYfEOHUZ6mRImL4Tv4tw9ahSbKR 77jGHbsnu7mJsRaJYfwnechVbEzBF6coa2KEdonkxLGcACFMeh3cUDVIEfWkjclBUQiA b76Z8jwnSIYanGYK/0l/0X5eOsGPTJ0gyhrtcCfnA7LAFyT+LyNfAZmhE706zQHBIHEZ Q8RV6O2s5a5tUNBQa0ycxBQunTdj2tDeUDYRCZ1B2k28s/hqY+YQeY/swXPC+pweVSr+ oxEQ== 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; bh=3lSpaVAFxsrE5e9IIvgtegxsRjzp2l3Pd0bb8fOJe2A=; b=ohlSr3IqvWkRRfMRqdSLEk2IMtYHKmusv/8mSbv0JERKZXpyPVGDa8Qun0RtsYw3AA GZ/9cA3GbBF3BLZC3JzGBF7JP9k/VcN07eT/TlLBme/tUIdJ84uEQBqzNJwxJTg7zV3d Km5rXxZt9nJChR6owjX5nTnImdCCVgiMd5d2Ob0OOX9V4t8yuw6DSyuVY/jgNabt5bvs aVvFCulEr2/2Qc7iemlZbPrPkZvF3+T8S0yWtu1xaCEHg36bVAzsxxBccCn/ENrFHJp3 SH/WkbD/kvgVv74Ah0cG5jzYTJ+6bH/1HZZ7ujqVXd5GLEEign6melcCnbtU5IzuMifs q61g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r8-20020a05640251c800b0046b44b34d88si281593edd.310.2022.12.08.17.55.48; Thu, 08 Dec 2022 17:56:12 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbiLIBxp (ORCPT + 99 others); Thu, 8 Dec 2022 20:53:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbiLIBxk (ORCPT ); Thu, 8 Dec 2022 20:53:40 -0500 Received: from out-94.mta0.migadu.com (out-94.mta0.migadu.com [91.218.175.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C8798EB7 for ; Thu, 8 Dec 2022 17:53:35 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Paolo Bonzini , Shuah Khan , Sean Christopherson , Vitaly Kuznetsov , Andrew Jones Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Ricardo Koller , Oliver Upton , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] KVM: selftests: Mark correct page as mapped in virt_map() Date: Fri, 9 Dec 2022 01:53:02 +0000 Message-Id: <20221209015307.1781352-4-oliver.upton@linux.dev> In-Reply-To: <20221209015307.1781352-1-oliver.upton@linux.dev> References: <20221209015307.1781352-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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?1751699656241579584?= X-GMAIL-MSGID: =?utf-8?q?1751699656241579584?= The loop marks vaddr as mapped after incrementing it by page size, thereby marking the *next* page as mapped. Set the bit in vpages_mapped first instead. Fixes: 56fc7732031d ("KVM: selftests: Fill in vm->vpages_mapped bitmap in virt_map() too") Signed-off-by: Oliver Upton --- tools/testing/selftests/kvm/lib/kvm_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index e9607eb089be..a256ec67aff6 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1411,10 +1411,10 @@ void virt_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr, while (npages--) { virt_pg_map(vm, vaddr, paddr); + sparsebit_set(vm->vpages_mapped, vaddr >> vm->page_shift); + vaddr += page_size; paddr += page_size; - - sparsebit_set(vm->vpages_mapped, vaddr >> vm->page_shift); } }