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.8 required=3.0 tests=BAYES_00, 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 681AAC433B4 for ; Mon, 17 May 2021 12:33:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A3DE61221 for ; Mon, 17 May 2021 12:33:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbhEQMe0 (ORCPT ); Mon, 17 May 2021 08:34:26 -0400 Received: from foss.arm.com ([217.140.110.172]:50034 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbhEQMeZ (ORCPT ); Mon, 17 May 2021 08:34:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF98F113E; Mon, 17 May 2021 05:33:08 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0111E3F73B; Mon, 17 May 2021 05:33:05 -0700 (PDT) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Cc: Steven Price , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Martin , Mark Rutland , Thomas Gleixner , qemu-devel@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Richard Henderson , Peter Maydell , Haibo Xu , Andrew Jones Subject: [PATCH v12 0/8] MTE support for KVM guest Date: Mon, 17 May 2021 13:32:31 +0100 Message-Id: <20210517123239.8025-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series adds support for using the Arm Memory Tagging Extensions (MTE) in a KVM guest. Changes since v11[1]: * Series is prefixed with a bug fix for a potential race synchronising tags. This is basically race as was recently[2] fixed for PG_dcache_clean where the update of the page flag cannot be done atomically with the work that flag represents. For the PG_dcache_clean case the problem is easier because extra cache maintenance isn't a problem, but here restoring the tags twice could cause data loss. The current solution is a global spinlock for mte_sync_page_tags(). If we hit scalability problems that other solutions such as potentially using another page flag as a lock will need to be investigated. * The second patch is from Catalin to mitigate the performance impact of the first - by handling the page zeroing case explicitly we can avoid entering mte_sync_page_tags() at all in most cases. Peter Collingbourne has a patch which similarly improves this case using the DC GZVA instruction. So this patch may be dropped in favour of Peter's, however Catalin's is likely easier to backport. * Use pte_access_permitted() in set_pte_at() to identify pages which may be accessed by the user rather than open-coding a check for PTE_USER. Also add a comment documenting what's going on. There's also some short-cuts added in mte_sync_tags() compared to the previous post, to again mitigate the performance impact of the first patch. * Move the code to sanitise tags out of user_mem_abort() into its own function. Also call this new function from kvm_set_spte_gfn() as that path was missing the sanitising. Originally I was going to move the code all the way down to kvm_pgtable_stage2_map(). Sadly as that also part of the EL2 hypervisor this breaks nVHE as the code needs to perform actions in the host. * Drop the union in struct kvm_vcpu_events - it served no purpose and was confusing. * Update CAP number (again) and other minor conflict resolutions. [1] https://lore.kernel.org/r/20210416154309.22129-1-steven.price@arm.com/ [2] https://lore.kernel.org/r/20210514095001.13236-1-catalin.marinas@arm.com/ [3] https://lore.kernel.org/r/de812a02fd94a0dba07d43606bd893c564aa4528.1620849613.git.pcc@google.com/ Catalin Marinas (1): arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage() Steven Price (7): arm64: mte: Handle race when synchronising tags arm64: mte: Sync tags for pages where PTE is untagged arm64: kvm: Introduce MTE VM feature arm64: kvm: Save/restore MTE registers arm64: kvm: Expose KVM_ARM_CAP_MTE KVM: arm64: ioctl to fetch/store tags in a guest KVM: arm64: Document MTE capability and ioctl Documentation/virt/kvm/api.rst | 53 +++++++++++++++ arch/arm64/include/asm/kvm_emulate.h | 3 + arch/arm64/include/asm/kvm_host.h | 9 +++ arch/arm64/include/asm/kvm_mte.h | 66 ++++++++++++++++++ arch/arm64/include/asm/page.h | 6 +- arch/arm64/include/asm/pgtable.h | 9 ++- arch/arm64/include/asm/sysreg.h | 3 +- arch/arm64/include/uapi/asm/kvm.h | 11 +++ arch/arm64/kernel/asm-offsets.c | 3 + arch/arm64/kernel/mte.c | 37 ++++++++-- arch/arm64/kvm/arm.c | 78 ++++++++++++++++++++++ arch/arm64/kvm/hyp/entry.S | 7 ++ arch/arm64/kvm/hyp/exception.c | 3 +- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 21 ++++++ arch/arm64/kvm/mmu.c | 37 +++++++++- arch/arm64/kvm/sys_regs.c | 28 ++++++-- arch/arm64/mm/fault.c | 21 ++++++ include/uapi/linux/kvm.h | 2 + 18 files changed, 381 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_mte.h -- 2.20.1 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.8 required=3.0 tests=BAYES_00, 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 1B1A4C433B4 for ; Mon, 17 May 2021 12:34:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 B6B0761221 for ; Mon, 17 May 2021 12:34:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6B0761221 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1licSS-0000f9-TJ for qemu-devel@archiver.kernel.org; Mon, 17 May 2021 08:34:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1licQs-0006WB-M5 for qemu-devel@nongnu.org; Mon, 17 May 2021 08:33:14 -0400 Received: from foss.arm.com ([217.140.110.172]:42694) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1licQp-0007kJ-Q0 for qemu-devel@nongnu.org; Mon, 17 May 2021 08:33:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF98F113E; Mon, 17 May 2021 05:33:08 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0111E3F73B; Mon, 17 May 2021 05:33:05 -0700 (PDT) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Subject: [PATCH v12 0/8] MTE support for KVM guest Date: Mon, 17 May 2021 13:32:31 +0100 Message-Id: <20210517123239.8025-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.140.110.172; envelope-from=steven.price@arm.com; helo=foss.arm.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Peter Maydell , "Dr. David Alan Gilbert" , Andrew Jones , Haibo Xu , Suzuki K Poulose , qemu-devel@nongnu.org, Dave Martin , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Steven Price , James Morse , Julien Thierry , Thomas Gleixner , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This series adds support for using the Arm Memory Tagging Extensions (MTE) in a KVM guest. Changes since v11[1]: * Series is prefixed with a bug fix for a potential race synchronising tags. This is basically race as was recently[2] fixed for PG_dcache_clean where the update of the page flag cannot be done atomically with the work that flag represents. For the PG_dcache_clean case the problem is easier because extra cache maintenance isn't a problem, but here restoring the tags twice could cause data loss. The current solution is a global spinlock for mte_sync_page_tags(). If we hit scalability problems that other solutions such as potentially using another page flag as a lock will need to be investigated. * The second patch is from Catalin to mitigate the performance impact of the first - by handling the page zeroing case explicitly we can avoid entering mte_sync_page_tags() at all in most cases. Peter Collingbourne has a patch which similarly improves this case using the DC GZVA instruction. So this patch may be dropped in favour of Peter's, however Catalin's is likely easier to backport. * Use pte_access_permitted() in set_pte_at() to identify pages which may be accessed by the user rather than open-coding a check for PTE_USER. Also add a comment documenting what's going on. There's also some short-cuts added in mte_sync_tags() compared to the previous post, to again mitigate the performance impact of the first patch. * Move the code to sanitise tags out of user_mem_abort() into its own function. Also call this new function from kvm_set_spte_gfn() as that path was missing the sanitising. Originally I was going to move the code all the way down to kvm_pgtable_stage2_map(). Sadly as that also part of the EL2 hypervisor this breaks nVHE as the code needs to perform actions in the host. * Drop the union in struct kvm_vcpu_events - it served no purpose and was confusing. * Update CAP number (again) and other minor conflict resolutions. [1] https://lore.kernel.org/r/20210416154309.22129-1-steven.price@arm.com/ [2] https://lore.kernel.org/r/20210514095001.13236-1-catalin.marinas@arm.com/ [3] https://lore.kernel.org/r/de812a02fd94a0dba07d43606bd893c564aa4528.1620849613.git.pcc@google.com/ Catalin Marinas (1): arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage() Steven Price (7): arm64: mte: Handle race when synchronising tags arm64: mte: Sync tags for pages where PTE is untagged arm64: kvm: Introduce MTE VM feature arm64: kvm: Save/restore MTE registers arm64: kvm: Expose KVM_ARM_CAP_MTE KVM: arm64: ioctl to fetch/store tags in a guest KVM: arm64: Document MTE capability and ioctl Documentation/virt/kvm/api.rst | 53 +++++++++++++++ arch/arm64/include/asm/kvm_emulate.h | 3 + arch/arm64/include/asm/kvm_host.h | 9 +++ arch/arm64/include/asm/kvm_mte.h | 66 ++++++++++++++++++ arch/arm64/include/asm/page.h | 6 +- arch/arm64/include/asm/pgtable.h | 9 ++- arch/arm64/include/asm/sysreg.h | 3 +- arch/arm64/include/uapi/asm/kvm.h | 11 +++ arch/arm64/kernel/asm-offsets.c | 3 + arch/arm64/kernel/mte.c | 37 ++++++++-- arch/arm64/kvm/arm.c | 78 ++++++++++++++++++++++ arch/arm64/kvm/hyp/entry.S | 7 ++ arch/arm64/kvm/hyp/exception.c | 3 +- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 21 ++++++ arch/arm64/kvm/mmu.c | 37 +++++++++- arch/arm64/kvm/sys_regs.c | 28 ++++++-- arch/arm64/mm/fault.c | 21 ++++++ include/uapi/linux/kvm.h | 2 + 18 files changed, 381 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_mte.h -- 2.20.1 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.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 C5A09C433ED for ; Mon, 17 May 2021 12:33:24 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 233AE61396 for ; Mon, 17 May 2021 12:33:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 233AE61396 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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 947EA4B860; Mon, 17 May 2021 08:33:21 -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 fRVq2n8-aK7A; Mon, 17 May 2021 08:33:17 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A86904B3F4; Mon, 17 May 2021 08:33:17 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1A91A4B4D6 for ; Mon, 17 May 2021 08:33:16 -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 lJaQi1UclQBv for ; Mon, 17 May 2021 08:33:09 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6CD184B4CB for ; Mon, 17 May 2021 08:33:09 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF98F113E; Mon, 17 May 2021 05:33:08 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0111E3F73B; Mon, 17 May 2021 05:33:05 -0700 (PDT) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Subject: [PATCH v12 0/8] MTE support for KVM guest Date: Mon, 17 May 2021 13:32:31 +0100 Message-Id: <20210517123239.8025-1-steven.price@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: "Dr. David Alan Gilbert" , qemu-devel@nongnu.org, Dave Martin , Juan Quintela , Richard Henderson , linux-kernel@vger.kernel.org, Steven Price , Thomas Gleixner , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 This series adds support for using the Arm Memory Tagging Extensions (MTE) in a KVM guest. Changes since v11[1]: * Series is prefixed with a bug fix for a potential race synchronising tags. This is basically race as was recently[2] fixed for PG_dcache_clean where the update of the page flag cannot be done atomically with the work that flag represents. For the PG_dcache_clean case the problem is easier because extra cache maintenance isn't a problem, but here restoring the tags twice could cause data loss. The current solution is a global spinlock for mte_sync_page_tags(). If we hit scalability problems that other solutions such as potentially using another page flag as a lock will need to be investigated. * The second patch is from Catalin to mitigate the performance impact of the first - by handling the page zeroing case explicitly we can avoid entering mte_sync_page_tags() at all in most cases. Peter Collingbourne has a patch which similarly improves this case using the DC GZVA instruction. So this patch may be dropped in favour of Peter's, however Catalin's is likely easier to backport. * Use pte_access_permitted() in set_pte_at() to identify pages which may be accessed by the user rather than open-coding a check for PTE_USER. Also add a comment documenting what's going on. There's also some short-cuts added in mte_sync_tags() compared to the previous post, to again mitigate the performance impact of the first patch. * Move the code to sanitise tags out of user_mem_abort() into its own function. Also call this new function from kvm_set_spte_gfn() as that path was missing the sanitising. Originally I was going to move the code all the way down to kvm_pgtable_stage2_map(). Sadly as that also part of the EL2 hypervisor this breaks nVHE as the code needs to perform actions in the host. * Drop the union in struct kvm_vcpu_events - it served no purpose and was confusing. * Update CAP number (again) and other minor conflict resolutions. [1] https://lore.kernel.org/r/20210416154309.22129-1-steven.price@arm.com/ [2] https://lore.kernel.org/r/20210514095001.13236-1-catalin.marinas@arm.com/ [3] https://lore.kernel.org/r/de812a02fd94a0dba07d43606bd893c564aa4528.1620849613.git.pcc@google.com/ Catalin Marinas (1): arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage() Steven Price (7): arm64: mte: Handle race when synchronising tags arm64: mte: Sync tags for pages where PTE is untagged arm64: kvm: Introduce MTE VM feature arm64: kvm: Save/restore MTE registers arm64: kvm: Expose KVM_ARM_CAP_MTE KVM: arm64: ioctl to fetch/store tags in a guest KVM: arm64: Document MTE capability and ioctl Documentation/virt/kvm/api.rst | 53 +++++++++++++++ arch/arm64/include/asm/kvm_emulate.h | 3 + arch/arm64/include/asm/kvm_host.h | 9 +++ arch/arm64/include/asm/kvm_mte.h | 66 ++++++++++++++++++ arch/arm64/include/asm/page.h | 6 +- arch/arm64/include/asm/pgtable.h | 9 ++- arch/arm64/include/asm/sysreg.h | 3 +- arch/arm64/include/uapi/asm/kvm.h | 11 +++ arch/arm64/kernel/asm-offsets.c | 3 + arch/arm64/kernel/mte.c | 37 ++++++++-- arch/arm64/kvm/arm.c | 78 ++++++++++++++++++++++ arch/arm64/kvm/hyp/entry.S | 7 ++ arch/arm64/kvm/hyp/exception.c | 3 +- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 21 ++++++ arch/arm64/kvm/mmu.c | 37 +++++++++- arch/arm64/kvm/sys_regs.c | 28 ++++++-- arch/arm64/mm/fault.c | 21 ++++++ include/uapi/linux/kvm.h | 2 + 18 files changed, 381 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_mte.h -- 2.20.1 _______________________________________________ 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=-12.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 A4C3FC433B4 for ; Mon, 17 May 2021 12:35:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 35A7F6124C for ; Mon, 17 May 2021 12:35:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35A7F6124C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc: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=ewyLqRF9Zub7qxAvB3I+poOm5fBSZzZ5CRkmGE9/mUY=; b=Dflo/voH2g2u3DosiEIdgyJxUP o4ZaJMmPLLfflq8rN7yNGmrYK0LjdRljIFHcAi7gQKH/wiEaweZpcScYOVT/9+Um/aweTovXxsQeR nVND57FiXl9tjz124ZTNVF1vbA0VfBsBRaKKD+qGvN/wJMJkf4DTfifdxcrCBQPxaaLf1ZkmASdMf OrEC07tLxPcRMduV/OixDXrewL79Xz8PfcdJ9yWOmWQkLzSX1whmq+rp9HQLesYZ8C8oJWMc3IiG4 qgh91g8bjlO5C8LSSl/9crvyDt6tBPWH2zrNSTAbeSaaoY133E91qfsfoZrC1EISnA01IFQ1ZUBNC KXQZaLwA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1licR1-00EunN-3X; Mon, 17 May 2021 12:33:25 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1licQv-00Eumx-Tp for linux-arm-kernel@desiato.infradead.org; Mon, 17 May 2021 12:33:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=nLxrgcyR6Iu726ue+eyvFy/vcoTLhMRfCgvVh4vaMJU=; b=Kp1rX+PAmOVzOztFBlfIsij9Vg wWgKzXecYCtRSEmt67tAHHu6/dvhy4KiWUsplICmPNlj66nvlhuhZ3wervZ/wRKe2SYbVZ5+r+WF1 5XfF7ne2iH54VZyad36qO2h0tzagvTs7aNjb9o12f+proHYSHmRyVwz14nBTUtBJx3lCXnl3NfSIC ru+Jp8If8YhXi7JEDau4FORroDtGvwzQihZB1Er7mKAxfCwI33Zi7XWGczalb+bheJs3BGFWzDt7l t7J1PHo1RdyxTODHvkcbmg3tM9YYfdNg25Ycczf6GOZp6TKrxU9H+fzjeriAILkoN2T4RFdcVIvQk wTXVKC0g==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1licQp-00Dl6M-Uj for linux-arm-kernel@lists.infradead.org; Mon, 17 May 2021 12:33:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF98F113E; Mon, 17 May 2021 05:33:08 -0700 (PDT) Received: from e112269-lin.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0111E3F73B; Mon, 17 May 2021 05:33:05 -0700 (PDT) From: Steven Price To: Catalin Marinas , Marc Zyngier , Will Deacon Cc: Steven Price , James Morse , Julien Thierry , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Dave Martin , Mark Rutland , Thomas Gleixner , qemu-devel@nongnu.org, Juan Quintela , "Dr. David Alan Gilbert" , Richard Henderson , Peter Maydell , Haibo Xu , Andrew Jones Subject: [PATCH v12 0/8] MTE support for KVM guest Date: Mon, 17 May 2021 13:32:31 +0100 Message-Id: <20210517123239.8025-1-steven.price@arm.com> 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-20210517_053312_106772_266E3BDD X-CRM114-Status: GOOD ( 17.08 ) 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 This series adds support for using the Arm Memory Tagging Extensions (MTE) in a KVM guest. Changes since v11[1]: * Series is prefixed with a bug fix for a potential race synchronising tags. This is basically race as was recently[2] fixed for PG_dcache_clean where the update of the page flag cannot be done atomically with the work that flag represents. For the PG_dcache_clean case the problem is easier because extra cache maintenance isn't a problem, but here restoring the tags twice could cause data loss. The current solution is a global spinlock for mte_sync_page_tags(). If we hit scalability problems that other solutions such as potentially using another page flag as a lock will need to be investigated. * The second patch is from Catalin to mitigate the performance impact of the first - by handling the page zeroing case explicitly we can avoid entering mte_sync_page_tags() at all in most cases. Peter Collingbourne has a patch which similarly improves this case using the DC GZVA instruction. So this patch may be dropped in favour of Peter's, however Catalin's is likely easier to backport. * Use pte_access_permitted() in set_pte_at() to identify pages which may be accessed by the user rather than open-coding a check for PTE_USER. Also add a comment documenting what's going on. There's also some short-cuts added in mte_sync_tags() compared to the previous post, to again mitigate the performance impact of the first patch. * Move the code to sanitise tags out of user_mem_abort() into its own function. Also call this new function from kvm_set_spte_gfn() as that path was missing the sanitising. Originally I was going to move the code all the way down to kvm_pgtable_stage2_map(). Sadly as that also part of the EL2 hypervisor this breaks nVHE as the code needs to perform actions in the host. * Drop the union in struct kvm_vcpu_events - it served no purpose and was confusing. * Update CAP number (again) and other minor conflict resolutions. [1] https://lore.kernel.org/r/20210416154309.22129-1-steven.price@arm.com/ [2] https://lore.kernel.org/r/20210514095001.13236-1-catalin.marinas@arm.com/ [3] https://lore.kernel.org/r/de812a02fd94a0dba07d43606bd893c564aa4528.1620849613.git.pcc@google.com/ Catalin Marinas (1): arm64: Handle MTE tags zeroing in __alloc_zeroed_user_highpage() Steven Price (7): arm64: mte: Handle race when synchronising tags arm64: mte: Sync tags for pages where PTE is untagged arm64: kvm: Introduce MTE VM feature arm64: kvm: Save/restore MTE registers arm64: kvm: Expose KVM_ARM_CAP_MTE KVM: arm64: ioctl to fetch/store tags in a guest KVM: arm64: Document MTE capability and ioctl Documentation/virt/kvm/api.rst | 53 +++++++++++++++ arch/arm64/include/asm/kvm_emulate.h | 3 + arch/arm64/include/asm/kvm_host.h | 9 +++ arch/arm64/include/asm/kvm_mte.h | 66 ++++++++++++++++++ arch/arm64/include/asm/page.h | 6 +- arch/arm64/include/asm/pgtable.h | 9 ++- arch/arm64/include/asm/sysreg.h | 3 +- arch/arm64/include/uapi/asm/kvm.h | 11 +++ arch/arm64/kernel/asm-offsets.c | 3 + arch/arm64/kernel/mte.c | 37 ++++++++-- arch/arm64/kvm/arm.c | 78 ++++++++++++++++++++++ arch/arm64/kvm/hyp/entry.S | 7 ++ arch/arm64/kvm/hyp/exception.c | 3 +- arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 21 ++++++ arch/arm64/kvm/mmu.c | 37 +++++++++- arch/arm64/kvm/sys_regs.c | 28 ++++++-- arch/arm64/mm/fault.c | 21 ++++++ include/uapi/linux/kvm.h | 2 + 18 files changed, 381 insertions(+), 16 deletions(-) create mode 100644 arch/arm64/include/asm/kvm_mte.h -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel