From patchwork Mon Oct 28 09:40:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13853220 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A63E1D13588 for ; Mon, 28 Oct 2024 09:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=qJTHi2KMszU57wb1zZI7nXL+Y5UzOwkROHjRJN6Unm0=; b=dUHWVQI5x54YvYeM9yGJ+U1Bha 4q2V9Ve003BXRk/jjBkAmPBxZj+LiReZBnc2OXcsyJSpsrNFS4EZ7NrkK+nhjq5qc4/UvjWNGK5SZ XoEv5OXzixR/4LHsAjMGhvqm2X5qJrjTxusruv2wBhWZy6Edmed7t1qtOvDfHp0x0+/Qx2qyaogFZ xdWsS9TTZtEDvsy/gGlUF0fGQoXehbVQKvL2bmh2ShuJ2QjfK6ZAxhns+DcLTgiDHmSizmtxnOZeS ofH4gWjIUnSEo//gjzZ/UcOEXlt++ZKLR8gTvJ/ljBK5U+XBTCrocSsdNpL02Ed1BdFmecHzIwa5x l3GALNiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5MOk-0000000AIZM-168B; Mon, 28 Oct 2024 09:50:54 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5MEe-0000000AGLH-04fU for linux-arm-kernel@lists.infradead.org; Mon, 28 Oct 2024 09:40:29 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1E43B5C597C; Mon, 28 Oct 2024 09:39:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD5BEC4CEC3; Mon, 28 Oct 2024 09:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730108426; bh=cJ+xOHKsd2TE6St+Y4s0cnha3ZN14d8zhSDTUgcPAJQ=; h=From:To:Cc:Subject:Date:From; b=E8Wy/uS8MmrVLrH6Eg66uVopyNyEs0D1w1NRIett4Jm9ho0cwd7BDvKUDI2tqtqaw FNEjL4wUvmmxz76o0sDV4u3FQ7LRJU8Z5dqiXscxE9iADdm+PKlmL31hftZLyNkwds fpmQ2gTPdz4S/s1bWxzzwDRc6iwzCuCkw9YVO4/1PhGsuxY296H0PYQ/YvOvcpfX5M BhQ+ppSTvKZP6Ydv6dCfxOJnCyi5/Z1G7Eb9L08+oKmBhT/fpiHASxEvKtaLp2AO78 PIjd7hdol5g9Zzq1n1YpmJ7hZe/fLb6SdS+rvkCvFintECgOPDLReqiZWCA9QMgWj+ e2sz3O+aLu6zQ== From: "Aneesh Kumar K.V (Arm)" To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Steven Price , Will Deacon , Catalin Marinas , Marc Zyngier , Mark Rutland , Oliver Upton , Joey Gouly , Zenghui Yu , "Aneesh Kumar K.V (Arm)" Subject: [PATCH 0/4] Add support for NoTagAccess memory attribute Date: Mon, 28 Oct 2024 15:10:10 +0530 Message-ID: <20241028094014.2596619-1-aneesh.kumar@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241028_024028_117924_0186B471 X-CRM114-Status: GOOD ( 11.99 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A VMM allows assigning different types of memory regions to the guest and not all memory regions support storing allocation tags. Currently, the kernel doesn't allow enabling the MTE feature in the guest if any of the assigned memory regions don't allow MTE. This prevents the usage of MTE in the guest even though the guest will never use these memory regions as allocation tagged memory. This patch series provides a way to enable MTE in such configs. Translations from non-MTE-allowed memory regions are installed in stage-2 with NoTagAccess memory attributes. Guest access of allocation tags with these memory regions will result in a VM Exit. Note: We could use the existing KVM_EXIT_MEMORY_FAULT for this. I chose to add a new EXIT type because this is an arm64-specific exit type and I was not sure whether KVM_EXIT_MEMORY_FAULT needs a NoTagAccess flag. Aneesh Kumar K.V (Arm) (4): arm64: Update the values to binary from hex arm64: cpufeature: add Allocation Tag Access Permission (MTE_PERM) feature arm64: mte: update code comments arm64: mte: Use stage-2 NoTagAccess memory attribute if supported arch/arm64/include/asm/cpufeature.h | 5 ++++ arch/arm64/include/asm/kvm_emulate.h | 5 ++++ arch/arm64/include/asm/kvm_pgtable.h | 1 + arch/arm64/include/asm/memory.h | 14 +++++----- arch/arm64/kernel/cpufeature.c | 9 +++++++ arch/arm64/kvm/hyp/pgtable.c | 16 ++++++++--- arch/arm64/kvm/mmu.c | 40 +++++++++++++++++++--------- arch/arm64/tools/cpucaps | 1 + include/uapi/linux/kvm.h | 7 +++++ 9 files changed, 77 insertions(+), 21 deletions(-) base-commit: c964ced7726294d40913f2127c3f185a92cb4a41