From patchwork Mon Jan 10 21:04:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12709130 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 2F65EC433EF for ; Mon, 10 Jan 2022 21:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343753AbiAJVFD (ORCPT ); Mon, 10 Jan 2022 16:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239741AbiAJVFD (ORCPT ); Mon, 10 Jan 2022 16:05:03 -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 E5AA6C06173F for ; Mon, 10 Jan 2022 13:05:02 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id a4-20020a17090a70c400b001b21d9c8bc8so362506pjm.7 for ; Mon, 10 Jan 2022 13:05:02 -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=tvWQrk5m+auOAW75En/9PBKMdEwVtYbyEoey6RrsQGY=; b=e5wvyEvF+6FHTqteWzNNKatxYnJ4VRlsfWm24dqvR6gh/YchZ8gn84JRPhHUb4l2TC a/zNUCJkZ4csmy+GqoZjvNoUj4m4oA3lpGHhSsmc9hXQt/1ZLfi4sS8GkEcGugkuWjcL Jwddo2N9Pam5r0DUjpQfgFV8cqesubSvju8AQut6DA5nPGQEZNSdYPqhtxbIsYY6tYJa TEG26xC6/S+/MM2dQQfBXHJD2GiW3MDF4b7xHvPOlZhFc3v1Mw3m8rXCRcxtvLH0hFFp LCSBqQhBbFIKfU9BOWZWcQu/L/lzZUjOw6+P0uiv4rGAd1JpNJ5JOBpHXFaTllRe9sN4 AyNA== 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=tvWQrk5m+auOAW75En/9PBKMdEwVtYbyEoey6RrsQGY=; b=2ckBpf/EzO6elE01JffoqQCvsNB5X9np1VoMAtncFngcyrAXlagREKQqZWgLPh2YGg nIvUMh2IDTkuRoHbeBPKyQQoq9Ho7K31c4Xi/n7D+B12u3USiYkWzIuTUoxq5yjkdFUJ TX75PdGOBUzFAIWYgd7yIHX1JCCQDZlEDnD7JAECZFEULeWPvA+AHn0tKiZKGYkM0YMd WiZfYclNSB9Se6FjwpuQKkkZSsTEv8JyKsE2N9wHICsXWEELNXp0jc6wjnbc8eIPtuNe E5t1CQlc3MzIHds/3buKkQYndndaZBba+2HRSvgNblAgNlEjYuqR850GfpZwELfS1wbr 6+1w== X-Gm-Message-State: AOAM532m0ebkfB9slEkqg/7cICdCQYcHzaKbUZbEY5Hw38R3iYW81DdR zI4ceAYq+/cyGUqBFv3AuvqmEmJ+63AtWtSj+uwOHn7ZYsHrZxk56dOIhLsUo3p0Ch/QFd3MfVm 4C8/OqVHVmBTcbLBBoxwPISwq0BLhJyXnLeRQwXoQR7RaVeCQh8RcfyhcIE+1zLGEJSW5UbQ= X-Google-Smtp-Source: ABdhPJzKNuD1sJM5lGJUPo9JWpQ9TX/uS6nn/vrAZPHCas8+Luj+bHqUKHRmoSvs4znM+7FiR3Lwl9FKVzdJYJZqtw== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a63:a706:: with SMTP id d6mr1340856pgf.390.1641848702323; Mon, 10 Jan 2022 13:05:02 -0800 (PST) Date: Mon, 10 Jan 2022 21:04:39 +0000 In-Reply-To: <20220110210441.2074798-1-jingzhangos@google.com> Message-Id: <20220110210441.2074798-2-jingzhangos@google.com> Mime-Version: 1.0 References: <20220110210441.2074798-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog Subject: [RFC PATCH 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 Cc: Jing Zhang Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org To reduce the contentions caused by MMU lock, some MMU operations can be performed under read lock. One improvement is to add a fast path for permission relaxation during dirty logging under the read lock. Signed-off-by: Jing Zhang --- 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 Mon Jan 10 21:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12709131 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 136E5C433F5 for ; Mon, 10 Jan 2022 21:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343766AbiAJVFF (ORCPT ); Mon, 10 Jan 2022 16:05:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239741AbiAJVFE (ORCPT ); Mon, 10 Jan 2022 16:05:04 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7E90C06173F for ; Mon, 10 Jan 2022 13:05:04 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id ik6-20020a170902ab0600b0014a1e5aab34so1994102plb.21 for ; Mon, 10 Jan 2022 13:05:04 -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=SblhaXcWijIzk0Mapv3cGqzGg1Y0/XESvuNWuvJevdk=; b=tJhw8ZATrv3Sjy9QhepZUWpfX9dTE8Ja4a0R/EZCvyfUQj/+OWsQL94ONBjWVMpaez b2bNJQTqp6okRMwCqrN5Tt4UOCN2V+ptEfZEk3C3g/c8Y//NHMFgSJRgtIdayXr0LemP UYcHoRiyjMfoQJC5LpxjbMcsa+oSbLKuBbaungcF3668+S7YF9EKmn4bGkYxiQEmQlke wBmpEIHWalDlZEJLoE+Zgt3IZ9NyHxeGMLCwYNIdPApvX/MtGJGslz6BjO464WpeSKwZ VEuOU2T24qaEojHNtI8BfU84V+5HoQzHehfcEfTff+Wvb5WL8jlpl/iyJK9Y6IbsYFvY w+mw== 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=SblhaXcWijIzk0Mapv3cGqzGg1Y0/XESvuNWuvJevdk=; b=Q5sauPqisO1ZEgaMg8wwEzUFJPevDLD0Ak3JuWDvh47HFI08abGBygweua3gQM2O42 dvyFa2d8OY9o96kK35PpT6+FB1SzCcnTrJBQnCzsCtk2BCxTnx+BGjEl4vX9zgc+3sur 2rA2xe1ZcjEYQUvztP1i39WkaxxN73XfQ4gmb4fAFqdPK0EpjNniUPGe3ifE9HVFd3GE H1EWLV999UpRVXISqyY8HCaiNc09NyRC6AGD6CjBNDdl2DAag6gqZcuC2ILXA8NEVMM3 Ag10ZPmFavcKYv4R96k7YrOsng4RDtT4tpiTAR3rfw7tkoqBtCKo8dM4TAekzwtJvN9Y hKHw== X-Gm-Message-State: AOAM532foVdupRXBl3JUfk8Gwtw7dqFTqGa5s2vW0qDw+rfWy5SHvqE3 +OwkMLONMnuD2NpvYfz3JzD1aAIxMKeChtc49Yw/PJI6qi3CSiZmyH07gMbexNXgp09Z46OVRkj 49DaF6216bHrHkMWTx8s9MRGEiQhzIrkcKh27coJ6mLzstQAKYi2NlXhjjOdnYtJBztURs20= X-Google-Smtp-Source: ABdhPJyZXewBlKNnGyc7EiD71gjJFzijvf+twsuG6PIplDMkIgqq41GFwCDp+OOvS5LS/4e8YnTET8+Nw0N7jOmrdQ== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a17:902:c407:b0:149:2ef4:b6b2 with SMTP id k7-20020a170902c40700b001492ef4b6b2mr1490383plk.112.1641848703948; Mon, 10 Jan 2022 13:05:03 -0800 (PST) Date: Mon, 10 Jan 2022 21:04:40 +0000 In-Reply-To: <20220110210441.2074798-1-jingzhangos@google.com> Message-Id: <20220110210441.2074798-3-jingzhangos@google.com> Mime-Version: 1.0 References: <20220110210441.2074798-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog Subject: [RFC PATCH 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 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 --- arch/arm64/kvm/mmu.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index cafd5813c949..dd1f43fba4b0 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1063,6 +1063,54 @@ static int sanitise_mte_tags(struct kvm *kvm, kvm_pfn_t pfn, return 0; } +static bool fast_mark_writable(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, + struct kvm_memory_slot *memslot, unsigned long fault_status) +{ + int ret; + bool writable; + bool write_fault = kvm_is_write_fault(vcpu); + gfn_t gfn = fault_ipa >> PAGE_SHIFT; + kvm_pfn_t pfn; + struct kvm *kvm = vcpu->kvm; + bool logging_active = memslot_is_logging(memslot); + unsigned long fault_level = kvm_vcpu_trap_get_fault_level(vcpu); + unsigned long fault_granule; + + fault_granule = 1UL << ARM64_HW_PGTABLE_LEVEL_SHIFT(fault_level); + + /* Make sure the fault can be handled in the fast path. + * Only handle write permission fault on non-hugepage during dirty + * logging period. + */ + if (fault_status != FSC_PERM || fault_granule != PAGE_SIZE + || !logging_active || !write_fault) + return false; + + + /* Pin the pfn to make sure it couldn't be freed and be resued for + * another gfn. + */ + pfn = __gfn_to_pfn_memslot(memslot, gfn, true, NULL, + write_fault, &writable, NULL); + if (is_error_pfn(pfn) || !writable) + return false; + + read_lock(&kvm->mmu_lock); + ret = kvm_pgtable_stage2_relax_perms( + vcpu->arch.hw_mmu->pgt, fault_ipa, PAGE_HYP); + + if (!ret) { + kvm_set_pfn_dirty(pfn); + mark_page_dirty_in_slot(kvm, memslot, gfn); + } + read_unlock(&kvm->mmu_lock); + + kvm_set_pfn_accessed(pfn); + kvm_release_pfn_clean(pfn); + + return true; +} + static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, struct kvm_memory_slot *memslot, unsigned long hva, unsigned long fault_status) @@ -1085,6 +1133,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R; struct kvm_pgtable *pgt; + if (fast_mark_writable(vcpu, fault_ipa, memslot, fault_status)) + return 0; fault_granule = 1UL << ARM64_HW_PGTABLE_LEVEL_SHIFT(fault_level); write_fault = kvm_is_write_fault(vcpu); exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu); From patchwork Mon Jan 10 21:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 12709132 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 C5571C4332F for ; Mon, 10 Jan 2022 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343767AbiAJVFH (ORCPT ); Mon, 10 Jan 2022 16:05:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239741AbiAJVFG (ORCPT ); Mon, 10 Jan 2022 16:05:06 -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 3A7A8C06173F for ; Mon, 10 Jan 2022 13:05:06 -0800 (PST) Received: by mail-pj1-x104a.google.com with SMTP id b11-20020a17090a6e0b00b001b34cd8941bso11180453pjk.1 for ; Mon, 10 Jan 2022 13:05:06 -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=vBy+mErr/Ri6TNTRhXUfpamv23OXSo9DbZDSg0SsleA=; b=j4wxxxti3g07KeR5JHvFJjSWeBtiIqEnlJZMlLN+QAnslR8j6tBWxo5GU+hia2wTGw W4jmM4Uh7jDA0RFkEjTe29a6Xs+Im3R7Oeir+9fg4a5+fcwiPsflg7OKLwo/qOOfKE2g skORzCFyO2ZQiMpz5MIDa1Cvo7YG4v/3cVutqX1mm6lkfEQZTD0NSXrpDN145MyFPWhj MAf0jDXO36ivf9Dm/Hhz8vXmZ4A7ai5SiRUy52hLcycYaMgnorvd/x90eWjdPGjL4UlU Q1vCcaJMoMfzLf/JS/Co/U0KZcX4Dnt+zug3KcIOu++dR9VgtyZWhGIJqgFyhQznpNUx C2Zw== 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=vBy+mErr/Ri6TNTRhXUfpamv23OXSo9DbZDSg0SsleA=; b=ED7gCDzAn03GwGLpx3djYmWcR8uEPw1039L5Ziffj+NH9d0fytB74t9vUQBoH0veXz 91hZYBHVXq0rl2Klef+xC6srlsb3nQbt2QV5UFUU7ypVkPOO3z3uLpZTSAJEo3MQTXCs uunscngLJnJ2aiDY5NKO6UJSNqFtyqmc+f7M1iyom5nxGRNLKFOPH0nL0rDf0P6q2iKi 3GF4ONAjfhyLObZQeLEGmswbVaTxkJnUHhCj+7dmWMjeILW8oLSsmBVySpkpYnh1J+da SIVa3jG+3BYRw2hB0gsu2SZ59vbqtYWBDPMEcZ12D7OKGkZUfM0arMchkFjW7O+bGNep FbNg== X-Gm-Message-State: AOAM532xWc3NnwTbhioMTJly5Y9ubdUGnfRimO3J/uCFgE7VFYdz23YB x82QD02GYMv3LdnohHjq14Gp73iWyv1tAo0S6BZerREpMApOC6UQ9ezDkjQOTv98mU5iGn9MypO s2xKW6jOyUIuYFPHPntlMQ2ZRO+94MQqeQd0UONvxEdGDZdhN1/m3ZGA17VzQ3Uo+nYLSJ88= X-Google-Smtp-Source: ABdhPJyA6eTvWUsrJk2S/OyaiGDE/FsFt0ITd8LARBlVorREgJZxAx6nOm6HJvMjiBTPntB3YG6byKs1bXRAzVy7wA== X-Received: from jgzg.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1acf]) (user=jingzhangos job=sendgmr) by 2002:a05:6a00:1819:b0:4ba:eaa6:d1b8 with SMTP id y25-20020a056a00181900b004baeaa6d1b8mr1349363pfa.78.1641848705619; Mon, 10 Jan 2022 13:05:05 -0800 (PST) Date: Mon, 10 Jan 2022 21:04:41 +0000 In-Reply-To: <20220110210441.2074798-1-jingzhangos@google.com> Message-Id: <20220110210441.2074798-4-jingzhangos@google.com> Mime-Version: 1.0 References: <20220110210441.2074798-1-jingzhangos@google.com> X-Mailer: git-send-email 2.34.1.575.g55b058a8bb-goog Subject: [RFC PATCH 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 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 --- 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;