From patchwork Mon Jan 13 17:06:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Khrustalev X-Patchwork-Id: 13937781 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 699911FBBD3; Mon, 13 Jan 2025 17:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736788001; cv=none; b=GplCKKAGDCMMG0LM62mbQv1LymaLzT3NA0T0fQsmyWMQaewy3JcJTIgCyO5no4dyEm/VTV3+rLlvSRbsTqlNXGmadAwQDpVGj1ppm6/ubYICS5qcwaDJMSyNvRBFfOQZR6qJARjTGPPkpdXgvBfUcRq7kRJX9CP4K+hVa6lLxJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736788001; c=relaxed/simple; bh=C6PEC0ZSyV4CBA00BhLPYCgWd4YnWCztsvZHoYJR6og=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fiRwoJjl4lj52Pbld96rdZ5pcl21sbSGJLjhblbk98YZGh1BBS6jt9B9Dku9+gwdTHxmmk945h0F1JJydhmadXSozLbNMj61PVya2mLEc9sDXs5WDHfV7EzZee/pSZMSodvdzmvhsUL7PQlJdN1keD+VTERZ4CqE9sW0aYJYuHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 01E3C1424; Mon, 13 Jan 2025 09:07:07 -0800 (PST) Received: from udebian.localdomain (unknown [10.1.25.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EFD0E3F673; Mon, 13 Jan 2025 09:06:35 -0800 (PST) From: Yury Khrustalev To: linux-arch@vger.kernel.org Cc: Arnd Bergmann , Kevin Brodsky , Joey Gouly , Dave Hansen , Sandipan Das , Michael Ellerman , Catalin Marinas , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Andrew Morton , nd@arm.com, Yury Khrustalev Subject: [RESEND v4 1/3] mm/pkey: Add PKEY_UNRESTRICTED macro Date: Mon, 13 Jan 2025 17:06:17 +0000 Message-Id: <20250113170619.484698-2-yury.khrustalev@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250113170619.484698-1-yury.khrustalev@arm.com> References: <20250113170619.484698-1-yury.khrustalev@arm.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Memory protection keys (pkeys) uapi has two macros for pkeys restrictions: - PKEY_DISABLE_ACCESS 0x1 - PKEY_DISABLE_WRITE 0x2 with implicit literal value of 0x0 that means "unrestricted". Code that works with pkeys has to use this literal value when implying that a pkey imposes no restrictions. This may reduce readability because 0 can be written in various ways (e.g. 0x0 or 0) and also because 0 in the context of pkeys can be mistaken for "no permissions" (akin PROT_NONE) while it actually means "no restrictions". This is important because pkeys are oftentimes used near mprotect() that uses PROT_ macros. This patch adds PKEY_UNRESTRICTED macro defined as 0x0. Signed-off-by: Yury Khrustalev Acked-by: Dave Hansen --- include/uapi/asm-generic/mman-common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index 1ea2c4c33b86..ef1c27fa3c57 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h @@ -85,6 +85,7 @@ /* compatibility flags */ #define MAP_FILE 0 +#define PKEY_UNRESTRICTED 0x0 #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\