From patchwork Tue Jan 18 01:57:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12715817 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 618F7C433EF for ; Tue, 18 Jan 2022 01:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239156AbiARB5L (ORCPT ); Mon, 17 Jan 2022 20:57:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239140AbiARB5K (ORCPT ); Mon, 17 Jan 2022 20:57:10 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACBDC06161C for ; Mon, 17 Jan 2022 17:57:09 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id t1-20020a6564c1000000b002e7f31cf59fso8592996pgv.14 for ; Mon, 17 Jan 2022 17:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kNn8CYLhEqc3+fS1C1muCti5DqMgFmeI9zA8ty3/McY=; b=JV0gxik4s7iG+F0pSgHW0H9GeVHuaJERHWeD5rrsV/yKUt/BaTg2CiG2he++8GvoYC 84JN4Zrv8nIJeq1ncnvlf4zzaaiMHqimhl1RUX5btMrpbpCEXez5L5govdO0DtTFqXpe 1qPMkYaSFrVGF9sTTPek/Yk5NSU+E/ZxX0RFf1rgGkqu3OWzQq/ZdEEbdFFCLPkNCOl0 NGkvA4KFzjr5oNr3/O/17Tb0WYE19NC5lcb/CCnwtUS5v1X7fxIFKoDu+7dcG7n+SqbM wR5A23QbyzxvjKbfdGwOWHu+//Q1DHPt7cDO3VuZzFjs5wXb3ijuEPn+T1aQMImt2j2r ZYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kNn8CYLhEqc3+fS1C1muCti5DqMgFmeI9zA8ty3/McY=; b=ATRsZXSMbB+v/fVLxXXL9SUpSigSiJAEjiYey4k+7QqfTpHd+eC3CsD9M83HaQGis/ d2YMFPBwKeJSa1+aAmAJJyACazXCchx2HOvsS6+mgZ8jFxOvDmHW1ctU3t4MK/M9WM9b N7wkAsOA1c95k2ii2y8oJX2QQehYGhLjABkfNhBQM3SlM9hIyjDCMyaQZaCFlN4S0DNn U7cfjcSi+z61YZyO2Wzn01w/BV5waZLfkG7Fu5I7xcIg7bf7pGNNESNnyeM3Tqtxf7bV Lct17eBO/YX836IOAyVMCLGYpkb8OlBeyuZe/Odb4AcQOeOfeaRzDz7tvE7fTSJcnbGm PHbg== X-Gm-Message-State: AOAM532rGk9LBy3ecHkXa8moP6GDprUYtLgfxDCcCg3DRklv/2ri/cAd ydrJv1PV0NgBz4LldodOzoob4t0pJxePJpoUULe/eyuNRniDOy6R2gXkVjIDvT3LYIPpu8fFpB/ rtAKhJhO/GrpCCjVQWp54t2xwbMKH3qa1IKPLEsYj7ub3g57MWtHiX8C0sbTyL1mT24MIzYQ= X-Google-Smtp-Source: ABdhPJwW5s1OUDoCrjyIaYH31QlroY8rIzcRgns4gmRHP+WHtSBr34woEKWFDWZu2+t0SN6I/FBVtYLD/diOGUPEOg== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a17:902:d2c8:b0:14a:55fb:cfe5 with SMTP id n8-20020a170902d2c800b0014a55fbcfe5mr25322479plc.51.1642471028683; Mon, 17 Jan 2022 17:57:08 -0800 (PST) Date: Tue, 18 Jan 2022 01:57:01 +0000 In-Reply-To: <20220118015703.3630552-1-jingzhangos@google.com> Message-Id: <20220118015703.3630552-2-jingzhangos@google.com> Mime-Version: 1.0 References: <20220118015703.3630552-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH v2 1/3] KVM: arm64: Use read/write spin lock for MMU protection From: Jing Zhang To: KVM , KVMARM , Marc Zyngier , Will Deacon , Paolo Bonzini , David Matlack , Oliver Upton , Reiji Watanabe , Ricardo Koller , Raghavendra Rao Ananta Cc: Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Replace MMU spinlock with rwlock and update all instances of the lock being acquired with a write lock acquisition. Future commit will add a fast path for permission relaxation during dirty logging under a read lock. Signed-off-by: Jing Zhang Tested-by: Fuad Tabba Reviewed-by: Fuad Tabba --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/mmu.c | 36 +++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 3b44ea17af88..6c99c0335bae 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -50,6 +50,8 @@ #define KVM_DIRTY_LOG_MANUAL_CAPS (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE | \ KVM_DIRTY_LOG_INITIALLY_SET) +#define KVM_HAVE_MMU_RWLOCK + /* * Mode of operation configurable with kvm-arm.mode early param. * See Documentation/admin-guide/kernel-parameters.txt for more information. diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index bc2aba953299..cafd5813c949 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -58,7 +58,7 @@ static int stage2_apply_range(struct kvm *kvm, phys_addr_t addr, break; if (resched && next != end) - cond_resched_lock(&kvm->mmu_lock); + cond_resched_rwlock_write(&kvm->mmu_lock); } while (addr = next, addr != end); return ret; @@ -179,7 +179,7 @@ static void __unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 struct kvm *kvm = kvm_s2_mmu_to_kvm(mmu); phys_addr_t end = start + size; - assert_spin_locked(&kvm->mmu_lock); + lockdep_assert_held_write(&kvm->mmu_lock); WARN_ON(size & ~PAGE_MASK); WARN_ON(stage2_apply_range(kvm, start, end, kvm_pgtable_stage2_unmap, may_block)); @@ -213,13 +213,13 @@ static void stage2_flush_vm(struct kvm *kvm) int idx, bkt; idx = srcu_read_lock(&kvm->srcu); - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); slots = kvm_memslots(kvm); kvm_for_each_memslot(memslot, bkt, slots) stage2_flush_memslot(kvm, memslot); - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); srcu_read_unlock(&kvm->srcu, idx); } @@ -720,13 +720,13 @@ void stage2_unmap_vm(struct kvm *kvm) idx = srcu_read_lock(&kvm->srcu); mmap_read_lock(current->mm); - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); slots = kvm_memslots(kvm); kvm_for_each_memslot(memslot, bkt, slots) stage2_unmap_memslot(kvm, memslot); - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); mmap_read_unlock(current->mm); srcu_read_unlock(&kvm->srcu, idx); } @@ -736,14 +736,14 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu) struct kvm *kvm = kvm_s2_mmu_to_kvm(mmu); struct kvm_pgtable *pgt = NULL; - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); pgt = mmu->pgt; if (pgt) { mmu->pgd_phys = 0; mmu->pgt = NULL; free_percpu(mmu->last_vcpu_ran); } - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); if (pgt) { kvm_pgtable_stage2_destroy(pgt); @@ -783,10 +783,10 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, if (ret) break; - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); ret = kvm_pgtable_stage2_map(pgt, addr, PAGE_SIZE, pa, prot, &cache); - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); if (ret) break; @@ -834,9 +834,9 @@ static void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot) start = memslot->base_gfn << PAGE_SHIFT; end = (memslot->base_gfn + memslot->npages) << PAGE_SHIFT; - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); stage2_wp_range(&kvm->arch.mmu, start, end); - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); kvm_flush_remote_tlbs(kvm); } @@ -1212,7 +1212,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (exec_fault && device) return -ENOEXEC; - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); pgt = vcpu->arch.hw_mmu->pgt; if (mmu_notifier_retry(kvm, mmu_seq)) goto out_unlock; @@ -1271,7 +1271,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, } out_unlock: - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); kvm_set_pfn_accessed(pfn); kvm_release_pfn_clean(pfn); return ret != -EAGAIN ? ret : 0; @@ -1286,10 +1286,10 @@ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa) trace_kvm_access_fault(fault_ipa); - spin_lock(&vcpu->kvm->mmu_lock); + write_lock(&vcpu->kvm->mmu_lock); mmu = vcpu->arch.hw_mmu; kpte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa); - spin_unlock(&vcpu->kvm->mmu_lock); + write_unlock(&vcpu->kvm->mmu_lock); pte = __pte(kpte); if (pte_valid(pte)) @@ -1692,9 +1692,9 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm, gpa_t gpa = slot->base_gfn << PAGE_SHIFT; phys_addr_t size = slot->npages << PAGE_SHIFT; - spin_lock(&kvm->mmu_lock); + write_lock(&kvm->mmu_lock); unmap_stage2_range(&kvm->arch.mmu, gpa, size); - spin_unlock(&kvm->mmu_lock); + write_unlock(&kvm->mmu_lock); } /* From patchwork Tue Jan 18 01:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12715818 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 EEB9BC433F5 for ; Tue, 18 Jan 2022 01:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239189AbiARB5M (ORCPT ); Mon, 17 Jan 2022 20:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239172AbiARB5L (ORCPT ); Mon, 17 Jan 2022 20:57:11 -0500 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF55C061574 for ; Mon, 17 Jan 2022 17:57:11 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id i8-20020a17090a718800b001b35ee7ac29so946359pjk.3 for ; Mon, 17 Jan 2022 17:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=FFJ0LKVBXmV+PQlVXimlN+9PR3R1f2e8LV1lWAds9CU=; b=pfvIFT7tUQ/lfy5xV/tlxtndZnM0AlSEqqjfbmpgRPXnF0D+BHDAvTalj9NsO+HEPq mSksHH9PCLFVenOrrjwk6g8CIKYlWCpf9xvEq5H+TgteXC37n+OXomLW9LvYHuVof9Qp 5jwBfAvBbhY+qMSlMX6ss1g6P4zYIh/ismtJXFIyHek36v9da2fltoPoiR0rKUfnfn9t aeqqWj6NxMnvm8p32CgwWtSYBMmmYiq6jJwtYk/7oLFqm74Xlx8QJJAq+4W3o65Sb3or aN6CWExuC6Og1Jt6whszPn/rwoquDJpfo/DNmcTzJ9LCsmHsOEIhVmi+X/HpN69Dfufm j/eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=FFJ0LKVBXmV+PQlVXimlN+9PR3R1f2e8LV1lWAds9CU=; b=U0pcLydApOIpYnunqyd4JdnJG4Wv3lnEzN6JPs8afenQW9b1dZYqEceERcgbmAARX4 r9GaDByR5mzRjzr7Dn6LcIEWE0coo1BWRo3o/hLmiCfPulmVrHnmqA85QxivacnLrKfL hCTWpleUSE4/lI7ZsRzxnnUOK4ONfovhAQt6wlPXIZ+5NDNreF7bSmm1mtTmngckwQDl 2NuFKkWu2rLnEXuYogfhPJ5EP4/IRogeyRQU6YZBipSKzbgvjZRmAtwXkAwp2t9a+jzF 8A0XnKlKSWqoTyMrxnN4UrMpgtl2eYB2IsEYy59WQoZZzJWAWL4A4sQZyZG0dhv/jVt6 uTjw== X-Gm-Message-State: AOAM533FdfOydW8NL5b9hDs9u2LyI69I0rymLXQKC6nig47D8FIC6PYa xYGhpnEFd8yNu9qU/rzMBz+JwvNN2kZx2G1nkRGhV2XkAB06pc/6XwyHGmS+JMl/m0C/g9lS/Ve Rt2atLepf0kIZM9UzFD2Tn0PSEnJ8v4T8/VPVJeMya6vpVI/nYXmaQM9nJLAOZ4bR3st77V8= X-Google-Smtp-Source: ABdhPJxhGRe+V900JEd7wGouyItkJhnzMy8lso2rLIVPW2lAzYzOWPMFZVPT+b8tM61zC+Z0DPCs4S/OSQ9SimggFw== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a17:90b:3a89:: with SMTP id om9mr7859711pjb.103.1642471030415; Mon, 17 Jan 2022 17:57:10 -0800 (PST) Date: Tue, 18 Jan 2022 01:57:02 +0000 In-Reply-To: <20220118015703.3630552-1-jingzhangos@google.com> Message-Id: <20220118015703.3630552-3-jingzhangos@google.com> Mime-Version: 1.0 References: <20220118015703.3630552-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH v2 2/3] KVM: arm64: Add fast path to handle permission relaxation during dirty logging From: Jing Zhang To: KVM , KVMARM , Marc Zyngier , Will Deacon , Paolo Bonzini , David Matlack , Oliver Upton , Reiji Watanabe , Ricardo Koller , Raghavendra Rao Ananta Cc: Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To reduce MMU lock contention during dirty logging, all permission relaxation operations would be performed under read lock. Signed-off-by: Jing Zhang Tested-by: Fuad Tabba Reviewed-by: Fuad Tabba --- arch/arm64/kvm/mmu.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index cafd5813c949..10df5d855d54 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1080,6 +1080,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, gfn_t gfn; kvm_pfn_t pfn; bool logging_active = memslot_is_logging(memslot); + bool logging_perm_fault = false; unsigned long fault_level = kvm_vcpu_trap_get_fault_level(vcpu); unsigned long vma_pagesize, fault_granule; enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R; @@ -1114,6 +1115,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (logging_active) { force_pte = true; vma_shift = PAGE_SHIFT; + logging_perm_fault = (fault_status == FSC_PERM && write_fault); } else { vma_shift = get_vma_page_shift(vma, hva); } @@ -1212,7 +1214,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, if (exec_fault && device) return -ENOEXEC; - write_lock(&kvm->mmu_lock); + /* + * To reduce MMU contentions and enhance concurrency during dirty + * logging dirty logging, only acquire read lock for permission + * relaxation. + */ + if (logging_perm_fault) + read_lock(&kvm->mmu_lock); + else + write_lock(&kvm->mmu_lock); pgt = vcpu->arch.hw_mmu->pgt; if (mmu_notifier_retry(kvm, mmu_seq)) goto out_unlock; @@ -1271,7 +1281,10 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, } out_unlock: - write_unlock(&kvm->mmu_lock); + if (logging_perm_fault) + read_unlock(&kvm->mmu_lock); + else + write_unlock(&kvm->mmu_lock); kvm_set_pfn_accessed(pfn); kvm_release_pfn_clean(pfn); return ret != -EAGAIN ? ret : 0; From patchwork Tue Jan 18 01:57:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12715819 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 B59FBC433EF for ; Tue, 18 Jan 2022 01:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239204AbiARB5O (ORCPT ); Mon, 17 Jan 2022 20:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239145AbiARB5N (ORCPT ); Mon, 17 Jan 2022 20:57:13 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6189C061574 for ; Mon, 17 Jan 2022 17:57:12 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id s8-20020a056a00178800b004c480752316so2498958pfg.7 for ; Mon, 17 Jan 2022 17:57:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=mvimdalggRqv44+8DxSjpX0UJ7y65xJ7W9TGgiRekLQ=; b=AiNhonZ8w18AjTZDIERNhgzwKTJ7KI9+QJJd8eVZ97usyEfyImywldUVzLovaShH9S cLGIp0JfORuBbqRrDQbnT8FEtXaKIml5rY0QTX1c3EsLUO1u1lusYyOq6/fGFppMM1// aMwpKmSOqoGv//5rZZjp+PvOE9ATF7D2w1i5j/1B1kIeL+BxfVCHYeJZm8XKHz56xqbV rTigTGzw72EsIWpvKlFSWwdzmOeSxzJ3UTPMbpRY8v00WHB1Iw74Xq6c0G1rYfZNMenY 43HurKrjCLaAFTZl6EzVTXc58H9IJkNCVSaKrl3M7BJdjavfNTeXC6nyEIxAsJu5lIxx fctQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mvimdalggRqv44+8DxSjpX0UJ7y65xJ7W9TGgiRekLQ=; b=LDIThpAMxNljTaUmWRwjaFFZvlJzypD8vNYAT0yI/xuDUfB3Uye1RoJmyZUuTdF8al NyeC8fLuVgbdZ5KqATa4lmjgv0hlSDimgCx8rthgoa7tI81ll7wRmLV1QpXwBLf+MUXB Db45zLQP71cQNz6GQ0kwQHgmgPcvaY16JPA7+HxQIxO/U/fQYpW0pE1MMcvd872B0neS +1sd9CZhN6Mb6y/93EfqTBIsyOvOXtFoR77fuNzssKvrnazzhA0BGo22+EPzKMfRIEBR 4qycOtUyE1sY06f75KEwNz7dYpXpjRblufTjDK8aLQbASSPkL0gv74nNF4Ne8fnolRGj p9GA== X-Gm-Message-State: AOAM530jBBle0PSbEC3S5eZ1TUp2GI6nGYInAIK8LJD1gv0YlNIwoo20 19/OjVofleMkQDP+l2yzuE/pHVL/t70yBs+TsgncHXXuxqhZwxNjHwEKh6sgNXjyfcofBa4eqzk tSBzG4bugkuGC0fEoK7jPzyiq/FApiIyLVrujVrZOjbNgPU1YBsQOPeclnRdjPJSGYuM2AR8= X-Google-Smtp-Source: ABdhPJy3MfvyC98SST6vF79hK6xhszFOokBw22k4x5+KH+epIuRlSbBOdJSPcTvn8fxkwxwF8De41dpAJAhSSAm4Fw== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a17:90b:4d84:: with SMTP id oj4mr1115111pjb.0.1642471031804; Mon, 17 Jan 2022 17:57:11 -0800 (PST) Date: Tue, 18 Jan 2022 01:57:03 +0000 In-Reply-To: <20220118015703.3630552-1-jingzhangos@google.com> Message-Id: <20220118015703.3630552-4-jingzhangos@google.com> Mime-Version: 1.0 References: <20220118015703.3630552-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog Subject: [PATCH v2 3/3] KVM: selftests: Add vgic initialization for dirty log perf test for ARM From: Jing Zhang To: KVM , KVMARM , Marc Zyngier , Will Deacon , Paolo Bonzini , David Matlack , Oliver Upton , Reiji Watanabe , Ricardo Koller , Raghavendra Rao Ananta Cc: Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org For ARM64, if no vgic is setup before the dirty log perf test, the userspace irqchip would be used, which would affect the dirty log perf test result. Signed-off-by: Jing Zhang Tested-by: Fuad Tabba Reviewed-by: Fuad Tabba --- tools/testing/selftests/kvm/dirty_log_perf_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/kvm/dirty_log_perf_test.c b/tools/testing/selftests/kvm/dirty_log_perf_test.c index 1954b964d1cf..b501338d9430 100644 --- a/tools/testing/selftests/kvm/dirty_log_perf_test.c +++ b/tools/testing/selftests/kvm/dirty_log_perf_test.c @@ -18,6 +18,12 @@ #include "test_util.h" #include "perf_test_util.h" #include "guest_modes.h" +#ifdef __aarch64__ +#include "aarch64/vgic.h" + +#define GICD_BASE_GPA 0x8000000ULL +#define GICR_BASE_GPA 0x80A0000ULL +#endif /* How many host loops to run by default (one KVM_GET_DIRTY_LOG for each loop)*/ #define TEST_HOST_LOOP_N 2UL @@ -200,6 +206,10 @@ static void run_test(enum vm_guest_mode mode, void *arg) vm_enable_cap(vm, &cap); } +#ifdef __aarch64__ + vgic_v3_setup(vm, nr_vcpus, 64, GICD_BASE_GPA, GICR_BASE_GPA); +#endif + /* Start the iterations */ iteration = 0; host_quit = false;