Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp987527ybs; Mon, 25 May 2020 04:30:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAb4vSkGII6LrH8KYpU06QacV+pdIviHORi/JvxlrtKRH2uMwEmn+BIoE6sbrQoFOLhyp4 X-Received: by 2002:aa7:d84b:: with SMTP id f11mr14992951eds.288.1590406256303; Mon, 25 May 2020 04:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590406256; cv=none; d=google.com; s=arc-20160816; b=Y5Er73UJhg8vZ3aY5T0C32iJImyogMqsMxt2pTdFfqDyDT/eb/eTKCven+bo29Ug7u R9yvtUj2SpBkInj5kb/QmQie0GAhX9rV25rQaGLq4RFb9g4IWgSFS6kExb4zd+kVA/ex G/8B6UE4HaCXabpLFhXFxUw4O3X/c6Pxjj6qmVfG1H/J7ODB2zAyGL23cDdTPTEf9i6V EbAfaxR1s6YBCpZbyppQYEPv/0g9hGT45GXF+W5ft4BW1RFZmGl+Tq/WDMjhm/E3Us5q Mfq04kKKQeOcb5ianJ3nnHdnbCmv5WVkmBi9cbXkNGs2wjbVzsnNAh1pWL2cgw1Wj4Eh QK4w== 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=isq9RR2HqABQxjjAW8USNG1/GtWczBViJWh3gZZCwEg=; b=LyNqFoXkhdSwJALXUdU2QkYM5lqDSWoFAtQaDkZDaCvZwgiZ2NRIw0k59L0B746vLB X4ioteEnv91YQfGKzo+95u3olRNlib2Sopjb+a++V77aSqZGM/eu+V+/nh4ETcWkmzS6 5OXxdeNO++LXvhB49Nn9ocLlHqEQCFkLM9WqnNl0+JLWccUItra/7OcEpNe+XLHp16Ns fA76x7ko3COEylvM0IR3L3VYGr65RnWjpYtfGXDKKHMeydhAg4c8n6NZHO5isGWbSB9A 8mCkbQPHYwYJcdOkkxk9xFcTniMxcLFPvMUBm6exIFOXjQzVZZu8W9EmpRDKRYDZUhKn RD1g== 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 cd12si4617930ejb.219.2020.05.25.04.30.33; Mon, 25 May 2020 04:30:56 -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 S2390194AbgEYLZc (ORCPT + 99 others); Mon, 25 May 2020 07:25:32 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:47048 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390174AbgEYLZR (ORCPT ); Mon, 25 May 2020 07:25:17 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8459C6C346A43648B102; Mon, 25 May 2020 19:25:14 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.173.221.230) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Mon, 25 May 2020 19:25:07 +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 , Peng Liang Subject: [RFC PATCH 7/7] KVM: arm64: Enable stage2 hardware DBM Date: Mon, 25 May 2020 19:24:06 +0800 Message-ID: <20200525112406.28224-8-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20200525112406.28224-1-zhukeqian1@huawei.com> References: <20200525112406.28224-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 ebc622432831..371ea6d65c16 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -721,6 +721,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 30b7ea680f66..cb727e1fb581 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -392,7 +392,7 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) { u64 vtcr = VTCR_EL2_FLAGS; u32 parange, phys_shift; - u8 lvls; + u8 lvls, hadbs; if (type & ~KVM_VM_TYPE_ARM_IPA_SIZE_MASK) return -EINVAL; @@ -428,6 +428,13 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) */ vtcr |= VTCR_EL2_HA; + hadbs = (read_sysreg(id_aa64mmfr1_el1) >> + ID_AA64MMFR1_HADBS_SHIFT) & 0xf; +#ifdef CONFIG_ARM64_HW_AFDBM + 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