From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79A70C433E1 for ; Thu, 30 Jul 2020 15:36:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 472992082E for ; Thu, 30 Jul 2020 15:36:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yKt3iLda"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZH/oQLHd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 472992082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=S+AlJ2ZqAIuYB9TU43McUSC5tB9xbF/SmIMwv+KtQaQ=; b=yKt3iLdazAwn4VqylO3guHnOxA WfySKVoU7zzohb5gH1HQ62Cz6iT5feuE5AYUtqdf8XOFHSpF7Qzv/e3p3gpfQRyJJLe+C41XRGeD7 KihAyY+tH9Ar8Tz+gZ1w9Ynepnpb4X6RxXW/RWlMZCYo9o5dYs2xHbRMKnYRzwAbrTPxXOE/0RrFQ v1dWElmgC8oVY+9V3NyeAecoIKF6nVnkWD+Rk7uDVJiG2szOCNhHuiQ2dLHSQ5OcH14cM9Mp+aUOV p0Y1YXMEAYMNhenrBdAVpmR4VWDIXb30SK0Za9LTkMqxu7gqDl0jnlXKg5o6COibh8mOdehthn0dx QLq71XOQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1AZb-0001r6-Pi; Thu, 30 Jul 2020 15:34:23 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1AZY-0001qQ-QL for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 15:34:21 +0000 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3B4D320829; Thu, 30 Jul 2020 15:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596123259; bh=avvDhmGN5YEENmQWEvu0ifb5DTujfbvPC6cuJ+c5uvE=; h=From:To:Cc:Subject:Date:From; b=ZH/oQLHdOh5Oev19+BcsO1nIukAVfYxJHRu/9gs1E1JFxjn0sGgyrNEAAYzUNv1/M /bRCeEdWe60tJwdLsFppTCl+/xYbQ2MFAF3YCrVouZQ4qOpgkI4r2OdFP9Tex8eVq0 mkOTq4gBsNPV/EUby+GCl1HB4hFymEIpkyXd/O/Q= From: Will Deacon To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 00/20] KVM: arm64: Rewrite page-table code and fault handling Date: Thu, 30 Jul 2020 16:33:46 +0100 Message-Id: <20200730153406.25136-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_113421_075608_FBF554E8 X-CRM114-Status: GOOD ( 20.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki Poulose , Marc Zyngier , Quentin Perret , James Morse , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, This fairly hefty series rewrites all of KVM's page-table code on arm64. You might be wondering why I've done that, and I can ensure you that it wasn't for fun. No, some of the benefits of rewriting this code are as follows: * The hypervisor stage-1 and guest stage-2 page tables can now be configured at runtime, independently of each other and of the host kernel's stage-1 configuration. This allows us to remove the extended idmap at EL2 entirely and accept large guest IPA sizes without worrying about the number of levels in use by the host. * The code is smaller. We're losing ~500 lines with this series, and that's in spite of a bunch of kerneldoc being added for the new API. * It paves the way for managing the stage-2 page-tables at EL2 on nVHE systems, which is a crucial part of the Android "Protected KVM" project, which aims to isolate guest memory from the host kernel. * In some cases, the new walker allows us to reduce the number of walks being performed. For example, user_mem_abort() no longer has to walk the page-table twice when handling permission faults. The series is based on kvmarm/next, plus these two series I sent previously: - memcache cleanups: https://lore.kernel.org/r/20200723110227.16001-1-will@kernel.org - Early S2 fault fixes: https://lore.kernel.org/r/20200729102821.23392-1-will@kernel.org It will conflict with Sean's memcache stuff in -next, but that shouldn't be too hard to sort out. I've tried to split up the conversion of kvm/mmu.c into reviewable chunks, mopping up all the leftover code at the end. That means bisection will warn about unused functions in the middle of the series, but I think it makes the changes considerably more focussed and easier to review. In terms of testing, I've done the usual Debian installer type things, but Quentin has also written targetted guest code [1] which we used to exercise dirty logging page-table collapse and coalescing. I also wrote a silly hack where KVM allocated two S2 page-tables for each VM; one using the old code and one using the new code. At PSCI SYSTEM_OFF, a walker walked each page-table, using siphash to create a hash of all of the entries (but masking out the address fields in table entries). After the walk, the hashes were compared for the two tables and I have so far been unable to trigger a mismatch. That said, I haven't really kicked the tyres outside of defconfig. To make things easier to work with, I've put the whole lot on a branch here: https://android-kvm.googlesource.com/linux/+/refs/heads/topic/pgtable Cheers, Will [1] https://android-kvm.googlesource.com/misc/+/refs/heads/qperret/pgtable-test Cc: Marc Zyngier Cc: Quentin Perret Cc: James Morse Cc: Suzuki Poulose Cc: Catalin Marinas Cc: kernel-team@android.com Cc: linux-arm-kernel@lists.infradead.org --->8 Quentin Perret (4): KVM: arm64: Add support for stage-2 write-protect in generic page-table KVM: arm64: Convert write-protect operation to generic page-table API KVM: arm64: Add support for stage-2 cache flushing in generic page-table KVM: arm64: Convert memslot cache-flushing code to generic page-table API Will Deacon (16): KVM: arm64: Add stand-alone page-table walker infrastructure KVM: arm64: Add support for creating kernel-agnostic stage-1 page tables KVM: arm64: Use generic allocator for hyp stage-1 page-tables KVM: arm64: Add support for creating kernel-agnostic stage-2 page tables KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table KVM: arm64: Convert kvm_phys_addr_ioremap() to generic page-table API KVM: arm64: Convert kvm_set_spte_hva() to generic page-table API KVM: arm64: Convert unmap_stage2_range() to generic page-table API KVM: arm64: Add support for stage-2 page-aging in generic page-table KVM: arm64: Convert page-aging and access faults to generic page-table API KVM: arm64: Add support for relaxing stage-2 perms in generic page-table code KVM: arm64: Convert user_mem_abort() to generic page-table API KVM: arm64: Check the cookie instead of the pgd when modifying page-table KVM: arm64: Remove unused page-table code KVM: arm64: Remove unused 'pgd' field from 'struct kvm_s2_mmu' KVM: arm64: Don't constrain maximum IPA size based on host configuration arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_mmu.h | 219 +--- arch/arm64/include/asm/kvm_pgtable.h | 269 ++++ arch/arm64/include/asm/pgtable-hwdef.h | 23 - arch/arm64/include/asm/pgtable-prot.h | 19 - arch/arm64/include/asm/stage2_pgtable.h | 215 ---- arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/mmu.c | 1549 +++-------------------- arch/arm64/kvm/pgtable.c | 906 +++++++++++++ arch/arm64/kvm/reset.c | 38 +- 10 files changed, 1340 insertions(+), 1902 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_pgtable.h create mode 100644 arch/arm64/kvm/pgtable.c -- 2.28.0.rc0.142.g3c755180ce-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel