Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2309251ybt; Tue, 16 Jun 2020 02:39:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVv/tDNGMdc8FVLgN5UmmPKs83d9Xk4ij1bv2Mweg/iv8nzLAh3Xd6Bj12GozrULym888D X-Received: by 2002:a17:906:1947:: with SMTP id b7mr1847081eje.320.1592300352033; Tue, 16 Jun 2020 02:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592300352; cv=none; d=google.com; s=arc-20160816; b=Dt220q6Rb+0M0IugrQPam7MU3pYy2xL+LG/3HkRgrKcNdUzP1JApF4kdbVQiTokGob sh7YfUMdWHB27ldVnJb0tZzfeUMMYdvWMArbVnDAdvlyQ2DlL0eQ6KBuod9rtCHTZlwx eS9ZwuIAYij5mWsaK0tV6CbxLUWCpu+PPtZCTRmyqa2w3RIgST834m1mY33GcKp/+GBW ZVoC0VQRygs4zrcnhAqAPBb+XKPSUFzv9d15THNRdYc8fuqTotTi2Ou5pxiQdksGT08P eo2HpaGzpPHetkYvV+7j+vU62HEn+DSyw2Vq1iyyqad/cabTcLvbUbaFLael09PTiLWq FcwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=VUFxUxibqvqlV/e3LZYAP80wkFraKM4c3dVkjIY2m9s=; b=EBxMnWGwsVfMTZcaL/5aQCVveCMRtK7AxCH5r6/x5gc527asVcqqgQfAgUDoOV5Hkm gKVR2TqnhHtxXGUOyxzAzQWHsoR6/hPLFRiYEtK2i5ECpkYz6OqZqbAmwy9N7pgMfhhr NyrPY54CRukGzIfr/lzitnggvBzgnbFRlIr6063ZTsl/seloYo1GSbMRyIWVi66q/L4z UJvGmFG5fG9Ytk81EkY0POIYDL6Vgr5YXoWQJ8/reahb6QqQjVnk81JZ0rLvLAFW+PsP h4/gQ7AHkM08AvcmRIzQSb2w1mfnqkmCwO2m2XalGdV6jo98YJ4P3wq0/AkUGEwdDFs1 Bsmg== 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 hh4si10682437ejb.549.2020.06.16.02.38.49; Tue, 16 Jun 2020 02:39:12 -0700 (PDT) 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 S1728462AbgFPJgc (ORCPT + 99 others); Tue, 16 Jun 2020 05:36:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6267 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728131AbgFPJg0 (ORCPT ); Tue, 16 Jun 2020 05:36:26 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B1B0AEC54AB3263F89AF; Tue, 16 Jun 2020 17:36:23 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.173.221.230) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 16 Jun 2020 17:36:14 +0800 From: Keqian Zhu To: , , , CC: Catalin Marinas , Marc Zyngier , James Morse , Will Deacon , "Suzuki K Poulose" , Sean Christopherson , Julien Thierry , Mark Brown , "Thomas Gleixner" , Andrew Morton , Alexios Zavras , , , , Keqian Zhu Subject: [PATCH 12/12] KVM: arm64: Enable stage2 hardware DBM Date: Tue, 16 Jun 2020 17:35:53 +0800 Message-ID: <20200616093553.27512-13-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20200616093553.27512-1-zhukeqian1@huawei.com> References: <20200616093553.27512-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.221.230] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We are ready to support hw management of dirty state, enable it if hardware support it. Signed-off-by: Keqian Zhu Signed-off-by: Peng Liang --- arch/arm64/include/asm/sysreg.h | 2 ++ arch/arm64/kvm/reset.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 463175f80341..b22bd903284d 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -744,6 +744,8 @@ #define ID_AA64MMFR1_VMIDBITS_8 0 #define ID_AA64MMFR1_VMIDBITS_16 2 +#define ID_AA64MMFR1_HADBS_DBS 2 + /* id_aa64mmfr2 */ #define ID_AA64MMFR2_E0PD_SHIFT 60 #define ID_AA64MMFR2_FWB_SHIFT 40 diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 52bb801c9b2c..c1215b13bdd5 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -427,7 +427,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) { u64 vtcr = VTCR_EL2_FLAGS, mmfr0; u32 parange, phys_shift; - u8 lvls; + u8 lvls, hadbs; if (type & ~KVM_VM_TYPE_ARM_IPA_SIZE_MASK) return -EINVAL; @@ -465,6 +465,13 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) */ vtcr |= VTCR_EL2_HA; +#ifdef CONFIG_ARM64_HW_AFDBM + hadbs = (read_sysreg(id_aa64mmfr1_el1) >> + ID_AA64MMFR1_HADBS_SHIFT) & 0xf; + if (hadbs == ID_AA64MMFR1_HADBS_DBS) + vtcr |= VTCR_EL2_HD; +#endif + /* Set the vmid bits */ vtcr |= (kvm_get_vmid_bits() == 16) ? VTCR_EL2_VS_16BIT : -- 2.19.1