Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2309295ybt; Tue, 16 Jun 2020 02:39:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzp420EdGLAm3/E3XuWR2CGQCv8NLUPr/6Vd6QXvw18nVNgBK1NGuMaPlOR12IrkX1ahiP X-Received: by 2002:a17:907:369:: with SMTP id rs9mr1855061ejb.187.1592300356814; Tue, 16 Jun 2020 02:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592300356; cv=none; d=google.com; s=arc-20160816; b=VfpoUYsoF9AFJV5KS3lBDgEDauXtae8/A2sJwO0GEKMhGfBnE+DYjb7nH9i6NUyCoq 5I5Wnu3C2PCsKrREsmPGOXERG/s/Pqf3kboNVWvwIg8zp6kstb3rU+EbsAfATFm5w0TB 1oeiP0yx1OcyaeVNur6TCOAmomnpHcFnj+oteaEzH/Ku7eHtKNr4lDaMHNs1csVo2Csl hTQ10/sLKjdn32lFMcLUBFoGYjXyQQGMHE/RT/cZ6Q7RvAKGIdbh9QPA2EEjUr0R+I/y WKrRo6KRcnhaV3+3cA/lpXUIddEyvqZzrjQ+6pq3h6hkczCGOCowRaE2LXJUcprHZ1X9 RqBg== 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=DtVxqmqpPYbHhqDrZlQrL9WsAH7BiciCaEg3bgqF05E=; b=iyBeqNn+4jOMDJ3mNZ88+7T8LjV2LDXLeoj0hjMR6gVdj3wh4JwN8ip0llfUNSzRms 3gtnr/yq/6TDMqagKsSdFlDUBj4iL0/PU6qkHdo5c3ZtLhtif8AG+3wSqa/S9wUIz+UP RfZ+Oh8kKeWB1m6gzXSogC5YtchrtC5LlW4aHIdAkmMMpjMIF16kIl5DmvP7eREnV69l OjN023Q7th0uNxNzJ3n89+lTrJ0wV9f5yZkzYelKR4IbnN3Vr7xVcKsHR+eupG+jHPMv Mnj3bQH23zNc8Bf5ihY9/O9uAm2VskUNCl5TNmEb1w52tpzXE/GW3+XrBFhi7AmJz6vG gsnA== 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 d19si10024288edr.611.2020.06.16.02.38.54; Tue, 16 Jun 2020 02:39:16 -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 S1728445AbgFPJgb (ORCPT + 99 others); Tue, 16 Jun 2020 05:36:31 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6268 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728384AbgFPJgZ (ORCPT ); Tue, 16 Jun 2020 05:36:25 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B9B15896D93109BC2DD5; 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:13 +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 11/12] KVM: arm64: Support disable hw dirty log after enable Date: Tue, 16 Jun 2020 17:35:52 +0800 Message-ID: <20200616093553.27512-12-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 should clear DBM bit of all PTEs and flush TLB, then sync dirty log, which promise we won't miss any dirty status set by hardware. Signed-off-by: Keqian Zhu --- arch/arm64/kvm/arm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 92f0b40a30fa..76cab4c0b5a6 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -93,6 +93,12 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, r = -EINVAL; } else { r = 0; + if (kvm->arch.hw_dirty_log && !cap->args[0]) { + mutex_lock(&kvm->slots_lock); + kvm_mmu_clear_dbm_all(kvm); + kvm_mmu_sync_dirty_log_all(kvm); + mutex_unlock(&kvm->slots_lock); + } kvm->arch.hw_dirty_log = cap->args[0]; } break; -- 2.19.1