From patchwork Fri May 3 13:01:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652780 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F7C6C4345F for ; Fri, 3 May 2024 13:02:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADFF46B008C; Fri, 3 May 2024 09:02:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A918A6B0093; Fri, 3 May 2024 09:02:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 97F256B0096; Fri, 3 May 2024 09:02:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8029F6B008C for ; Fri, 3 May 2024 09:02:03 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0781981139 for ; Fri, 3 May 2024 13:02:03 +0000 (UTC) X-FDA: 82077097326.29.D77ED42 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id AF08714000B for ; Fri, 3 May 2024 13:01:59 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741319; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qHuOu1z46rPW34oVvLWofFqZQlecCLnKF1jlWSzrNJQ=; b=vuatluIwLeH1z289fJ9yuU4VEoGxLmfFVFr/5OhtcpqG3VgctPCiARA7rt5g/YCG6PRg5k 1sySqyb0B4R31iDodiuWOoA8uU5crumyCmhNQJ9CXdHN7L0HA43K1IgqHbqJrJ4yvlDutv xLjX19zWQOmkMQtN942F5SWKqpNy84Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741319; a=rsa-sha256; cv=none; b=eFk8gOBTpfX+lR14Dlad46J0l39oqAu+qtgcKncwD99h4A0m7NQeLzNDDBUTYUI8tN6UQb 9QAl1iEMyZeQ7l0ba6aEhXa/nxdppi5SzXW2i8b3DJFnsGSwvkPwpn3yQG6yCwxGEnYhJx u+4Sq0r9gi+9Nlg0U4922T/TzZS1/A8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 206C41474; Fri, 3 May 2024 06:02:24 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C40D03F73F; Fri, 3 May 2024 06:01:55 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 01/29] powerpc/mm: add ARCH_PKEY_BITS to Kconfig Date: Fri, 3 May 2024 14:01:19 +0100 Message-Id: <20240503130147.1154804-2-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: z1bouuqus6b87uhjgkornzdiudnb49og X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: AF08714000B X-HE-Tag: 1714741319-809989 X-HE-Meta: U2FsdGVkX1/erqOLDVQWI0L7dMzjpk+WEVbGF4FlS/vmNgzm+PvB6WUzddEHUu11pLKj8fxRe7bhe21yLJUzMdmuNaRwhVCGv+cSH7Vi0GzA73L/IX8fDbcVV3rOqseoKvQpEf14RfQ/LBo/1Eb8fjYBowE9dhxfRT0ODTcXCcs+bKlQLUbzme4Vz8VOgkB2LF7bdTUDeDvi+a37mVH7RHL7ykRzJRS0eAS7Y3khXtpMMn5X4nDSatL1oiK7F5cQo1Ie98Z/DFFCJmJUkCoP0TY1cX2G3eTCkX2Zxi9PYYohWxvETNMhfhHLIq0bs75ywrcnN39vMmNtaHo7f7YjcVeGtnIGIcii8ILc1B5EojCVmiU4MbhQAyY15j1uMAFf+dLm2RG3mOwy3RY6Q14cBf701Xd071sIc6jtePvzaKl72lyKZCZkFKgDPU5eJwt1mtNdQsGepF1GBhTgDuJYRUp2LJauWjqFw7oTnP9PeNjOGktlLxY0Zl5ympMA3ZYgIdCZHr/tTptN0vDNJkEkYXVQL7SOvadcpnyjIJHc5clwzeZn3EmK6aRlSywRQPQ/6EAJgFCWDTt1+4mdpMBQIlaGZWMcPEJg5E8lljJKxxLKuKh9nM1riE/aW4AZZOQHb/2BgYVwcqofIdrd1gy/w6Vfan40HhjS4fhor8F7zaLXkvrgbchwe7bXWWJitMPKZ6ZF7q0ifGAYPUTQ36/nUwZergiIfvV3HQ2TnwlZua2vCRiFFsCXXQ7kVkYZqkLi04qjRmwmMTRm95bfDSD+B52mXrRXvy1RCfqbHeoUrzJgZYa1LyDQP/iM9smUhT/f4V/SZkRIv/RXJVdfDVEpb6JDVTclctvSptZ5tSqp+C06i+laUuXdv/nWE3YA1IAGjOm+f54L+vkL+1s/fMpswaTaPJsaQamMi3RZuzZPoh20DGhmcWRZhr1V6TDf2YHnMAmlYNtAjyFtcf3hwKL mHkINd/R 6gzDB47LiZmBYxCeyGO+5RJrq5OttjoEGxrwFQ2K7f4Zvp+GoLk0W63QvwRHxFnog1YD9XVAGvixa1dWmPeZFOGH8p6IqSbviZHjbwPFPER/Twfnet8Rf3YZ1L30vJD88ONdxK6jJHR8iwcM/kBPrhlzZk04MGgWORE7q2dckJQ8dVxib5zRPWZcdMPRnFx94vNdfsCkNBlBEr0oM8W66wCoUctXSP1tzg1/NIZNf4LiaUwceDbEB5IOnWYUdfgCFkfUZjdnSEW8t9Gz1H4FJwneuJgpjbcE7WN6yhngkexG50Y37QcBnGgLNA2Bp72ACkoBWG1DZZVxUfEVWS033qrZJa+zdluw2Uu6IfZOC1tMtLtE4baztn+Usb8xEFWJVJy8rpO5oIaoplFEYLdGXU9+UKA/I+kpR7pfpPZ6v/Sli4jY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The new config option specifies how many bits are in each PKEY. Signed-off-by: Joey Gouly Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: "Naveen N. Rao" Cc: linuxppc-dev@lists.ozlabs.org Acked-by: Michael Ellerman (powerpc) --- arch/powerpc/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 1c4be3373686..6e33e4726856 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -1020,6 +1020,10 @@ config PPC_MEM_KEYS If unsure, say y. +config ARCH_PKEY_BITS + int + default 5 + config PPC_SECURE_BOOT prompt "Enable secure boot support" bool From patchwork Fri May 3 13:01:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652781 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C63B4C25B5C for ; Fri, 3 May 2024 13:02:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D6AD6B0093; Fri, 3 May 2024 09:02:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5894A6B0096; Fri, 3 May 2024 09:02:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44EB66B0098; Fri, 3 May 2024 09:02:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2A8386B0093 for ; Fri, 3 May 2024 09:02:07 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0D364141106 for ; Fri, 3 May 2024 13:02:05 +0000 (UTC) X-FDA: 82077097410.19.7FC10F3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf30.hostedemail.com (Postfix) with ESMTP id 0E99C8002F for ; Fri, 3 May 2024 13:02:02 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741323; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sZ4YkuCwNTOaWA/ypJULqxKYcOXcTXL0XcMF1LvyKEQ=; b=6mXwz6pi7A6lI+ns7MwlnULWyqKl+JKsj41mlGyg0LnQqlXOMGmk/qpqHTq/StNsXPsWLB SjwMCsYrc7ZCa4HN+q2IqI8Vm/qW91PUEYUDIqg8vJqrfXwrqkYTCfGMRv1/r16opJ3Du+ FJHcrvZzYCBZbftfULkt2Xgu82m2TKg= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741323; a=rsa-sha256; cv=none; b=jTpJiqLO8451GFilQLaXoHFzW4knyvL1+ooUUFzcU2tBrdnvU2pRbh9XSMJj3XxxImnvJm r/lky+NtOjmVQOEPFfuJzqZfSiIl3EyFA61CW+2PDhXQm3UZUt3zXNyHU6Nduii4Lt3yhs v3lS5RPAyOgwNNbwaC9kUeWPqixF8Gw= 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 777061596; Fri, 3 May 2024 06:02:27 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A7ED3F73F; Fri, 3 May 2024 06:01:58 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 02/29] x86/mm: add ARCH_PKEY_BITS to Kconfig Date: Fri, 3 May 2024 14:01:20 +0100 Message-Id: <20240503130147.1154804-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: abcmwi3tr5m11yjjmap5j868gmduaxy9 X-Rspam-User: X-Rspamd-Queue-Id: 0E99C8002F X-Rspamd-Server: rspam05 X-HE-Tag: 1714741322-367576 X-HE-Meta: U2FsdGVkX1+Yr7+qdNGjbBipMN//062DjhWGnGJdpduO1p2ieJHnct4zTUtlhf/Q1S33vDcoQGiCrkyjitOXrwSd3RTjVyRxoOgl+9/ee7nLGPBzlL/4cYwU2htZ2xD7DExKTg85FpUGkB1R1TlP+ImkHAHUXdMa7Z3NkeIuCaCmlg6JRjLGwtjJ2QHr38nBzOcvtn8STRu4KfwMRQediecFJ8cUEblbCzk8G6HEWaMyrXkJv2txa1W8Z04PCq+JTsWBiWz4rqn9h2t36LYYE2U+oxGbpDv1OBlgWF5LRL3COBows7Bq5nyTQuvLVT5WKWxyk/3x/0t+URHxZaq4OOjPJedQZJ0330FK2FSnU8NBd0UEdHEvUVpQff9QiehvGVYsBbhrErVBjSxqjv81SSLoqml1ne+Be6plNvFvm0eFoYLhUr8bjJgZGzhlrJFxFpTvsUeS1VvSHRwiz2vbgisxOmoz1+rB+pWTSlcEKMUYMrDDlNCV6tfZ1+xT4/fGMrA1RDUYsA1O7GevaxJAq9sTTnC1fFHaHjZSfchWwLGI7ojFDRYvrhqo7Q0YDyD859PL0jCEwsRjpxtZN+UKUCZkmxxhqUj47+YDmnooakFME8Jme0/3lsOLBERomH+a/xxCL4SBP8ldnYeT+EBuR/cmV+/ka1McBSjzC1385leBCBxofVWJttEP8POXCp+mDJdPeyIqih6DIEgj76OAygN7Q4o4OpTGWtcmNYXT4LZmdGENLjvztobCVWfcxj3ptmSkoqVPjvnCoSN2f/GmoL8Kwp9yjY/SuMVe0UbMds/wf/fKHV/qw912/LTMlPUnK/3pR9qCtIsxFqapoOsNft0jxkX+tW5zbls1V1/S1ByvQZ8OwhqqD5j/foQsvoadlKZkoT+/kVo3YUYEkeejgEpFqKN3tHUKHqpXuRrP6XAvj4jgKsu0/6v7+98flgBdBPQFqeQt94P16yQgDdL m4c4QcvU IxaoQ5nle50VwevmVoCg6qu7sJVa31CDHXC9+w2REASQplcZOIQuDBECvYk2JufcFdBhCoRd5sMyuzIoJwzbD8iFJER3VKInWhruDiwqah5eSX/GxcuBR4B208RmAFgsBLDX3U54URYJb3VR/FZSVS+QvkEPtD3PxYMNOQnrIXqsuJNROpKSHlj3ynn30oEBP9S5yjveDXJPiuLlLIihnOses+NNrjLWtEkf0kTTamq/vRK3QxyxJoT4Z/kisz3I5tu/V9MSITVsig1fqMurbO5K1P9VbqUyebt397M48OuofeAwYk5K62Ei2n3x/PQATESZw/eW8EPahEvQ7RaOtPuIVXNbFlYGxhG5tyOX2Q0RFaKG2onS/3iNVKw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The new config option specifies how many bits are in each PKEY. Signed-off-by: Joey Gouly Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: x86@kernel.org Acked-by: Dave Hansen --- arch/x86/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 928820e61cb5..109e767d36e7 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1879,6 +1879,10 @@ config X86_INTEL_MEMORY_PROTECTION_KEYS If unsure, say y. +config ARCH_PKEY_BITS + int + default 4 + choice prompt "TSX enable mode" depends on CPU_SUP_INTEL From patchwork Fri May 3 13:01:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652782 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C28C10F16 for ; Fri, 3 May 2024 13:02:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 588DB6B0096; Fri, 3 May 2024 09:02:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 539206B0098; Fri, 3 May 2024 09:02:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 400AC6B0099; Fri, 3 May 2024 09:02:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 27C656B0096 for ; Fri, 3 May 2024 09:02:08 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B008F1C0F8A for ; Fri, 3 May 2024 13:02:07 +0000 (UTC) X-FDA: 82077097494.04.C4B92C8 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 1875C4001A for ; Fri, 3 May 2024 13:02:05 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741326; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ngGB0Bj2BuNTbRSE4L9TicbHMy2yLYIVIV+RC2ewmr0=; b=dt4w4qrLYpVTesI+JSv1qaZ1KM/MBbeCiGypCpgu9QI9OuHwlVi+leb6E9UNv17+2bNB1l SxIpCrOBotPpKIkvBWcO/QdhTxpc4+mFhIPFfHMs5PBNjj1lZqsbdDBkzbg5XB6mY++lHd b0FNiZC+h9bhtn6x/pQNr/wCNbyh6pI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf07.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741326; a=rsa-sha256; cv=none; b=S5JaIqV5LkCRls5pttxWANQMue++avrbaHPyh9eDvjhpJYKM/LXPaoF2ISMZUvoYupvAVW rFIAgR9XjPneNgTBfhWf6chEjm6Zy7+70C7qZeqEKWeYDO+hbIfZ7gZkyo/twlrmlyBtOb 9Uv7TSHOXaY52sTijkC678mEMBetVcM= 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 B60E31477; Fri, 3 May 2024 06:02:30 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 650863F73F; Fri, 3 May 2024 06:02:02 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 03/29] mm: use ARCH_PKEY_BITS to define VM_PKEY_BITN Date: Fri, 3 May 2024 14:01:21 +0100 Message-Id: <20240503130147.1154804-4-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: 93y5cg6t5yyjcqtg5jsk4xy86se7qhps X-Rspamd-Queue-Id: 1875C4001A X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714741325-76161 X-HE-Meta: U2FsdGVkX18NBkjwgAUjTY6dBlXZL02mTBq/Agc9kshCLp2fZiZIWkuJHKOAuqdjRt6XfW3NKk3UqkveVjjlDsxmclVEutbDkoLfXWhjaY7rbTkaXDRzdDuXAa61Uvr7wfECYBXz3142k4Ule7sXMS1mx/CVJkvOB7bWlv28gJPhQEjhUf5m68+Fjn31csrtGhE67NgV4BAEqNlJKAeWSPGpIFGNiay/2bpJNV7Yek+0QkX15MsKjQuNOQIpm31yh/uShjx6WSUfeMBEpQYxBvtNXUpasLMc1pGEiStYkRHBK/OgLQH2MifVKUT3zJUjuO8P3yuFCd8Vwdi/nLFc893+GH+1BqOQuXM8RU5bqGL/eb4dKlJXhNTVQtRrfmMTdPTuhnwGlP6VBziznR7y1Mh1ADnRqtOqhuMaseugeUIRlay7NehXZTP3O95+KrwYGpa/NgDjx6FINh8WOEDuyZ/0hDlcOHuDGkANXxKBdvaMISqjsGGytqRSajRoVDQpO6/x024DejuEyzPyk8IdV4WdEy4buoR0EVN9nRwxchBDZSvIph4PJZkMjm/v9CsN+ZR21k/MAAXBFks3ebyNXrOV8KKMt9P+weKIXNFdmCwt4sHBIzUncf+FXJkdP7LCwXeevHievAqedkV6faK0lzVgp/7XgUBcjlTywver5e0jeo3fdryPe/Y6yFvJ5mnHwFzH2XNrMGexJ0F1Ue/Mwq9g6W305dzH1MIl9Rghh/0PxcQpYuZh01srDKdAuF/O/k43P2Fqskt0MgNtacwThWbiZw6N3ZsisxenL1i1rCwOzXlW2QcIKO2HePiREiuUJo51U5kkkqu4EkWT+HQcB2Rd5Ab7Ot96VjEzCgRZg+PD6Tv5zuS6hKRooENGE5BMngaPTt1laqyikKLFPFGvTfm+7sLwSPX+iz04nh1airjNq9mjeFb5Op6Zysu8MMLL/HBl/C5+fFrjLi2BRNB YOQuXKX6 2mcpaiTq8S37V2O5yz1e5t+JbuZt/zfnfqj0aJTHn2bbcYORE066stsCoC7U/VlgolOQIu6YME3DIE3UvfJo0En4K1QdJUWQguqWZuv0OYxkGQshd29ii9/abohStjA16Z9qHOWfztzx7O5pcxvOW9aScBZHg2L3C9Erut07EJoP+KyhLb5xpMEvS5V9sH/Ph0Jan1lDkdwtRlIgZItCrQ1dyGQ+l4mye9lnDjaOv61t3mfFZPPEJnsMCi50bGvuAKPCcADkYdW1Bx6Mja84oxOTlRe1CL/JbzSYBAeaPE8NG2FOApSiwAZoNrauY/MQa/uPR8g5ZDUklBK0xeDuEMpfOAadG8ziZznedCpD3u4k4I16Xu2THtZQBXIx1AwygdEsR X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use the new CONFIG_ARCH_PKEY_BITS to simplify setting these bits for different architectures. Signed-off-by: Joey Gouly Cc: Andrew Morton Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Acked-by: Dave Hansen Reviewed-by: Anshuman Khandual --- fs/proc/task_mmu.c | 2 ++ include/linux/mm.h | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 23fbab954c20..0d152f460dcc 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -692,7 +692,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_PKEY_BIT0)] = "", [ilog2(VM_PKEY_BIT1)] = "", [ilog2(VM_PKEY_BIT2)] = "", +#if VM_PKEY_BIT3 [ilog2(VM_PKEY_BIT3)] = "", +#endif #if VM_PKEY_BIT4 [ilog2(VM_PKEY_BIT4)] = "", #endif diff --git a/include/linux/mm.h b/include/linux/mm.h index b6bdaa18b9e9..5605b938acce 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -329,12 +329,16 @@ extern unsigned int kobjsize(const void *objp); #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS -# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 -# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 /* A protection key is a 4-bit value */ -# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 /* on x86 and 5-bit value on ppc64 */ -# define VM_PKEY_BIT2 VM_HIGH_ARCH_2 -# define VM_PKEY_BIT3 VM_HIGH_ARCH_3 -#ifdef CONFIG_PPC +# define VM_PKEY_SHIFT VM_HIGH_ARCH_BIT_0 +# define VM_PKEY_BIT0 VM_HIGH_ARCH_0 +# define VM_PKEY_BIT1 VM_HIGH_ARCH_1 +# define VM_PKEY_BIT2 VM_HIGH_ARCH_2 +#if CONFIG_ARCH_PKEY_BITS > 3 +# define VM_PKEY_BIT3 VM_HIGH_ARCH_3 +#else +# define VM_PKEY_BIT3 0 +#endif +#if CONFIG_ARCH_PKEY_BITS > 4 # define VM_PKEY_BIT4 VM_HIGH_ARCH_4 #else # define VM_PKEY_BIT4 0 From patchwork Fri May 3 13:01:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652783 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A33DC4345F for ; Fri, 3 May 2024 13:02:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2B166B0098; Fri, 3 May 2024 09:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB4076B0099; Fri, 3 May 2024 09:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7B6D6B009A; Fri, 3 May 2024 09:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9A4186B0098 for ; Fri, 3 May 2024 09:02:11 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 55DB91210AD for ; Fri, 3 May 2024 13:02:11 +0000 (UTC) X-FDA: 82077097662.05.11A200A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 9918F4000F for ; Fri, 3 May 2024 13:02:09 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741329; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m1YNZzVNHUKXEqwCd6c41mepOkwzhluAkxFa5wlr4ak=; b=6d7w8tSkHKTVhLS4dB6tfwpb2DR1K/y97GXRxV2k7WBmtPm6RuyCQ1d0iMp0oIVxaSEVK1 FMDNDS3RcUD7lSHAbXcuiOkT6A34u4eJFRiMlda6jOxOMQWipdJYygd69X+2hApS6hVomg d5N0X0Pdev6Sekqjf9h9z1sWcEyXss0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf11.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741329; a=rsa-sha256; cv=none; b=nM+FYnU3bjmK5HRfMzR/PR1ixqpVbDgGriPVvmSABrrDjvNXtF1LBskrM9gfK9mQZT+RWU j70gEGlp0Lr8eib+zfn3oua50vzRQOy4FbbAf8stlihgL8X9NaeHc/HlCT2iLm+COn3iEA sWhfU8WmAmq7Mhgk5v7OvFJrLBJIpvg= 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 0CCDA1595; Fri, 3 May 2024 06:02:34 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B03A13F73F; Fri, 3 May 2024 06:02:05 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 04/29] arm64: disable trapping of POR_EL0 to EL2 Date: Fri, 3 May 2024 14:01:22 +0100 Message-Id: <20240503130147.1154804-5-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9918F4000F X-Stat-Signature: 6c4rx156yysd4w4ec5p7cx4nmubhj8xm X-Rspam-User: X-HE-Tag: 1714741329-849384 X-HE-Meta: U2FsdGVkX1+mHzyHyKbtvvwR3Zt30iXltn+U7+RAvp9cqzSWAS28P8Ix/VXLv3jqFneoImZ+BP1UAf9EZyOoSMCEqaiOIfFOlCn7z2EZUoreDDVttAgExIQzxfzyYncfl/DANJHZZ8UiG3zVHxpOd8JR+vmq/yPjnp9XsQ2grL/isYZtGsOTBaBhdEbsulSD6vDsMZBfxvW4LAxRAa1h6xVv5bOPHQHIQI9LoE2B/QYwvZnHhNRJ6EMFAyDvAimQxHEVW7tva01siX3dQPPNkTDCHs8LKKv4mZpHQHNjNkdGn/gdMzrtRu3PNdZKWMvcOBQNFbdRI/Au8FkfY5wEeu/PCe5m6IFAQGHeSKSne9jW849BzpIstgDzyKpum/T9HdMp3A6pUxWy+DwDiEHHzNfI4Gl2ychfnB45lptaiAoWyGs/7BdPL7gIPS2xpvVOfiQmidZgrtF91wYkzy0Wg16JnO3+gTTmcsiTg0wFpLMWCwhtgnXSlR9BtwSDtdIUm0AhvQZIYOPCzE6Ea2Ssgr4BlIDtzOyZyD0Be693pyVifVaKpaOz0P070xjQr8bpyJQns1MohlJB2Q/ZwHOQzmP3MNUBfzQL8odj9THbqnjxv8LkjPU9uX4VsN4YCQWnYbiztuLI2mVKXpsI3QeSdnOKHUT7t1hnEYj8hjK7nJKxlX7MAdgKoTjE4e2YmUQq+pm0DMnscCg4yzF4fvW0BZ3Va2A9aVMHcOM+p2uDsR1ntJepYFu5IfasYmuUuGeCp8qba4jNyg4O+vhI8k32jKK8qerbXa21Mkvr4qK4myzgRL+Zf5qQtKo7j2x2zctp02478lklsnwbXOpgheb3uyE0TYt+mbdEMA4K79rE4Vx+LqKsSu8JYjGlQ66AONYbxP7Pj+xBeOCui+09kArHRtLHOF3E/uEb6hrNBXgUkmbxJYGWaT5fXyB+MNzg1xUygODjNgymW0uHVtcvyjA 0T2hesG0 RW77wefgul1alATZcR8/m+RH8H9dXMtjp0/rMasU16CUYmW/ehKPZN3nHPim0UGtgH6w5uSVGfpwbgduf9Iiuux0zWPGntHoCDgzBOCXqPvpIJGTsRcmQ0tGpHIAMFfWrYO09oHR42zirBBEVsc2+Zk7SdsIKsPmeWILimBL7Fh8x09oRo7sXrxJZ76InjfcUUaPCmKP859Mj6qqzRzoqyBIR+91corGxAc5cN1cs02OXqQq4W0MY0HRviRUJ4CKbvW90IgLXjWOvG9k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Allow EL0 or EL1 to access POR_EL0 without being trapped to EL2. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/el2_setup.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h index b7afaa026842..df5614be4b70 100644 --- a/arch/arm64/include/asm/el2_setup.h +++ b/arch/arm64/include/asm/el2_setup.h @@ -184,12 +184,20 @@ .Lset_pie_fgt_\@: mrs_s x1, SYS_ID_AA64MMFR3_EL1 ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4 - cbz x1, .Lset_fgt_\@ + cbz x1, .Lset_poe_fgt_\@ /* Disable trapping of PIR_EL1 / PIRE0_EL1 */ orr x0, x0, #HFGxTR_EL2_nPIR_EL1 orr x0, x0, #HFGxTR_EL2_nPIRE0_EL1 +.Lset_poe_fgt_\@: + mrs_s x1, SYS_ID_AA64MMFR3_EL1 + ubfx x1, x1, #ID_AA64MMFR3_EL1_S1POE_SHIFT, #4 + cbz x1, .Lset_fgt_\@ + + /* Disable trapping of POR_EL0 */ + orr x0, x0, #HFGxTR_EL2_nPOR_EL0 + .Lset_fgt_\@: msr_s SYS_HFGRTR_EL2, x0 msr_s SYS_HFGWTR_EL2, x0 From patchwork Fri May 3 13:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652785 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B8BC10F16 for ; Fri, 3 May 2024 13:02:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69A646B009A; Fri, 3 May 2024 09:02:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64ACA6B009B; Fri, 3 May 2024 09:02:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49D176B009C; Fri, 3 May 2024 09:02:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2C4C36B009A for ; Fri, 3 May 2024 09:02:20 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DC46DC07D7 for ; Fri, 3 May 2024 13:02:19 +0000 (UTC) X-FDA: 82077097998.05.638FDB4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id BCFE2100052 for ; Fri, 3 May 2024 13:02:12 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741332; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EMTlE16KHg92fuatX2tP/KfEsLj0enCW7nGDqhK+fxQ=; b=0Z+v3yrSYCAmIj2xsaDN8LT+hp+QoYJJoLly0r8NJMJFohIJZHt+WDFpVEYz3P1nstl3NT yLRYG8k+96Ve8auwDw63qrcaYfCA/4RgwPv9JsAEQd8iSHtyJfZFlUnhqkWmih2qpaRneY H9oTrEJ2j7IjM51JWvWOnklhLAHIB0k= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741332; a=rsa-sha256; cv=none; b=hh2fYnTVO0R+wXRA/WXDOH2Pbi/rcg3rYhWewEEyQ0+5vJA46ZDdiVRbcgsW428CWW4YDh R2lmiBz37yjLgQ6wFnwiuA3rDyosVRckXLQaoUuop0NbOC5lza6cB5ZUhaFcTd/FsROPn8 ZOHE7slswV23u1cVB0jPApA0ZCQnPYQ= 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 57FC215BF; Fri, 3 May 2024 06:02:37 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0728D3F73F; Fri, 3 May 2024 06:02:08 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 05/29] arm64: cpufeature: add Permission Overlay Extension cpucap Date: Fri, 3 May 2024 14:01:23 +0100 Message-Id: <20240503130147.1154804-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: k4mj1w5faxnp9rkfzx839w9opehtiu4f X-Rspam-User: X-Rspamd-Queue-Id: BCFE2100052 X-Rspamd-Server: rspam05 X-HE-Tag: 1714741332-502966 X-HE-Meta: U2FsdGVkX18RWB3Q+rYMZksYFCH9+sAP42KydJAUh1D9T0I23cQHAxDcxlAuYyM/5cgghOV6lfRU/+vEEA/bWj9ovCIamEMfAKD0YQoFMCyQuq4KfM/ltq1hbR9Kw5nA6fHIGM3budZFpvsCR8IafOPfgwsw4Bw/3WnIgZYnYTFfZMEueqIf5w1Bjc9BQBNeC1eeWj+hxk596knJdVbDGxbC8e5HWskoM6UWlGDCaMaoyVtS5+/vh19SnZbKYD0Iqz0sF+uwit3fWo0gLTXPclhQerN7PIfgIWeAq3ALzNfNWv9lX5WCUATQYxZWKMzRa/llq/n3lw80YtKZQKiafYv1ImzcVChhZ7V7VUo7ryxMw43m0ts/U7vKG6wMb7ENuKgcMQjtavGWYZYMM7cN9XGcdjd0WPI+42PPnwFDpQWXKbqPlKLryZblnHy70V8POzdr2xJKiA7mAiiO28zA37xVJfDuDCGDij7V3bqhk7MwjNdjQoTm0GBwVysUxATC90foliuy8pnCNFIJLqYYePYAADdZU80JHh/bi4UhIUaxNAiUOrwonDRxD9SFbnImTFLCqkREjAKY6kY3g3vxf9mljDYD5It5Fs8pmanweNkgTRYtbFBeoDxTe+OFE5Do8MOTkxvbRbwO3Uph5UnDNOJI1erTNTlXPzflTRSx0q0QSVaeP8WE9K4hBaX7UhaSPs4uyBaFErEc5JHiaAb6PJxMgepZfTRsZAzGyv5K4RZRQNAiOT26q1lKDKSc5lT6x+mUySNUXo5RM6pEc8Jp2ug/WvIjo75PraktRI7IRBZobGToYItJic5i5s/Nx1wnxf9dHPRR66gxpmUrdqivLSuI/tHnGtTYy2ni4bXCfBf2370o/79F+8nGpII04TAUx8hoUdeiDUZFTwClQLssaLADYDkXBefPGe97Gx5LpSbJI7sIqouX4r3HedWvw0EDo6fVyQwKTS5dAJ/FkNK BZizjQUd swMaoRAVgCPaAITzX7uEJg1wjjGQPBQ+wMQVieg6bB3tSxPzED0Kh2ECuTgDNvuS4O3DiS6C0ymeEMRwhLuJWIa4eEfGDvaIO5bIkeGLjE612kr91obRMbSt2MNZ9m2RkCw6QTXAuW70FQpyilgEBwZ5KuxGGsWZVn24/PpUuICE+a9deirk0tHNjeGwGT41TfIUlVVvNEV8p9UjCIaPSH6l9ww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This indicates if the system supports POE. This is a CPUCAP_BOOT_CPU_FEATURE as the boot CPU will enable POE if it has it, so secondary CPUs must also have this feature. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas Acked-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/kernel/cpufeature.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 2 files changed, 10 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 56583677c1f2..2f3c2346e156 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -2861,6 +2861,15 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = has_nv1, ARM64_CPUID_FIELDS_NEG(ID_AA64MMFR4_EL1, E2H0, NI_NV1) }, +#ifdef CONFIG_ARM64_POE + { + .desc = "Stage-1 Permission Overlay Extension (S1POE)", + .capability = ARM64_HAS_S1POE, + .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, + .matches = has_cpuid_feature, + ARM64_CPUID_FIELDS(ID_AA64MMFR3_EL1, S1POE, IMP) + }, +#endif {}, }; diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index 62b2838a231a..45f558fc0d87 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -45,6 +45,7 @@ HAS_MOPS HAS_NESTED_VIRT HAS_PAN HAS_S1PIE +HAS_S1POE HAS_RAS_EXTN HAS_RNG HAS_SB From patchwork Fri May 3 13:01:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652784 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AD35C4345F for ; Fri, 3 May 2024 13:02:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B55316B0099; Fri, 3 May 2024 09:02:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B051A6B009A; Fri, 3 May 2024 09:02:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1B3D6B009B; Fri, 3 May 2024 09:02:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8A6216B0099 for ; Fri, 3 May 2024 09:02:19 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DC98B160D0A for ; Fri, 3 May 2024 13:02:17 +0000 (UTC) X-FDA: 82077097914.12.B8A822C Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP id 1D395A003D for ; Fri, 3 May 2024 13:02:15 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf15.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741336; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NyED+DBvvFHRV6yjjoolrEgVtOiqM/VX8VwTXZjwix4=; b=tWL1UCf0cMjmK3WmkCBMAZCD38usDosZlXOvbwkTrUaxMczQ4Gc6kzovPigGGgzPYqKET1 PSvIywmPLK2woyr2d4iZ8HzZbAoEEYQQUwZdEDNdcewXPkLX2XyZF1cY+XekAaGtphu43F LU7ZWbYyz67A1YYK/S9QAeFxITiZxlQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf15.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741336; a=rsa-sha256; cv=none; b=rf9vOKEiAYS0jrO3ylMsa/OgKqFyFtuSeuyj5p1hkdwgCpqmYuv2bDpkW9ic+6SEuO01g2 L+Jb1CkoDLpWNsgDAWtBMTg9tO0Y5AuH9smWc2zeorTAx6EPp+OfOL4S7Klih+txTRLnVH h/nmdOXLZITTJmO3/qzI03P338N1O4k= 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 A58911650; Fri, 3 May 2024 06:02:40 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54B283F73F; Fri, 3 May 2024 06:02:12 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 06/29] arm64: context switch POR_EL0 register Date: Fri, 3 May 2024 14:01:24 +0100 Message-Id: <20240503130147.1154804-7-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: d9gg7aqaj8othhpsgcuhbjx3x4ohw6ei X-Rspam-User: X-Rspamd-Queue-Id: 1D395A003D X-HE-Tag: 1714741335-420929 X-HE-Meta: U2FsdGVkX19wXr0BGsovgLnzqoqFXN4PE3jaC1MTiVbhYRoWZDusxkI0tkhISyZsexzeD0y2GUiLut3QRoOie03jzBXUvjQZ2gK0bWyC/6LtBPb+4lNoA6l4uuWiGc98E6s3mhNoIY4/UAdecljo9wWdZ8M42P8cZm38G5/Qd671R2xGzj/Ww92SB0Ru77VzoGFxXo2dVD23ln7XQ0Wl5QgW8dTOvRWqknPsUk65EoMEl1mxP86qWQjeuowaYvUua9dlKl7Nsumtv5IDMiLuNwASyIVDXZRpOOu9Jyjaoa4uYHDrVU4ZkCn1RAXSnEYiPOC7JlfdipxwBA7AFtC2jw16Z7tO/04hGO+Vk5hkxWD+627xgoGGCw4NxGKTGvvmWRSpexowdeRSg0eJat25TNza0txRq1+0+GuYhxNpB2mShuMtiDhUptmX5+fW/3hUAcr7LEtE80iqIpufpKprmGMP54YJFhylXdOKd0dt0lAm6i4XpCxHkONzYP+jFeVlr6zT+ZMjHMqj/bSzbLWQgatjNo1vaFhOA9J9lhXbRscNWZzbhizVUElrvSxNFtvj9QT0qXFcXBDRjMlxcAWQj/CwpEoe5lq8DCQSSLg2e08oX0PFyPHUIrWp6MaVrOkOOBp7Exrv41iAf5mkem1osiX6XodjoR9O+I2Wf2Upz9UHUz9O+iA+JtStLphJ+KNPYzZa1mo8oN9NBCWwOQ4OaN/nT7ks5E5vFoz9jKNmde3rBG/oLOHEyarKnKNvL1BLBvMmhXgzrC1T1nP6bnlAElrlIA3KGbPWvkFbr+SdEw/z8pKAlqQzBZDAlgG+7hlHkQlBgenP2q9idpXr+07gW/1wVwmguQ7eu/6nanorS8MhyfUN+g5J7CszQ98fZd6vgyQiNkj64FZzi8olURC00JBDzXZ5bkAeylPIVivtT+qT3Zs35cxxBj3nhF+g60w2v52rg+DM84JaltfmIcx uo+SKTSH /O0RXg79qoWCepj6g3wPPmezj04CCv/w02hxOVgdnV6ipgBCEj9yjryqIIbgrfzCHm31OO+14sSua9xVtiW2eDTcI+JXxDVtn/R30U4p0o4H4v8wmTMlbvMZc9I13E4yZM49hWAs2m3tAkw/pqQur+/TodXm8V2J+1BVXTtUa3tfXvf4mlXPx9XKFuBvQ79f8ZRNka3gfz8bI7ih5gKnwQ2Do9oP4yjsgK6/WFtXaj0gADiTLWqCNO4OAtx50Xxu7mVdBNXv0NZdLSOg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: POR_EL0 is a register that can be modified by userspace directly, so it must be context switched. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/cpufeature.h | 6 ++++++ arch/arm64/include/asm/processor.h | 1 + arch/arm64/include/asm/sysreg.h | 3 +++ arch/arm64/kernel/process.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 8b904a757bd3..d46aab23e06e 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -832,6 +832,12 @@ static inline bool system_supports_lpa2(void) return cpus_have_final_cap(ARM64_HAS_LPA2); } +static inline bool system_supports_poe(void) +{ + return IS_ENABLED(CONFIG_ARM64_POE) && + alternative_has_cap_unlikely(ARM64_HAS_S1POE); +} + int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt); bool try_emulate_mrs(struct pt_regs *regs, u32 isn); diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index f77371232d8c..e6376f979273 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -184,6 +184,7 @@ struct thread_struct { u64 sctlr_user; u64 svcr; u64 tpidr2_el0; + u64 por_el0; }; static inline unsigned int thread_get_vl(struct thread_struct *thread, diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 9e8999592f3a..62c399811dbf 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1064,6 +1064,9 @@ #define POE_RXW UL(0x7) #define POE_MASK UL(0xf) +/* Initial value for Permission Overlay Extension for EL0 */ +#define POR_EL0_INIT POE_RXW + #define ARM64_FEATURE_FIELD_BITS 4 /* Defined for compatibility only, do not add new users. */ diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 4ae31b7af6c3..0ffaca98bed6 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -271,12 +271,23 @@ static void flush_tagged_addr_state(void) clear_thread_flag(TIF_TAGGED_ADDR); } +static void flush_poe(void) +{ + if (!system_supports_poe()) + return; + + write_sysreg_s(POR_EL0_INIT, SYS_POR_EL0); + /* ISB required for kernel uaccess routines when chaning POR_EL0 */ + isb(); +} + void flush_thread(void) { fpsimd_flush_thread(); tls_thread_flush(); flush_ptrace_hw_breakpoint(current); flush_tagged_addr_state(); + flush_poe(); } void arch_release_task_struct(struct task_struct *tsk) @@ -371,6 +382,9 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) if (system_supports_tpidr2()) p->thread.tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0); + if (system_supports_poe()) + p->thread.por_el0 = read_sysreg_s(SYS_POR_EL0); + if (stack_start) { if (is_compat_thread(task_thread_info(p))) childregs->compat_sp = stack_start; @@ -495,6 +509,19 @@ static void erratum_1418040_new_exec(void) preempt_enable(); } +static void permission_overlay_switch(struct task_struct *next) +{ + if (!system_supports_poe()) + return; + + current->thread.por_el0 = read_sysreg_s(SYS_POR_EL0); + if (current->thread.por_el0 != next->thread.por_el0) { + write_sysreg_s(next->thread.por_el0, SYS_POR_EL0); + /* ISB required for kernel uaccess routines when chaning POR_EL0 */ + isb(); + } +} + /* * __switch_to() checks current->thread.sctlr_user as an optimisation. Therefore * this function must be called with preemption disabled and the update to @@ -530,6 +557,7 @@ struct task_struct *__switch_to(struct task_struct *prev, ssbs_thread_switch(next); erratum_1418040_thread_switch(next); ptrauth_thread_switch_user(next); + permission_overlay_switch(next); /* * Complete any pending TLB or cache maintenance on this CPU in case From patchwork Fri May 3 13:01:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652786 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CABE5C25B74 for ; Fri, 3 May 2024 13:02:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A45186B009B; Fri, 3 May 2024 09:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A6C96B009C; Fri, 3 May 2024 09:02:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D1FB6B009D; Fri, 3 May 2024 09:02:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 62E846B009B for ; Fri, 3 May 2024 09:02:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0FA561610E3 for ; Fri, 3 May 2024 13:02:23 +0000 (UTC) X-FDA: 82077098166.27.B1F818E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 7761B1C0031 for ; Fri, 3 May 2024 13:02:19 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741339; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZKkM3nUtjH+4c3zGfMTsW026pruK2hRVJ3hGy9/6vr4=; b=xgH27BAtarqezRoc9FK6O3+b9gFd0gaSkrhMy9xfNuSQQs5yA9zYUYxNZvMLVD3CjPH/C3 RRJL3V3GKRoH2YhD9ky2yNVoURgjV/imGSn5NH5/AooHYsE5s0NvPooTY8agM65wsDL5y7 05Dm3QI8QJZjIS5veWJolMgzpe0XSRg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741339; a=rsa-sha256; cv=none; b=hnfqKG7NFnDSL38xO7wfCEY/m8Xevgb72XHNE10t5roo19zLKDmHBURsgmtvOD4r4xy3Tk ASlknHcqFDAn+XIMD9LcwmqXQtFvhrB8emb6n3ZwTvoqqNDDW1ept/zAk/ivu45cEh2J1M hsZFlGYKpFrLafsWkvlDut4EGV9rJso= 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 F1EAB1655; Fri, 3 May 2024 06:02:43 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A036D3F73F; Fri, 3 May 2024 06:02:15 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 07/29] KVM: arm64: Save/restore POE registers Date: Fri, 3 May 2024 14:01:25 +0100 Message-Id: <20240503130147.1154804-8-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: mwpahoxjzn45zb35yiyo1gryodk9rfst X-Rspamd-Queue-Id: 7761B1C0031 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714741339-823608 X-HE-Meta: U2FsdGVkX1/GlHdbAE0pm0ElA9K9F333RnPVr9vXbERv1gVoBIwYoK9JqfPQpVu8bMu1BXsKF8dxJJaDpI3NfIkICwlomFQO01UO0VWjDmXbfdU4O8VZWPXPik9Efisb3qzgC8It33XLM6oRf71X25DYV50I//TLEaZNNvqlKOLpN5YYrefWRMlKjxObq0YdA2Mu/dZ8Qb/EWtcVbUS47iv6j3nIYxRCqnL9RsPabie55S7JCPJ4lygRjUEjSq3fCG/E/7VxO/NsLuSWoWEltY74pCiE9q2kPa3f0klFSleCds0iFa45ByozrGke8FSN3QbjJDSYZdRbNv9PQuEz2O1FY1X/XxQ0eyVJTAdizu1RCs/6o/uhANk9TycfVKC4Hvw/1BBl5jZIeZSZL1tgJpikk/Y7KZjAugBNDaND0Xftyj2YzO0Opsyof/Q/wmrVNdbf7waDA9wl7vAfk1YRxWNxdpDLAr5TvSDNjsrbE6CSZuFO3yeW+PW8/LXbwejOR9P8CCb7I9Txx/ZBYqUQsxNI8CbENHicmATMogaCrLaJNh3QbhEM11nBYjpNmQqxZpSJm539AEjVOL1WiQ4fuSV64zMjPfVgzAIK8SQLFw219i6dCZDRIOwe6HUg7Zx58NnUDogyB4pgP1DlJhQgKZsacYfEUIRVSCmIac1UdwSC9AtePeAHpljZsBovEvJNHnqTVawXgxLiuK92MhTpiiWAR5FSo2aVtJDv38DYKFcE4sDR+gXjLcZZdsYOZersSFs6nU7FmJNkmG8ZS4ZnWnPySLoUCenpYUuRd1sIfYW6J3GweqbEulei19P0O18pzpf+s677LOBiyodWOYqmi0NBxpnFFDdDgQ79ELFvabfBnJ1Olgbf9nAT987h8rrBmzzBEX7Lh0x140potNdFNhANdbVgURSyrVaQuTDAMneNZtM/OBjqHrApxkigubHH073e4kXrps6GIYhXBMQ 5G5aKe8m sG0/toqUCE5BdSm5Y0acKTte68E4MwF9f5/utapDcfgRNUKh9KzaGkhPb+mJcQRXxP3ZBz10ORHmwzO/LOXnJ9Ucyd2Z2q2SiH9WSmArLmtE5HBFhrmKrW2sC+O/wOjm3XOxJrf3IlGKn3dSC3XRZstqFecwED4m/ZL50q+yyN3E+/JzieVFFqkgsE2xlsGZ+bCGi2Qvz5XU0VoyyadN5qhP7TY94d90npEFw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Define the new system registers that POE introduces and context switch them. Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 4 +++ arch/arm64/include/asm/vncr_mapping.h | 1 + arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 29 ++++++++++++++++++++++ arch/arm64/kvm/sys_regs.c | 8 ++++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 9e8a496fb284..28042da0befd 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -419,6 +419,8 @@ enum vcpu_sysreg { GCR_EL1, /* Tag Control Register */ TFSRE0_EL1, /* Tag Fault Status Register (EL0) */ + POR_EL0, /* Permission Overlay Register 0 (EL0) */ + /* 32bit specific registers. */ DACR32_EL2, /* Domain Access Control Register */ IFSR32_EL2, /* Instruction Fault Status Register */ @@ -489,6 +491,8 @@ enum vcpu_sysreg { VNCR(PIR_EL1), /* Permission Indirection Register 1 (EL1) */ VNCR(PIRE0_EL1), /* Permission Indirection Register 0 (EL1) */ + VNCR(POR_EL1), /* Permission Overlay Register 1 (EL1) */ + VNCR(HFGRTR_EL2), VNCR(HFGWTR_EL2), VNCR(HFGITR_EL2), diff --git a/arch/arm64/include/asm/vncr_mapping.h b/arch/arm64/include/asm/vncr_mapping.h index df2c47c55972..06f8ec0906a6 100644 --- a/arch/arm64/include/asm/vncr_mapping.h +++ b/arch/arm64/include/asm/vncr_mapping.h @@ -52,6 +52,7 @@ #define VNCR_PIRE0_EL1 0x290 #define VNCR_PIRE0_EL2 0x298 #define VNCR_PIR_EL1 0x2A0 +#define VNCR_POR_EL1 0x2A8 #define VNCR_ICH_LR0_EL2 0x400 #define VNCR_ICH_LR1_EL2 0x408 #define VNCR_ICH_LR2_EL2 0x410 diff --git a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h index 4be6a7fa0070..1c9536557bae 100644 --- a/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h +++ b/arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h @@ -16,9 +16,15 @@ #include #include +static inline bool ctxt_has_s1poe(struct kvm_cpu_context *ctxt); + static inline void __sysreg_save_common_state(struct kvm_cpu_context *ctxt) { ctxt_sys_reg(ctxt, MDSCR_EL1) = read_sysreg(mdscr_el1); + + // POR_EL0 can affect uaccess, so must be saved/restored early. + if (ctxt_has_s1poe(ctxt)) + ctxt_sys_reg(ctxt, POR_EL0) = read_sysreg_s(SYS_POR_EL0); } static inline void __sysreg_save_user_state(struct kvm_cpu_context *ctxt) @@ -55,6 +61,17 @@ static inline bool ctxt_has_s1pie(struct kvm_cpu_context *ctxt) return kvm_has_feat(kern_hyp_va(vcpu->kvm), ID_AA64MMFR3_EL1, S1PIE, IMP); } +static inline bool ctxt_has_s1poe(struct kvm_cpu_context *ctxt) +{ + struct kvm_vcpu *vcpu; + + if (!system_supports_poe()) + return false; + + vcpu = ctxt_to_vcpu(ctxt); + return kvm_has_feat(kern_hyp_va(vcpu->kvm), ID_AA64MMFR3_EL1, S1POE, IMP); +} + static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) { ctxt_sys_reg(ctxt, SCTLR_EL1) = read_sysreg_el1(SYS_SCTLR); @@ -77,6 +94,10 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) ctxt_sys_reg(ctxt, PIR_EL1) = read_sysreg_el1(SYS_PIR); ctxt_sys_reg(ctxt, PIRE0_EL1) = read_sysreg_el1(SYS_PIRE0); } + + if (ctxt_has_s1poe(ctxt)) + ctxt_sys_reg(ctxt, POR_EL1) = read_sysreg_el1(SYS_POR); + ctxt_sys_reg(ctxt, PAR_EL1) = read_sysreg_par(); ctxt_sys_reg(ctxt, TPIDR_EL1) = read_sysreg(tpidr_el1); @@ -107,6 +128,10 @@ static inline void __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt) static inline void __sysreg_restore_common_state(struct kvm_cpu_context *ctxt) { write_sysreg(ctxt_sys_reg(ctxt, MDSCR_EL1), mdscr_el1); + + // POR_EL0 can affect uaccess, so must be saved/restored early. + if (ctxt_has_s1poe(ctxt)) + write_sysreg_s(ctxt_sys_reg(ctxt, POR_EL0), SYS_POR_EL0); } static inline void __sysreg_restore_user_state(struct kvm_cpu_context *ctxt) @@ -153,6 +178,10 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt) write_sysreg_el1(ctxt_sys_reg(ctxt, PIR_EL1), SYS_PIR); write_sysreg_el1(ctxt_sys_reg(ctxt, PIRE0_EL1), SYS_PIRE0); } + + if (ctxt_has_s1poe(ctxt)) + write_sysreg_el1(ctxt_sys_reg(ctxt, POR_EL1), SYS_POR); + write_sysreg(ctxt_sys_reg(ctxt, PAR_EL1), par_el1); write_sysreg(ctxt_sys_reg(ctxt, TPIDR_EL1), tpidr_el1); diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index c9f4f387155f..be04fae35afb 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2423,6 +2423,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { { SYS_DESC(SYS_MAIR_EL1), access_vm_reg, reset_unknown, MAIR_EL1 }, { SYS_DESC(SYS_PIRE0_EL1), NULL, reset_unknown, PIRE0_EL1 }, { SYS_DESC(SYS_PIR_EL1), NULL, reset_unknown, PIR_EL1 }, + { SYS_DESC(SYS_POR_EL1), NULL, reset_unknown, POR_EL1 }, { SYS_DESC(SYS_AMAIR_EL1), access_vm_reg, reset_amair_el1, AMAIR_EL1 }, { SYS_DESC(SYS_LORSA_EL1), trap_loregion }, @@ -2506,6 +2507,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { .access = access_pmovs, .reg = PMOVSSET_EL0, .get_user = get_pmreg, .set_user = set_pmreg }, + { SYS_DESC(SYS_POR_EL0), NULL, reset_unknown, POR_EL0 }, { SYS_DESC(SYS_TPIDR_EL0), NULL, reset_unknown, TPIDR_EL0 }, { SYS_DESC(SYS_TPIDRRO_EL0), NULL, reset_unknown, TPIDRRO_EL0 }, { SYS_DESC(SYS_TPIDR2_EL0), undef_access }, @@ -4057,8 +4059,6 @@ void kvm_init_sysreg(struct kvm_vcpu *vcpu) kvm->arch.fgu[HFGxTR_GROUP] = (HFGxTR_EL2_nAMAIR2_EL1 | HFGxTR_EL2_nMAIR2_EL1 | HFGxTR_EL2_nS2POR_EL1 | - HFGxTR_EL2_nPOR_EL1 | - HFGxTR_EL2_nPOR_EL0 | HFGxTR_EL2_nACCDATA_EL1 | HFGxTR_EL2_nSMPRI_EL1_MASK | HFGxTR_EL2_nTPIDR2_EL0_MASK); @@ -4093,6 +4093,10 @@ void kvm_init_sysreg(struct kvm_vcpu *vcpu) kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPIRE0_EL1 | HFGxTR_EL2_nPIR_EL1); + if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, S1POE, IMP)) + kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPOR_EL1 | + HFGxTR_EL2_nPOR_EL0); + if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, AMU, IMP)) kvm->arch.fgu[HAFGRTR_GROUP] |= ~(HAFGRTR_EL2_RES0 | HAFGRTR_EL2_RES1); From patchwork Fri May 3 13:01:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652787 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC189C4345F for ; Fri, 3 May 2024 13:02:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675076B009E; Fri, 3 May 2024 09:02:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D6296B009D; Fri, 3 May 2024 09:02:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F04A6B009E; Fri, 3 May 2024 09:02:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 034BE6B009C for ; Fri, 3 May 2024 09:02:26 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A63631A104A for ; Fri, 3 May 2024 13:02:26 +0000 (UTC) X-FDA: 82077098292.07.34AACE9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf23.hostedemail.com (Postfix) with ESMTP id D2C62140079 for ; Fri, 3 May 2024 13:02:22 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf23.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741342; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6BSTx1I1TiIaBVl43DDc7myhpFfSSqXVzGJv0kKeY+k=; b=1nmJ48ZGUI3sFPG2ApJ+nIeOgVK/V1/DdetThx76DnwwmtL4qRc4HGAGFE+UMxqW6mTmEK /GhQ6x5lG8X0ug4+irVXaqaGLlwFKnHlzOjuSd5Wp+k/pMBj59BhqHSh9KwRHs+3msvnNB osllfXe02rkvJWkK1PzuAgLZT90nkMc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf23.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741342; a=rsa-sha256; cv=none; b=vpZ2YJNAUU21ocIG9NnoGlJkAm0mrTM0B1zbZH/P0NS12/Mrg5igpI8y7mrPH4LzOaYC5m cazAV6u1sOrJdFduWLXac7BzLm/cLCWAi5W3OYUWzzHEbkwk/XLlD13OUB30bioWQnkVYQ 7ZVIxDnQxtVsA/YgL+8q2aMoIE6ng5I= 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 46B66165C; Fri, 3 May 2024 06:02:47 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EA6483F73F; Fri, 3 May 2024 06:02:18 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 08/29] KVM: arm64: make kvm_at() take an OP_AT_* Date: Fri, 3 May 2024 14:01:26 +0100 Message-Id: <20240503130147.1154804-9-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: 4zzs65ojc7fgww95tjsmu7hiukco5gu5 X-Rspamd-Queue-Id: D2C62140079 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714741342-156441 X-HE-Meta: U2FsdGVkX1+EdR+RddNvcIOQTKvIAa4tkrXRQNEcGUS8+2sDjBi/GU2aLSoWshd7MFqiIYbYF0t4xVwVMyuGuDmhfMHVKiZFvliCfR82V+dJmhk3VEvtaV4Ym95e4V8SRBlgdPgrA0Nq6JxzRoWOoGZDzAuEQ9S5ygGbn2W2j/qSc/JGxlHN/HdiriEYn7dA+bqlUnLz9QkSKOc6qGtxWLSRjax5PrRTScgq2pocFWiTYA3q9S+FFYMWZxO4SlATGfOeIQKk8HoD1z9Wdv6d4N10qVb8Efne6BxwnGu0CwngMG39F6uFRK/TvtsBdmC0//fezKUoWmlFXRADA/0jDoYpckRtc9j9Vl7CSn4V1wRf3Y2e8JgSQTdEbTOEY0wkdwH2Bm5fHBFH7eJwm4ooAvuT1rDv/4MOe4E3e6an1CpfEU8X3kmRVbGPcY995LuJ3ja5FhKvZuS4Wb1NurUYPwIHz5r5qJC35BEJ4x7Y2uQ07XfmoaFSkUcT1ou4j7EGaajcs+HIn6PE8a1N6XbxMLPP4aRioOTw/9xOqBmE9/3oBZ40AiP91/mGVDyUFi7i2xJr5oHkSiZSdHyQ925/bdGELUNsW7QeoHZQdyZ9ugHmaINOCfKFo5SbK1clL9zyflYtWqzcL4hQvUOwYfMNPdFIKYkkfYmJe6yDXhaOwj4wC/mRfWvU+kNI2CRRQsUBDFOkhh/hy9e1y/YqRUABv6FQxfBbML+9aLCmVEUX0TqfFYKBlj+a0d6mJB2rTjW666W49s/DDl9Ak4ul7yqv0Pmu0oAZG4Qr752ZNlIFlrbImc1fDlHT7er5iQMP0WS+zFiaE3AXN2+FzNCJxZe4t3LFHGuVuqpPHJ+0O5HUp3VjqSxSvskpOb4c6wSlMbayRpfU2NRHBWb9CO39tA7gUppGQTpL3Cjn2Pgwd9pjrBA2O3lwtZR7P3N1wtCnLQFBf6YHLDP4kS1c8k81T8R 5f6YFAzG XRM0qq+RiY5hab7RBD0NHBL5bYlbJlZWBxeEpNBX6rHvZJwwg9wMXNKJUH9t9oXmsUptdtmkXBLaPBXrtP2wocX4s16nQGJaL8bAQZt29aywOwaQi0rog/YQudtNM+F6EOEs2VID5wo0GM6tyhmrnSB9SiQN4memrgvNzy/asJtlIDwTkR6rsoXvya/fys1gDnC+TR5A/QMnlZWRH1xxgpd1bMTQ74WFf2gmVMMHTy6RMWHpyA7/4Z8KJDtxrZVVIDUH4t8DqypX7Leo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To allow using newer instructions that current assemblers don't know about, replace the `at` instruction with the underlying SYS instruction. Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Marc Zyngier --- arch/arm64/include/asm/kvm_asm.h | 3 ++- arch/arm64/kvm/hyp/include/hyp/fault.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index 24b5e6b23417..ce65fd0f01b0 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -10,6 +10,7 @@ #include #include #include +#include #define ARM_EXIT_WITH_SERROR_BIT 31 #define ARM_EXCEPTION_CODE(x) ((x) & ~(1U << ARM_EXIT_WITH_SERROR_BIT)) @@ -261,7 +262,7 @@ extern u64 __kvm_get_mdcr_el2(void); asm volatile( \ " mrs %1, spsr_el2\n" \ " mrs %2, elr_el2\n" \ - "1: at "at_op", %3\n" \ + "1: " __msr_s(at_op, "%3") "\n" \ " isb\n" \ " b 9f\n" \ "2: msr spsr_el2, %1\n" \ diff --git a/arch/arm64/kvm/hyp/include/hyp/fault.h b/arch/arm64/kvm/hyp/include/hyp/fault.h index 9e13c1bc2ad5..487c06099d6f 100644 --- a/arch/arm64/kvm/hyp/include/hyp/fault.h +++ b/arch/arm64/kvm/hyp/include/hyp/fault.h @@ -27,7 +27,7 @@ static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar) * saved the guest context yet, and we may return early... */ par = read_sysreg_par(); - if (!__kvm_at("s1e1r", far)) + if (!__kvm_at(OP_AT_S1E1R, far)) tmp = read_sysreg_par(); else tmp = SYS_PAR_EL1_F; /* back to the guest */ From patchwork Fri May 3 13:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652788 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB77C25B5C for ; Fri, 3 May 2024 13:02:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A06F6B008A; Fri, 3 May 2024 09:02:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B5716B009C; Fri, 3 May 2024 09:02:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E0156B009D; Fri, 3 May 2024 09:02:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EA20B6B008A for ; Fri, 3 May 2024 09:02:27 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9C09D1210E3 for ; Fri, 3 May 2024 13:02:27 +0000 (UTC) X-FDA: 82077098334.19.D9EE241 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id ED77914000B for ; Fri, 3 May 2024 13:02:25 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741346; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3BBJ4QOdsv0Ue4NZqULidDC6xGwONndSxZgf7b76ofQ=; b=EauCLRxVWqd7gKSiKORNryAEMQxufOQfTIk2orzgpNuFrMn4KqOpHUAH7pqsexsDicEd7e 8RDo64UbZnFtcZ1DDhfILDbTB+pkep4nNDwZXFRNzzbuUOFUll2hBPMKZ/sQLmF3ObtSFX r0DT+J794/vKs7+zhLizz5IkYz7h010= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741346; a=rsa-sha256; cv=none; b=8ZcUg57FSV+7ReaVticI5659OjO7A6ntHmgclqsT4InaDegGiXRqtUV/Ux8KX8J0Z0OXP7 p+WGYiaWVwyNCBQkEalWgoplobDJref3g2ZOLDDy3XY1m+Zgi7thcllgrj/5I2XRtl2JRs T27W+l5uIFV8d/aa/LPGnrvsBlFQujA= 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 9246B1682; Fri, 3 May 2024 06:02:50 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 412BC3F73F; Fri, 3 May 2024 06:02:22 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 09/29] KVM: arm64: use `at s1e1a` for POE Date: Fri, 3 May 2024 14:01:27 +0100 Message-Id: <20240503130147.1154804-10-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: tgxap6m4xzqj6n1xpjuzy3h3sii5emst X-Rspamd-Queue-Id: ED77914000B X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714741345-274261 X-HE-Meta: U2FsdGVkX187zb0kH9DgpIEJ/UDF0QBN+p7ZJEkQePWup5itWMHoeUqpniamTAR7YOc9Y0vtntEBoJOxPri23tGRS8so/d9pbCUYckBnw4saFIY3tFp7+QuZF9Smbm7WixjoC0lPmVqRpWfjVKRO4jbqYjOusPkBMBH8yWsflUQjLzQeqO0rI5duffxTKacmxV2cbbNhmZ40OSo8XMxqXEvXDEvHVjagVRuiX0k8W4tR2qlE9QprJ3HVKDlQ/A6hsy8LZZb56EYgwjapmXZYGUH14nQvYOCh2QUkgNbTo4eC6Iqf15FBBnaL+GD6vVzlcxtav9zN81HiBuO5+C3ieXYzpVwlcthGgUNCBCdtIBZvcPCyEf86JZNbMWzosSlvPvioxWON9g40ymGXl5+gb9X5otYEbZv3lwDG0sRG8o/GRxRbEEiAp8pbWsicf0dQS0/Z5u5VxpIkpli42hWIGFxZt1ajvtNjm0zqXd1Vkdom/BR/bFPxpfRRN66wZ4ljNYS2vOnlrV2Y7jLlXMCHtldpFBHSwEZyKxS0VEF9Gpnz59MJf8vXih3YTSvwy5/oyW0I8zKq+h7cnCT7Y2kghRIFleG5rVw0j6OZlvJqQU3U0LIveefy0eqqalA+reh6IRnQhzpMZ6e56svlTW45VOeW2Rsrc5G6CNJdn6MN0bbrc8LF+fYc99LPQ2YzSDcYbxUBijnh4KTbvuDpzyGPYoFZBxV960NgmhkQqnuvK1M1Lkc8rqUBG/7FVQr2hqvW/6WJKXUoC1DHH2eQEpV0pdEWZVGYNOdzaKZWKLu7PduhyzSwBhBa9G6z9P96RRTy1rjtGZ8p4fOVXJ8bZ9ygzx7qxtuyO19VoFBjdLrHvxWIXav/Ztjsh9zub7S25rezuKTfaRIdz2rXi+ZUcgkxHwUQo/l2mLEZ0eBdrt8HPmAU2WGYZq9wbX4ZJfonw0BJwArnDvjZdPtd3h8IKCC 9jUeJBkt AXCCrfmlBvCrn/+BICWX/KeIvsG5NbRCJRXqehATbPm+I8rvwfW0MKmgDj8daE1fHcnmAQA6oWmJIPLygO6MzLCVH+a+Ve3G3k+++3ixCTEs72StQiBkLj5H/shJxvACxZWRF0it9Gzjy8EJ1VOTZw1sfo8Bk58XdzStEwES+X2SevMc5qERmyirKskC7sN3srXjYOgAVAVLOA6NVBMDqJWdK7A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: FEAT_ATS1E1A introduces a new instruction: `at s1e1a`. This is an address translation, without permission checks. POE allows read permissions to be removed from S1 by the guest. This means that an `at` instruction could fail, and not get the IPA. Switch to using `at s1e1a` so that KVM can get the IPA regardless of S1 permissions. Signed-off-by: Joey Gouly Cc: Marc Zyngier Cc: Oliver Upton Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Marc Zyngier Reviewed-by: Anshuman Khandual --- arch/arm64/kvm/hyp/include/hyp/fault.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/include/hyp/fault.h b/arch/arm64/kvm/hyp/include/hyp/fault.h index 487c06099d6f..17df94570f03 100644 --- a/arch/arm64/kvm/hyp/include/hyp/fault.h +++ b/arch/arm64/kvm/hyp/include/hyp/fault.h @@ -14,6 +14,7 @@ static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar) { + int ret; u64 par, tmp; /* @@ -27,7 +28,9 @@ static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar) * saved the guest context yet, and we may return early... */ par = read_sysreg_par(); - if (!__kvm_at(OP_AT_S1E1R, far)) + ret = system_supports_poe() ? __kvm_at(OP_AT_S1E1A, far) : + __kvm_at(OP_AT_S1E1R, far); + if (!ret) tmp = read_sysreg_par(); else tmp = SYS_PAR_EL1_F; /* back to the guest */ From patchwork Fri May 3 13:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652789 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF55AC4345F for ; Fri, 3 May 2024 13:02:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A7B66B009C; Fri, 3 May 2024 09:02:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90BB46B009D; Fri, 3 May 2024 09:02:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C3606B009F; Fri, 3 May 2024 09:02:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 27FB86B009C for ; Fri, 3 May 2024 09:02:31 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D9F89A1F8E for ; Fri, 3 May 2024 13:02:30 +0000 (UTC) X-FDA: 82077098460.19.711CCFD Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 3D3241C0012 for ; Fri, 3 May 2024 13:02:29 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741349; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o61NYhGsFgdZKjuXABWojJ8Kkmr59EH31u5S+lz6bS8=; b=oekagnp+VnaeSU+rVJRe7Hk9hKBeVg+l3O3q+vD0v2rhtWLQWgUTfnf8qR6bIEHtKk9spy wYQoZIHeeKkaRoQ4M8OLvCp8lIFCq3dtcrUE+kdun010XeMhJorW/6uRy6tZew18H0auLH oy0bxNFTNa/nWcIXJD9DBqO0yo2RWk4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741349; a=rsa-sha256; cv=none; b=iPUDaFVXFFcxRywtLdcMZQQGBHqfouP25SkgiZUQOj9CbqFnvIPR6GBgrQ+9777x6ZEfUu 3b8Z2Ugb61hVCYQFS2OKUKCfKDkFivIsuY+FAJnVn37Ua5HrxhoHA8MMUIIWRFggktVC1K jz3Ftp1qlEtvQah3C4cGBX+zuJ5JLH8= 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 DD6911684; Fri, 3 May 2024 06:02:53 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D1543F73F; Fri, 3 May 2024 06:02:25 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 10/29] arm64: enable the Permission Overlay Extension for EL0 Date: Fri, 3 May 2024 14:01:28 +0100 Message-Id: <20240503130147.1154804-11-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: hemcygzfioz5ajsnfhk7y56gun5atfkq X-Rspamd-Queue-Id: 3D3241C0012 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714741349-619453 X-HE-Meta: U2FsdGVkX18/NpkSLb+ixzh6Sm7egSvKH03G6d1wCWBqEMWQzDz1TeZmmVMKKc7z33lJWhYnrcZMXgrgOsmiBXRkdvgm3Qo6OMdLOld1EN675q93+MVEVh1fBtN9/e+Mj0aShu5TldQjN/K4myNDL6ParUkCE1C+8Hz9GBUzHQLGAIZHyJ794aJNX0dl5xp3LMlxn7a/FpL06ioVxVWPgwc/CNlciqWhGz91oA9/LDx1lPrWNvwqBwZF2BCpJbglXl6KSCaSwTPL+2FHwHxU7ykvnUcs6rii7TmhWcmMb3GYsuw7mZv8I39vrxHimzIsk6h8zLIT35DpPMVtchYoWC6O/h37SfbwpBR+rPDeo7GMjDJt0SUrMXMuJRlVdfBs4SwmnWZv4TqgdWetZWFwKn+8nwkriKlP+vYr9xiaAz0nuGQgSa2MxjZNjsaIkIKdxI4hVHYyVuwt1gNR14xEDFkRla6npy0IDTCWS2dZfrnx1a+Td8GpY2lzNfDh3XRtDLVQWvgyNW3tvh6DHIgTk0J//aJbF8lgv7ZhvkwVSt4j6WT4Aw7By4dK4GXDNQ4QbxZC8HQoohtgLZ2NMcgal54XTjmEebUt9K0Vr5maPBx2zdjpqvRfY3PP6AAc4Pk/ElkjJB+HDZAnpvhvy3F1NIR81KHYbiFoiRj35/3sR9vxkmMkcdfFfwVT5IZGdn51Xw2ZLhSseH0I+S8Jv9BXFagxBcjj5UdN6eR631BK0pWReJEOhvMBSuAOwvBkNb+AvHzEqCNn+O9yxaS1ZkPgKqI9YSScv2K0ibej0c8QYjWchRGx/XRKg676N4TpZja6z574lywgo5G+BcLpgiZrMqgE+9bU07gAvw3Mo57DxjLP8KAc3vnVuN1+8Rl5ChxbpX8cFIS2RQHsuqD8xzjmzcbWe2y5+2YMLWJrtVfKCiuCYORfILz6lhCx9U5vhLa9UQZh62h+BvTtgO3gRq4 +UFZ2gso Yqx1WoLYUHABgNNyhGz2Ns14oNctAVQJxV7Qlriwi/YoKcd/pDNY4U7lFyovnAmthFgxuLlrr8KWnwT3QDl70icsQUuG6lmblAhrpKqpE0Ns766Oq7d+tGG8JYNBDmw2XPAfMvc3ZZaa/GDSFnK+oOyEUOzQuEQL6PblchtaWD9NDsSN7Sg5TGU6pwtdJNj4Iz3+H/clEgOaiWw6+aEmeOQIuPyHCUF6JiBphOuoc3I8MdcuqKP0kNYXmc2VriHEId1wiT7xX1TNK1i8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Expose a HWCAP and ID_AA64MMFR3_EL1_S1POE to userspace, so they can be used to check if the CPU supports the feature. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- This takes the last bit of HWCAP2, is this fine? What can we do about more features in the future? Documentation/arch/arm64/elf_hwcaps.rst | 2 ++ arch/arm64/include/asm/hwcap.h | 1 + arch/arm64/include/uapi/asm/hwcap.h | 1 + arch/arm64/kernel/cpufeature.c | 14 ++++++++++++++ arch/arm64/kernel/cpuinfo.c | 1 + 5 files changed, 19 insertions(+) diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst index 448c1664879b..694f67fa07d1 100644 --- a/Documentation/arch/arm64/elf_hwcaps.rst +++ b/Documentation/arch/arm64/elf_hwcaps.rst @@ -365,6 +365,8 @@ HWCAP2_SME_SF8DP2 HWCAP2_SME_SF8DP4 Functionality implied by ID_AA64SMFR0_EL1.SF8DP4 == 0b1. +HWCAP2_POE + Functionality implied by ID_AA64MMFR3_EL1.S1POE == 0b0001. 4. Unused AT_HWCAP bits ----------------------- diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index 4edd3b61df11..a775adddecf2 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -157,6 +157,7 @@ #define KERNEL_HWCAP_SME_SF8FMA __khwcap2_feature(SME_SF8FMA) #define KERNEL_HWCAP_SME_SF8DP4 __khwcap2_feature(SME_SF8DP4) #define KERNEL_HWCAP_SME_SF8DP2 __khwcap2_feature(SME_SF8DP2) +#define KERNEL_HWCAP_POE __khwcap2_feature(POE) /* * This yields a mask that user programs can use to figure out what diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h index 285610e626f5..055381b2c615 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -122,5 +122,6 @@ #define HWCAP2_SME_SF8FMA (1UL << 60) #define HWCAP2_SME_SF8DP4 (1UL << 61) #define HWCAP2_SME_SF8DP2 (1UL << 62) +#define HWCAP2_POE (1UL << 63) #endif /* _UAPI__ASM_HWCAP_H */ diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 2f3c2346e156..8c02aae9db11 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -465,6 +465,8 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr2[] = { }; static const struct arm64_ftr_bits ftr_id_aa64mmfr3[] = { + ARM64_FTR_BITS(FTR_VISIBLE_IF_IS_ENABLED(CONFIG_ARM64_POE), + FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR3_EL1_S1POE_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR3_EL1_S1PIE_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR3_EL1_TCRX_SHIFT, 4, 0), ARM64_FTR_END, @@ -2339,6 +2341,14 @@ static void cpu_enable_mops(const struct arm64_cpu_capabilities *__unused) sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_MSCEn); } +#ifdef CONFIG_ARM64_POE +static void cpu_enable_poe(const struct arm64_cpu_capabilities *__unused) +{ + sysreg_clear_set(REG_TCR2_EL1, 0, TCR2_EL1x_E0POE); + sysreg_clear_set(CPACR_EL1, 0, CPACR_ELx_E0POE); +} +#endif + /* Internal helper functions to match cpu capability type */ static bool cpucap_late_cpu_optional(const struct arm64_cpu_capabilities *cap) @@ -2867,6 +2877,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .capability = ARM64_HAS_S1POE, .type = ARM64_CPUCAP_BOOT_CPU_FEATURE, .matches = has_cpuid_feature, + .cpu_enable = cpu_enable_poe, ARM64_CPUID_FIELDS(ID_AA64MMFR3_EL1, S1POE, IMP) }, #endif @@ -3034,6 +3045,9 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = { HWCAP_CAP(ID_AA64FPFR0_EL1, F8DP2, IMP, CAP_HWCAP, KERNEL_HWCAP_F8DP2), HWCAP_CAP(ID_AA64FPFR0_EL1, F8E4M3, IMP, CAP_HWCAP, KERNEL_HWCAP_F8E4M3), HWCAP_CAP(ID_AA64FPFR0_EL1, F8E5M2, IMP, CAP_HWCAP, KERNEL_HWCAP_F8E5M2), +#ifdef CONFIG_ARM64_POE + HWCAP_CAP(ID_AA64MMFR3_EL1, S1POE, IMP, CAP_HWCAP, KERNEL_HWCAP_POE), +#endif {}, }; diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 09eeaa24d456..b9db812082b3 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -143,6 +143,7 @@ static const char *const hwcap_str[] = { [KERNEL_HWCAP_SME_SF8FMA] = "smesf8fma", [KERNEL_HWCAP_SME_SF8DP4] = "smesf8dp4", [KERNEL_HWCAP_SME_SF8DP2] = "smesf8dp2", + [KERNEL_HWCAP_POE] = "poe", }; #ifdef CONFIG_COMPAT From patchwork Fri May 3 13:01:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652790 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1A1CC4345F for ; Fri, 3 May 2024 13:02:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 402B26B00A0; Fri, 3 May 2024 09:02:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38D8E6B00A1; Fri, 3 May 2024 09:02:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2055D6B00A2; Fri, 3 May 2024 09:02:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ED74E6B00A0 for ; Fri, 3 May 2024 09:02:35 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A942B1210DA for ; Fri, 3 May 2024 13:02:35 +0000 (UTC) X-FDA: 82077098670.19.D223648 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 96CF440052 for ; Fri, 3 May 2024 13:02:32 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741352; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eVppK3cbE0MLbRwer+Rt+CSrlyEjMrJ6mkyo0wProYI=; b=mjrV3Pd06NhYedVyQ4rsYBz9zHkyxL7o8Mb3N8oKWfN+NsX0ikjSEtyM3T3T8CYIjHPsMC YW2V9PuDLVHa/42oe1RF4fOWwTQjtu1Iox4PEdPBP6rI7mAY9YRDIuJdruoWmTPBwpWmI2 vBOSBqbrzULfbGb5ORVGE9sF4m1hwS0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741352; a=rsa-sha256; cv=none; b=5UWR2+rD55Xcg37POohHW+zrC4t7h8855UFRvvCQQy/veCyOAp5XP5I0Z9B7AnOCJSz3Rj 13GDRhHcbOhH4olzk4yC/NCxEfCO5w0K0sp3FUlOuho14Lm/wK+lHSCY0Zb/ZFByFbqYgt CONvt43e3Sk6IlnvtfTiU8ldnXRiPEk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 3471E1691; Fri, 3 May 2024 06:02:57 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C373F73F; Fri, 3 May 2024 06:02:28 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 11/29] arm64: re-order MTE VM_ flags Date: Fri, 3 May 2024 14:01:29 +0100 Message-Id: <20240503130147.1154804-12-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 96CF440052 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 8g1az3ao5zxx3x9rjgx1zipf8a8cguu3 X-HE-Tag: 1714741352-680643 X-HE-Meta: U2FsdGVkX18vI3QO3zJTn5qpaWkTIiylksE/IEvEwkDIAllhSw86XCSOSgMPPBbVYdsTY9y7KA8+0/PayFyuOc0XPAciiW0jkjTfqqvB26fYuxQDxkphZMm2q1sT/sBhhzeKfyF1XtZFREQcZZ2xBEzS+X14chhkKomWUOLzb/Gpi0Ts3NXA+X+djJgL9XBxhhzQKkjbvsAAkHe0p4HOnEiq3OBDNICUNslpx7SPbb+Hk1Mbevr/rUuZDbLDopISkY+SEpsBsiU5w7edS2D5p3etGRlyOLER9DFkoBHgygShyma1m95QaFRToj0QAj6yHSYDrYlpBrORRU0f6LV12S2ckhUNshKvRcgU0IVXgHjNsj4wBsTu2R5hW429qPCrEZSXTP61eMDRQ/a4I1HZwttvqhQFAGHHAN9z1s5EaP0ID4G99yQAF/T0dkQlpqPYoz8Lepgl1LesdFyBuJK8F5Bx3SvxDxwqWyYiadg5okIPm75EpWINr8sygiwLHjYn+MCzKGDVRThC0YIaodZi5q8ioioJDaX1FE5ODJRTtafah2MkDcxwS5bg/8bjM8FlWaJvKaeluXh6yvbm+/scR3Q5hemjkY7Q+rzN0cl7eKJFEEwQXJe+L24/tV4CElSXggXdYX1zAECs1Qdv1MNH7Y1oIq8A6777hnA39Wu7RntzDWuGNywmjX4AUOvi4reX3KTvYsi8q+gY5ZgrvP+ChYomZ1TTdVZERXKvqI0d0sYXhH7vRxX7xxqo9bcSaqQOIj3WwA+vtr9k4chXzGNhdCq6oP+QErWd3EpAtmGbDhcrdQJIuR4np0avD3a9CmBS8LYUAZ/jrdPDV3kGslIKGjr1Md9nDTLbz/ZDyB1D4XwkGWHDCvOOlysKcTlEFl8Rv7R1XS9ZztqJGngAcEZ9CGsmq8qq3njNRgvX21RNPHcXYYwp5vkVYEOBvIvPZO7x3uXusqM7T+uZtZkASIE R0qKvLF5 +1DdipgImxwfaqqquSX/tJS7coLj3/AmSkT7b/AQObVxRggAhta2PXlepYECuOCF3iHlIiRY84BY0Gwa/dHg+mXLTerbwIoFpaJxwsn/O8WP425XLa/ERhzItwUgAYU2CNXCIQRU9cDe6+eVbht8IK2RdzRiUTzMRggfk6e7MkO11C8pUzC/Wjaxm1l0gHQAQBDg9i1UcvG97xoZ2tyXgNPPs8kV2rRDFkYFxj2lUoEqHn6rJHtkYDMt3SaTreeVK2lSL2GM1dUD4qlqQS2rZaNrDH23nDVXV4Llm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To make it easier to share the generic PKEYs flags, move the MTE flag. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas --- include/linux/mm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5605b938acce..2065727b3787 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -377,8 +377,8 @@ extern unsigned int kobjsize(const void *objp); #endif #if defined(CONFIG_ARM64_MTE) -# define VM_MTE VM_HIGH_ARCH_0 /* Use Tagged memory for access control */ -# define VM_MTE_ALLOWED VM_HIGH_ARCH_1 /* Tagged memory permitted */ +# define VM_MTE VM_HIGH_ARCH_4 /* Use Tagged memory for access control */ +# define VM_MTE_ALLOWED VM_HIGH_ARCH_5 /* Tagged memory permitted */ #else # define VM_MTE VM_NONE # define VM_MTE_ALLOWED VM_NONE From patchwork Fri May 3 13:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652791 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C57AAC4345F for ; Fri, 3 May 2024 13:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C67C6B00A4; Fri, 3 May 2024 09:02:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 450A46B00A5; Fri, 3 May 2024 09:02:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CA676B00A6; Fri, 3 May 2024 09:02:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 08B916B00A4 for ; Fri, 3 May 2024 09:02:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BAC8181117 for ; Fri, 3 May 2024 13:02:38 +0000 (UTC) X-FDA: 82077098796.30.3A4A812 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 062A8140047 for ; Fri, 3 May 2024 13:02:35 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741356; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Sp/zMkd1O17Y0P57cMty+ugGvuVwgG6SQDqH9zWhnI=; b=1z+YgsPJZCN3gxuQUqgMIA8VYTfE8kv9iT8I5EnixsXU3gS5yhE5xtbU20ObSGpLHkACvL UwbOvuDOi7/CmxsvXP7AvwpD6zIiJhzKqiJFmpSnj8RMQzlUVR5nmA4KFbaEEyH0M04J5z v+o11UZgaHmVLjwQM8kLIYq0bvN1kAo= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741356; a=rsa-sha256; cv=none; b=vZljgqTtrJN8w4talSDlmiuGgabXOFX1aOZiwHrt2EG8W+dCUSMh1RzUgh3vCJ68lo+Uez rhVLn2dE0zTXxlzywfRLRJJ8gSYD/lHN+KI7dJV9bwh+1sbhgKjoa/LYLNtRXV4U4Pb9k7 G/mLHtSLjao0nPHbcOL4D0uvry4E/ZQ= 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 7F63A1692; Fri, 3 May 2024 06:03:00 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2EC6C3F73F; Fri, 3 May 2024 06:02:32 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 12/29] arm64: add POIndex defines Date: Fri, 3 May 2024 14:01:30 +0100 Message-Id: <20240503130147.1154804-13-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: 6fpgn1sn8jqm974p7dhx4aqycbt6ie49 X-Rspam-User: X-Rspamd-Queue-Id: 062A8140047 X-HE-Tag: 1714741355-847078 X-HE-Meta: U2FsdGVkX19nqF24L4h4sbLJaIM0xZidyWZdMP7XBclPeofUgdp8RRrCjxZAj6DSk6RfV4GdjQ+s73dKEE5HFnpKHB87RyZnpC3PbE+n1XtFc0wQO807JOH6nQop+AL5Wl2vRhvT+d0ImHfgj70jxHUBEuTucCTPr01ebadlLL4hWzWdlb0/MT4p6PVfaPKQu7U2v+IDz5njWJ2QoDYUA74zu9CNjT+EQzZHwT3CkVVoWip1ehceQU1YI5KNgTByUcbDgH1A7iOUwJ+6VwygW1h2UwMv32YtMZQH7Ym+OpDPXkG2AFc9ou6bwMrOE3sK3db8WFHRpNzP9YPUYfrA/QUrfFQ2RFffCw6wyGkDCrvIXH3V8UuVmO9/hRvmVWPdDLqZ01ivjRahr4LZ3EHF0peOLI7ujkXejQ8qsKVqdDT0P3wyOkRzV87LbG9viS8EV3wsbNtbarzF8OZy/8oShuL82wk5Df7mDaKy+P6y7CNACHbb6I2DJq6LfabsXesSCg+XVh4dkU66A+uv/WY6DCetxGRZrH38/fXDV4iSPXI72r4B/jOn3JWkHrPobuqIngbdgvS8vymA4rQ9pk9WM+vBJdc0rqI5pEcjTk5NyLPwPCLZJ0at9L8TpsUdpq8pWeo1tic58vjugvsPeji2RS49DgjtdKwkUUqTdI3+AgRtIoAv2D+8qtR4B9oJuKiVoasOQoRk1iPus6t3O9eCJmNewNJi7L3Nk9tK6jMDTVdvE5leEpolbIEWOIZyzHbtbwfHm+CPrcPpEEret9rhMVru2BkzMkWl3WxfoV0504dejymB+v0o83FvYgrElu/Js+cA1P8/HP9IS8dGdfJFs63YHRLH9qt4Z3P0Y1+iocSOpUw4P6BrC236CqiPOaAjbRynweask0p/VQni+VySbtRbruw9OIiUh0e6zqxZWyMILqt2scgvtPf3sVCvpWcsEAlsMONFWy8Xnzv3Xn8 O+/nAfbj trYPAtJH+k7otWnk1+c4hyZ8WXrzQ0X7vKZz7OaOyWZnfEBo4s1VWUNJvFQefoolPsiRFByPSyVSc74RYiGcWTUQrquM1a8o5Jd80CAuiDUyAn/WXLkaSTtrgzC1nWy316CjNf/j3i/GtQntgaICTjVWajZN/MuZkmNHpDYsJQV/jOP29hltPp7W+kfvqa0fkjSy2NrsEAlEpap7/V02EUFgmnQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The 3-bit POIndex is stored in the PTE at bits 60..62. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas --- arch/arm64/include/asm/pgtable-hwdef.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h index ef207a0d4f0d..370a02922fe1 100644 --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -198,6 +198,16 @@ #define PTE_PI_IDX_2 53 /* PXN */ #define PTE_PI_IDX_3 54 /* UXN */ +/* + * POIndex[2:0] encoding (Permission Overlay Extension) + */ +#define PTE_PO_IDX_0 (_AT(pteval_t, 1) << 60) +#define PTE_PO_IDX_1 (_AT(pteval_t, 1) << 61) +#define PTE_PO_IDX_2 (_AT(pteval_t, 1) << 62) + +#define PTE_PO_IDX_MASK GENMASK_ULL(62, 60) + + /* * Memory Attribute override for Stage-2 (MemAttr[3:0]) */ From patchwork Fri May 3 13:01:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652792 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96035C4345F for ; Fri, 3 May 2024 13:02:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2564E6B0099; Fri, 3 May 2024 09:02:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DEA86B00A7; Fri, 3 May 2024 09:02:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07EE66B00A8; Fri, 3 May 2024 09:02:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D8C8B6B0099 for ; Fri, 3 May 2024 09:02:44 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 59C3F1210CC for ; Fri, 3 May 2024 13:02:41 +0000 (UTC) X-FDA: 82077098922.05.34843E6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 35FBCC0017 for ; Fri, 3 May 2024 13:02:39 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741359; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jC9SquTn4hL8Q9MxX9qSv/R/1kmB2MKiuuZuTQW/vfk=; b=oD9RXawVRjt95Ia4H4Wf3gtSeBNcvb7XIBZjijHQsDQ1lL2vQQf5WlPXuifBiLaQobKLwp INLjtEHzLgaio4lBPXTwd5z+Yp/hSjl40aerADjv+8jRgWm18wFbiJL17ufbHAmgMEKcmg 5ztNYYI65hoUQaYkDAH6oDd/VASHhkc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741359; a=rsa-sha256; cv=none; b=JjZCUE7GOUVGxpPoZnYi0THstf5A5pL7rTfiEvRZ9TysWtuk58/utnwTaDW/iJsoLDMcYE ywF6qI0uqgP32Zi81cWl50/SsfRaA7tDUaW5EZIoCT8hUGAtnL3X8xQ1RJFkVsR+POxPf/ +0pqiQ+uQlKmjK/+yYLiwmwywTebrms= 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 CAB99169C; Fri, 3 May 2024 06:03:03 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 797533F73F; Fri, 3 May 2024 06:02:35 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 13/29] arm64: convert protection key into vm_flags and pgprot values Date: Fri, 3 May 2024 14:01:31 +0100 Message-Id: <20240503130147.1154804-14-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Stat-Signature: b44hpzc3st3utwnr7z8pub4m9edci4wz X-Rspam-User: X-Rspamd-Queue-Id: 35FBCC0017 X-HE-Tag: 1714741359-855480 X-HE-Meta: U2FsdGVkX18JXpiokuFrhNyhMt/qnVM/zUFpwTO0A6JTvB/AAV1EoW/j00QSHbVHCXA2PpDcnVGfp3AVJBe9Q5qvyDSEAnZMa6mBnZfGCi/NNd7bOTh63LCeP4NF/hPcFx3Y8ZSA2aPLw/johyTBET6l5P6MtfaEAv88RLdxYszqGGqJlLE2qqZXmz0Y71d07qsRy8hHoXIxlVZ+SVJyR7nqMsiP4+VBe7FIBrWkrP3egFzCuPMvt/Rr5ktqeZaH9mrlnFuCCo9mrVAba6p2JLnUuOk3p36I2xlrmeN9U5k6J0+IdINhSOGylKbjfXmlbNONAMOGh041Q68PELd77PuKlBvuClrY7iFyg8RnE1iiKuuCt1LD53MrrgFwnwcXlcayN7oC5C83WFtkRSdcdvsT2F2wghKrwpOJSmrPWxh09auP+E+GC6eND9+qEVpGt9M2btLYAacj3UHraQDZmPE4320D/IpPrSxKjckrdwyjc9f80XgoDxlj1F+0gufX0QpLKCqaUlAfBwKtt1V0pVCIHx6Savc0ejlWIsx5VLSGCMuczBEnfToom5r9UR7NVlEF5SynsgkcHGA0q+w9BDJQlb7aFbhZZKoR9Qj2WXjHwA6d6NMjep5k6+pcZBpBGMOO4/a8huar37Ll5qErwbsMo/EMS1KCSx637/MjIeIR6gLZNhgxEiX940D3TiQJP9Qe2oTC4uNh/+TTBNF7yTF75otXSfbfP30aTD2oAxFV5DQyqCJA5KCg21O+UZdwkHgZi1Lg6d/xS3Aj+U9QLM8sEndzZvvx8BX2M2Aoiwdyzvx9SQ+JeMW5MtC8NwjQsA/8bJ2EPPVDxKZx7AYCncHg5ZiBvWcwhgCjf9pdS/lAwzE7g1N5rbwnIRYWWizNP3t93B1vu6cAjBTETDViJRgBq24LOW1Yv/fGx36gYXB0RLToa8GWcQphpGQqsnFzT8mZScklH6QEO2TM2bG jEXV8Bkf 0fUnF6cWdkTstq/M96LLOkNLIH/2wUv71nP8qd0vT3amgUk2HmV7FKcO3EA7u6ktIxkfX07yS3M98Xiiyx/hMZbMkzG1B6HOndpI4+Ghvsb//5ixZYCLvfH6FIcrSuD+8gRfJO1OzEXQNUyil0Fi44RhDAHuIfz3wx+zMQ5zSejZk7/6kr4bbRbkyTaS+KK8tY4NiedbZO1etbclygZ1gXaMa1mwniak5tgDe9fRCpLyWq3jccNkB9JN5MK+fFxWeDTKoCCwabpJfA08= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Modify arch_calc_vm_prot_bits() and vm_get_page_prot() such that the pkey value is set in the vm_flags and then into the pgprot value. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/mman.h | 8 +++++++- arch/arm64/mm/mmap.c | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h index 5966ee4a6154..ecb2d18dc4d7 100644 --- a/arch/arm64/include/asm/mman.h +++ b/arch/arm64/include/asm/mman.h @@ -7,7 +7,7 @@ #include static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, - unsigned long pkey __always_unused) + unsigned long pkey) { unsigned long ret = 0; @@ -17,6 +17,12 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot, if (system_supports_mte() && (prot & PROT_MTE)) ret |= VM_MTE; +#if defined(CONFIG_ARCH_HAS_PKEYS) + ret |= pkey & 0x1 ? VM_PKEY_BIT0 : 0; + ret |= pkey & 0x2 ? VM_PKEY_BIT1 : 0; + ret |= pkey & 0x4 ? VM_PKEY_BIT2 : 0; +#endif + return ret; } #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey) diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c index 642bdf908b22..86eda6bc7893 100644 --- a/arch/arm64/mm/mmap.c +++ b/arch/arm64/mm/mmap.c @@ -102,6 +102,15 @@ pgprot_t vm_get_page_prot(unsigned long vm_flags) if (vm_flags & VM_MTE) prot |= PTE_ATTRINDX(MT_NORMAL_TAGGED); +#ifdef CONFIG_ARCH_HAS_PKEYS + if (vm_flags & VM_PKEY_BIT0) + prot |= PTE_PO_IDX_0; + if (vm_flags & VM_PKEY_BIT1) + prot |= PTE_PO_IDX_1; + if (vm_flags & VM_PKEY_BIT2) + prot |= PTE_PO_IDX_2; +#endif + return __pgprot(prot); } EXPORT_SYMBOL(vm_get_page_prot); From patchwork Fri May 3 13:01:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652793 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F30C10F16 for ; Fri, 3 May 2024 13:02:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D37F6B00A8; Fri, 3 May 2024 09:02:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 75C796B00A9; Fri, 3 May 2024 09:02:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B23A6B00AA; Fri, 3 May 2024 09:02:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3A35B6B00A8 for ; Fri, 3 May 2024 09:02:47 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E9CBF40F95 for ; Fri, 3 May 2024 13:02:46 +0000 (UTC) X-FDA: 82077099132.14.0BFF81A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id B24E34003F for ; Fri, 3 May 2024 13:02:42 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741362; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UCOC1oT2eBl3OuHcpEdtcFY9AiX3PwI5X0vEATuJgdQ=; b=FetMN+ZgXAn+3Rtly8y9oPtiRi7ePRa/OkoPFry5SLE3ob5mAYSWUsCqw3FgUt2RWze9Zr s3dwaY/MizOQVIFB2LXq68JMRQt+wrQjQbixpNK1FOT28efl07u9Ofke1Zd3lwUxnA9nr3 ukxIRruomp8M59jJEMM4zqtlYtSLNjQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741362; a=rsa-sha256; cv=none; b=J34W/hsVL+hvZKhtl8FmzRE5vcZP0CBiNODm2rTukmVqM4WVaKq0NdlzCea8YCZf9rJMY1 Tq0+YdWAQLW7txU9Iyaoc5IX64Q3XSUjNO9RA0O/GVeJki3u8xYrS2FxcC9PHuygrN9TEi aHIMYip5fWP03S5Nabw1MkgS1t67r88= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 23D4916A3; Fri, 3 May 2024 06:03:07 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C71E83F73F; Fri, 3 May 2024 06:02:38 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 14/29] arm64: mask out POIndex when modifying a PTE Date: Fri, 3 May 2024 14:01:32 +0100 Message-Id: <20240503130147.1154804-15-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: p8tgu7c9mtreiepck8ern8mo9rg8mkdh X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B24E34003F X-HE-Tag: 1714741362-319152 X-HE-Meta: U2FsdGVkX1+qZgcgD6drmpkC8NHUDBaqyaH+bxvpXZyxQhy1mNAcLCASn4gtJxbxjzQ8e4hc9qObWhaa7pqrjR+O4Jqzgg4Vvq79q67ZpYvh5LEr8kJ4DLSXXMRIwacmyNXxVUVvNNipdPZbp+p1Bv3nsWcWit/oAsAmJ0fj9yNtc69176e3Im5Ke/BrV5RxCdyGN2SjTaQR7HgPgl4Cj9g/ZyMYxehvqdyOe22LPkNzbTAwQNt4/2DAjhW3tTV3AIa4BPeue7AdM42O/FjDd1chRAOzcCmntlei1aLFoIeqFoMhtkCe4se/l/3vicS2mjySX1BiQkYWgpQrg5z9M7M7Vwgib3QfHU6gbyk4tTp8JUC/8Fwvp7/+EwpjSFFxrZTTpKZ2U6m7Cy5h2JAnGnK8Q9W1laIAHqgNBwgon7bN1iPAkjHH5+9TKEMDYBD38VrR3b4VnbYzkgs+PxM9gRrxYJOS6N+JxNYAh0qWQEjtFTXHOBUi+nsqr6ASzkDXbsl33LS6r2MpO+H1fxPvCdlHddhcNohgLF+t1QhHYmVCm7LNydq01CUKjdcarjofdrf63KQvcTmnhe7CbB57iAVj9fpApQFaiewt+ek3exD0EKfLoOOnkB/PnM7sJohPmd+wgCs95rrcRhzL04K3Edkb3aT7Jc3L9maVloQ8lgDUjMSiM24/4BIU5XSblin0OcDUHsNXyxYIiwmT7zILwDYU/nu/IXGPCOH/jxVQa2id/BlKjR++8B0Ojho8pEC/vZai4Y4wfw7lbORJrvGcGFOBzwjMTftr6xS0KEETfJ4aj6zGaPPr6T20fV+bkfObCIySTs1fKVQhPtdTTbY6jFnzhupY1M7gS7aorHBk+AyvKfatthWncBrQxYYWY9B/Vct4GRmIjD+WGQ9Y+heI7iclhziS9VRRut1G2po7EavWpfQPysQk2S5npOxztfo+KSLDADkWH7GDr0Zw+pF YiktR1+Q O18no83dl/XPNkviUi7bm0cvRAFzLrQolgS5P70ogoq6uHIaDS9wySFjo7RaGP5oMXur3A2K5aNaoEP1hd6oVMDEvKFK0+BGFYv3fBWnD9WLMvkKXxX6LCwGuVPQN3isEkyO/urXF2L6iwPCpoEDtHum72G9/wagf7NzfNk39zwJ7ponHZnWFhUyTBjFIB3u3u8b5kotdZN1H7HEkvKvsGZe5EQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When a PTE is modified, the POIndex must be masked off so that it can be modified. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/pgtable.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index afdd56d26ad7..5c970a9cca67 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1028,7 +1028,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) */ const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY | PTE_PROT_NONE | PTE_VALID | PTE_WRITE | PTE_GP | - PTE_ATTRINDX_MASK; + PTE_ATTRINDX_MASK | PTE_PO_IDX_MASK; + /* preserve the hardware dirty information */ if (pte_hw_dirty(pte)) pte = set_pte_bit(pte, __pgprot(PTE_DIRTY)); From patchwork Fri May 3 13:01:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652794 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 172DBC4345F for ; Fri, 3 May 2024 13:02:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AD9F6B00A9; Fri, 3 May 2024 09:02:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 711366B00AB; Fri, 3 May 2024 09:02:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 429E76B00AC; Fri, 3 May 2024 09:02:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1415E6B00A9 for ; Fri, 3 May 2024 09:02:48 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CA3B01C16B8 for ; Fri, 3 May 2024 13:02:47 +0000 (UTC) X-FDA: 82077099174.24.C8AF5B6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf15.hostedemail.com (Postfix) with ESMTP id F2940A001D for ; Fri, 3 May 2024 13:02:45 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741366; a=rsa-sha256; cv=none; b=WlRS1cVwXjYtHLYGx3Ixu2pEBj9cAC+0J7pQ6aaL6cY+G51uGz0l9wvXRbOqHzBl5pnkYG Lwk+SdiwPUEQQRoFVkOXD+QkboGolIS7/k6lAzM4o1l8hU+fLWj60h+a050Gj9lOKKdKoY IVVsIBl+QybtZ2//eP/epHY5xKHSF/w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741366; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KBI5PC2Sjgr5q/lRbWwQKGtcG+FQFgqzDWWR8xEOTc4=; b=PM6GFQHGAMRRWcylrUKIOfJlp3MhKORv1UyX8NuoQPQX7SErl119mbayogwycknTapqd2k qcsCwHNe1Nhyyzn1kzX3Rj5Y4XFVC23nTqXLewobarUu2SW5MPUW1witU6p0w+1+3z2bnl qIt3+FY4cebNj1i5e8xE4UgnCoQX+YI= 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 6F8C416F2; Fri, 3 May 2024 06:03:10 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1ECA63F73F; Fri, 3 May 2024 06:02:42 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 15/29] arm64: handle PKEY/POE faults Date: Fri, 3 May 2024 14:01:33 +0100 Message-Id: <20240503130147.1154804-16-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: cujicfb16zxb3xtcmjo9tduxqrsokycp X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: F2940A001D X-HE-Tag: 1714741365-419627 X-HE-Meta: U2FsdGVkX1+3zDy34cT3ycjYispE6tKIcMuczbqQwNV5WYH8vRMSqZJxPsg1zkYazgXBAU/TNhBwYb+QAbOq1e2uyo6jhjTu1K1p32hWAnjewtlUt/QoZnRC8AmIK4Gir5i4tRdGvDW4d+qYNXNd0YkwJWYmCqdNrOIQW9nbRbwCQ57UOTkGX6Nn2oNfbHbHE7pLmS3fq00I3KNc1OyGIYWkauVVwV99TLEBk07/z/a59VSj27NdQG5xazc6F6PHk9UHJINF5kqJTnsLdFcku+Xia8o6kjvVGidqILCqSqwprG3BB1G9ys/mgHUJ5tebpql0XNm13CVbwbm2OfiHk9McBFrSvFsaKZjGVB3wOUbvA0uRhczyWbI/CIV+h8MxmVQQyHnIWjI2sT4HZhyiPvzRZGqv9xnCXIIImurYXOzju9E0QNQa0lnb/mIgoQnI5nROYbAiyn48j0Upyzlci25XJF0YIy2ES8w6OhACPWMVWzJhBPHpOhbCit99nDSvEx8atzLLjIB2oMdG5HNOO1dR8jWJ+hM8ZZwhNll4UoXafaXRs44GZ5314vYLsfPrmumiYbYlJgjryvzu8FQnOZrNyXGAcWai8EQxdZ3tsyzR5kjYk++WwQhrQqeQxUeJFIT12C0eiIgFe7vzAovLh0mejYKesM6s+uUbjcW3qVYvb1l0JOcNeQDOAot2LHdfgxlm7DLDFyNFcvtkxFaCn3m+4WfYeKsxuB2XoGSMTIJWYhrgHR+0gvPbzS5196slkzm/gv7Btg7bzTmds6j4niJ+Ib0RxJI5a3S7GdJ8gWglAEAYsEUlM2qqC1S7A1lJYJKLNMySpObXbqXovM6qEbcEZBQ55msHG6yVbTOGj8OPfD4s45Jq3hIihBeD3fH4i26ro8KPM6SLcRtRNUsBxvwq5FQjp0qF+Y4MtgIChv7suocQI7xKKb5/hTaE+LQyDjYsu+86bwFSDgZ37k7 YliwIZnC 5DZLu5cs7dc1D24SIdoJJtPJQ9xC4OU1/EmVUneIt+96kjF+Pv848U6r9D08X55OivyWdsKhcLivdxuzC7xVvDwjP/qBjjpvsuq6U5PH1t32woqkZ4k7fG/S+VLHay9hprA0z5vG13l+k7xGN12dWO/cmYTbxu2hOZvIAKRutiW+iUO8hCKXTc2gV5jkW1YoDtgpitjiQJQXG9eP+y9NGQ86nXth3A1RhVYr7 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If a memory fault occurs that is due to an overlay/pkey fault, report that to userspace with a SEGV_PKUERR. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/traps.h | 1 + arch/arm64/kernel/traps.c | 12 ++++++-- arch/arm64/mm/fault.c | 56 ++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h index eefe766d6161..f6f6f2cb7f10 100644 --- a/arch/arm64/include/asm/traps.h +++ b/arch/arm64/include/asm/traps.h @@ -25,6 +25,7 @@ try_emulate_armv8_deprecated(struct pt_regs *regs, u32 insn) void force_signal_inject(int signal, int code, unsigned long address, unsigned long err); void arm64_notify_segfault(unsigned long addr); void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str); +void arm64_force_sig_fault_pkey(int signo, int code, unsigned long far, const char *str, int pkey); void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str); void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str); diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 215e6d7f2df8..1bac6c84d3f5 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -263,16 +263,24 @@ static void arm64_show_signal(int signo, const char *str) __show_regs(regs); } -void arm64_force_sig_fault(int signo, int code, unsigned long far, - const char *str) +void arm64_force_sig_fault_pkey(int signo, int code, unsigned long far, + const char *str, int pkey) { arm64_show_signal(signo, str); if (signo == SIGKILL) force_sig(SIGKILL); + else if (code == SEGV_PKUERR) + force_sig_pkuerr((void __user *)far, pkey); else force_sig_fault(signo, code, (void __user *)far); } +void arm64_force_sig_fault(int signo, int code, unsigned long far, + const char *str) +{ + arm64_force_sig_fault_pkey(signo, code, far, str, 0); +} + void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str) { diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 8251e2fea9c7..585295168918 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -489,6 +490,23 @@ static void do_bad_area(unsigned long far, unsigned long esr, #define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) #define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) +static bool fault_from_pkey(unsigned long esr, struct vm_area_struct *vma, + unsigned int mm_flags) +{ + unsigned long iss2 = ESR_ELx_ISS2(esr); + + if (!arch_pkeys_enabled()) + return false; + + if (iss2 & ESR_ELx_Overlay) + return true; + + return !arch_vma_access_permitted(vma, + mm_flags & FAULT_FLAG_WRITE, + mm_flags & FAULT_FLAG_INSTRUCTION, + mm_flags & FAULT_FLAG_REMOTE); +} + static vm_fault_t __do_page_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned int mm_flags, unsigned long vm_flags, @@ -529,6 +547,8 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, unsigned int mm_flags = FAULT_FLAG_DEFAULT; unsigned long addr = untagged_addr(far); struct vm_area_struct *vma; + bool pkey_fault = false; + int pkey = -1; if (kprobe_page_fault(regs, esr)) return 0; @@ -590,6 +610,12 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, vma_end_read(vma); goto lock_mmap; } + + if (fault_from_pkey(esr, vma, mm_flags)) { + vma_end_read(vma); + goto lock_mmap; + } + fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED))) vma_end_read(vma); @@ -617,6 +643,11 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, goto done; } + if (fault_from_pkey(esr, vma, mm_flags)) { + pkey_fault = true; + pkey = vma_pkey(vma); + } + fault = __do_page_fault(mm, vma, addr, mm_flags, vm_flags, regs); /* Quick path to respond to signals */ @@ -682,9 +713,28 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, * Something tried to access memory that isn't in our memory * map. */ - arm64_force_sig_fault(SIGSEGV, - fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR, - far, inf->name); + int fault_kind; + /* + * The pkey value that we return to userspace can be different + * from the pkey that caused the fault. + * + * 1. T1 : mprotect_key(foo, PAGE_SIZE, pkey=4); + * 2. T1 : set POR_EL0 to deny access to pkey=4, touches, page + * 3. T1 : faults... + * 4. T2: mprotect_key(foo, PAGE_SIZE, pkey=5); + * 5. T1 : enters fault handler, takes mmap_lock, etc... + * 6. T1 : reaches here, sees vma_pkey(vma)=5, when we really + * faulted on a pte with its pkey=4. + */ + + if (pkey_fault) + fault_kind = SEGV_PKUERR; + else + fault_kind = fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR; + + arm64_force_sig_fault_pkey(SIGSEGV, + fault_kind, + far, inf->name, pkey); } return 0; From patchwork Fri May 3 13:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652795 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26BC9C4345F for ; Fri, 3 May 2024 13:02:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6007A6B00AC; Fri, 3 May 2024 09:02:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 589B46B00AD; Fri, 3 May 2024 09:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B42C6B00AE; Fri, 3 May 2024 09:02:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 157C36B00AC for ; Fri, 3 May 2024 09:02:51 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C1FCDA10B4 for ; Fri, 3 May 2024 13:02:50 +0000 (UTC) X-FDA: 82077099300.24.8248220 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 1966C18001A for ; Fri, 3 May 2024 13:02:48 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741369; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UHZii1WwyPiQbM25MJuHnPX8X8jSD4FoCigkDlugWZU=; b=14u3DfU8scv0ZMXRv4CyeIfRJ3SEBoCCnctw3f/PEnFUHKtoq9itK13vAYyhYQ1Z5wVXun TlwofIDeRuj9rDPLq5t219xj3tgafcd6b2MLe29oLu/JAsOoKcv5vQn6gdaYiLcdS8BsTv /yv7OX4IIaLaszkOROp8Yd/poIHc7zw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741369; a=rsa-sha256; cv=none; b=b2sTDyLBRVrqPqaUVXzt6FsJW3yj9cBWlEJggvS4iosXKtuPDXCR2h5lJxoJwn1cQcYoBi oI3jckCvBhc576NVXbfWsYvinTYS7sRFaGF2JKsiPREztIkTeF38pFTey7yRwI3coCIvUn CNJbLyQHBLJttufHk3z1Fw3CREtynp4= 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 BE51016F3; Fri, 3 May 2024 06:03:13 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69B1E3F73F; Fri, 3 May 2024 06:02:45 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 16/29] arm64: add pte_access_permitted_no_overlay() Date: Fri, 3 May 2024 14:01:34 +0100 Message-Id: <20240503130147.1154804-17-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1966C18001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: r8pcczikomdh73aqezh3rakinkbpcjp4 X-HE-Tag: 1714741368-54459 X-HE-Meta: U2FsdGVkX1+iE5wVeb3FER3Hu/xUOKwXO7Gi2j3BrBsPSgc5647neJhbyHJFVf0EsWCMXkwRQfuFTwfN5vhB7ozOKKWhNsbisHPwfAkbNfIJl0R6foJXG+D9fhlpfWU9yPQd8vvLIkjcugsnl67KDKgHDLqilATBD2Zjbj2y0smzeHdSNfJ1f33uCNg5MWgIVtnfNK+zKKyFqlDHGOWMLyK2MZNcKX4dhCC4Mern0dvtPCMwKYgPOpmnPvMKQFno6aDi7WHK2SKMsVCYA0EOkc8wLjfcxduFr2Eg1F4iE46K/CiZlaR7GvmH+wzfrWw/FkwTl+NdOvzXBCbp/WQBRNlIyqNp1YtbWPmAZmNd2kmAGvKo9IxDw24rjcvtFwe4AMBTUiddHqnqZv1XZ4RhAqGhqjhArw5RGKgkSUIiY8dnr5iN0goMONju2dvN7ud9fcDRh1j50gLVoBl0wvkQ/si06P0/zB0y/ky/1YOWErSma++vaWUaBp//pb1JUz8HfIPkvejwfXkP0jhDLrGvTKWnhJSpdzxUDXNdhoHN5URuuW8QVj7DaL9AzwJYn4Ga3upzuJa9JDfUTbYTm9qVHBL5MuHPBXbZCv+ls5Oq4xWmsuXBJZyk31qXqVGAmhp7gsNAjmTvB5Dv2A5pLqUS3ffw2HqOX0FJeJi/Bc0l04Fim/YN++AUYVwXfGd7+xJgoiBhrM+qIgrwecdkxJFDVDysh++1Nf9gVlegxIWpnJF1y3RMBreyZKKG5HWAjILsgyvZMaJGZEPYicLL4oppU7x0YfeQquUBUI8/IxZhdykLLweodQTB/uBTboPPnSfpWD13/z2po3MGPTDw3UFVYkZ9w9Fr760RhtI2BjE/fvNWX3o3DYlBAM3CjSB6cyRNZjAXkxdV048254Euddk2BfUVR8yQy36DGNzW6IPSb8e8DMZNU5lG200D4WLKdr4ustbEwQC4E6dxQFJeFUg oo+Q/XaJ 4eVZRPM/GueHwK7CDR6eL5LxPhCUG6JzAEfhrr+dqwvPM8kV+R8vBoMxlfcYHrwGLjGscMUlmw1cnpHUqwjNvNIvXBjbcd4aNEEWZ+p/gQ2OW0AX5orlDLbicS/n8anHGn/8xzO0HTG5uwM+IGZVpKNoyr30X7g2H9Rb9TDs+2fdmBx9K0vMFs2fuFD6ynvu2WhVYhEeDKgwYbbJOUdDqn73ussKJ8yRVruCPgPIlVbqW/zpW8EyjRoVutdPVKdZhiZHhMKU8F255eE0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We do not want take POE into account when clearing the MTE tags. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/pgtable.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 5c970a9cca67..2449e4e27ea6 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -160,8 +160,10 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) * not set) must return false. PROT_NONE mappings do not have the * PTE_VALID bit set. */ -#define pte_access_permitted(pte, write) \ +#define pte_access_permitted_no_overlay(pte, write) \ (((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) && (!(write) || pte_write(pte))) +#define pte_access_permitted(pte, write) \ + pte_access_permitted_no_overlay(pte, write) #define pmd_access_permitted(pmd, write) \ (pte_access_permitted(pmd_pte(pmd), (write))) #define pud_access_permitted(pud, write) \ @@ -348,10 +350,11 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages) /* * If the PTE would provide user space access to the tags associated * with it then ensure that the MTE tags are synchronised. Although - * pte_access_permitted() returns false for exec only mappings, they - * don't expose tags (instruction fetches don't check tags). + * pte_access_permitted_no_overlay() returns false for exec only + * mappings, they don't expose tags (instruction fetches don't check + * tags). */ - if (system_supports_mte() && pte_access_permitted(pte, false) && + if (system_supports_mte() && pte_access_permitted_no_overlay(pte, false) && !pte_special(pte) && pte_tagged(pte)) mte_sync_tags(pte, nr_pages); } From patchwork Fri May 3 13:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652796 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D955BC10F16 for ; Fri, 3 May 2024 13:02:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 711786B00AE; Fri, 3 May 2024 09:02:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69BE06B00AF; Fri, 3 May 2024 09:02:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C4C26B00B0; Fri, 3 May 2024 09:02:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 270786B00AE for ; Fri, 3 May 2024 09:02:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 550F9A0ECA for ; Fri, 3 May 2024 13:02:55 +0000 (UTC) X-FDA: 82077099510.14.A18D8F2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf29.hostedemail.com (Postfix) with ESMTP id 828E5120019 for ; Fri, 3 May 2024 13:02:52 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741372; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NgybyCj367i4fYs5e7Frafhw+Q+kR5+4e9inSTgsNWY=; b=A8kdWVDz0Gcqr8T2HTEdIz+BwkFExWEmnzmsTuHWsmcWjZQwAtgHHtcuO/tqTEKTAK2Ynj zgmVN8OXYnR99bFjSvtCD8b+b6vlfXw2kK1OGfkrmPhUHXScPrTyUZwWPSr372o109zYIM ZMtC0k7z2kzYlhv3k/jtKQhHvHNCIXE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf29.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741372; a=rsa-sha256; cv=none; b=GEBRJXZhRBdSGKZ+x7g0dnSIcHyxHOkAVTZYRHo/2XqbUDbTmMIZAc+xQxND5/eYmvuxTQ lWra+HwPRaTV7ns/WR3DOjXAb+nrS0bjUJq9ht8cq4kKl67DE0u/+SRcyBfRl42LvCYd1c +jjYObumWTR4o3Gvy1NXPdjzkYQmoGk= 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 3171916F8; Fri, 3 May 2024 06:03:17 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B94D03F73F; Fri, 3 May 2024 06:02:48 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 17/29] arm64: implement PKEYS support Date: Fri, 3 May 2024 14:01:35 +0100 Message-Id: <20240503130147.1154804-18-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 828E5120019 X-Stat-Signature: mdtcdoka3x5b5it98r4tmmdxrq86cfmc X-Rspam-User: X-HE-Tag: 1714741372-459747 X-HE-Meta: U2FsdGVkX19EcZ0mSCF87QEcYoN17dYkhH3hF7/QTRn4O2i9k3lAvSF/3Ij/be1ziNcPFF8qWEBap/tefZC4rhFlyvqT9yE/z2D6LGQZD+IW2c4su8Whxy6tjxo6A+34ntSSc3gSvQsEqHmDXw0dFdaCPTjJXwxdlDEZjV3kHlU0MpkrsBEBnZlbldS/Bzj28gW83K70HCbAEwLG94ORiIDCapNSVaujfYvclA/z9zuSHTOHoul5ToP4L1sQdfEznwKN3jS2cqtM/1+lXC/podLcBHxIgpkUqYcAnIsl34qX36IAkg5tFmaMGdyDTaKqxmOvh5w9xBI3K8OnFSymZDwVm12cYQgs9obfvGGghw3CKIavAIkUHyuDTAY2iulC+KrD0hcB81mjk+ZLxGEl3JyZDDnpk9Hpk/r+y80wOTZagk8EFE16hiYpDmRrJ8DBlZKh817SoKkxYruW/2JNZFkSghZ3TDbErVfPvmVqKEoE+htDw0E9hcdJPZh7ZVS/BkcDGZ/ScRGul671w4lmKK9cSWiAlDT/zXPkExNQJZak9zZelju/3J2NFhe6Y7Vqj0ds1hGt9CG54ARrTEtypSE2qjZNf9ivm5VRPaHtz0nxhWA8DBIk/W3o2PREat9UnZTkVDnAJy5XqbR0TaNqg9weAXWfPNnJOm/teTAPPgXGf/FBeNj6lVLC49hihM04oHgIMorGPiCroAmUew3wWMFGV8wVT/5xIegd+/7YEpHEjqVctunWSqobTyoyMH49uXAx+2aojTOOX41plrJMkHChGyumPDA259PMsvimELyijVjKIdO6o/UA13sNJY2zFRiqotA5R/+eQ/Kafl0kEzKevDbSZlECVcZLWPGr70ioh551AIsz1vGP2qPJmSWnEKHHjjW+tqs4A4zzrUa7UvqV+KFTcMjlcARGJToNSuizCZIvYmfJnuc1cECVVuLuv5FMpWWOPX7aEjFNe68 vDB0XKVR nYNW67Awo/13i20+8IrR6PGwcjtiQi4SmfVhg2GUnM+JTtt8izPhD1+q2RbaG3ErfslDGmvPZ4PE3jcdQ0ktmxyTK/TFJGsVNdJovwdLRh3p+i0WcyiQaSp6nl2zXDn33tssFsqZBq+gX13yYk5WeRvNNpscrHRVx9WeDeSEmu3oYe2s+wTap1cRgj8vqD9KvuuKMZdaZmYE4nt6+Auc9VHRJ7ir75RTtszdZ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Implement the PKEYS interface, using the Permission Overlay Extension. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/mmu.h | 1 + arch/arm64/include/asm/mmu_context.h | 51 ++++++++++++- arch/arm64/include/asm/pgtable.h | 22 +++++- arch/arm64/include/asm/pkeys.h | 110 +++++++++++++++++++++++++++ arch/arm64/include/asm/por.h | 33 ++++++++ arch/arm64/mm/mmu.c | 40 ++++++++++ 6 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/include/asm/pkeys.h create mode 100644 arch/arm64/include/asm/por.h diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 65977c7783c5..983afeb4eba5 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -25,6 +25,7 @@ typedef struct { refcount_t pinned; void *vdso; unsigned long flags; + u8 pkey_allocation_map; } mm_context_t; /* diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index c768d16b81a4..cb499db7a97b 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -175,9 +175,36 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm) { atomic64_set(&mm->context.id, 0); refcount_set(&mm->context.pinned, 0); + + /* pkey 0 is the default, so always reserve it. */ + mm->context.pkey_allocation_map = 0x1; + + return 0; +} + +static inline void arch_dup_pkeys(struct mm_struct *oldmm, + struct mm_struct *mm) +{ + /* Duplicate the oldmm pkey state in mm: */ + mm->context.pkey_allocation_map = oldmm->context.pkey_allocation_map; +} + +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) +{ + arch_dup_pkeys(oldmm, mm); + return 0; } +static inline void arch_exit_mmap(struct mm_struct *mm) +{ +} + +static inline void arch_unmap(struct mm_struct *mm, + unsigned long start, unsigned long end) +{ +} + #ifdef CONFIG_ARM64_SW_TTBR0_PAN static inline void update_saved_ttbr0(struct task_struct *tsk, struct mm_struct *mm) @@ -267,6 +294,28 @@ static inline unsigned long mm_untag_mask(struct mm_struct *mm) return -1UL >> 8; } +/* + * We only want to enforce protection keys on the current process + * because we effectively have no access to POR_EL0 for other + * processes or any way to tell *which * POR_EL0 in a threaded + * process we could use. + * + * So do not enforce things if the VMA is not from the current + * mm, or if we are in a kernel thread. + */ +static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, + bool write, bool execute, bool foreign) +{ + if (!arch_pkeys_enabled()) + return true; + + /* allow access if the VMA is not one from this process */ + if (foreign || vma_is_foreign(vma)) + return true; + + return por_el0_allows_pkey(vma_pkey(vma), write, execute); +} + #include #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 2449e4e27ea6..8ee68ff03016 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -153,6 +154,24 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) #define pte_accessible(mm, pte) \ (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid(pte)) +static inline bool por_el0_allows_pkey(u8 pkey, bool write, bool execute) +{ + u64 por; + + if (!system_supports_poe()) + return true; + + por = read_sysreg_s(SYS_POR_EL0); + + if (write) + return por_elx_allows_write(por, pkey); + + if (execute) + return por_elx_allows_exec(por, pkey); + + return por_elx_allows_read(por, pkey); +} + /* * p??_access_permitted() is true for valid user mappings (PTE_USER * bit set, subject to the write permission check). For execute-only @@ -163,7 +182,8 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) #define pte_access_permitted_no_overlay(pte, write) \ (((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) && (!(write) || pte_write(pte))) #define pte_access_permitted(pte, write) \ - pte_access_permitted_no_overlay(pte, write) + (pte_access_permitted_no_overlay(pte, write) && \ + por_el0_allows_pkey(FIELD_GET(PTE_PO_IDX_MASK, pte_val(pte)), write, false)) #define pmd_access_permitted(pmd, write) \ (pte_access_permitted(pmd_pte(pmd), (write))) #define pud_access_permitted(pud, write) \ diff --git a/arch/arm64/include/asm/pkeys.h b/arch/arm64/include/asm/pkeys.h new file mode 100644 index 000000000000..a284508a4d02 --- /dev/null +++ b/arch/arm64/include/asm/pkeys.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Arm Ltd. + * + * Based on arch/x86/include/asm/pkeys.h + */ + +#ifndef _ASM_ARM64_PKEYS_H +#define _ASM_ARM64_PKEYS_H + +#define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2) + +#define arch_max_pkey() 7 + +int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, + unsigned long init_val); + +static inline bool arch_pkeys_enabled(void) +{ + return false; +} + +static inline int vma_pkey(struct vm_area_struct *vma) +{ + return (vma->vm_flags & ARCH_VM_PKEY_FLAGS) >> VM_PKEY_SHIFT; +} + +static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, + int prot, int pkey) +{ + if (pkey != -1) + return pkey; + + return vma_pkey(vma); +} + +static inline int execute_only_pkey(struct mm_struct *mm) +{ + // Execute-only mappings are handled by EPAN/FEAT_PAN3. + WARN_ON_ONCE(!cpus_have_final_cap(ARM64_HAS_EPAN)); + + return -1; +} + +#define mm_pkey_allocation_map(mm) (mm->context.pkey_allocation_map) +#define mm_set_pkey_allocated(mm, pkey) do { \ + mm_pkey_allocation_map(mm) |= (1U << pkey); \ +} while (0) +#define mm_set_pkey_free(mm, pkey) do { \ + mm_pkey_allocation_map(mm) &= ~(1U << pkey); \ +} while (0) + +static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey) +{ + /* + * "Allocated" pkeys are those that have been returned + * from pkey_alloc() or pkey 0 which is allocated + * implicitly when the mm is created. + */ + if (pkey < 0) + return false; + if (pkey >= arch_max_pkey()) + return false; + + return mm_pkey_allocation_map(mm) & (1U << pkey); +} + +/* + * Returns a positive, 3-bit key on success, or -1 on failure. + */ +static inline int mm_pkey_alloc(struct mm_struct *mm) +{ + /* + * Note: this is the one and only place we make sure + * that the pkey is valid as far as the hardware is + * concerned. The rest of the kernel trusts that + * only good, valid pkeys come out of here. + */ + u8 all_pkeys_mask = ((1U << arch_max_pkey()) - 1); + int ret; + + if (!arch_pkeys_enabled()) + return -1; + + /* + * Are we out of pkeys? We must handle this specially + * because ffz() behavior is undefined if there are no + * zeros. + */ + if (mm_pkey_allocation_map(mm) == all_pkeys_mask) + return -1; + + ret = ffz(mm_pkey_allocation_map(mm)); + + mm_set_pkey_allocated(mm, ret); + + return ret; +} + +static inline int mm_pkey_free(struct mm_struct *mm, int pkey) +{ + if (!mm_pkey_is_allocated(mm, pkey)) + return -EINVAL; + + mm_set_pkey_free(mm, pkey); + + return 0; +} + +#endif /* _ASM_ARM64_PKEYS_H */ diff --git a/arch/arm64/include/asm/por.h b/arch/arm64/include/asm/por.h new file mode 100644 index 000000000000..d6604e0c5c54 --- /dev/null +++ b/arch/arm64/include/asm/por.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Arm Ltd. + */ + +#ifndef _ASM_ARM64_POR_H +#define _ASM_ARM64_POR_H + +#define POR_BITS_PER_PKEY 4 +#define POR_ELx_IDX(por_elx, idx) (((por_elx) >> (idx * POR_BITS_PER_PKEY)) & 0xf) + +static inline bool por_elx_allows_read(u64 por, u8 pkey) +{ + u8 perm = POR_ELx_IDX(por, pkey); + + return perm & POE_R; +} + +static inline bool por_elx_allows_write(u64 por, u8 pkey) +{ + u8 perm = POR_ELx_IDX(por, pkey); + + return perm & POE_W; +} + +static inline bool por_elx_allows_exec(u64 por, u8 pkey) +{ + u8 perm = POR_ELx_IDX(por, pkey); + + return perm & POE_X; +} + +#endif /* _ASM_ARM64_POR_H */ diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 495b732d5af3..e50ccc86d150 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -1535,3 +1536,42 @@ void __cpu_replace_ttbr1(pgd_t *pgdp, bool cnp) cpu_uninstall_idmap(); } + +#ifdef CONFIG_ARCH_HAS_PKEYS +int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val) +{ + u64 new_por = POE_RXW; + u64 old_por; + u64 pkey_shift; + + if (!arch_pkeys_enabled()) + return -ENOSPC; + + /* + * This code should only be called with valid 'pkey' + * values originating from in-kernel users. Complain + * if a bad value is observed. + */ + if (WARN_ON_ONCE(pkey >= arch_max_pkey())) + return -EINVAL; + + /* Set the bits we need in POR: */ + if (init_val & PKEY_DISABLE_ACCESS) + new_por = POE_X; + else if (init_val & PKEY_DISABLE_WRITE) + new_por = POE_RX; + + /* Shift the bits in to the correct place in POR for pkey: */ + pkey_shift = pkey * POR_BITS_PER_PKEY; + new_por <<= pkey_shift; + + /* Get old POR and mask off any old bits in place: */ + old_por = read_sysreg_s(SYS_POR_EL0); + old_por &= ~(POE_MASK << pkey_shift); + + /* Write old part along with new part: */ + write_sysreg_s(old_por | new_por, SYS_POR_EL0); + + return 0; +} +#endif From patchwork Fri May 3 13:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652797 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95EF9C4345F for ; Fri, 3 May 2024 13:02:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53C2A6B0085; Fri, 3 May 2024 09:02:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 479706B00B0; Fri, 3 May 2024 09:02:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C9916B00AF; Fri, 3 May 2024 09:02:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0590A6B0082 for ; Fri, 3 May 2024 09:02:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ABDA54100B for ; Fri, 3 May 2024 13:02:57 +0000 (UTC) X-FDA: 82077099594.14.FA95906 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 0EDB014002E for ; Fri, 3 May 2024 13:02:55 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lSYtiCmX6V74+mnj2qi0sxuLVyv7igCTfD+EW0872oI=; b=qQcuTlQm8J5Eq/xXKjoxB34S5o/4VBMMXdp1JvOwDvw+fBjFTwm/Dd3g3jo7if+IJfBQyF 6aJ62/7JDIKjPEjdsmet2ATmT9OTs4GJN7kV0wAMkXwffF/7ZXkIK4Qv9QadzFulOcsETD bGDL78L6TBD/dbBsVkVpXTOQmoFWYJM= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741376; a=rsa-sha256; cv=none; b=Z9cM4r6tiDiim6f4ZZPGq5ToiJwBaamXlTJji2SidVgwCgijZnrHjZOoH+Q/rPkdLd1WOu 2qfEMdxJa9StnVbWCcpRlwdYdV1EGpslVXxl11Q3hrKQbuMkUc/QX6knv0W+xWoOv38ceP If4Hg0YCZFYTGmeyPeTq9rMcIGvjADI= 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 7DEFA1756; Fri, 3 May 2024 06:03:20 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2BCEA3F73F; Fri, 3 May 2024 06:02:52 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 18/29] arm64: add POE signal support Date: Fri, 3 May 2024 14:01:36 +0100 Message-Id: <20240503130147.1154804-19-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0EDB014002E X-Stat-Signature: jerogkrtmftyc8uo5etyi7zz63iu4sw1 X-HE-Tag: 1714741375-965671 X-HE-Meta: U2FsdGVkX18lfu6FOCohQIb5pjKwC1TG2gAcThgZCi5U89eWDtFXGY9wxfC4M4N/jUHfAyvqkdDRG/OEFcMSXiSyMuS/ZozR1AQMbuXcyaOHXfxkGG3gtSYe5QW44bjFXtzZTUqPUWzEo/nbypH94eJf+kmoyk/hzdGNpzMRrLYt/txshSlXsTCaEIVN1/ED9myLozYA4643yT87rB7/KOYZNr+kPk1dyvseDnKdkPjuV/KL56ezGfAzRPHr1u35Mc/YkHDwMeaM8RzIbPT68zWVTdCZoQcAzSSvXgIevWn1n8MFJ8+O0Wgf+iVu4/G7yIvyN2+JVQp+utCU4CS3FRK1chTH1Wi1MUmndTvpHbWhjVZk1RKMFvNIywCyCnWaTxpThYFqT8bHfUZRlX0MAOJ7QnxZvodiV2a8dsNPLd8yNnCqlqVzA0hhuOdCQPFZbB0EewzwIJE0wwMlWhkKROCcHFtWSaIWLl76PujKx+plOYIvRDSR3AGNhGCNdII6RaBWBvGwul1GvISI277UQm+HtuKgq/mOcsRT3yeQj/rARcDEfSGZUWH4X9MfLojKL2K598JiiOSNr2itYhhm08E382eUkkKb0zUJa4q5r/bnMg6nA9L8pc47IA7XUcI7q30ubzV5ZvsQrVFT8YzYrGJC59UxEcgwnHvo/XINzg5/2l3jGCGxRaCbOqgXrkyXX7iOIU34okt6dVNbasgEMc3vOFadjSoPM/FyKP5SLA0gO+8B0Am+19XhkPAyOnR3d3Qrqkej9ZA/4ZVAPtTsZVG+zGwRO0jJgOgOAy50cIkDRXRYyL0iiuC7i5dZdPuPxL65IPy8ob/51QlYfS+cw+c2c0AK7brl134QVrdeYJAI0/wIL+/5mdiTcfbvCUAprhkJ6SAUAuddEmQGXkDp8NSqrn5yYvPs/JXFNP6EbKH3jLu35X38cU7pb8o522CAvn5KMv4aQA4WLRIlBVq LWH8V/DF apkrZ85QVgmCtKz4tD+Q2BBRU8ZBWfMQeY9w84t9QbTGUqHEp3z8TCvPheXR0+GCx/GVjfozGzQPdZwRQ+kb0FbgT9+1LTOqv6Rgk6mGxNaIRy34iPmM9TIYENK4FItPxxDXcVJgo5bwANw+krHDe/wfiJncvnbqxaFQnRlvD4alMUcWBEei69TNW94PEKsCW19IqO4oeLsdWkcM0J0w0MnTbnA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add PKEY support to signals, by saving and restoring POR_EL0 from the stackframe. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Mark Brown Acked-by: Szabolcs Nagy Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/uapi/asm/sigcontext.h | 7 ++++ arch/arm64/kernel/signal.c | 52 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/arch/arm64/include/uapi/asm/sigcontext.h b/arch/arm64/include/uapi/asm/sigcontext.h index 8a45b7a411e0..e4cba8a6c9a2 100644 --- a/arch/arm64/include/uapi/asm/sigcontext.h +++ b/arch/arm64/include/uapi/asm/sigcontext.h @@ -98,6 +98,13 @@ struct esr_context { __u64 esr; }; +#define POE_MAGIC 0x504f4530 + +struct poe_context { + struct _aarch64_ctx head; + __u64 por_el0; +}; + /* * extra_context: describes extra space in the signal frame for * additional structures that don't fit in sigcontext.__reserved[]. diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 4a77f4976e11..077436a8bc10 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -63,6 +63,7 @@ struct rt_sigframe_user_layout { unsigned long fpmr_offset; unsigned long extra_offset; unsigned long end_offset; + unsigned long poe_offset; }; #define BASE_SIGFRAME_SIZE round_up(sizeof(struct rt_sigframe), 16) @@ -185,6 +186,8 @@ struct user_ctxs { u32 zt_size; struct fpmr_context __user *fpmr; u32 fpmr_size; + struct poe_context __user *poe; + u32 poe_size; }; static int preserve_fpsimd_context(struct fpsimd_context __user *ctx) @@ -258,6 +261,21 @@ static int restore_fpmr_context(struct user_ctxs *user) return err; } +static int restore_poe_context(struct user_ctxs *user) +{ + u64 por_el0; + int err = 0; + + if (user->poe_size != sizeof(*user->poe)) + return -EINVAL; + + __get_user_error(por_el0, &(user->poe->por_el0), err); + if (!err) + write_sysreg_s(por_el0, SYS_POR_EL0); + + return err; +} + #ifdef CONFIG_ARM64_SVE static int preserve_sve_context(struct sve_context __user *ctx) @@ -621,6 +639,7 @@ static int parse_user_sigframe(struct user_ctxs *user, user->za = NULL; user->zt = NULL; user->fpmr = NULL; + user->poe = NULL; if (!IS_ALIGNED((unsigned long)base, 16)) goto invalid; @@ -671,6 +690,17 @@ static int parse_user_sigframe(struct user_ctxs *user, /* ignore */ break; + case POE_MAGIC: + if (!system_supports_poe()) + goto invalid; + + if (user->poe) + goto invalid; + + user->poe = (struct poe_context __user *)head; + user->poe_size = size; + break; + case SVE_MAGIC: if (!system_supports_sve() && !system_supports_sme()) goto invalid; @@ -857,6 +887,9 @@ static int restore_sigframe(struct pt_regs *regs, if (err == 0 && system_supports_sme2() && user.zt) err = restore_zt_context(&user); + if (err == 0 && system_supports_poe() && user.poe) + err = restore_poe_context(&user); + return err; } @@ -980,6 +1013,13 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user, return err; } + if (system_supports_poe()) { + err = sigframe_alloc(user, &user->poe_offset, + sizeof(struct poe_context)); + if (err) + return err; + } + return sigframe_alloc_end(user); } @@ -1020,6 +1060,15 @@ static int setup_sigframe(struct rt_sigframe_user_layout *user, __put_user_error(current->thread.fault_code, &esr_ctx->esr, err); } + if (system_supports_poe() && err == 0 && user->poe_offset) { + struct poe_context __user *poe_ctx = + apply_user_offset(user, user->poe_offset); + + __put_user_error(POE_MAGIC, &poe_ctx->head.magic, err); + __put_user_error(sizeof(*poe_ctx), &poe_ctx->head.size, err); + __put_user_error(read_sysreg_s(SYS_POR_EL0), &poe_ctx->por_el0, err); + } + /* Scalable Vector Extension state (including streaming), if present */ if ((system_supports_sve() || system_supports_sme()) && err == 0 && user->sve_offset) { @@ -1178,6 +1227,9 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, sme_smstop(); } + if (system_supports_poe()) + write_sysreg_s(POR_EL0_INIT, SYS_POR_EL0); + if (ka->sa.sa_flags & SA_RESTORER) sigtramp = ka->sa.sa_restorer; else From patchwork Fri May 3 13:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652798 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48B8BC10F16 for ; Fri, 3 May 2024 13:03:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69BC06B00B1; Fri, 3 May 2024 09:03:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FFFA6B00B2; Fri, 3 May 2024 09:03:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4510F6B00B3; Fri, 3 May 2024 09:03:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1D1626B00B1 for ; Fri, 3 May 2024 09:03:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D5BFF1610DF for ; Fri, 3 May 2024 13:03:00 +0000 (UTC) X-FDA: 82077099720.04.02E7D3A Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 3EA95100028 for ; Fri, 3 May 2024 13:02:59 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741379; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eFcL62Rr/RtgJpD5kNZCw3oVg04mkYe5C9YhBh4nh5U=; b=gmWH0F1ZZQZbLVc3cPgLO9QxKJqBVJmFtkVFTNKFBaxbvVXtru1Cl5FyzYVrNKgmcJZc8G q7bUKNT/ovxIbUza+L1wI85UP3EUmwSM7MPQ8thM277f9ZDeWbgZPPklpv0sqsHWU6kUEg khlSiXhUB8Qa5+8FbNGNy9nC2efXHnI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741379; a=rsa-sha256; cv=none; b=6WYHjmU2x9hb25fFnbXqs0xNVgyMM08jGFhVk5gGW6QvtOoSanfGZDVsBm40LjbLnXRiVT fa4cO76gVLPYr5dyy5Th1tmhXiwg1KtlEBBfrGPYTn3A/wCcjczv0DhOnq1UroydoXSoAi TAuLS725Bpy2HzNhweiSz2H3Zx4NiOU= 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 CCFCE1713; Fri, 3 May 2024 06:03:23 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 78C943F73F; Fri, 3 May 2024 06:02:55 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 19/29] arm64: enable PKEY support for CPUs with S1POE Date: Fri, 3 May 2024 14:01:37 +0100 Message-Id: <20240503130147.1154804-20-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3EA95100028 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ji8rqa48zkbt8wqg1smkctwp8knbahu5 X-HE-Tag: 1714741379-936196 X-HE-Meta: U2FsdGVkX1/b5ehPRPyKvgqNwtd+YJJtZ+SHk8Si+ZKd06YVBbnpAzrgjoB8hmiME8IQpxM2wjJgGfpfvRBwTbdF0XAQSO3vYAthByHipDq1iQ5NE9tty09mO0Fr3Y5lxolzew9c3NkUHhYEZeijusMPqI2yAnwThdcvenZzuDgjo5EIjjBEU1Wqk+CuNiedgjLEdIYK1Uw0Eg0IHUFxaOsehZ+aw0VQl1pCMTQfy5RBZnD1zq72K5ktPuE3/jglyuTbJus9MpjlgH/KJ+82HkiaLI9kmUb2Oy3xT7j923brW9NabVxEKOOFKhNFakZh//P8KmQj8KSv8HXDeEuTUo/nyv9aWGuW3ylc8EHXpS4E0eD/NVUMy2B72MvbwlYa3guX/wjDvW6cWWzkiy7JDs/RmveVPmMO1/A0d03iGLAazzSr1WvyebjwPJOB1HNZ/WrDGaKGu73eg1f1VR5Q9HMk6djBoJqHYPe5DGn1pjJo1IVadmom47WCj5qvsi0D25LWhz5d1ANif+rMLjWaE6K6tWVHT9A8eoAJ0wtwURlHi8IM4ywS+1K0fduXTPK0nDHAnk3giDNGxxdYhgqb1VGBg8Uu1OWgTEA21P1q09XkbnQ26FSpZaC+sJf0IF355Djr7zd7tseZOvU1MwyP2sAxEnhmS1PRpx6ix7AvLzdZYGl33CQ1QNgikZNgHUY+x1H7gvSVqSjQ4c49MEW3VEx9gCcsgfJAiz2pce6TmbWh47wCmXhF8EnkyZBfH4Trhbn8fzzHKk/SmGT7FmS8i3OA7sCZENz7/iHMaSyH1J933pp/76W+LdGJ+efWi1iWyp5sQIa/FIytc1axUsqcc7QdnJxROi6i7kofnkC+eaAWdGAu3brYrCvyigY3YFoS1LxBar15p5anIoCeoAWI7VTC5k8oLQqVvlqaAs54VzqhNPHTDt8NF/qauRH+HTyKmiNZdd+FUtyS84SdaTV jDzHGWs2 3KaJc8/X9rK+5/q4+Kl2wsfJqkQxN9JL+OKtFwf7Yad6LM0vsi2RbR37qSMHcR9l56EkdWc2vIxeA4EkT1SRDZ+grJSuv84ZdH6/FgcOv96bBKgfksRhm2t92MaBHwCPKbugq/Em+zqzkhWKLdXs6ixFAjjvcaDJryVhA3f0iRyQO2OjnbiehXNXS3clLOIEtz/758zhThCIi6v1ZwulvvWphUA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that PKEYs support has been implemented, enable it for CPUs that support S1POE. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/pkeys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pkeys.h b/arch/arm64/include/asm/pkeys.h index a284508a4d02..3ea928ec94c0 100644 --- a/arch/arm64/include/asm/pkeys.h +++ b/arch/arm64/include/asm/pkeys.h @@ -17,7 +17,7 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, static inline bool arch_pkeys_enabled(void) { - return false; + return system_supports_poe(); } static inline int vma_pkey(struct vm_area_struct *vma) From patchwork Fri May 3 13:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652799 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47530C4345F for ; Fri, 3 May 2024 13:03:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C69066B00B2; Fri, 3 May 2024 09:03:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF3F46B00B3; Fri, 3 May 2024 09:03:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6AC96B00B4; Fri, 3 May 2024 09:03:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 85DA26B00B2 for ; Fri, 3 May 2024 09:03:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3AE3E140F7E for ; Fri, 3 May 2024 13:03:04 +0000 (UTC) X-FDA: 82077099888.13.05CF97B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 8B90E1C001B for ; Fri, 3 May 2024 13:03:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741382; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eB19ddR2DWz24xNZl612MbQy7DTD7VV83qSPNmMAQnc=; b=oVJRmTCKawHcAaE2qVS84LmqgBGdBHXSjdAMywfisw7lKC4y1nillVfOuHpd56TeCUR9R/ 65FTiIxocRj46Lvslt7Iks/pzPd1wScCve7/5rQsN+VWWSRqhjMhu9cXt/B14NLSgmF/A9 8XVlrjd25RCog36OiSMaeCy+d9h/GPg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741382; a=rsa-sha256; cv=none; b=mRQgG2j6+utlRK26luJdhr9rpL7YMQaoS1ckk7I/dPiiAp8QcKVOdlKc5LJYgzlivPnk71 l2O8eciI95Q8Vi+Tqig+LyACI+4/1P/W5VW3N00eHDakf1BCp9iu9Km7A2aL5H7TgINLZZ jR8ZxeOboc7tHgo/FiyQBpE0TnVQRSg= 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 2499E1758; Fri, 3 May 2024 06:03:27 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7F013F73F; Fri, 3 May 2024 06:02:58 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 20/29] arm64: enable POE and PIE to coexist Date: Fri, 3 May 2024 14:01:38 +0100 Message-Id: <20240503130147.1154804-21-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: t7k1654kjxapi4mnc6cxfifsrwyea1ro X-Rspamd-Queue-Id: 8B90E1C001B X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714741382-629576 X-HE-Meta: U2FsdGVkX19WVjQzAmeUKxJmP43YlEXXZnjES0xwCb2shk/X8Psu3b0cDph8oPk1ft4FKH2mEQX328DDbkvrxKi6kP8huiDTWv4FvHMXbFt59lNaSHowY4VNWumaXDDtvL9Pi/jHdahuTlx9g5RNpUhrrAN97hG1qKfjRUkpZCd+jgdEmsfa6NdtNS63kU2169GxTkBucN8LtX8sJWoSC7Xy9eqPO/U1qF5xcpGGnaM3A9eX9pQck89n0079T8+X7dL88KpYz0+m/6XnoMC+t9iO4gdzoiKMv5NNQdMbDsxBYcW79EWqzWJi8EvWxrLZ7UWf0ZD7cmgGhvTmPzDm5w7kZolEuVNtZsK2baUBS7gMbyrId2GAywIQ2YVcniu5Y9DTm9niUZ7dMJkhuNkcHLMwnVM6wDz8Ssfna13L5s7y0HvHusuUxp606ChstXcaA+ZrmXvrolxpAlUYE6JcN4VYNbz6YPnC/ZJ4llTKH17VWDBarch6NCCc9ZwAiq1vGwoIK0GIWpiU6bL9VCBOPFbgxSigTX9VAa8z7Im7saG+LIVgyJLhbnBS8IsmfmMrj44GUF4LiVGVc/Or6MwvuonnTxalizcYs9xcoDm8PFRYIBrhu53E3lfQ1T/tYgPTOfi1dPc5akxIvUGbwfURPEyYGW9WJF2Z46OtBNZncjxCSh6WuhSeQJjnS+7bveI8uljqvqj+0VQ12ZaZGfZqe2RnWCrRIvYn5cqnRcJtaHxfNQ1Z5JKgWM9xxO6PDNUdOQLsWbOuoYzjr1oudwPEX7xEZQPgG6GSBSOm1bWdHDaBdEQkg9GxG89nutUV1tLrthTRPQVsG0FTIIctDduf4fdf0AES0mxMVI6aPgPh8JQfsCHAP1D978nAOCc1TNND5y/BNQa1vEFA/0MMNwwO3ugMJZTAPkNe9U85F9SEs3n4DkUDoDakFMJ6QaTgxQVI9/vZ/tTOnZi62i6vzZR p9T0w4X6 NAt9MFu4KjTb2b2Ut6xA1iI4qrZb80B6kOEbDb5jMGirzrLCw+HJN8w4Va6KEWO0kEhEyRD5nmRGpv8nAZo1RC7MVxm5tQ18VlE67g8ktPm8aIytHQG74MoaTgFVWLwGJArFGFDDSahoxFvQuAjsrny0tcLYFUvbps/jTC2EP9EHtFn+iDMNLNmuCOyIyaK7adzwbIRwuzxcNGlLxqiI8yRFtABBNZ5gQEe2z X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Set the EL0/userspace indirection encodings to be the overlay enabled variants of the permissions. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas --- arch/arm64/include/asm/pgtable-prot.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index dd9ee67d1d87..4f9f85437d3d 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -147,10 +147,10 @@ static inline bool __pure lpa2_is_enabled(void) #define PIE_E0 ( \ PIRx_ELx_PERM(pte_pi_index(_PAGE_EXECONLY), PIE_X_O) | \ - PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY_EXEC), PIE_RX) | \ - PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED_EXEC), PIE_RWX) | \ - PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY), PIE_R) | \ - PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED), PIE_RW)) + PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY_EXEC), PIE_RX_O) | \ + PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED_EXEC), PIE_RWX_O) | \ + PIRx_ELx_PERM(pte_pi_index(_PAGE_READONLY), PIE_R_O) | \ + PIRx_ELx_PERM(pte_pi_index(_PAGE_SHARED), PIE_RW_O)) #define PIE_E1 ( \ PIRx_ELx_PERM(pte_pi_index(_PAGE_EXECONLY), PIE_NONE_O) | \ From patchwork Fri May 3 13:01:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652800 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8D3FC4345F for ; Fri, 3 May 2024 13:03:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62BAD6B00B3; Fri, 3 May 2024 09:03:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58A776B00B4; Fri, 3 May 2024 09:03:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DCAB6B00B5; Fri, 3 May 2024 09:03:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 19E9A6B00B3 for ; Fri, 3 May 2024 09:03:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D1756C0E5B for ; Fri, 3 May 2024 13:03:08 +0000 (UTC) X-FDA: 82077100056.14.467B639 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id F05054002A for ; Fri, 3 May 2024 13:03:05 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741386; a=rsa-sha256; cv=none; b=7tOhNJgec1MRK4uoVbLAs32pSb70qkKVkoKQqNqeBfUj4uQCERqtp8hVAZawkLWeR0wK8D yINcGE1vAAUkZ/yxwaMpFWMI+Ht8NXioxFjG1rCJk/cqfozhLXSyxpxwXlG31g2dhclXyH ay04g/bYSFgJ7ovU4EvNVG/wfp4ogw8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741386; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P4Jt4GmyL8MRvVkxRMnAEmqY2NaJe0tHqKLTGMa5hho=; b=ZoUiCLoIqOg2q1jdI7CMWBk4w/JFlCEu2ZT/tAhq819TtARa5xMZfTZHVsJ0vjpXWBIj0p pwst7VMx3YDz2JrPy3eCf2w31HbXD7xIM4bfpdH4XjUJreIXSv/S3fmZZ/Ym2xO7yWsdwa M3JOs4u9JGCJQgWrjNf1NyusTjW4wPg= 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 70D791756; Fri, 3 May 2024 06:03:30 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1F2EF3F73F; Fri, 3 May 2024 06:03:02 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 21/29] arm64/ptrace: add support for FEAT_POE Date: Fri, 3 May 2024 14:01:39 +0100 Message-Id: <20240503130147.1154804-22-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: yph9euf4sijb5bqg3s88tdesbzmxtjex X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: F05054002A X-HE-Tag: 1714741385-222457 X-HE-Meta: U2FsdGVkX1+CqpgjoFkefROq0QnJdow85NI5bTnffwtSknGd+Uws/ax+QTATElQq6fu9xzXKzsD1JKvcMPvsO24Adl4ywIgc6Jo/um+/YCzGkVU/nawsi895ki+WD6b5RBZyPWtLmw5RDixmMZYVpTqdKklSZyrFvDS35rFM69fyKnTmfzDd9J0Hb76gvSyzNjOZXDKvkBACImCOFvrfW5eYONwL2k2TuJ7zkefzGZeqPgPtZMyQ8bKhJds1VFEqm07IA8lSpZ0pS4tmbuDhJLEPic6sTR162UGX2eQtjKO9uZqIVYrAkfns05piVtKQLu0U1A5OVH8AIzi7KMjogronm2eCJsAss15QZkiA4GOlkoHwUTDRSDKfof8ZvxaVgM1yvyN2YKZvr+BauAmOPwznHp2ORueDWoPytZr4/X+REfnMa+eNe4NkE87RUlTSlo/ETj513bIUZC02cfjfO7RCh4C4J2Xi28tjynzB4yESlGBo2c+JULe1BqM7haeMEfFV7KvVU0irDUclro+vvkuBvH4EK22YeXrVX4MJteT8qKBE1M+xEFj6nSKQp0RS4FX7kE5vPovr1FQJlEVYNnOleS2IKbvtn83sLhDNttztPRkrTCdSIinULMBa32cV2NYB6lk4seFmeO2TOQnqtK8O1t/+VRDS0RoWfxqA81zFGBh5T4dPsybYpl0vn4m7rd9+wupQmQ/DxBnURS77sMVPm5t8ZNXpZ4fgNnc/0vDTfQ1+Lf4Vbt3Jku1rKDJej12xk8wE/lBfEunk5wCjpnj2B9Oa7uju5lzu2F446CFXMrJMrFbksfEuX394Y5m8dOuYy4ahcL0aZJcLHNYOZwD5pHBjIBlChZtPXN3Mgl3jIIX1G3oShXimwBBpz7pfqCiFj6A6sKghYfsqqNSj2kMgxC7d80QlbmnGUqBLwhvy79WW8HyL+CBSMO548Ls5wMdcvarrChlvZQ8D4Uz 4qbgfD56 VYPbjTI/Av59CI7/GmTSy1zww2O6IMFp+Q9z6byJCX1AMFSb0187J3eHEM2ino/1pFVCcrAMnz1s8Y2RK5Rel8lLqRCa7LZcvsrlSkYX0cElMsPJKbheK1kYjZv5hWTwrtOljIJnn2R/X4DsOWk5lhYlpmwieb96SwxqDZo/cTzAUAXNMY0o1iiyWpiyHSlCP/2GTk4q36W4TJ4T4I9EbqJcXP+cP9q0lbq3IARVm9ENyuiZ+mR/r0GQhMGTsH9FccC8q63b+H4h8eAI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a regset for POE containing POR_EL0. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Mark Brown Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/kernel/ptrace.c | 46 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 2 files changed, 47 insertions(+) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 0d022599eb61..b756578aeaee 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1440,6 +1440,39 @@ static int tagged_addr_ctrl_set(struct task_struct *target, const struct } #endif +#ifdef CONFIG_ARM64_POE +static int poe_get(struct task_struct *target, + const struct user_regset *regset, + struct membuf to) +{ + if (!system_supports_poe()) + return -EINVAL; + + return membuf_write(&to, &target->thread.por_el0, + sizeof(target->thread.por_el0)); +} + +static int poe_set(struct task_struct *target, const struct + user_regset *regset, unsigned int pos, + unsigned int count, const void *kbuf, const + void __user *ubuf) +{ + int ret; + long ctrl; + + if (!system_supports_poe()) + return -EINVAL; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, 0, -1); + if (ret) + return ret; + + target->thread.por_el0 = ctrl; + + return 0; +} +#endif + enum aarch64_regset { REGSET_GPR, REGSET_FPR, @@ -1469,6 +1502,9 @@ enum aarch64_regset { #ifdef CONFIG_ARM64_TAGGED_ADDR_ABI REGSET_TAGGED_ADDR_CTRL, #endif +#ifdef CONFIG_ARM64_POE + REGSET_POE +#endif }; static const struct user_regset aarch64_regsets[] = { @@ -1628,6 +1664,16 @@ static const struct user_regset aarch64_regsets[] = { .set = tagged_addr_ctrl_set, }, #endif +#ifdef CONFIG_ARM64_POE + [REGSET_POE] = { + .core_note_type = NT_ARM_POE, + .n = 1, + .size = sizeof(long), + .align = sizeof(long), + .regset_get = poe_get, + .set = poe_set, + }, +#endif }; static const struct user_regset_view user_aarch64_view = { diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index b54b313bcf07..81762ff3c99e 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -441,6 +441,7 @@ typedef struct elf64_shdr { #define NT_ARM_ZA 0x40c /* ARM SME ZA registers */ #define NT_ARM_ZT 0x40d /* ARM SME ZT registers */ #define NT_ARM_FPMR 0x40e /* ARM floating point mode register */ +#define NT_ARM_POE 0x40f /* ARM POE registers */ #define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */ #define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */ #define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */ From patchwork Fri May 3 13:01:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652801 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13C52C25B5C for ; Fri, 3 May 2024 13:03:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FA646B00B6; Fri, 3 May 2024 09:03:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 674976B00B7; Fri, 3 May 2024 09:03:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45C8F6B00B8; Fri, 3 May 2024 09:03:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 22B4A6B00B6 for ; Fri, 3 May 2024 09:03:11 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D5579A1E86 for ; Fri, 3 May 2024 13:03:10 +0000 (UTC) X-FDA: 82077100140.21.C363C27 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 2376714003F for ; Fri, 3 May 2024 13:03:08 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741389; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eZ68NJa2WyaTC8M/kZMZCcQ9BNgJXdlMN8QEbFpkniU=; b=kXJ5pfETUOoKkOt8H0lk60c/TLwb808fIhRB91cA2uVeYR6NXAcDVDJAikjC3i0kwf7YvN vmldyvSXKUjvafAvCeqsrj8Zbd5CVLGUHYq2SlCSbSK6KOV/mFZgIjinlpgKT0ICwnzacw rjX038w7mlMkSfkwXHtFOleltdqAcZA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741389; a=rsa-sha256; cv=none; b=4TGKDOJjx2nZ6EFkkYL2AID2cB81a9j4hD2rsz0vZYJJb4A2a6k7bBLWYtX4W4BPW/0FK9 P6AcVa4y8C7+9yMjmaBuQLZjFyRgxYCUshBd9cfIuDpWVl6gO80PUuS4/2igIzjKjEAY3N 1/uOoGw5e+Rmd4Uih7fm2T2SMjYTfH8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 BC8511713; Fri, 3 May 2024 06:03:33 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B5063F73F; Fri, 3 May 2024 06:03:05 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 22/29] arm64: add Permission Overlay Extension Kconfig Date: Fri, 3 May 2024 14:01:40 +0100 Message-Id: <20240503130147.1154804-23-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: o8jnajgdtqai1kk4fywgm7iogixgiryi X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2376714003F X-HE-Tag: 1714741388-39603 X-HE-Meta: U2FsdGVkX183Oi3dqbtyHquYpPCZCBA1J7WAMWn8k6PNq8AEua7yCd0UKuEIYlZBRmmBpb9zfg4QvoLO4fUVFXWTW7SSsteahiZIF00bgoqL279+ZNUNeravJoB4iuvQXvYW+XZmbk9LDKsGlbSBbtw3PLPvq6ZkGXeWY9GaexaWyqPpOVe8UelgxKy2oAGyBYUy6h9MPd7ncqqKrV+dgIHOi99uBjkpz6eSMJs3NERyOJrcGdF3ae+BfB1FjS+tkc7Fps37Cde82T6FcO/AJy2ZmaNNmLGcILg5/6KexLov2hBY72FNM59mtG56cRYSJoU9ceV+ATgQvyhquu2F6ZTa5I59EiD3PcTtNDqmEarDvwUIREpbPeVj4rHnnT84Q66+rzQErF4rIEp0atOub4RKQsDBkYlthEIGxIc5CQ6i5fNW9/i2VlAv88YfpLcivo6n8W/TwQP+CfC0DSO4wLNtHCLvzLJ9bqrrAD3L5EIqJ8MPGoVjyFcn588ohUxPUlfoJGWBQu+75zJcLAKNlyDg35NhnHUIx7fIb9mbkNNeAzsd/VG/hFlW7h4KSW3J05WMw4rup6goc6BgCZZdenj7eMrLeVRLJe/1Ao6VH/pvFxArXukpD9H/um//iS7Jen7VcvW4SD/CAxMxPAW/cEEhwklQtwJNb3fctMmLBa1eAx0dROiMzItzy2EBh22OwTT6ZpvmGdR8MgsRlU4AYKT4/RLL9+cg97mnTOenOCpb+hAu44T+2bBdtoEA3izXeh3/Pkc8mK2tgSc/f84O3A+5OA/4O27kBK0Dzkf1LnBaR+MgjvZmZYBbkG3KwAhXRjYNWB87wQjks6CkVM8UEWfdGPqS7E9Mcs3TddWHyoF+/OvJArio51XvScOEDGncaIal4ji8dX9gapjabph6bkxPr4JdsNPS9XQY8XdwsaRFxhzR+e0rdCz+px2jNb1ut+4/C0y01SO7b28PQJp 7PatgDQE Qe9KqOPumengSU7N5nyeIaOkK7nNjx58s2p7pRnEjYMIGRF9TLSgQgpR0BVUgHf/Z+7zaX0ZzijLqBZmsDZq2+1fAgeY8hIsaLcKYj9MkKvN5/PcKaBhyYBx+jMj5FjJeWCZ7rENRIoyZCqP3s5Cuo1MHoMGR1DqgHK21jzAGhUYFatp2L1toGniSgezNOWzS7QZNNrnqFc+8LQtPlx92U3wKRg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that support for POE and Protection Keys has been implemented, add a config to allow users to actually enable it. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Acked-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/Kconfig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 7b11c98b3e84..676ebe4bf9eb 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2095,6 +2095,28 @@ config ARM64_EPAN if the cpu does not implement the feature. endmenu # "ARMv8.7 architectural features" +menu "ARMv8.9 architectural features" +config ARM64_POE + prompt "Permission Overlay Extension" + def_bool y + select ARCH_USES_HIGH_VMA_FLAGS + select ARCH_HAS_PKEYS + help + The Permission Overlay Extension is used to implement Memory + Protection Keys. Memory Protection Keys provides a mechanism for + enforcing page-based protections, but without requiring modification + of the page tables when an application changes protection domains. + + For details, see Documentation/core-api/protection-keys.rst + + If unsure, say y. + +config ARCH_PKEY_BITS + int + default 3 + +endmenu # "ARMv8.9 architectural features" + config ARM64_SVE bool "ARM Scalable Vector Extension support" default y From patchwork Fri May 3 13:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652802 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E395C4345F for ; Fri, 3 May 2024 13:03:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDF776B00BC; Fri, 3 May 2024 09:03:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C694D6B00BF; Fri, 3 May 2024 09:03:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6CAE6B00C0; Fri, 3 May 2024 09:03:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7D7446B00BC for ; Fri, 3 May 2024 09:03:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 39B39120A80 for ; Fri, 3 May 2024 13:03:14 +0000 (UTC) X-FDA: 82077100308.30.B1AFCEF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf05.hostedemail.com (Postfix) with ESMTP id 81A3E100031 for ; Fri, 3 May 2024 13:03:12 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741392; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x5qaRrvaTgsp6IZ5lmLtMUtBFAvLk5BnoCjm+fv3M4I=; b=Oa/imXj48iXYlD06jYEwl/UfDPBrysOUB1OgyzqIBMCj2ToC62v3qJXg5sd3+T00OzTlJ5 lWlrhGyxNSebfdYAzao/AVErxkeq2H/TLPls4dX7UJOGc2QU+mbwlWlPNtAjLv4XjOg1BE 7VznSu4v+kVmcwGZlfuP+7WNslL9EBY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741392; a=rsa-sha256; cv=none; b=Ozdp1JILBn4CLrOSWBmQbGqDCdzd2j+FG9mjwnvYM3O3bWyuOvk/+XJlfbfn9VbN9Pw8dp 6SkI4jo67DLkMXoAnS+lvxes7hPr6M/9JV0itJIqZWHnMPLpngq+mQ3rWqGpHsuE1Gr3ZT DJpCZA7EFytfdpnqBRb/6isa1n+Wrss= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf05.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com 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 14B72175D; Fri, 3 May 2024 06:03:37 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7DF53F73F; Fri, 3 May 2024 06:03:08 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 23/29] kselftest/arm64: move get_header() Date: Fri, 3 May 2024 14:01:41 +0100 Message-Id: <20240503130147.1154804-24-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 81A3E100031 X-Stat-Signature: 7658q75krrka7y58h4wtnxy8fhha8k86 X-Rspam-User: X-HE-Tag: 1714741392-302029 X-HE-Meta: U2FsdGVkX1+IBV1Gykj6wwVR2YIYg+WzN7cQvDTmNV37VjAd+RaYqR+rbRJOSyHEaZAnCImgBxRkVIQViu8K2qDJq0B2QO4g8GgBA+1vh93OQK7vxIvnDFeAvxIHcrCTi6daYhIAhh9sf5IKG5NHSxPwhjdIyeOkUtOyuYkyDgm6yO9wxXHAf9wgQ4eVz6i6QiGQAbfTBggqDlQr4sY3dIZVe71SMLw1COIMaZ9NRCRAiaOfvXj7k2jC/J9RIlABS2MTDdylmtZ7csakj7hbY/Bra+pI6zx86gJgwSJwgLRmF2DDMMzLIN93JGxuqtKRmcluR9EyCbeRlgYgFrqQtmRrTDcheGuvQaEXYkBnkqLawzDmvzFQGBLEEFMBRwQxdtfj1yCszqNv7tYZJyY5Kdrmd4mHDaUQJk0FAEk5mlRlSA1j26CmznpLh3Q35a57LHH31fmRiCyC974WJ1xRxY5Sq+n+j/uJ00Sctgulk6NQEVySpKecYtktWrqTpQtzGFOXqc4kQmqo9iidPFo+/IhaeWVglcYG7x4SMQSOkIwIzHxme2JdvauIflh+GMRZh+u/xVtiLr1AKfk+RXC3T7km2r/mJn9a58i70t6r2bDNxTDqLiBhssRShNmUnK1UoYstWS/0H6TAzwhzpdILwoA9HN/u8rqQwsA44A9/3hiXJ1DLPKDmtQO9llJ/qKFurMp2PHZkCxCXgd+uXushFvZILuj24GaWddK3DfddPyjV0J8QOPAGWfJR/s85Bf9WGKQUBwh+frDzSJHN+tq+QYQjin1PNZbran/huoYLdyIMWKEKh8V/6RGD29+WnKWxamzqmvNpmQ8tyOn41rW+6RiQpcu/OVFmorsbbDwq0zvQJiJ3hObmxHUP28ILvsbC+zlHlFIsMBlgFNPRBPNCaFatLLIHNAYeUMjU9Id8tu7PLkle5NIab4jbWtHoJQl7j7hnpsx/s92LH25vuA7 c2amy8oP VlIEDJH9lKIMq8LTvuMSkbjwikfLWJajgaReNkR0UVTvs1LLcjxC3xRe4C29m3wPWZa5TTExk9ZyLHsXgYxVx5Apy8tM2SMT6NlXUz0MDLXEhWBgzFOA97TNFswkzM6Bcex8BKPWllZ+IPV3cTTl5UWV9X+acawRwVFSf+0L36iYQvgoZ30dnVlMZ0B+XKAVnujQCYDQrf2Ayu812/5OrbxTgFMCX+DRT/Kabr2e4+T7ZpUShMsMGMQQHGe9r1a63Yq2ZMChKO13qcJZnk5vu9rrxkvHg+nRddB0I1XkESKnpFlkixsxwYq9ZYZ4KD3BUeuPDwiPOQCMnHgyNOhf0wtpegT3WLpz9MepWgEMUw0lnIyUwh9rDFKdhUQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Put this function in the header so that it can be used by other tests, without needing to link to testcases.c. This will be used by selftest/mm/protection_keys.c Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Shuah Khan Cc: Dave Hansen Cc: Aneesh Kumar K.V Reviewed-by: Mark Brown --- .../arm64/signal/testcases/testcases.c | 23 ----------------- .../arm64/signal/testcases/testcases.h | 25 +++++++++++++++++-- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c index 674b88cc8c39..e4331440fed0 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.c +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c @@ -6,29 +6,6 @@ #include "testcases.h" -struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic, - size_t resv_sz, size_t *offset) -{ - size_t offs = 0; - struct _aarch64_ctx *found = NULL; - - if (!head || resv_sz < HDR_SZ) - return found; - - while (offs <= resv_sz - HDR_SZ && - head->magic != magic && head->magic) { - offs += head->size; - head = GET_RESV_NEXT_HEAD(head); - } - if (head->magic == magic) { - found = head; - if (offset) - *offset = offs; - } - - return found; -} - bool validate_extra_context(struct extra_context *extra, char **err, void **extra_data, size_t *extra_size) { diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.h b/tools/testing/selftests/arm64/signal/testcases/testcases.h index 7727126347e0..3185e6875694 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.h +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.h @@ -88,8 +88,29 @@ struct fake_sigframe { bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err); -struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic, - size_t resv_sz, size_t *offset); +static inline struct _aarch64_ctx *get_header(struct _aarch64_ctx *head, uint32_t magic, + size_t resv_sz, size_t *offset) +{ + size_t offs = 0; + struct _aarch64_ctx *found = NULL; + + if (!head || resv_sz < HDR_SZ) + return found; + + while (offs <= resv_sz - HDR_SZ && + head->magic != magic && head->magic) { + offs += head->size; + head = GET_RESV_NEXT_HEAD(head); + } + if (head->magic == magic) { + found = head; + if (offset) + *offset = offs; + } + + return found; +} + static inline struct _aarch64_ctx *get_terminator(struct _aarch64_ctx *head, size_t resv_sz, From patchwork Fri May 3 13:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652803 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DD38C4345F for ; Fri, 3 May 2024 13:03:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A62C6B00BF; Fri, 3 May 2024 09:03:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22C456B00C1; Fri, 3 May 2024 09:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07F5D6B00C2; Fri, 3 May 2024 09:03:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D843A6B00BF for ; Fri, 3 May 2024 09:03:17 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 996A51C1811 for ; Fri, 3 May 2024 13:03:17 +0000 (UTC) X-FDA: 82077100434.07.AEFC882 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id CD3C84001A for ; Fri, 3 May 2024 13:03:15 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741396; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nf0bnlih327pJ9LVoEnFCmIEPGMwPw+b0fVcM0ZWIqM=; b=Y0+VoZypuU8JRSMJSNGgWk3bWUBf5bEh3QrS6uYbTSpfEwgzaiBVcZoaB4t8fHlskkM7Oy cLKZPhs798661/AFGszFb6xcdnLLYGYw1LnabOIvC6xrzL1e8d9TMwXMxmiQKzdc7HF6RM XIArusW+Rx+zX54iVt83bCf3C+gQNSo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741396; a=rsa-sha256; cv=none; b=RfIaMHjBakEM/roOIgTJI9Lm7uSNoZknVY+VRlfWlCEAICdC7n4IKWDqIycd9Sdjf6Z9rZ 5+KLokZ0yDepo/pbOqLr+e8g1L2LFLRNIKtLN1tkudqwKjBeX85hYMAskhl3blTGZFmSWy Kx3V2ExS2+L5vludVPHMu2N453vPjgA= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf01.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com 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 6752F1756; Fri, 3 May 2024 06:03:40 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FFD63F73F; Fri, 3 May 2024 06:03:11 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 24/29] selftests: mm: move fpregs printing Date: Fri, 3 May 2024 14:01:42 +0100 Message-Id: <20240503130147.1154804-25-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CD3C84001A X-Stat-Signature: g114c8uia6suu3u385cckiwm87gc7us7 X-Rspam-User: X-HE-Tag: 1714741395-327735 X-HE-Meta: U2FsdGVkX19yIjcThxu5+5ZxSD0mMxAvARwBCJ7DF1EMW/VUHPPyPpRPLMv0ONfUeF7HHA3vvq3Q9Ona5dji9OjiZy18PiLFS8X24QL92MykAJ/qs/S1nfVcZkvmq7ZlX8WitV3XH743YAtEeRoxNYTKVZbcRwUsd+ecEMnu+M8MtRWeoptERLbka/tke9uv93p9011hSVAvFTTQrZ9RddjiUbfsYJodoycMdtcBc846cgPTlMThpmqvuu9sja3NG8yPnCMy4BS82hpSXtbEn7LF3TwRVMtlhmmnALtW4a7vu16XsNkc0M4mNiNCVM2zF1i5KLh57vplCLg3hbkyZyyB+h19uNW0uZQHZtYNenrR9EOhYIhwqIcOauqFqFU8cgHb0AIZE8Adxhen1Q2ARwQzqbd1ozOZ2W7xi8uBg0xreTh7oH/TJiTGvIOMBVCyMau6i8o4fOdK64OFImTJmrRqR1/yC9wNw4bqUR3wO6Mllh9jVcP0Hll1Njln+o7oFPYXVaHy9CV6A4EV/CYeUwQXnQegIqC3d3K8+dtG91CqSC0oEcN0ar8tQu4vZmC3u+RcAnW6/P4YVTy2wthChzsUUbo2DmzaDWTxYS0uw+Z4MLm9o5G6sFquSemfTjxnr3sBdGS7CpPv/YLCjbAokHGx0Fn9+K4SFwIkBON/gwolVpYFmQ/VflilLJk3/DLVRNnZ8NgdQbIlKsfT/VaDx+CDBn/fLxtjTJTqlxsKyzt4la5gMN+g6c3+YYryjNDgtE9BPUR/gSHYZckWS2/KC6S2JHSW6kebSP/MwztgysAgH2h3fv+q28/IfI/ia2MdHH9oLwEMfSMWeSA+ScKbZgLaUsT4v7AgE9+YYPyDeXuXeh20A91ivDpT1CNdAEpaLX9RwZI68lCYjj2U3lJer8wZ2mh8dP4u+KoXNKUR94B9hbjQYgPLffXw9G1P/fMCyngzZqe5Wa3PPxtcD8a qe+5f1oB HT2s+TTVTiK/ugKpRBOsfg8xgfYEXwJWTBLB7jLoacupt8m0R9iEMWdw78ITtSvaX5px6IGMVuaednrMDkZ7GmA4R4/sHH+HuZcAxkBfytHFkb0l+bXPzGF1fa51nPl35ANwt+WFBF5qgbg8bhd3EJBp5imtk8sbYaD1zqVba+uVsyyoqvmA0NJ195CYIqNrKeXusZl7VcdecKWdvrH1m1jjNZ4RLtEwgc1ON++ugGu/p3TcKz8guxNpSPSxl2PJE+PqRHvsLyJgy5tZkQPHd5IX7crhsad6YoiZAxAl3M9Ho+mLaMuHTx+iu5ADDNoJxNSLH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: arm64's fpregs are not at a constant offset from sigcontext. Since this is not an important part of the test, don't print the fpregs pointer on arm64. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Shuah Khan Cc: Dave Hansen Cc: Aneesh Kumar K.V Acked-by: Dave Hansen --- tools/testing/selftests/mm/pkey-powerpc.h | 1 + tools/testing/selftests/mm/pkey-x86.h | 2 ++ tools/testing/selftests/mm/protection_keys.c | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/tools/testing/selftests/mm/pkey-powerpc.h b/tools/testing/selftests/mm/pkey-powerpc.h index ae5df26104e5..6275d0f474b3 100644 --- a/tools/testing/selftests/mm/pkey-powerpc.h +++ b/tools/testing/selftests/mm/pkey-powerpc.h @@ -9,6 +9,7 @@ #endif #define REG_IP_IDX PT_NIP #define REG_TRAPNO PT_TRAP +#define MCONTEXT_FPREGS #define gregs gp_regs #define fpregs fp_regs #define si_pkey_offset 0x20 diff --git a/tools/testing/selftests/mm/pkey-x86.h b/tools/testing/selftests/mm/pkey-x86.h index 814758e109c0..b9170a26bfcb 100644 --- a/tools/testing/selftests/mm/pkey-x86.h +++ b/tools/testing/selftests/mm/pkey-x86.h @@ -15,6 +15,8 @@ #endif +#define MCONTEXT_FPREGS + #ifndef PKEY_DISABLE_ACCESS # define PKEY_DISABLE_ACCESS 0x1 #endif diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index 48dc151f8fca..b3dbd76ea27c 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -314,7 +314,9 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) ucontext_t *uctxt = vucontext; int trapno; unsigned long ip; +#ifdef MCONTEXT_FPREGS char *fpregs; +#endif #if defined(__i386__) || defined(__x86_64__) /* arch */ u32 *pkey_reg_ptr; int pkey_reg_offset; @@ -330,7 +332,9 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) trapno = uctxt->uc_mcontext.gregs[REG_TRAPNO]; ip = uctxt->uc_mcontext.gregs[REG_IP_IDX]; +#ifdef MCONTEXT_FPREGS fpregs = (char *) uctxt->uc_mcontext.fpregs; +#endif dprintf2("%s() trapno: %d ip: 0x%016lx info->si_code: %s/%d\n", __func__, trapno, ip, si_code_str(si->si_code), @@ -359,7 +363,9 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) #endif /* arch */ dprintf1("siginfo: %p\n", si); +#ifdef MCONTEXT_FPREGS dprintf1(" fpregs: %p\n", fpregs); +#endif if ((si->si_code == SEGV_MAPERR) || (si->si_code == SEGV_ACCERR) || From patchwork Fri May 3 13:01:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652804 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5509C4345F for ; Fri, 3 May 2024 13:03:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75F4E6B00C1; Fri, 3 May 2024 09:03:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ECFF6B00C3; Fri, 3 May 2024 09:03:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C5F36B00C4; Fri, 3 May 2024 09:03:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1E4176B00C1 for ; Fri, 3 May 2024 09:03:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C4FC140FA8 for ; Fri, 3 May 2024 13:03:20 +0000 (UTC) X-FDA: 82077100560.08.8BEE11B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id 1709140013 for ; Fri, 3 May 2024 13:03:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741399; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZzGCdLsbW43H8Rf7dPaJFclq8AIKm27xsi7X6Tg/o5w=; b=zdufott1F2Y8bva7S8s8S43IAsH8rppnWXgt6f7jdnkeZCcSWgJj9/1Q0/Yx3HRhgF9tFy QZ3o8a/+0ZnEhmbwrYiDhR1qZRxdwv+RuNaVgCHNf7HANesvzwxhywPgB3ygH834QvR46N Iyo6AMp8ijvwE6/kEmC6i1Gsu2cs3IU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741399; a=rsa-sha256; cv=none; b=u59Al4xUox3RWcOH9eX7jQ67ZVB8ltgmUYd4stnatYNBhu1uz6kXP0rmaB/cy6i06qBAx6 Air74A41ZeC2Mm/7Nv031Y008kxasA5hRKwhjyxP7eohSxjlfGLspPWPlNjeul1vWL/iE6 G4DxWoHRWqcpGXq3Luo6bQmPGT8IGEA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 AEEF61758; Fri, 3 May 2024 06:03:43 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E4C93F73F; Fri, 3 May 2024 06:03:15 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 25/29] selftests: mm: make protection_keys test work on arm64 Date: Fri, 3 May 2024 14:01:43 +0100 Message-Id: <20240503130147.1154804-26-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1709140013 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: sf7pcynsb16oo8dct474sutnih4mce7s X-HE-Tag: 1714741398-872577 X-HE-Meta: U2FsdGVkX1/brfru7+sjqKNdl++NwFvGNYfMcBfsdHQ+rRgFdZpK8z4vWYhq9Z9Cj+9Ub5/D5fyoXyEDuMs7XErLqbnKwio8HBWwBMmzP6aF8zs8w4UTyFPnOTDeVeHvkf55qIbSv1o4bTsuQFRIMgW1PcNQGL7iOy5eFXph7fiSgE+98kf78/Ej3jt7f0KparYQRby62DVmfOaw1Gm+nv2Fvk9+qiPXdcMOPvadvTEYjYTSnjLPjxXIYs0JFOswtJWrYk5Yh5Wm2ORUU9Zv48C+DpChfHnngPjJ3c+yXr3J1As64AcZSpKmYqs7UQWo3IoAJFiuXxD6PxgImjl3lur2YcA5p+bhDYjEQ2lWnjUa39p0lZfnQFl8qzyW7nvrrehyQvhHHoPPNvVgbO/GJHD8ysf+FyB0la+xHK4AL+24fzKcdUwU0e0AJIazfPiVdtbMXze7JrBSMow55WMtaUUdnKyUUmzle45/SkrBKW5zyxTUbCy5ncU+EJHXG6o3E1qksXRZCC8C/bK5exJFbYTJ/LZBpjAsxczLd5pWVWGILyelr9jAbhNLwQGlN8IFzT0cUSMY6sWi/x5ymu7aIdmDIQhvtMKuFwBtDZM7u6nkRlaG9UYv0ArSm4y9+yqh1nhr0IXyhQUzzZaU62zKh30TkzUYijCwZYo9XEgruJaZ/6zoMkdhdmile0CBD73Ku3PE6ChQ2z4PT0BGV6KHmzuzBIFv3kPrJgCg4e/0qcPwOfDtmABG72hIRUN00YeNIza5V5ONgBag/tz56JWdE9KzR6aU2I6x97ewDVrYIw8VrYJZDT9NCkM9naasDrPVCTzY1D8gqZyQrIzw3aLONqk1GutuLhECHlQsnR9Qzc8BgyxzqJTykDEE19p6mqF2tE1TbVEizFbY3M2KTlMPDKSzgtVQyw23ykbHWncW9mHrCC8CoFHcVkV/CpbKCSeTZ1+V7ODuXKtxX/+T/c8 1IBMsSVd x6dFFD260LjtAn7kj2JLS3ZcbHZ+LfyBYncZaJSgwkzS/vuVbjrO6zpYewkcjPJMrvEiHY76mEYInfx5FlWMQvISkbNTVhrCat0EXk4Bf9OP+zEQVrv6SEOo0UDvYXZTexgpDmCV6YUxcY7EYh8fTMsR7OXKmGnuJ99z7Icr0DHlxJLN2Mz5QFISupXDHNgK3Ky0RH9lZeoWq7OnSw7cSK8aB0pqWRxESDMgA1L97+ZgaFLHcsmh+Ahf7xNrn9WfyDMTqOtz65TnLg2+Z9AcJI8z45q7beWtOa4NrkYK4GXGFbbqwf0Dsy4w+PBbiiWElgHSVTACDUorzKQbbCics58IyDT2SAAdsPQt2p3A0oM/CyjhYXAu3cikuDQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The encoding of the pkey register differs on arm64, than on x86/ppc. On those platforms, a bit in the register is used to disable permissions, for arm64, a bit enabled in the register indicates that the permission is allowed. This drops two asserts of the form: assert(read_pkey_reg() <= orig_pkey_reg); Because on arm64 this doesn't hold, due to the encoding. The pkey must be reset to both access allow and write allow in the signal handler. pkey_access_allow() works currently for PowerPC as the PKEY_DISABLE_ACCESS and PKEY_DISABLE_WRITE have overlapping bits set. Access to the uc_mcontext is abstracted, as arm64 has a different structure. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Andrew Morton Cc: Shuah Khan Cc: Dave Hansen Cc: Aneesh Kumar K.V Acked-by: Dave Hansen --- .../arm64/signal/testcases/testcases.h | 3 + tools/testing/selftests/mm/Makefile | 2 +- tools/testing/selftests/mm/pkey-arm64.h | 139 ++++++++++++++++++ tools/testing/selftests/mm/pkey-helpers.h | 8 + tools/testing/selftests/mm/pkey-powerpc.h | 2 + tools/testing/selftests/mm/pkey-x86.h | 2 + tools/testing/selftests/mm/protection_keys.c | 103 +++++++++++-- 7 files changed, 247 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/mm/pkey-arm64.h diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.h b/tools/testing/selftests/arm64/signal/testcases/testcases.h index 3185e6875694..9872b8912714 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.h +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.h @@ -26,6 +26,9 @@ #define HDR_SZ \ sizeof(struct _aarch64_ctx) +#define GET_UC_RESV_HEAD(uc) \ + (struct _aarch64_ctx *)(&(uc->uc_mcontext.__reserved)) + #define GET_SF_RESV_HEAD(sf) \ (struct _aarch64_ctx *)(&(sf).uc.uc_mcontext.__reserved) diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index eb5f39a2668b..18642fb4966f 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -98,7 +98,7 @@ TEST_GEN_FILES += $(BINARIES_64) endif else -ifneq (,$(findstring $(ARCH),ppc64)) +ifneq (,$(filter $(ARCH),arm64 ppc64)) TEST_GEN_FILES += protection_keys endif diff --git a/tools/testing/selftests/mm/pkey-arm64.h b/tools/testing/selftests/mm/pkey-arm64.h new file mode 100644 index 000000000000..d17cad022100 --- /dev/null +++ b/tools/testing/selftests/mm/pkey-arm64.h @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023 Arm Ltd. + */ + +#ifndef _PKEYS_ARM64_H +#define _PKEYS_ARM64_H + +#include "vm_util.h" +/* for signal frame parsing */ +#include "../arm64/signal/testcases/testcases.h" + +#ifndef SYS_mprotect_key +# define SYS_mprotect_key 288 +#endif +#ifndef SYS_pkey_alloc +# define SYS_pkey_alloc 289 +# define SYS_pkey_free 290 +#endif +#define MCONTEXT_IP(mc) mc.pc +#define MCONTEXT_TRAPNO(mc) -1 + +#define PKEY_MASK 0xf + +#define POE_NONE 0x0 +#define POE_X 0x2 +#define POE_RX 0x3 +#define POE_RWX 0x7 + +#define NR_PKEYS 7 +#define NR_RESERVED_PKEYS 1 /* pkey-0 */ + +#define PKEY_ALLOW_ALL 0x77777777 + +#define PKEY_BITS_PER_PKEY 4 +#define PAGE_SIZE sysconf(_SC_PAGESIZE) +#undef HPAGE_SIZE +#define HPAGE_SIZE default_huge_page_size() + +/* 4-byte instructions * 16384 = 64K page */ +#define __page_o_noops() asm(".rept 16384 ; nop; .endr") + +static inline u64 __read_pkey_reg(void) +{ + u64 pkey_reg = 0; + + // POR_EL0 + asm volatile("mrs %0, S3_3_c10_c2_4" : "=r" (pkey_reg)); + + return pkey_reg; +} + +static inline void __write_pkey_reg(u64 pkey_reg) +{ + u64 por = pkey_reg; + + dprintf4("%s() changing %016llx to %016llx\n", + __func__, __read_pkey_reg(), pkey_reg); + + // POR_EL0 + asm volatile("msr S3_3_c10_c2_4, %0\nisb" :: "r" (por) :); + + dprintf4("%s() pkey register after changing %016llx to %016llx\n", + __func__, __read_pkey_reg(), pkey_reg); +} + +static inline int cpu_has_pkeys(void) +{ + /* No simple way to determine this */ + return 1; +} + +static inline u32 pkey_bit_position(int pkey) +{ + return pkey * PKEY_BITS_PER_PKEY; +} + +static inline int get_arch_reserved_keys(void) +{ + return NR_RESERVED_PKEYS; +} + +void expect_fault_on_read_execonly_key(void *p1, int pkey) +{ +} + +void *malloc_pkey_with_mprotect_subpage(long size, int prot, u16 pkey) +{ + return PTR_ERR_ENOTSUP; +} + +#define set_pkey_bits set_pkey_bits +static inline u64 set_pkey_bits(u64 reg, int pkey, u64 flags) +{ + u32 shift = pkey_bit_position(pkey); + u64 new_val = POE_RWX; + + /* mask out bits from pkey in old value */ + reg &= ~((u64)PKEY_MASK << shift); + + if (flags & PKEY_DISABLE_ACCESS) + new_val = POE_X; + else if (flags & PKEY_DISABLE_WRITE) + new_val = POE_RX; + + /* OR in new bits for pkey */ + reg |= new_val << shift; + + return reg; +} + +#define get_pkey_bits get_pkey_bits +static inline u64 get_pkey_bits(u64 reg, int pkey) +{ + u32 shift = pkey_bit_position(pkey); + /* + * shift down the relevant bits to the lowest two, then + * mask off all the other higher bits + */ + u32 perm = (reg >> shift) & PKEY_MASK; + + if (perm == POE_X) + return PKEY_DISABLE_ACCESS; + if (perm == POE_RX) + return PKEY_DISABLE_WRITE; + return 0; +} + +static void aarch64_write_signal_pkey(ucontext_t *uctxt, u64 pkey) +{ + struct _aarch64_ctx *ctx = GET_UC_RESV_HEAD(uctxt); + struct poe_context *poe_ctx = + (struct poe_context *) get_header(ctx, POE_MAGIC, + sizeof(uctxt->uc_mcontext), NULL); + if (poe_ctx) + poe_ctx->por_el0 = pkey; +} + +#endif /* _PKEYS_ARM64_H */ diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 1af3156a9db8..15608350fc01 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -91,12 +91,17 @@ void record_pkey_malloc(void *ptr, long size, int prot); #include "pkey-x86.h" #elif defined(__powerpc64__) /* arch */ #include "pkey-powerpc.h" +#elif defined(__aarch64__) /* arch */ +#include "pkey-arm64.h" #else /* arch */ #error Architecture not supported #endif /* arch */ +#ifndef PKEY_MASK #define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) +#endif +#ifndef set_pkey_bits static inline u64 set_pkey_bits(u64 reg, int pkey, u64 flags) { u32 shift = pkey_bit_position(pkey); @@ -106,7 +111,9 @@ static inline u64 set_pkey_bits(u64 reg, int pkey, u64 flags) reg |= (flags & PKEY_MASK) << shift; return reg; } +#endif +#ifndef get_pkey_bits static inline u64 get_pkey_bits(u64 reg, int pkey) { u32 shift = pkey_bit_position(pkey); @@ -116,6 +123,7 @@ static inline u64 get_pkey_bits(u64 reg, int pkey) */ return ((reg >> shift) & PKEY_MASK); } +#endif extern u64 shadow_pkey_reg; diff --git a/tools/testing/selftests/mm/pkey-powerpc.h b/tools/testing/selftests/mm/pkey-powerpc.h index 6275d0f474b3..3d0c0bdae5bc 100644 --- a/tools/testing/selftests/mm/pkey-powerpc.h +++ b/tools/testing/selftests/mm/pkey-powerpc.h @@ -8,6 +8,8 @@ # define SYS_pkey_free 385 #endif #define REG_IP_IDX PT_NIP +#define MCONTEXT_IP(mc) mc.gp_regs[REG_IP_IDX] +#define MCONTEXT_TRAPNO(mc) mc.gp_regs[REG_TRAPNO] #define REG_TRAPNO PT_TRAP #define MCONTEXT_FPREGS #define gregs gp_regs diff --git a/tools/testing/selftests/mm/pkey-x86.h b/tools/testing/selftests/mm/pkey-x86.h index b9170a26bfcb..5f28e26a2511 100644 --- a/tools/testing/selftests/mm/pkey-x86.h +++ b/tools/testing/selftests/mm/pkey-x86.h @@ -15,6 +15,8 @@ #endif +#define MCONTEXT_IP(mc) mc.gregs[REG_IP_IDX] +#define MCONTEXT_TRAPNO(mc) mc.gregs[REG_TRAPNO] #define MCONTEXT_FPREGS #ifndef PKEY_DISABLE_ACCESS diff --git a/tools/testing/selftests/mm/protection_keys.c b/tools/testing/selftests/mm/protection_keys.c index b3dbd76ea27c..989fdf489e33 100644 --- a/tools/testing/selftests/mm/protection_keys.c +++ b/tools/testing/selftests/mm/protection_keys.c @@ -147,7 +147,7 @@ void abort_hooks(void) * will then fault, which makes sure that the fault code handles * execute-only memory properly. */ -#ifdef __powerpc64__ +#if defined(__powerpc64__) || defined(__aarch64__) /* This way, both 4K and 64K alignment are maintained */ __attribute__((__aligned__(65536))) #else @@ -212,7 +212,6 @@ void pkey_disable_set(int pkey, int flags) unsigned long syscall_flags = 0; int ret; int pkey_rights; - u64 orig_pkey_reg = read_pkey_reg(); dprintf1("START->%s(%d, 0x%x)\n", __func__, pkey, flags); @@ -242,8 +241,6 @@ void pkey_disable_set(int pkey, int flags) dprintf1("%s(%d) pkey_reg: 0x%016llx\n", __func__, pkey, read_pkey_reg()); - if (flags) - pkey_assert(read_pkey_reg() >= orig_pkey_reg); dprintf1("END<---%s(%d, 0x%x)\n", __func__, pkey, flags); } @@ -253,7 +250,6 @@ void pkey_disable_clear(int pkey, int flags) unsigned long syscall_flags = 0; int ret; int pkey_rights = hw_pkey_get(pkey, syscall_flags); - u64 orig_pkey_reg = read_pkey_reg(); pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); @@ -273,8 +269,6 @@ void pkey_disable_clear(int pkey, int flags) dprintf1("%s(%d) pkey_reg: 0x%016llx\n", __func__, pkey, read_pkey_reg()); - if (flags) - assert(read_pkey_reg() <= orig_pkey_reg); } void pkey_write_allow(int pkey) @@ -330,8 +324,8 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) __func__, __LINE__, __read_pkey_reg(), shadow_pkey_reg); - trapno = uctxt->uc_mcontext.gregs[REG_TRAPNO]; - ip = uctxt->uc_mcontext.gregs[REG_IP_IDX]; + trapno = MCONTEXT_TRAPNO(uctxt->uc_mcontext); + ip = MCONTEXT_IP(uctxt->uc_mcontext); #ifdef MCONTEXT_FPREGS fpregs = (char *) uctxt->uc_mcontext.fpregs; #endif @@ -395,6 +389,8 @@ void signal_handler(int signum, siginfo_t *si, void *vucontext) #elif defined(__powerpc64__) /* arch */ /* restore access and let the faulting instruction continue */ pkey_access_allow(siginfo_pkey); +#elif defined(__aarch64__) + aarch64_write_signal_pkey(uctxt, PKEY_ALLOW_ALL); #endif /* arch */ pkey_faults++; dprintf1("<<<<==================================================\n"); @@ -908,7 +904,9 @@ void expected_pkey_fault(int pkey) * test program continue. We now have to restore it. */ if (__read_pkey_reg() != 0) -#else /* arch */ +#elif defined(__aarch64__) + if (__read_pkey_reg() != PKEY_ALLOW_ALL) +#else if (__read_pkey_reg() != shadow_pkey_reg) #endif /* arch */ pkey_assert(0); @@ -1498,6 +1496,11 @@ void test_executing_on_unreadable_memory(int *ptr, u16 pkey) lots_o_noops_around_write(&scratch); do_not_expect_pkey_fault("executing on PROT_EXEC memory"); expect_fault_on_read_execonly_key(p1, pkey); + + // Reset back to PROT_EXEC | PROT_READ for architectures that support + // non-PKEY execute-only permissions. + ret = mprotect_pkey(p1, PAGE_SIZE, PROT_EXEC | PROT_READ, (u64)pkey); + pkey_assert(!ret); } void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey) @@ -1671,6 +1674,84 @@ void test_ptrace_modifies_pkru(int *ptr, u16 pkey) } #endif +#if defined(__aarch64__) +void test_ptrace_modifies_pkru(int *ptr, u16 pkey) +{ + pid_t child; + int status, ret; + struct iovec iov; + u64 trace_pkey; + /* Just a random pkey value.. */ + u64 new_pkey = (POE_X << PKEY_BITS_PER_PKEY * 2) | + (POE_NONE << PKEY_BITS_PER_PKEY) | + POE_RWX; + + child = fork(); + pkey_assert(child >= 0); + dprintf3("[%d] fork() ret: %d\n", getpid(), child); + if (!child) { + ptrace(PTRACE_TRACEME, 0, 0, 0); + + /* Stop and allow the tracer to modify PKRU directly */ + raise(SIGSTOP); + + /* + * need __read_pkey_reg() version so we do not do shadow_pkey_reg + * checking + */ + if (__read_pkey_reg() != new_pkey) + exit(1); + + raise(SIGSTOP); + + exit(0); + } + + pkey_assert(child == waitpid(child, &status, 0)); + dprintf3("[%d] waitpid(%d) status: %x\n", getpid(), child, status); + pkey_assert(WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP); + + iov.iov_base = &trace_pkey; + iov.iov_len = 8; + ret = ptrace(PTRACE_GETREGSET, child, (void *)NT_ARM_POE, &iov); + pkey_assert(ret == 0); + pkey_assert(trace_pkey == read_pkey_reg()); + + trace_pkey = new_pkey; + + ret = ptrace(PTRACE_SETREGSET, child, (void *)NT_ARM_POE, &iov); + pkey_assert(ret == 0); + + /* Test that the modification is visible in ptrace before any execution */ + memset(&trace_pkey, 0, sizeof(trace_pkey)); + ret = ptrace(PTRACE_GETREGSET, child, (void *)NT_ARM_POE, &iov); + pkey_assert(ret == 0); + pkey_assert(trace_pkey == new_pkey); + + /* Execute the tracee */ + ret = ptrace(PTRACE_CONT, child, 0, 0); + pkey_assert(ret == 0); + + /* Test that the tracee saw the PKRU value change */ + pkey_assert(child == waitpid(child, &status, 0)); + dprintf3("[%d] waitpid(%d) status: %x\n", getpid(), child, status); + pkey_assert(WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP); + + /* Test that the modification is visible in ptrace after execution */ + memset(&trace_pkey, 0, sizeof(trace_pkey)); + ret = ptrace(PTRACE_GETREGSET, child, (void *)NT_ARM_POE, &iov); + pkey_assert(ret == 0); + pkey_assert(trace_pkey == new_pkey); + + ret = ptrace(PTRACE_CONT, child, 0, 0); + pkey_assert(ret == 0); + pkey_assert(child == waitpid(child, &status, 0)); + dprintf3("[%d] waitpid(%d) status: %x\n", getpid(), child, status); + pkey_assert(WIFEXITED(status)); + pkey_assert(WEXITSTATUS(status) == 0); +} +#endif + void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey) { int size = PAGE_SIZE; @@ -1706,7 +1787,7 @@ void (*pkey_tests[])(int *ptr, u16 pkey) = { test_pkey_syscalls_bad_args, test_pkey_alloc_exhaust, test_pkey_alloc_free_attach_pkey0, -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) test_ptrace_modifies_pkru, #endif }; From patchwork Fri May 3 13:01:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652805 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60437C10F16 for ; Fri, 3 May 2024 13:03:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7B1B6B00C3; Fri, 3 May 2024 09:03:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D05DB6B00C5; Fri, 3 May 2024 09:03:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B567C6B00C6; Fri, 3 May 2024 09:03:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 933516B00C3 for ; Fri, 3 May 2024 09:03:24 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4DEED140F7E for ; Fri, 3 May 2024 13:03:24 +0000 (UTC) X-FDA: 82077100728.28.B854999 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 772CE40024 for ; Fri, 3 May 2024 13:03:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741402; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eksSlg40KT/UC9A+H2dgGP3iV0ySpnxVzcGhGVsrjJA=; b=4TJbUZlfgmrSbye85FAR1lqDFhz3z8ruZzD9hz32mfILrP1XWyuNcCS0E3iTt3F8QzyMRn YflEXJINm0L3/xhqqnBz8+cv+GsNiQNw5HiBff9C52ZiP5/QR/M5e0gyLJQ9DuPI5mrzKq Q1pAu4HATLhqGw0dkvIH2qS/Mwa4REQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741402; a=rsa-sha256; cv=none; b=GAz+BNF1SytRJtRehurie6l3jHJWw9EOBBUU4j/+LJlTA2jJzy5Yc2quCJW54+HRdh2EJs MYp9GWQLMXHZuSb2H7eLUDFoUNYtQH7L+arXuB1vKg7yxwVmSHwNsqwYQlacBHGFI3lsn4 e66eDk72tHdoBDqMQkXeAbQMm0hzrkM= 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 0A9D21713; Fri, 3 May 2024 06:03:47 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ABFB83F73F; Fri, 3 May 2024 06:03:18 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 26/29] kselftest/arm64: add HWCAP test for FEAT_S1POE Date: Fri, 3 May 2024 14:01:44 +0100 Message-Id: <20240503130147.1154804-27-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 772CE40024 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jk93hpkresnzxygorkfqyypqn7699uza X-HE-Tag: 1714741402-324828 X-HE-Meta: U2FsdGVkX1+BR8pt/9mcXZYLNtRP6YZPqUpoMXM/18/azh88Rde7kRFsi1kbw+weuiJWX+m/8VPGs54gDpJZ+a5VEfA1B0ngtRM5tAPnlWKXmQl7qlFx9IBeLzWTiXBT763fUpY8qtLa9IaJ2dIc4zkYeUJBMMRbwMCSdWnTA9SNHGvr5aIg4SjBdADVuzZhpJ4lEHxnmTG/btKqNNCTg14o9wTdecHWyIXJbmpoRAl3Q0JGdqnhi4ThSyHNJRITgHgKboJWIl0VSt8Jvvut31RHivYj0AMy8+SMi3y9XqsAgYObkqfZS6g7LEdHcHF4SGLLzBsaw1lUpRSM8II+j0h+xNjBDlsgX1kk8Vr/aV13bYAR5jA36kccPb6jEabTitk5nDmPyTl1ErVyF2eSiI45/DqjVPr+hQ3/d9LvRJDcbImdngEvmPXEtz4QFcfB5sOA+6ecQ/tmgoHKHQxkj7CnS8ddLZsyziJy5JBxa92vXCso7TorN+g1wqv5L9B2gFfpvJ3OKZVNMUVGvgRzf/+8/CgAKG9ZUjZdwmw6ek/qJVxaE3iORHZq0Lr2qT0iKaCdz/BYamemOKgipiuJ0w7J+mDKsKoNY4vfqe1muJW9silHvUI/tHeJmKu3+gn4gDdBu9Zo25/Pkd4+7yeYoL6lI6SeV/okLD45DuGjMN07igyy11/eizTuFz4/ec+ft0QKa93VDl1N2xnVyP/BWg6ZAiL6hh/l1oN5klAW9W5OJTWekl7Ny4mYoRiHo+KT0oSKEFVtNJ1WtbIFp714RkDTE5V9cyxdcWdyRLJ38DyopomjgMfawlDedzc2vpZhtAUIWJQXYGc5f1XJRJIzuRL37yBUIRAYCZeJN75FwinpYSpB6YdM3Ejnvo8hmZOMaLxLC2e2OUXOi3CXvMVnZMVedtYzjxmlUcI5MxI/vKsr1A4YZQwAqinffbPB9ptUX3zllknlRdidsn8naF9 PdmYWFY0 e+fD7oN2CNbiv8T+GFQZtC3L+KonLHyU8/p+Vr9hDlleoMibuL04oqZu8/wtN5FsyL5jZbPimlvZGwbXdG1qLYMCP/G2DtS+4FN45S38xhKN7DdrXcTZvu5hyd2QvOg6OJ9wnafwGY8/SBGTC+Xk32GMsCfvBX98szumiMuJ8sTzCv5t8Dz41Pcwf4lbpK3pKmbiyR4gWQ91xep91wPB9KDDw0WQr/R8Lcnvs890aCO2uZYnr5kE2aIugndLauTsf1h4RwHY6ccr4Uaw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Check that when POE is enabled, the POR_EL0 register is accessible. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown --- tools/testing/selftests/arm64/abi/hwcap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c index d8909b2b535a..f2d6007a2b98 100644 --- a/tools/testing/selftests/arm64/abi/hwcap.c +++ b/tools/testing/selftests/arm64/abi/hwcap.c @@ -156,6 +156,12 @@ static void pmull_sigill(void) asm volatile(".inst 0x0ee0e000" : : : ); } +static void poe_sigill(void) +{ + /* mrs x0, POR_EL0 */ + asm volatile("mrs x0, S3_3_C10_C2_4" : : : "x0"); +} + static void rng_sigill(void) { asm volatile("mrs x0, S3_3_C2_C4_0" : : : "x0"); @@ -601,6 +607,14 @@ static const struct hwcap_data { .cpuinfo = "pmull", .sigill_fn = pmull_sigill, }, + { + .name = "POE", + .at_hwcap = AT_HWCAP2, + .hwcap_bit = HWCAP2_POE, + .cpuinfo = "poe", + .sigill_fn = poe_sigill, + .sigill_reliable = true, + }, { .name = "RNG", .at_hwcap = AT_HWCAP2, From patchwork Fri May 3 13:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652806 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6411C4345F for ; Fri, 3 May 2024 13:03:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 564206B00C5; Fri, 3 May 2024 09:03:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4ECA56B00C7; Fri, 3 May 2024 09:03:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 371946B00C8; Fri, 3 May 2024 09:03:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 11E4B6B00C5 for ; Fri, 3 May 2024 09:03:28 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BBCCFA1E86 for ; Fri, 3 May 2024 13:03:27 +0000 (UTC) X-FDA: 82077100854.19.7A4B6B3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 19DF2C0017 for ; Fri, 3 May 2024 13:03:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741406; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d107Nc8e2wWzFjiKX3Az52a6yyKX4riHtX0fSda4/Es=; b=vVcgkY4jDr7uGcPufb2KATVJeQ8LuzU9oXeezgxs3Zg1iuQqlDGdaNhR1/+yeI98W8NM7A ObNAIaO46h1Q5TNdRio+07hVhhhLWNQXtT+B6Lthf/Vf0KTNeNcRaupv6c0SEM+v1RyxS9 N2X0nnScTQM1pgZ/RvNttJonxiWsW7s= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741406; a=rsa-sha256; cv=none; b=1Lv5rFrQIBPKm0mddEfTQ4syKTy0k0gWUQ5Yp1q1HEzWmDDgKZwc7FSZlHU0z1l3+fziFU uHmv5R8476OY8/Vp+pMicggSKFm+EzpCUhvxYHCIGF6uVEFMri5t69+iWplE5cEIcRYgOs AM8Ni3nYa3Ki2FQbg5bRd5NY2DCEYIo= 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 90E15175A; Fri, 3 May 2024 06:03:50 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 052593F73F; Fri, 3 May 2024 06:03:21 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 27/29] kselftest/arm64: parse POE_MAGIC in a signal frame Date: Fri, 3 May 2024 14:01:45 +0100 Message-Id: <20240503130147.1154804-28-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: ypnud9x55bb5yebrrufhidz8gjxhgjui X-Rspam-User: X-Rspamd-Queue-Id: 19DF2C0017 X-Rspamd-Server: rspam05 X-HE-Tag: 1714741405-19978 X-HE-Meta: U2FsdGVkX1+JKY9I182YoRnkq0UKlZXp3FOSAUt0LWLuErn3MPFjRo/9YyUEl0ng4LZvmXP/9SMda8elDHD6z7FKATEL3UYJFrQGxycwbdPkb84Y4P9GYU0iKwMv0tQdoFYmvBAfAGEDRIbG71apCtu7zW30uILsT6StICsv0hRhqQ+jYll8qEIWOb03jHJz38vCNP775PeMKMNvFkPJEp+8AQoFq50k6Qq5KGpRhEUtLQ8f8Tc2bK65932sFS1fX9FQt3go/SzJdHa3lbBf75YgMFX8H5S7BocXcaPZAbhMYo1MxR6q+tWvmI0dAXs675Z9nu3gr7XMTv0+0VA3++yxT3jmse8VV54SUHWgtb22ON0jIEayGGpv66Iff4G33wn7atuWAOUioG7Wu4hjSE8xgDybxW4cbmmUEhbKFF0sk2pCEfHa1DtHzpfmOPm5rsa9qZCAwl2BA7odVq+dM2TA/Er0R0KxP3vjwUJknOmnUv9xmWvleLYoL5dAny4qtDF6Uuz5Nhu6OC9BPpSWjjsozKuzJ/CqWDc0J8qv5Ef55hOB58UExHroIRzEJY/bv2c/llAYz0ALSUgiRsbJPWwsLvLKANQuIjPxDYYeC1tgk9ik9zrQmtKCj95kNjNnO6SyJ0bf5Yo7RMKIOkpyHB4UMXN6QGpDmkwaJPNRrMavucEmCoDxgOtR+KqDTs7OoeZEh+7E2wLuADeUfQoIgq82QRiO6lXmDKd+lWmO/HwXwXgYrxMxhc0dbP0F+zERlSG5PUoea3KYxETTsVMuYIg3l7h+Jve8Awfrlkw00J2bxEOf/rvN6wAtza9zwwnNBvZGj/ESloLpvIlKSHsY8c8sR/+5A3WiwYkY+DnPX1r9V0UIW1s6LkXv72XqNX7hkA0GTzL5P8XtNIrTIrahYtNLGIh+vO612ze2kS219F1foKd7q2RGjhby/qfbzceJr92wEKQyuNE3/zVUb4K nAdMYozv ZiHOFAA7soUP8+35II1UKLZPYmBGJiqQ7sVK8A9BrNtawNFc8A2xrXubC/YfCaQeCHV670sqg04RJN394OR/aGQvOofpfsgILaYFnoQ42gjrGqbV/VRoRcR0o/o07wa76hbTMJCR11HF4fAC7oPz2eaZkC7RvKL3aAqp+ybbJCWHTon79BGN1GVsgF8yekhftCbjM/KXuQhAczFf9myHYf5SQImTblhf18s3ZEmZsxVnCmWErTAWdcn+7QDnxsCMO8/RZ5OgArFmc7ZA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Teach the signal frame parsing about the new POE frame, avoids warning when it is generated. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown --- tools/testing/selftests/arm64/signal/testcases/testcases.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/arm64/signal/testcases/testcases.c b/tools/testing/selftests/arm64/signal/testcases/testcases.c index e4331440fed0..e6daa94fcd2e 100644 --- a/tools/testing/selftests/arm64/signal/testcases/testcases.c +++ b/tools/testing/selftests/arm64/signal/testcases/testcases.c @@ -161,6 +161,10 @@ bool validate_reserved(ucontext_t *uc, size_t resv_sz, char **err) if (head->size != sizeof(struct esr_context)) *err = "Bad size for esr_context"; break; + case POE_MAGIC: + if (head->size != sizeof(struct poe_context)) + *err = "Bad size for poe_context"; + break; case TPIDR2_MAGIC: if (head->size != sizeof(struct tpidr2_context)) *err = "Bad size for tpidr2_context"; From patchwork Fri May 3 13:01:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652807 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD512C4345F for ; Fri, 3 May 2024 13:03:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C3A86B00C7; Fri, 3 May 2024 09:03:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64E456B00C9; Fri, 3 May 2024 09:03:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C7AD6B00CA; Fri, 3 May 2024 09:03:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1EAD76B00C7 for ; Fri, 3 May 2024 09:03:31 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C05EA1210CC for ; Fri, 3 May 2024 13:03:30 +0000 (UTC) X-FDA: 82077100980.07.29CDD08 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id 1E8A8C0003 for ; Fri, 3 May 2024 13:03:28 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741409; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4CEAfIaeEBfWG28tM/+Z+JU6dETZKCB1H0URWPlfLto=; b=1Mnc3nGmdbMAJ7K8znaK03qGnMUyt8NfqqUFeqlzlrEwNP5pFYIFfBniL/Od/tkmVB96np pcG4UaXNqIAWl3YEJJIwJ7Jnx1eIqxcnTBEFUWos5yRBV6oHE9KoGCCAztukszthmMGDG7 3jgedztFsydjafAckwlfCNlHbuj3Yn0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741409; a=rsa-sha256; cv=none; b=Jiq1zlXpnGasDMYakcDfCA96+mTsmxBiUNSo1RO7YeCaoUYMLkt6YN0ErPVZNr1D+AFuId bZfz0uANW1JNWQbgMjsnl/6oH9D2/JoIYgvtAhKJlwmMOZE2KSCva9xv8JYSQz8BMO0eLh j6hgUi3KZCqollLz/fGG1Qcd9Qo2RXc= 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 A16001762; Fri, 3 May 2024 06:03:53 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 503FB3F881; Fri, 3 May 2024 06:03:25 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 28/29] kselftest/arm64: Add test case for POR_EL0 signal frame records Date: Fri, 3 May 2024 14:01:46 +0100 Message-Id: <20240503130147.1154804-29-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Stat-Signature: 8gz8rxngjyc1p4qn8ruaap4ipczaqkup X-Rspamd-Queue-Id: 1E8A8C0003 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714741408-377573 X-HE-Meta: U2FsdGVkX1+ela8wBOk/ulw0QHXAS5LHMJ/dMXed8FH7+nkiyDLUOay0omxsedVVlWFHp2xH2jz2h09569Eq1FJWlvOSq4DCStWleZhx+8BRX81Ueq9vM8xt+pl9XMDgzQGecNSdjVcODtjLwQAjbkpKMmj3fgJtzqXJaFGO7f6DOsGf4hOGDmR0wWynkFeO6xq8bKOubGh1nziPreVZOQTlS6+3WuaJPl7oyA2Pyml2SQuGT2HVo1sUADxI6IwjlQn0bjJaeINWCXhId2YRSW4wPd6d29911efvMwA1Kn2p6dgEBWEjv9bcOMu8fIHmpcrvsHNRbLNJ4dZNqRu9jzer4K+Ol15ezvSkjYPMEoiO+5jVDEkYfCFxOZ4aiqo2CY7RfUqHUz0lYl71yZkXKkDGaRqNbBeUajXhH6WZQvYW4xCS6LxKbJBXbi3b7D/4aV7Jnyou3ABsHbv/0xyPq8N1v23lrpA+YvRuo5K4XqfjaaOVa6QI3drGj5KFvpkJ5QUaTdC5NKcE4wCnQZr4VKoF4Yh9l7JX9IpTzKhaV/AUEc7IpGqqRDe1FvDX1T0eH4SdtA3JbOgaHWpxMcCZejbCUkAboW4PTXp0o3B0xbZFDD4T+U2VO7TjtL/7+RxdVbuniG48oh8GrlbplrJ2WK6maNv6jp4aF1RGd7AhpljSmi47TZ4OIbrpbx1okFh01UqlaKKaLQ8qmtQD6CO8v/sYW58qtXiC0d3aSuCkKxDvdJ/GtfpgC1Kq+mLK+RZsEa6ZLFoWYggeS8APnEQCoPJe+fggskn4lFsRvlB1sBjTNiQnHm6Ml5dyRB3oHiyADgcWSf47LZZDoPpaHAMcHXIbl4A5zRrAwAkV/tc6MU5m2r2kVm4jKkCP2QfIhNi3k7E/ewtL1gp6QDsAErr8WSWs/DBtsWgoYZ4rdpZlYMEnrMrta2k2e4LbE+VfYC+bH0wXM7q+ATQgRtsyuqK Ek90FaY2 6Va6HQGVRrVFN1DyUPI6KKYkKi81uqOpzhks+rtD/wA9xX28SobApgoD/v198XSEcm4w+E8dphj1vC/SNAewRVUng+stIMBr9JuTDpGiWgn1TurifG83rUt4sSo0Gyuph+FzHtY+qL2TpPiA8suN3uXq9wlFbr/VpC82fgIFQmspRr6XGUIrsCyYSElM1n3Ic8S4VtEDgMldogSjAcBwd2VBLuZwjf2XlIJjGAM/9UU6UzU+AxbKKwXcyMjq2fP4hiy47B1iGYbrkyko= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Ensure that we get signal context for POR_EL0 if and only if POE is present on the system. Copied from the TPIDR2 test. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Acked-by: Shuah Khan --- .../testing/selftests/arm64/signal/.gitignore | 1 + .../arm64/signal/testcases/poe_siginfo.c | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c diff --git a/tools/testing/selftests/arm64/signal/.gitignore b/tools/testing/selftests/arm64/signal/.gitignore index 1ce5b5eac386..b2f2bfd5c6aa 100644 --- a/tools/testing/selftests/arm64/signal/.gitignore +++ b/tools/testing/selftests/arm64/signal/.gitignore @@ -2,6 +2,7 @@ mangle_* fake_sigreturn_* fpmr_* +poe_* sme_* ssve_* sve_* diff --git a/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c b/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c new file mode 100644 index 000000000000..d890029304c4 --- /dev/null +++ b/tools/testing/selftests/arm64/signal/testcases/poe_siginfo.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Arm Limited + * + * Verify that the POR_EL0 register context in signal frames is set up as + * expected. + */ + +#include +#include +#include +#include +#include +#include + +#include "test_signals_utils.h" +#include "testcases.h" + +static union { + ucontext_t uc; + char buf[1024 * 128]; +} context; + +#define SYS_POR_EL0 "S3_3_C10_C2_4" + +static uint64_t get_por_el0(void) +{ + uint64_t val; + + asm volatile ( + "mrs %0, " SYS_POR_EL0 "\n" + : "=r"(val) + : + : "cc"); + + return val; +} + +int poe_present(struct tdescr *td, siginfo_t *si, ucontext_t *uc) +{ + struct _aarch64_ctx *head = GET_BUF_RESV_HEAD(context); + struct poe_context *poe_ctx; + size_t offset; + bool in_sigframe; + bool have_poe; + __u64 orig_poe; + + have_poe = getauxval(AT_HWCAP2) & HWCAP2_POE; + if (have_poe) + orig_poe = get_por_el0(); + + if (!get_current_context(td, &context.uc, sizeof(context))) + return 1; + + poe_ctx = (struct poe_context *) + get_header(head, POE_MAGIC, td->live_sz, &offset); + + in_sigframe = poe_ctx != NULL; + + fprintf(stderr, "POR_EL0 sigframe %s on system %s POE\n", + in_sigframe ? "present" : "absent", + have_poe ? "with" : "without"); + + td->pass = (in_sigframe == have_poe); + + /* + * Check that the value we read back was the one present at + * the time that the signal was triggered. + */ + if (have_poe && poe_ctx) { + if (poe_ctx->por_el0 != orig_poe) { + fprintf(stderr, "POR_EL0 in frame is %llx, was %llx\n", + poe_ctx->por_el0, orig_poe); + td->pass = false; + } + } + + return 0; +} + +struct tdescr tde = { + .name = "POR_EL0", + .descr = "Validate that POR_EL0 is present as expected", + .timeout = 3, + .run = poe_present, +}; From patchwork Fri May 3 13:01:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652808 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23EFFC4345F for ; Fri, 3 May 2024 13:03:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A49376B00C9; Fri, 3 May 2024 09:03:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CFF46B00CB; Fri, 3 May 2024 09:03:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 848AA6B00CC; Fri, 3 May 2024 09:03:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F6F56B00C9 for ; Fri, 3 May 2024 09:03:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 21E83A0E72 for ; Fri, 3 May 2024 13:03:34 +0000 (UTC) X-FDA: 82077101148.20.5CBECFB Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf30.hostedemail.com (Postfix) with ESMTP id 5D33F80002 for ; Fri, 3 May 2024 13:03:32 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714741412; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2H4c67QvHxeqPFRAilDr0mBKJApc4yFfxpvnrzVVS5Q=; b=VDaq7nGF4MnQOKnbM860BzDpuVdSWrX84E2O1khNyY41OnkJnRyE/6lo0f38G0Mb/aD2AS e+6W5DCQ8c8oD9OW/QhMps+4ekZMCxnlESH6fhp8MNlBlTXX6ZMHsWhnZS0+WxerIazZw5 5ceG8Hl3W0Igqr4bZua/nknF/5DHpn4= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714741412; a=rsa-sha256; cv=none; b=nur7jKQ5OEE/aDYgPx0dyMyW3L3djT9gJSpahRqonoq8xer/weLnsQYijxA5l3vIV7pE7N 3u/e+MdSxKp4wY8deRi5mGuZQDI7VqtKltCy2kguTuBnfdDnA0UgNfCVOgIvOGvGISeIh6 /usY+nIibc/Uyb1baJwnTYufQF5BP60= 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 EDB5D1764; Fri, 3 May 2024 06:03:56 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9AEB03F73F; Fri, 3 May 2024 06:03:28 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 29/29] KVM: selftests: get-reg-list: add Permission Overlay registers Date: Fri, 3 May 2024 14:01:47 +0100 Message-Id: <20240503130147.1154804-30-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5D33F80002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 94qxt1nn7ohn3adfi4mhic3gar1zh5hp X-HE-Tag: 1714741412-423995 X-HE-Meta: U2FsdGVkX19pwDAaIq0Rxx/wpvvaonuOvjxyC39AOhk/mwtz4y+q/5MbInwUF3KIcccS15iMbPeuW6eKX49zE/bwpxV5VJiqp294abwRdPiKSaCegyrOitaYuAtU0b0EBGbRSV6BregKoBGU7T9QY6lWjzsJzyYaizsepZBLUKyJQPvDMLLMyLzjWMD5qels5COVbMcjlhMmBrXPkCTohRpyUlelMAROHRY2koPQhx/7SoSkdOA1uAnCzzl0/OTP1M65RzsyCcp15icQ1XhzeSt/jQOnioxjKbK/luglSBhZY2gz1MTrE3daN7igQm2qDb8yNoCtrU9NewOXhSdkZqZCmd5YHqEhOqnT4OJELf5swQVNNpbMY2DSym/B9WCePQBvmNpv3DGY+Ubb177HTe/2vaC8tJEYqiFtaktwrBOuyW/dSjEjSkbOy4xwJrVdKdGmbMBqTXWZf+xzRY8rhwxUQOJyOaBKWfkAvhpljbCwcd2hT49PLUc9kgNeBxw/kPhgN3fXViY6msLm/J+j9n1e7wOzJcdz+KwijrZiUmzKs4WjORH17WG5qW5VKKDYeDyS2IrqYMr2uVlKoI6WYXml07V81fXYbjH62EZi9i6frmwz9nhTApmf4cnrh0E84KX4jIJiglgSolWW59rmOn2ib2vTjNA3D/T/W4gl8prCXgfL/XZqNNl2uT2CdOPf+wmwENSqHcP8d/K/sJoOmmvQgNB07VP2Pv7pvew3lbdkbe6vkqB3h5eTTSCLzXGiaVkidisu6j1RPjEF9wWo6BYeN3nB5EF4IkBBSUFjifI4UzVUsD3Sj7EBBMoHVs4RyG+GpWgT0BlnUwgAOFgUOIQzPZ4wqiInizOThbvItePCa7toigfLUbX158YHOlbTLxb5fohELQgqoFfpDPzyU67YdV4awRu5BHGCpALCdwB18wJ9jzfZbQeYfmdAXYIVTUUkwMm6zgmf0qT8ftE Qz//iEls MHflUzatbcgGBOenndE9lel6+Nrz9InFqiLcJPAU4Uwt9N36TpgZaWsaW0Pd1tGAulB2tZ+Py5wcqjbYpJUXnQbiIDFFdWRqcR1PzEknL43ghdhGqLZ/w81BnaSAhOL1Jq2e2j3uwBRtQmKnKxl/LsuT4k+lk7At22T6BbTaIq9/9oUHVSrHUe64zDw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add new system registers: - POR_EL1 - POR_EL0 Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: Oliver Upton Cc: Shuah Khan Reviewed-by: Mark Brown --- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c index 709d7d721760..ac661ebf6859 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -40,6 +40,18 @@ static struct feature_id_reg feat_id_regs[] = { ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */ 4, 1 + }, + { + ARM64_SYS_REG(3, 0, 10, 2, 4), /* POR_EL1 */ + ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */ + 16, + 1 + }, + { + ARM64_SYS_REG(3, 3, 10, 2, 4), /* POR_EL0 */ + ARM64_SYS_REG(3, 0, 0, 7, 3), /* ID_AA64MMFR3_EL1 */ + 16, + 1 } }; @@ -468,6 +480,7 @@ static __u64 base_regs[] = { ARM64_SYS_REG(3, 0, 10, 2, 0), /* MAIR_EL1 */ ARM64_SYS_REG(3, 0, 10, 2, 2), /* PIRE0_EL1 */ ARM64_SYS_REG(3, 0, 10, 2, 3), /* PIR_EL1 */ + ARM64_SYS_REG(3, 0, 10, 2, 4), /* POR_EL1 */ ARM64_SYS_REG(3, 0, 10, 3, 0), /* AMAIR_EL1 */ ARM64_SYS_REG(3, 0, 12, 0, 0), /* VBAR_EL1 */ ARM64_SYS_REG(3, 0, 12, 1, 1), /* DISR_EL1 */ @@ -475,6 +488,7 @@ static __u64 base_regs[] = { ARM64_SYS_REG(3, 0, 13, 0, 4), /* TPIDR_EL1 */ ARM64_SYS_REG(3, 0, 14, 1, 0), /* CNTKCTL_EL1 */ ARM64_SYS_REG(3, 2, 0, 0, 0), /* CSSELR_EL1 */ + ARM64_SYS_REG(3, 3, 10, 2, 4), /* POR_EL0 */ ARM64_SYS_REG(3, 3, 13, 0, 2), /* TPIDR_EL0 */ ARM64_SYS_REG(3, 3, 13, 0, 3), /* TPIDRRO_EL0 */ ARM64_SYS_REG(3, 3, 14, 0, 1), /* CNTPCT_EL0 */