Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp218631pxb; Thu, 14 Jan 2021 04:18:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyeJjHkKkV2acwF9zxWZOkk16wS5W1AAqWlvLVzGcbVdMVV+l+A3WO+YdscYO8UH7GGCxx X-Received: by 2002:a05:6402:1714:: with SMTP id y20mr5330428edu.360.1610626682753; Thu, 14 Jan 2021 04:18:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610626682; cv=none; d=google.com; s=arc-20160816; b=Bc5RCzwF++AK+fqQ5Rtc67OhgcmMMAylYJ+FJ8c7J5eCnEZ7+APWIaMObAr0nPY6oI /wNgweTki9zH+UWM4cdpx6T0gbWE+oB+Rw4M+E3eOzPreruMhqbAJMKipqbRY9N0cK5O iNAIoUf4KyjmhG2F1qlMGdO4sVDnpfyQ8inV/X0VTQCWnCPvAExhF7xNaR4CRuHiIdEC NM5/ku4lqjDH6O1me7vTMWmxtR25/MN4khdoChAl+TwKxr9V6Hgz+vShhQCI+OtHidLF 4gQAgR9TbjAntmmVYja1HWBUUapOm7QjaH4tDxWjGHy5WsC/LSVccZIRStn47+e9AnX7 CYCw== 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=/QvLvSlfW5C4XMt0+GrcFWYQIE5WGsCTWwzWOdqchmA=; b=Fhtnpca7j+W2OvcV+WFwjm1QQFh+n9vOa1UDs+wSnl8f/VMKF8sJ8oq1yOuREKcxGf FSVcKW54PvUTuIAYQ5BnpqKecJeomQPN7Td6bz7FID7Sf5YYgR62Cw6pxpyTHr2mVqpr ZwcY6ylnvtvt9z9BU0CfDEUR2NAURz5NYNhQBnC0r008IxdSXi+Nr2YdA7bphpy5jVMH SROj2U8+rwJjaiFnY3OwXh7UFypWX6ZPEIqLyEQUStMERinto6UfBhGqUUqPRYVUjez1 EG+KiiwXdEgkszx6rrbs3x+vxoH+Z0gd6/YlKYH1FBQOSvQNWy+O89IliqIkdlC5beU0 47ow== 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 he34si2323577ejc.729.2021.01.14.04.17.37; Thu, 14 Jan 2021 04:18:02 -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 S1729020AbhANMOr (ORCPT + 99 others); Thu, 14 Jan 2021 07:14:47 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:11386 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbhANMOq (ORCPT ); Thu, 14 Jan 2021 07:14:46 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DGjrD4zP5z7VFy; Thu, 14 Jan 2021 20:13:00 +0800 (CST) Received: from DESKTOP-TMVL5KK.china.huawei.com (10.174.187.128) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.498.0; Thu, 14 Jan 2021 20:13:52 +0800 From: Yanan Wang To: Marc Zyngier , Will Deacon , "Catalin Marinas" , , , , CC: James Morse , Julien Thierry , Suzuki K Poulose , Gavin Shan , Quentin Perret , , , , , Yanan Wang Subject: [PATCH v3 0/3] Some optimization for stage-2 translation Date: Thu, 14 Jan 2021 20:13:47 +0800 Message-ID: <20210114121350.123684-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, This patch series(v3) make some optimization for stage-2 translation. About patch-1: Procedures of hyp stage-1 map and guest stage-2 map are quite different, but they are now tied closely by function kvm_set_valid_leaf_pte(). So adjust the relative code for ease of code maintenance in the future. About patch-2: There have been the separate map handler and perms handler used independently for mapping and relaxing permissions in the new page-table infrastructure for stage-2, yet there is still a specific case where we end up changing the access permissions in the map path, and something unsatisfactory could happen because of current handling for this case. To solve above problem, we can filter out this case from the map path and abort the PTE update. Instead, let the vCPU enter back the guest and it will exit next time to go through the relax_perms path if still needed. About patch-3: We now set the pfn dirty and mark the page dirty before calling fault handlers in user_mem_abort(), so we might end up having spurious dirty pages if update of permissions or mapping has failed. Let's move these two operations after the fault handlers, and they will be done only if the fault has been handled successfully. When an -EAGAIN errno is returned from the map handler, we hope to the vcpu to enter guest directly instead of exiting back to userspace, so adjust the return value at the end of function. --- Changelogs v2->v3: - Rebased on top of v5.11-rc3 - Refine the commit messages - Make some adjustment about return value in patch-2 and patch-3 - v2: https://lore.kernel.org/lkml/20201216122844.25092-1-wangyanan55@huawei.com/ v1->v2: - Make part of the diff a seperate patch (patch-1) - Add Will's Signed-off-by for patch-1 - Return an errno when meeting changing permissions case in map path - Add a new patch (patch-3) - v1: https://lore.kernel.org/lkml/20201211080115.21460-1-wangyanan55@huawei.com/ --- Yanan Wang (3): KVM: arm64: Adjust partial code of hyp stage-1 map and guest stage-2 map KVM: arm64: Filter out the case of only changing permissions from stage-2 map path KVM: arm64: Mark the page dirty only if the fault is handled successfully arch/arm64/include/asm/kvm_pgtable.h | 5 ++ arch/arm64/kvm/hyp/pgtable.c | 83 ++++++++++++++++------------ arch/arm64/kvm/mmu.c | 13 +++-- 3 files changed, 60 insertions(+), 41 deletions(-) -- 2.19.1