From patchwork Fri Oct 27 18:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13438782 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 1D6D1C25B70 for ; Fri, 27 Oct 2023 18:09:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7FC26B03D8; Fri, 27 Oct 2023 14:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0A156B03E2; Fri, 27 Oct 2023 14:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 881A36B03E3; Fri, 27 Oct 2023 14:09:33 -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 79A076B03D8 for ; Fri, 27 Oct 2023 14:09:33 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 570DE80A2D for ; Fri, 27 Oct 2023 18:09:33 +0000 (UTC) X-FDA: 81392029026.11.5E19E37 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf19.hostedemail.com (Postfix) with ESMTP id A42E01A001D for ; Fri, 27 Oct 2023 18:09:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.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=1698430171; 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=SL44FeauWdJKT/Grfju3ARYVmijSdcuu6FKtWr4kxFw=; b=VWXVHn3bX8yaeTxIs6MIR0xkrxGULT08A6MIMp3KlT1cEDBzdWInVl2TQRUzp6oslCjKB7 cxb178COE/p544zUtznKWXqp5DLOll3ku/DMMbOpYC8dd+xf2OvlQeOz7Eic72yploaQkj jydQuJh39O95YrQRSBGO/s3t1d/2YfI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf19.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=1698430171; a=rsa-sha256; cv=none; b=oU3HWD+CogIhUhXIphAcYnFh4XTShue97MODcjK4au1FDe2p8ZMxi9IgIuKY00954SeZJf amm+tr9F8hU3gH5jw9OSWrzcxQdtlUnex/i+HEjEN6oY0z6hv8RmLWkiHSrVnbKzO1wOei hyaB0tHmzRwCnxE3YPEagP28dc0pJt8= 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 A1C3B153B; Fri, 27 Oct 2023 11:10:12 -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 D3E853F64C; Fri, 27 Oct 2023 11:09:28 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, broonie@kernel.org, catalin.marinas@arm.com, dave.hansen@linux.intel.com, joey.gouly@arm.com, maz@kernel.org, oliver.upton@linux.dev, shuah@kernel.org, will@kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, James Morse , Suzuki K Poulose , Zenghui Yu Subject: [PATCH v2 11/24] arm64: enable ARCH_HAS_PKEYS on arm64 Date: Fri, 27 Oct 2023 19:08:37 +0100 Message-Id: <20231027180850.1068089-12-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231027180850.1068089-1-joey.gouly@arm.com> References: <20231027180850.1068089-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A42E01A001D X-Stat-Signature: iss1e7j3wsue7g7ruy1699ccb7hb5fno X-Rspam-User: X-HE-Tag: 1698430171-442315 X-HE-Meta: U2FsdGVkX18Etq1PgE0M2ZO5ZUDc/si3Lp+huWss8UHL6nkH1COShap4CN/4pT7LskYTIsQ9bcKngo9MbKNCSZpoYzAS4AAvRcGsdVAbTML2wImYh466sBvI/MbnBPuzu3jzd7UXX/8icWIVAZlYgY3FEWPnNCpAG9qos4DCCN3GyZtny97ws7KfO5HW/uZAWhkkCiyD2yX/lqbPj5yCBvklNRnadJq+vGo87jDcSGdyjqjqzfwqZuNV7DUuzkAe0xsTHUqr40MJQOsG3s8WDskURBisaslI3Vb5ssaEfRF+pyrVHorg+vLdvid/F/PqK3uxzLHs1JqXFBZArdqZaabHU2f6VDQi8ecRkiHJMI6GvUMHgUpHiWvwWLXnaUkZJo5VvzRikhb6DqV/wpFpqThwSOBgF/H8IznkUGMy8WbV6tcr0fLXDwevG5xWJ9FnnADyD2EX0IxX2aUe4OZ+dXVEfcPNxRJHLLU8utV49fWCRB+zLpIAute1YLHkZYapA87Y70kXzj9lzmDBlO3zOes0RSp9xvtVRla061IFxQrqNwZdURBLgAdgy/VrmqizhpW7b3Y6Nh2hD1+VGy+NV1TD5ukXTSQ652SBaVCy4eXoZDOWNV8YCcFpguK1JUnMpu4pnDhXyo2M6nakjh5f41aBUWGdQrS+HDITFvDycosS3eJ6VqW1906xai2kgWuEzTxeG4cOx7MiX/eh6fljvGR4tmHuIbt9lxzafoE+wNQtar4Zn8AHUAU+VVXl2lr2tHNtrAVRB8zWWV7QCLxozo/xpS9LLMSNGHRIvkii1VlHfuwfjv585UuUpUEvWJgiSnlT0iOuaUZDyYwKybcn5mOLdD+LKD2+7SzCyFI+H3Zh+IIMEdR2pQylJp1sXiSbt40dKmB9V/tKF8isKmKxKIN6pRwFps8Codg0RZr/JMdsfCMnfBQnHDrhmrYznSdtHwRuSeMPSmBPBBmn2X7 E27aB/FP 0YQSa2qaeEpKaUBoxKT4JUUtmg6u1DAneqCEgErhL+zAcUz/msUuxkj+HSt2rsrugTjGZDdEGGh/lBGzjborYljlfu6G8nHjBx6iV3PpQr+u9q3DvrRtX31gp/o9UxwNFg5I8HtlZXNP3adMEsKpa53vG4rPxxdRoxNZtm+z5RN26mqGgwxuDSnzJz2L6Bl3uhLsfhEtox4W0MURxvMP5h8e4KK7ZFEvbjJiWXdRj7PsRYRJZU/JEj7sdGsIFrrf2z1Qtm/uMMOc/h6Q= 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: Enable the ARCH_HAS_PKEYS config, but provide dummy functions for the entire interface. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/Kconfig | 2 ++ arch/arm64/include/asm/pkeys.h | 54 ++++++++++++++++++++++++++++++++++ arch/arm64/mm/mmu.c | 7 +++++ 3 files changed, 63 insertions(+) create mode 100644 arch/arm64/include/asm/pkeys.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 1f1a12e28c3f..68cfcbd95c8e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2064,6 +2064,8 @@ 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 diff --git a/arch/arm64/include/asm/pkeys.h b/arch/arm64/include/asm/pkeys.h new file mode 100644 index 000000000000..5761fb48fd53 --- /dev/null +++ b/arch/arm64/include/asm/pkeys.h @@ -0,0 +1,54 @@ +/* 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() 0 + +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 -1; +} + +static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, + int prot, int pkey) +{ + return -1; +} + +static inline int execute_only_pkey(struct mm_struct *mm) +{ + return -1; +} + +static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey) +{ + return false; +} + +static inline int mm_pkey_alloc(struct mm_struct *mm) +{ + return -1; +} + +static inline int mm_pkey_free(struct mm_struct *mm, int pkey) +{ + return -EINVAL; +} + +#endif /* _ASM_ARM64_PKEYS_H */ diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 47781bec6171..11765791b880 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1487,3 +1487,10 @@ void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte { set_pte_at(vma->vm_mm, addr, ptep, pte); } + +#ifdef CONFIG_ARCH_HAS_PKEYS +int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, unsigned long init_val) +{ + return -ENOSPC; +} +#endif