Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3800974pxb; Tue, 26 Jan 2021 05:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjSAc+c9PyqgetOz7ALFmuUU8PSDWMOLrvA4i00EIyH8kCUpzGym9p+0inNtJiaKs9IdU8 X-Received: by 2002:a05:6402:1398:: with SMTP id b24mr4351235edv.108.1611667047128; Tue, 26 Jan 2021 05:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611667047; cv=none; d=google.com; s=arc-20160816; b=SXO42trV2936RDm6hZkaP1WOwv5E8rp2MKMtL8yBtgMcm9IW8rB1kpFXEZKR6Jt4F6 oPFulNID4hqMAsSmRtUcmf+HxvtvKWwvzrdlCacyLVbVt+96/A3cADqjviynZ1WSHkk4 08fMIoEzVmpnFMW9ApMC7pNOOETDOpEtoxZXZJeZ7mDptzLXt8MBNjrLSLuvwCaK6Wz/ ZYiZfYzkV5qM76N2b1qG9KAiv3pD5cDcDCrKTKQaxzZ7Gsq665dY4fk936mTj0lXoLQo xRFDmKhrMyDxAyiGG0a4tBhRe1BbsJo/sehFn4XXVqywIlmdgb+sAcxmm5IYqngVRbZw gedw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=W5RoVobSKGXWiF2esE/aLXx1FLXtV+QlhWZY2wybfvk=; b=J+Gyb2v8PU3SUle1drr3fjqgyUuj897TT0mAnLTTePPJJ/p0Nt0EiFHai3ZZgndubm ZZzFcrL5MqYPacCHovLYy8Pj4KfTsPaRJOiREeO/pa5CWukoa6lkOkdqSLFf1Zw0X9P+ Acd5ljhgRLBx27i6x6bBAECnhv9bQWno19D4ZGc69c+bjFw38k0bA9EBMBMUUjfMneDJ /FWjQpIUfXmCu3uRu3gKjsNOqyGEGUJdL31ul1Vmn5GA6kHUkZbe+LR0N95Su3tMtT+u Iz73pQM5MdcK/0wj2xODpNWWn/tqkha7dh0mG5DTV1ScmvOWrr1cxvOMYTBq5eT5p29n sPUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si8489896edu.286.2021.01.26.05.17.02; Tue, 26 Jan 2021 05:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392543AbhAZNPG (ORCPT + 99 others); Tue, 26 Jan 2021 08:15:06 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:11508 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391851AbhAZMrV (ORCPT ); Tue, 26 Jan 2021 07:47:21 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DQ5yX1ljRzjDdp; Tue, 26 Jan 2021 20:44:04 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.184.42) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Tue, 26 Jan 2021 20:45:05 +0800 From: Keqian Zhu To: , , , , Marc Zyngier , Will Deacon , Catalin Marinas CC: Alex Williamson , Kirti Wankhede , Cornelia Huck , Mark Rutland , James Morse , Robin Murphy , Suzuki K Poulose , , , , , Subject: [RFC PATCH 5/7] kvm: arm64: Add some HW_DBM related mmu interfaces Date: Tue, 26 Jan 2021 20:44:42 +0800 Message-ID: <20210126124444.27136-6-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210126124444.27136-1-zhukeqian1@huawei.com> References: <20210126124444.27136-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds set_dbm, clear_dbm and sync_dirty interfaces in mmu layer. They simply wrap those interfaces of pgtable layer, adding reschedule semantics. Signed-off-by: Keqian Zhu --- arch/arm64/include/asm/kvm_mmu.h | 7 +++++++ arch/arm64/kvm/mmu.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index e52d82aeadca..51dd31ba1b94 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm/kvm_mmu.h @@ -183,6 +183,13 @@ int create_hyp_exec_mappings(phys_addr_t phys_addr, size_t size, void **haddr); void free_hyp_pgds(void); +void kvm_stage2_clear_dbm(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages); +void kvm_stage2_set_dbm(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages); +void kvm_stage2_sync_dirty(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages); + void stage2_unmap_vm(struct kvm *kvm); int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu); void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu); diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 7d2257cc5438..18717fd12731 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -609,6 +609,36 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm, kvm_mmu_write_protect_pt_masked(kvm, slot, gfn_offset, mask); } +void kvm_stage2_clear_dbm(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages) +{ + phys_addr_t base_gfn = slot->base_gfn + gfn_offset; + phys_addr_t addr = base_gfn << PAGE_SHIFT; + phys_addr_t end = (base_gfn + npages) << PAGE_SHIFT; + + stage2_apply_range_resched(kvm, addr, end, kvm_pgtable_stage2_clear_dbm); +} + +void kvm_stage2_set_dbm(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages) +{ + phys_addr_t base_gfn = slot->base_gfn + gfn_offset; + phys_addr_t addr = base_gfn << PAGE_SHIFT; + phys_addr_t end = (base_gfn + npages) << PAGE_SHIFT; + + stage2_apply_range_resched(kvm, addr, end, kvm_pgtable_stage2_set_dbm); +} + +void kvm_stage2_sync_dirty(struct kvm *kvm, struct kvm_memory_slot *slot, + gfn_t gfn_offset, unsigned long npages) +{ + phys_addr_t base_gfn = slot->base_gfn + gfn_offset; + phys_addr_t addr = base_gfn << PAGE_SHIFT; + phys_addr_t end = (base_gfn + npages) << PAGE_SHIFT; + + stage2_apply_range_resched(kvm, addr, end, kvm_pgtable_stage2_sync_dirty); +} + static void clean_dcache_guest_page(kvm_pfn_t pfn, unsigned long size) { __clean_dcache_guest_page(pfn, size); -- 2.19.1