Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp806540pxu; Wed, 2 Dec 2020 04:03:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmKrsI2aXbDwB6lGD+PPw8/SZ0hrpx3v0kFKm62zy0FBWekZGHGI78HxPDQuRps6fKNWly X-Received: by 2002:a17:906:4982:: with SMTP id p2mr1940664eju.416.1606910611812; Wed, 02 Dec 2020 04:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606910611; cv=none; d=google.com; s=arc-20160816; b=PMxpjeS57wYLw+fzAsoLPg3s6LVq221hTKuc2TTSCcK/ZTw63kfajVPpw4ihxna2L3 QatkBUOjLo/1buHBmJf8p9POdhwIn5EHME/NhAnD/rgGTn1OU1VGwIUOrzkh67WjBvQm lk14g/n6ht+CirVuMemtdRklTvdC3Ey+5fjPg/fv+bJiBjMrKwMQrcGs6JLfWLTOUlb1 +K6d0eDSWaIXyZ7HV6605um4NT4SZ5ZLy5yXXM90VkRqnVG2LplOBgeePq3ABMgqHgZo 90lXXSyuj6D9XrEM5i00/0eCBEcsNJvHnhJWUonLvKQ41zqopAoO9VFpj42l+VG1LG4X biwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Vyvf6D4gNTINqXmsXCwKlhBelMiz41/90lSFixY3/1E=; b=DfNqNNZc9Vd0qbotO+97Eje2/vO96zWRYOjH0G7MeRirvNlRN/ghfVYfcGVqq4s1Eq 4D/Ql/fqQA/NFD+nl6by+aO0YapC2pXMUJOm7MZmKxMhUFWe1/Qb7JrPggPqA7G3hXaR yyNIlyuxj9wVdLZWrBkdfBqgu1n9bUatSHYO3wf0mSULJEX2TAkPdAuIGnbrOJbjoowm AhfzE+XYvzYB01SJ0Ksk/kEJAUggNWPruPLWGy9KP1iZFj8GNKRyiefrFs31yoD2Qavq +nr0YxrwNYCQSeQo/GHIHovwh477Y6kKDm9IdxrBTrwFNNUhsWwtQkta68pSgRJEljAf TG8w== 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 j26si682251ejk.615.2020.12.02.04.03.01; Wed, 02 Dec 2020 04:03:31 -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 S1726562AbgLBMA6 (ORCPT + 99 others); Wed, 2 Dec 2020 07:00:58 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:2388 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbgLBMA5 (ORCPT ); Wed, 2 Dec 2020 07:00:57 -0500 Received: from dggeme717-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4CmHZg5wvfz50gV; Wed, 2 Dec 2020 19:59:39 +0800 (CST) Received: from [10.174.186.123] (10.174.186.123) by dggeme717-chm.china.huawei.com (10.1.199.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1913.5; Wed, 2 Dec 2020 20:00:12 +0800 Subject: Re: [PATCH v2 0/3] Fix several bugs in KVM stage 2 translation To: Will Deacon , Marc Zyngier CC: , , Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , Gavin Shan , Quentin Perret , , , , , , , References: <20201201201034.116760-1-wangyanan55@huawei.com> <20201201205948.GA28178@willie-the-truck> From: "wangyanan (Y)" Message-ID: <74540986-6197-34bc-cd53-850472091ee3@huawei.com> Date: Wed, 2 Dec 2020 20:00:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201201205948.GA28178@willie-the-truck> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.186.123] X-ClientProxiedBy: dggeme719-chm.china.huawei.com (10.1.199.115) To dggeme717-chm.china.huawei.com (10.1.199.113) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Will, Marc, On 2020/12/2 4:59, Will Deacon wrote: > On Wed, Dec 02, 2020 at 04:10:31AM +0800, Yanan Wang wrote: >> When installing a new pte entry or updating an old valid entry in stage 2 >> translation, we use get_page()/put_page() to record page_count of the page-table >> pages. PATCH 1/3 aims to fix incorrect use of get_page()/put_page() in stage 2, >> which might make page-table pages unable to be freed when unmapping a range. >> >> When dirty logging of a guest with hugepages is finished, we should merge tables >> back into a block entry if adjustment of huge mapping is found necessary. >> In addition to installing the block entry, we should not only free the non-huge >> page-table pages but also invalidate all the TLB entries of non-huge mappings for >> the block. PATCH 2/3 adds enough TLBI when merging tables into a block entry. >> >> The rewrite of page-table code and fault handling add two different handlers >> for "just relaxing permissions" and "map by stage2 page-table walk", that's >> good improvement. Yet, in function user_mem_abort(), conditions where we choose >> the above two fault handlers are not strictly distinguished. This will causes >> guest errors such as infinite-loop (soft lockup will occur in result), because of >> calling the inappropriate fault handler. So, a solution that can strictly >> distinguish conditions is introduced in PATCH 3/3. > For the series: > > Acked-by: Will Deacon > > Thanks for reporting these, helping me to understand the issues and then > spinning a v2 so promptly. > > Will > . Thanks for the help and suggestions. BTW: there are two more things below that I want to talk about. 1.  Recently, I have been focusing on the ARMv8.4-TTRem feature which is aimed at changing block size in stage 2 mapping. I have a plan to implement this feature for stage 2 translation when splitting a block into tables or merging tables into a block. This feature supports changing block size without performing *break-before-make*, which might have some improvement on performance. What do you think about this? 2. Given that the issues we discussed before were found in practice when guest state changes from dirty logging to dirty logging canceled. I could add a test file testing on this case to selftests/ or kvm unit tests/, if it's necessary. Yanan