Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp243457pxy; Thu, 22 Apr 2021 00:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6Gq0wQ2/+NHEQ/eXOmP8BY3cQV+n1wCqcPbGA8IneEwyV6xuLf20vIjKAbhqXcBT2K17d X-Received: by 2002:a05:6402:5203:: with SMTP id s3mr2117909edd.360.1619077509309; Thu, 22 Apr 2021 00:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619077509; cv=none; d=google.com; s=arc-20160816; b=TwzBgyhY8gkxOQcAF4Q9PMvsUUYV2rNZ5P2Dqr+kRHssTytGt7sXrTzgL4LWLU2ndZ 6vQ5DNoPgJGo+od4qnWACraC6W1IlAzFHseIG8xmRsNo26LbHgbsKj7DhrWrya8U/p8N Ms2xuP7sVWm71Vq130uxKoRjjxhJGX+ApXUp3RcmJz5iUxH2edV4/QwDdYcu3+Z3es4S 57FTWPGJn9z+IGVTpN7juGGZnRenR572AZmlgBWG2GOUpqd8XgjUeFYIKqQvgVb47akd Ez/goaNQZpeM0FtVpZ4YfKSIPJJ7UKoCObC06J6f+Sy48bhtBJeuVFEF3aprXydlGX+a +Lpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:cc:from:references:to :subject; bh=INJMAw3iqmG5uH+FDopYdh/Bq1Nkb0BjoDQ34+frpng=; b=Xi3nfUABiZI8yOIFil+Gd2IxzM+kciQ8H5sGJnwPGx/pXVi7KdUhCQoN8YsU1R8+f3 mS82451w8yUgSZS6LPQV4YGdEFgIwecGumzWwHttxZBHoWMFLZMwmyHmz2PzyeAA3cRb guJUWPHsf5DfgPaeDrpVhMYuKs3uQPP1yCh40UvuITXsaCXOttsMLSdPtG5Yviy3nMue GQXBCVggnodZNCnkNBfTn5yR2NkEeKRC/8ZZV54QHw+ji1wTAq6md8wWnrKfe30lbkSh H1qM+hmLCU8G7opOjEdXfuidPT1w4QFY4PzjnhzJ7HGNWnANACPItiFO3MVLyVM6y/uH HBHg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo9si1415930edb.184.2021.04.22.00.44.45; Thu, 22 Apr 2021 00:45:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbhDVHmT (ORCPT + 99 others); Thu, 22 Apr 2021 03:42:19 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:17389 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbhDVHmS (ORCPT ); Thu, 22 Apr 2021 03:42:18 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FQq7g5J1TzjbVK; Thu, 22 Apr 2021 15:39:43 +0800 (CST) Received: from [10.174.187.224] (10.174.187.224) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Thu, 22 Apr 2021 15:41:34 +0800 Subject: Re: [PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions To: Gavin Shan References: <20210415140328.24200-1-zhukeqian1@huawei.com> <20210415140328.24200-2-zhukeqian1@huawei.com> From: Keqian Zhu CC: , , , , Marc Zyngier , Santosh Shukla Message-ID: <9eb47a6c-3c5c-cb4a-d1de-1a3ce1b60a87@huawei.com> Date: Thu, 22 Apr 2021 15:41:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.187.224] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gavin, On 2021/4/22 10:12, Gavin Shan wrote: > Hi Keqian, > > On 4/21/21 4:28 PM, Keqian Zhu wrote: >> On 2021/4/21 14:38, Gavin Shan wrote: >>> On 4/16/21 12:03 AM, Keqian Zhu wrote: >>>> The MMIO regions may be unmapped for many reasons and can be remapped >>>> by stage2 fault path. Map MMIO regions at creation time becomes a >>>> minor optimization and makes these two mapping path hard to sync. >>>> >>>> Remove the mapping code while keep the useful sanity check. >>>> >>>> Signed-off-by: Keqian Zhu >>>> --- >>>> arch/arm64/kvm/mmu.c | 38 +++----------------------------------- >>>> 1 file changed, 3 insertions(+), 35 deletions(-) >>>> >>> >>> After removing the logic to create stage2 mapping for VM_PFNMAP region, >>> I think the "do { } while" loop becomes unnecessary and can be dropped >>> completely. It means the only sanity check is to see if the memory slot >>> overflows IPA space or not. In that case, KVM_MR_FLAGS_ONLY can be >>> ignored because the memory slot's base address and length aren't changed >>> when we have KVM_MR_FLAGS_ONLY. >> Maybe not exactly. Here we do an important sanity check that we shouldn't >> log dirty for memslots with VM_PFNMAP. >> > > Yeah, Sorry that I missed that part. Something associated with Santosh's > patch. The flag can be not existing until the page fault happened on > the vma. In this case, the check could be not working properly. > > [PATCH] KVM: arm64: Correctly handle the mmio faulting Yeah, you are right. If that happens, we won't try to use block mapping for memslot with VM_PFNMAP. But it keeps a same logic with old code. 1. When without dirty-logging, we won't try block mapping for it, and we'll finally know that it's device, so won't try to do adjust THP (Transparent Huge Page) for it. 2. If userspace wrongly enables dirty logging for this memslot, we'll force_pte for it. Thanks, Keqian