Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3823755pxb; Tue, 26 Jan 2021 05:52:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi+7Bf0xKJcsDDFQADBkZraF8Y1hNsRpVQ9MvQ0Go+5f5rGek1V3tvBbhoC4j9OIUH5hDw X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr3523816eje.109.1611669150284; Tue, 26 Jan 2021 05:52:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611669150; cv=none; d=google.com; s=arc-20160816; b=Tss3u3vUlNsy869BbEhxbdQDQnrl7O1swLSmSojxt5jWBsUsUOcpwkoFlrXkarVByJ AqZMTjViINj4ELHaS/Q0tNZ1hWkVFDcel8xbxcYu5l1tebckkZTPRIkuDH1bbHZvIIbZ TWcJR2Qr0s0sM3pFI0DQQUrm+MAlnWXxXhU86T0e6rQy+yPPD5KrQX5pwqRhOFGW8FYy 5cpz0V5RQc3Owi+Y6nbLkSVJftrHGBIp/7GfVq+2HdIc/HDbx3+3hRBMGJHLRbok9hoK oDwVjEp0pAiPwnPwE+DVTBUamT21BDPWxh1PLlVdvAxJ8R4Dz1TzeynlbEx+WWEREvmp AbHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=mWJxYGwVRpY1kaHHl3P6HOrb8bJGiZeHYqKe/8b8l28=; b=szJkGiLoiJYAz77+GqOkg5uXCDs66tRzO9Mz1AFxGCKmkxG6QWIQ/7CZAAvB6rcbxi Q/jrpp9USVCq/LjnBAm2TWVTtrUh7eJfLbB/u6koFmJ1J4sq9bCdVsxpi8uifgMVozAR FlBEDeRfF/Hqjn4epRxxpFe+U5BIGYj9zUk/ZUHps+TPcDSfylQTj2OyFLNgF+R1Y/xc M5jad7Qgp6XvOPUHK6wbAy353b9nQwX7oi2pescJPdwpsOIlOY8DBXmY2rlYoVUg4D9h wsa9cowDMSYhJ7Uy5ZzOkwOPOghLNwcpfth1e4DmCjRLam/WZUb/GYfwd2z3sLcTmHnA vpHw== 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 f13si7952571edc.38.2021.01.26.05.52.05; Tue, 26 Jan 2021 05:52:30 -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 S2405020AbhAZNto (ORCPT + 99 others); Tue, 26 Jan 2021 08:49:44 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:11445 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404850AbhAZNmy (ORCPT ); Tue, 26 Jan 2021 08:42:54 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DQ7DT5ZtPzjCXP; Tue, 26 Jan 2021 21:41:13 +0800 (CST) Received: from DESKTOP-TMVL5KK.china.huawei.com (10.174.187.128) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Tue, 26 Jan 2021 21:42:04 +0800 From: Yanan Wang To: , , , , Marc Zyngier , Will Deacon , Catalin Marinas CC: Mark Rutland , James Morse , Julien Thierry , Suzuki K Poulose , , , , , Yanan Wang Subject: [RFC PATCH v1 0/5] Enable CPU TTRem feature for stage-2 Date: Tue, 26 Jan 2021 21:41:57 +0800 Message-ID: <20210126134202.381996-1-wangyanan55@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.128] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, This series enable CPU TTRem feature for stage-2 page table and a RFC is sent for some comments, thanks. The ARMv8.4 TTRem feature offers 3 levels of support when changing block size without changing any other parameters that are listed as requiring use of break-before-make. And I found that maybe we can use this feature to make some improvement for stage-2 page table and the following explains what TTRem exactly does for the improvement. If migration of a VM with hugepages is canceled midway, KVM will adjust the stage-2 table mappings back to block mappings. We currently use BBM to replace the table entry with a block entry. Take adjustment of 1G block mapping as an example, with BBM procedures, we have to invalidate the old table entry first, flush TLB and unmap the old table mappings, right before installing the new block entry. So there will be a bit long period when the old table entry is invalid before installation of the new block entry, if other vCPUs access any guest page within the 1G range during this period and find the table entry invalid, they will all exit from guest with a translation fault. Actually, these translation faults are not necessary, because the block mapping will be built later. Besides, KVM will still try to build 1G block mappings for these spurious translation faults, and will perform cache maintenance operations, page table walk, etc. In summary, the spurious faults are caused by invalidation in BBM procedures. Approaches of TTRem level 1,2 ensure that there will not be a moment when the old table entry is invalid before installation of the new block entry. However, level-2 method will possibly lead to a TLB conflict which is bothering, so we use nT both at level-1 and level-2 case to avoid handling TLB conflict aborts. For an implementation which meets level 1 or level 2, the CPU has two responses to choose when accessing a block table entry with nT bit set: Firstly, CPU will generate a translation fault, the effect of this response is simier to BBM. Secondly, CPU can use the block entry for translation. So with the second kind of implementation, the above described spurious translations can be prevented. Yanan Wang (5): KVM: arm64: Detect the ARMv8.4 TTRem feature KVM: arm64: Add an API to get level of TTRem supported by hardware KVM: arm64: Support usage of TTRem in guest stage-2 translation KVM: arm64: Add handling of coalescing tables into a block mapping KVM: arm64: Adapt page-table code to new handling of coalescing tables arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/cpufeature.h | 13 ++++++ arch/arm64/kernel/cpufeature.c | 10 +++++ arch/arm64/kvm/hyp/pgtable.c | 62 +++++++++++++++++++++++------ 4 files changed, 74 insertions(+), 14 deletions(-) -- 2.19.1