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=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 06EEAC12002 for ; Mon, 19 Jul 2021 10:47:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE7A160200 for ; Mon, 19 Jul 2021 10:47:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236527AbhGSKHE (ORCPT ); Mon, 19 Jul 2021 06:07:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236499AbhGSKHC (ORCPT ); Mon, 19 Jul 2021 06:07:02 -0400 Received: from mail-wm1-x349.google.com (mail-wm1-x349.google.com [IPv6:2a00:1450:4864:20::349]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604E5C061574 for ; Mon, 19 Jul 2021 02:55:36 -0700 (PDT) Received: by mail-wm1-x349.google.com with SMTP id x6-20020a7bc2060000b0290218ad9a8d4aso3813417wmi.1 for ; Mon, 19 Jul 2021 03:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=TT8gWUbNyJACYMfSgAbkMfXL/hIgt2K4TeYX1798Z+RVovD7a9k8A+Ys5fdzbqZULc 4B4P7CHpNEvod4gaq/gLeRGehtUvM3mqYd9uMnL6DvHv5ac9mTltH59uNuqNUJ6+FHMX 6K7zECMso0T+Ls2KaIQrVCU5PlKH3Im0K9x845PYuGR0Nlijm9kVeTa9AlAEx7TlHy++ FyexRWmDWWzgBlUDElyQiNQ2vKbRBh1YBi4tObrK7iEB5+Mq/UlRniB4sw1uIdHbZRAw uZ575TJO1dEKtWRybLGfWQSPoqEwTr4VkbdKWgYrBmrVd1j9JN+rBwgxonbrMZJ4fnJM 80Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=H+PgK2J7oxAHzimKqInnuyEdrrF/K67cpDGQQFA33UnwffF5ZA3c2ove0ULQsMVtu9 64DLx9/aShjfYXtn6P1Z88zvSIZ+Skgk6BVy6CDdo6rJr4zHIyA36rf9RvGZaQ6Grheq XdfQee56/We2fNLjKTjwL4kjKz+e/ItiokMaUzRKB3hXluz7EKOfMmAEqST290Wtjlw8 vQzdqmGLm4MDDWq7F2thHGuiLwUIU5SK3qJ/Kpcl9wfj3tk1D2qwdn7QRJflIqiUu6vh r9o8fgkmR7bPHNwpNUBv8/m8FUfqJiqs94kGs0TNaAyKzdbhk8tfjJYOxS6X54M3PmGz P1JQ== X-Gm-Message-State: AOAM532T4ckv2vgpKtzmkKI+Pc7zCgLhyHWTqSu/VS1gIoL6l+PE4EKq +MH49WdCQg2BFKUCVjH3AbMPavk7dGD9 X-Google-Smtp-Source: ABdhPJyapMlzacXUANT8CGyWjaSfGRj8ZkKY3ZV1NxaiDQ/d+WmxKezlFsiAVAsdL+q2omGDMLjGV6nnVEbo X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:1a96:a43f:6c2e:bb5a]) (user=qperret job=sendgmr) by 2002:a5d:6846:: with SMTP id o6mr29073942wrw.326.1626691660737; Mon, 19 Jul 2021 03:47:40 -0700 (PDT) Date: Mon, 19 Jul 2021 11:47:21 +0100 Message-Id: <20210719104735.3681732-1-qperret@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 00/14] Track shared pages at EL2 in protected mode From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Quentin Perret Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, This series aims to improve how the nVHE hypervisor tracks ownership of memory pages when running in protected mode ("kvm-arm.mode=protected" on the kernel command line). The main issue with the existing ownership tracking code is that it is completely binary: a page is either owned by an entity (e.g. the host) or not. However, we'll need something smarter to track shared pages, as is needed for virtio, or even just host/hypervisor communications. This series introduces a few changes to the kvm page-table library to allow annotating shared pages in ignored bits (a.k.a. software bits) of leaf entries, and makes use of that infrastructure to track all pages that are shared between the host and the hypervisor. We will obviously want to apply the same treatment to guest stage-2 page-tables, but that is not really possible to do until EL2 manages them directly, so I'll keep that for another series. The series is split as follows: - patches 01-04 are essentially cleanups and optimizations of existing code paths that might be relevant on their own, but also prepare the ground for the rest of the series; - patches 05-08 introduce support in the page-table library for annotating shared pages with software bits; - patches 09-14 make use of the previously introduced infrastructure to annotate all pages shared between the host and the hypervisor; The series is based on the latest kvmarm/fixes branch, and has been tested on AML-S905X-CC (Le Potato) and using various Qemu configurations. Thanks! Quentin Quentin Perret (14): KVM: arm64: Provide the host_stage2_try() helper macro KVM: arm64: Optimize kvm_pgtable_stage2_find_range() KVM: arm64: Continue stage-2 map when re-creating mappings KVM: arm64: Rename KVM_PTE_LEAF_ATTR_S2_IGNORED KVM: arm64: Don't overwrite ignored bits with owner id KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits KVM: arm64: Enable forcing page-level stage-2 mappings KVM: arm64: Add support for tagging shared pages in page-table KVM: arm64: Mark host bss and rodata section as shared KVM: arm64: Enable retrieving protections attributes of PTEs KVM: arm64: Expose kvm_pte_valid() helper KVM: arm64: Refactor pkvm_pgtable locking KVM: arm64: Restrict hyp stage-1 manipulation in protected mode KVM: arm64: Prevent late calls to __pkvm_create_private_mapping() arch/arm64/include/asm/kvm_asm.h | 2 +- arch/arm64/include/asm/kvm_pgtable.h | 109 ++++++--- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/include/nvhe/mm.h | 3 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 17 +- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 156 +++++++++++-- arch/arm64/kvm/hyp/nvhe/mm.c | 20 +- arch/arm64/kvm/hyp/nvhe/setup.c | 52 ++++- arch/arm64/kvm/hyp/pgtable.c | 219 +++++++++++++----- arch/arm64/kvm/mmu.c | 14 +- 10 files changed, 454 insertions(+), 140 deletions(-) -- 2.32.0.402.g57bb445576-goog 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=-11.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 C1F90C07E9D for ; Mon, 19 Jul 2021 10:47:46 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 443FD60FF4 for ; Mon, 19 Jul 2021 10:47:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 443FD60FF4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AA0604B086; Mon, 19 Jul 2021 06:47:45 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id atB9gxPIiG8U; Mon, 19 Jul 2021 06:47:44 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8B7FE4A319; Mon, 19 Jul 2021 06:47:44 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 342EF4A193 for ; Mon, 19 Jul 2021 06:47:43 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pNEwWaLHFb-0 for ; Mon, 19 Jul 2021 06:47:42 -0400 (EDT) Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 0CB3749DE7 for ; Mon, 19 Jul 2021 06:47:42 -0400 (EDT) Received: by mail-wm1-f73.google.com with SMTP id j141-20020a1c23930000b0290212502cb19aso5288577wmj.0 for ; Mon, 19 Jul 2021 03:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=TT8gWUbNyJACYMfSgAbkMfXL/hIgt2K4TeYX1798Z+RVovD7a9k8A+Ys5fdzbqZULc 4B4P7CHpNEvod4gaq/gLeRGehtUvM3mqYd9uMnL6DvHv5ac9mTltH59uNuqNUJ6+FHMX 6K7zECMso0T+Ls2KaIQrVCU5PlKH3Im0K9x845PYuGR0Nlijm9kVeTa9AlAEx7TlHy++ FyexRWmDWWzgBlUDElyQiNQ2vKbRBh1YBi4tObrK7iEB5+Mq/UlRniB4sw1uIdHbZRAw uZ575TJO1dEKtWRybLGfWQSPoqEwTr4VkbdKWgYrBmrVd1j9JN+rBwgxonbrMZJ4fnJM 80Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=o4dE1dyPgKYgcBEG6Tx2uTacedXXeujssFWki+C4dLFb2vO5Sdu59+gO8GrZtjSrHO 2yQSvdvVjW33rzsCrwn51D1UwnaBko74Jd3fTc9Zn6teglmoUWt4SpbPRbUqnnlYaNT9 KlEy50hFzg2irwoxP2XOYBXM3q11os9Dm3iWL0otTvT61KG5cw+evhUqUd1I/xGr7wxv milqz3eWCHRIOBbEVZQbsgZDCG80p1Mav/vVm0DGu7MvWG1TTw3AZpk+16GU4vyqSeBZ waOMlfRL1PJNBIjB/n7PaIaSgHy9eCgnqDBIc0pnc0Qs/TedYou8lGZxs4geBs6yuByG ubqA== X-Gm-Message-State: AOAM530bWu5vDEBIzwxb9RsTiThsNyYV533tBhVBGUBzSgHBKFbqjvyB +BZL8lvj2F+RdBtK8lBYKjqjWjm2DJII X-Google-Smtp-Source: ABdhPJyapMlzacXUANT8CGyWjaSfGRj8ZkKY3ZV1NxaiDQ/d+WmxKezlFsiAVAsdL+q2omGDMLjGV6nnVEbo X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:1a96:a43f:6c2e:bb5a]) (user=qperret job=sendgmr) by 2002:a5d:6846:: with SMTP id o6mr29073942wrw.326.1626691660737; Mon, 19 Jul 2021 03:47:40 -0700 (PDT) Date: Mon, 19 Jul 2021 11:47:21 +0100 Message-Id: <20210719104735.3681732-1-qperret@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 00/14] Track shared pages at EL2 in protected mode From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: qwandor@google.com, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kernel-team@android.com X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi all, This series aims to improve how the nVHE hypervisor tracks ownership of memory pages when running in protected mode ("kvm-arm.mode=protected" on the kernel command line). The main issue with the existing ownership tracking code is that it is completely binary: a page is either owned by an entity (e.g. the host) or not. However, we'll need something smarter to track shared pages, as is needed for virtio, or even just host/hypervisor communications. This series introduces a few changes to the kvm page-table library to allow annotating shared pages in ignored bits (a.k.a. software bits) of leaf entries, and makes use of that infrastructure to track all pages that are shared between the host and the hypervisor. We will obviously want to apply the same treatment to guest stage-2 page-tables, but that is not really possible to do until EL2 manages them directly, so I'll keep that for another series. The series is split as follows: - patches 01-04 are essentially cleanups and optimizations of existing code paths that might be relevant on their own, but also prepare the ground for the rest of the series; - patches 05-08 introduce support in the page-table library for annotating shared pages with software bits; - patches 09-14 make use of the previously introduced infrastructure to annotate all pages shared between the host and the hypervisor; The series is based on the latest kvmarm/fixes branch, and has been tested on AML-S905X-CC (Le Potato) and using various Qemu configurations. Thanks! Quentin Quentin Perret (14): KVM: arm64: Provide the host_stage2_try() helper macro KVM: arm64: Optimize kvm_pgtable_stage2_find_range() KVM: arm64: Continue stage-2 map when re-creating mappings KVM: arm64: Rename KVM_PTE_LEAF_ATTR_S2_IGNORED KVM: arm64: Don't overwrite ignored bits with owner id KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits KVM: arm64: Enable forcing page-level stage-2 mappings KVM: arm64: Add support for tagging shared pages in page-table KVM: arm64: Mark host bss and rodata section as shared KVM: arm64: Enable retrieving protections attributes of PTEs KVM: arm64: Expose kvm_pte_valid() helper KVM: arm64: Refactor pkvm_pgtable locking KVM: arm64: Restrict hyp stage-1 manipulation in protected mode KVM: arm64: Prevent late calls to __pkvm_create_private_mapping() arch/arm64/include/asm/kvm_asm.h | 2 +- arch/arm64/include/asm/kvm_pgtable.h | 109 ++++++--- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/include/nvhe/mm.h | 3 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 17 +- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 156 +++++++++++-- arch/arm64/kvm/hyp/nvhe/mm.c | 20 +- arch/arm64/kvm/hyp/nvhe/setup.c | 52 ++++- arch/arm64/kvm/hyp/pgtable.c | 219 +++++++++++++----- arch/arm64/kvm/mmu.c | 14 +- 10 files changed, 454 insertions(+), 140 deletions(-) -- 2.32.0.402.g57bb445576-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 04F44C07E9D for ; Mon, 19 Jul 2021 10:49:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C499A61006 for ; Mon, 19 Jul 2021 10:49:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C499A61006 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date: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=ihY07H98kNHi+N6gbOg6n2ZLO4GDqZoP3DOkr7Ah1ew=; b=M53 +JO1uWukwMrObC+CjY52EO1O86HkObymAyYDun0V6sd32aRvkctgSWyq21cyizqjJ9CiCD+VNraE/ dz4PVDUrdVXiF7PCfZFWjnpMNWurF0X8/O8VZqQeFPeiDMKQqSEMKqwh4qf5TQbQlz+PnttACq/Pj Epva1i9TujlQ15cjHX2gEIw+/j11X/WCMCEb/rXCI84mFaaQCNssJBVeaUx7/gz12XVJP9S5YxoCr H1ioRSJQrR2LmJGxa18cPx+bEMPNjfeOwCDSyZ0wabo7Mk+QToyApEZ3+BMKN22sJRnExbh8nHezh NTJ/sPiB4WqPuPZpPQBL1iylmxjO4Hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5QoQ-009KSd-VY; Mon, 19 Jul 2021 10:47:51 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5QoJ-009KPi-BK for linux-arm-kernel@lists.infradead.org; Mon, 19 Jul 2021 10:47:46 +0000 Received: by mail-wm1-x349.google.com with SMTP id i7-20020a05600c3547b0290229a389ceb2so3787598wmq.0 for ; Mon, 19 Jul 2021 03:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=TT8gWUbNyJACYMfSgAbkMfXL/hIgt2K4TeYX1798Z+RVovD7a9k8A+Ys5fdzbqZULc 4B4P7CHpNEvod4gaq/gLeRGehtUvM3mqYd9uMnL6DvHv5ac9mTltH59uNuqNUJ6+FHMX 6K7zECMso0T+Ls2KaIQrVCU5PlKH3Im0K9x845PYuGR0Nlijm9kVeTa9AlAEx7TlHy++ FyexRWmDWWzgBlUDElyQiNQ2vKbRBh1YBi4tObrK7iEB5+Mq/UlRniB4sw1uIdHbZRAw uZ575TJO1dEKtWRybLGfWQSPoqEwTr4VkbdKWgYrBmrVd1j9JN+rBwgxonbrMZJ4fnJM 80Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=6r6SQ5Sfe1ngDPnI/RzrWml59LLxArWehQBwowrYG0g=; b=C4XDJZR5u8sHUYMtM0B3N9suWrVei1pXYf4A9AgEqFUX6koyShdobGK1uO2zW1VZNe pvDXrrAHWrzihCCpakwGw0xCvTsR3AmM9Cx16YLUwzrpmsFCzzvO8fTodhkXYAaH/DMJ 0Ftk+o4rvJFvl6sL6cX6pPeAB5bE+EE21VCV7Igje68/3NHb3CGDGkYAl/ZUeQPxP3tb 334hgz47PmLhTsKXr5uIP6cVbfctHl4lq/+ndfUnMuTf7mmMBpjqAFZBHiYbdgi6OSJq FSQPhL7ZzSAGE7dYllt5OvE1etSkZBVU/wkTGqfgY/MUiazavEeCQzHraafLqnkVGj07 HGRQ== X-Gm-Message-State: AOAM5328JHkbhp2bWyzkFe94CWu3CFUZr1ifFMBS76/SmCdoBR+gCIB0 YxMopS8oNhHDPg+TUm1L1b8FnhXYDrpZ X-Google-Smtp-Source: ABdhPJyapMlzacXUANT8CGyWjaSfGRj8ZkKY3ZV1NxaiDQ/d+WmxKezlFsiAVAsdL+q2omGDMLjGV6nnVEbo X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:1a96:a43f:6c2e:bb5a]) (user=qperret job=sendgmr) by 2002:a5d:6846:: with SMTP id o6mr29073942wrw.326.1626691660737; Mon, 19 Jul 2021 03:47:40 -0700 (PDT) Date: Mon, 19 Jul 2021 11:47:21 +0100 Message-Id: <20210719104735.3681732-1-qperret@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.402.g57bb445576-goog Subject: [PATCH 00/14] Track shared pages at EL2 in protected mode From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Quentin Perret X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210719_034743_462346_99837100 X-CRM114-Status: GOOD ( 17.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 series aims to improve how the nVHE hypervisor tracks ownership of memory pages when running in protected mode ("kvm-arm.mode=protected" on the kernel command line). The main issue with the existing ownership tracking code is that it is completely binary: a page is either owned by an entity (e.g. the host) or not. However, we'll need something smarter to track shared pages, as is needed for virtio, or even just host/hypervisor communications. This series introduces a few changes to the kvm page-table library to allow annotating shared pages in ignored bits (a.k.a. software bits) of leaf entries, and makes use of that infrastructure to track all pages that are shared between the host and the hypervisor. We will obviously want to apply the same treatment to guest stage-2 page-tables, but that is not really possible to do until EL2 manages them directly, so I'll keep that for another series. The series is split as follows: - patches 01-04 are essentially cleanups and optimizations of existing code paths that might be relevant on their own, but also prepare the ground for the rest of the series; - patches 05-08 introduce support in the page-table library for annotating shared pages with software bits; - patches 09-14 make use of the previously introduced infrastructure to annotate all pages shared between the host and the hypervisor; The series is based on the latest kvmarm/fixes branch, and has been tested on AML-S905X-CC (Le Potato) and using various Qemu configurations. Thanks! Quentin Quentin Perret (14): KVM: arm64: Provide the host_stage2_try() helper macro KVM: arm64: Optimize kvm_pgtable_stage2_find_range() KVM: arm64: Continue stage-2 map when re-creating mappings KVM: arm64: Rename KVM_PTE_LEAF_ATTR_S2_IGNORED KVM: arm64: Don't overwrite ignored bits with owner id KVM: arm64: Tolerate re-creating hyp mappings to set ignored bits KVM: arm64: Enable forcing page-level stage-2 mappings KVM: arm64: Add support for tagging shared pages in page-table KVM: arm64: Mark host bss and rodata section as shared KVM: arm64: Enable retrieving protections attributes of PTEs KVM: arm64: Expose kvm_pte_valid() helper KVM: arm64: Refactor pkvm_pgtable locking KVM: arm64: Restrict hyp stage-1 manipulation in protected mode KVM: arm64: Prevent late calls to __pkvm_create_private_mapping() arch/arm64/include/asm/kvm_asm.h | 2 +- arch/arm64/include/asm/kvm_pgtable.h | 109 ++++++--- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 2 + arch/arm64/kvm/hyp/include/nvhe/mm.h | 3 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 17 +- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 156 +++++++++++-- arch/arm64/kvm/hyp/nvhe/mm.c | 20 +- arch/arm64/kvm/hyp/nvhe/setup.c | 52 ++++- arch/arm64/kvm/hyp/pgtable.c | 219 +++++++++++++----- arch/arm64/kvm/mmu.c | 14 +- 10 files changed, 454 insertions(+), 140 deletions(-) -- 2.32.0.402.g57bb445576-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel