From: Andrei Vagin <avagin@google.com>
To: Kees Cook <kees@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, cgroups@vger.kernel.org,
criu@lists.linux.dev, "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Vipin Sharma" <vipinsh@google.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Andrei Vagin" <avagin@google.com>
Subject: [PATCH 3/3] Documentation: cgroup-v2: Document misc.mask interface
Date: Fri, 5 Dec 2025 00:58:32 +0000 [thread overview]
Message-ID: <20251205005841.3942668-5-avagin@google.com> (raw)
In-Reply-To: <20251205005841.3942668-1-avagin@google.com>
Updates the cgroup-v2 documentation to include details about the newly
introduced 'misc.mask' interface. This interface, part of the 'misc'
cgroup controller, allows masking out hardware capabilities (AT_HWCAP,
AT_HWCAP2, AT_HWCAP3, AT_HWCAP4) reported to user-space processes within
a cgroup.
Signed-off-by: Andrei Vagin <avagin@google.com>
---
Documentation/admin-guide/cgroup-v2.rst | 25 +++++++++++++++++++++++++
Documentation/arch/arm64/elf_hwcaps.rst | 21 +++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 4c072e85acdf..9d9d923e0d4e 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2924,6 +2924,31 @@ Miscellaneous controller provides 3 interface files. If two misc resources (res_
cgroup i.e. not hierarchical. The file modified event generated on
this file reflects only the local events.
+Miscellaneous controller provides one interface file to control masks.
+
+ misc.mask
+ A read-write flat-keyed file shown in all cgroups. It allows
+ setting/reading the masks. The file format is a series of lines, each
+ describing a mask of a specific mask type.
+
+ The file has the following format for each line::
+
+ $NAME\t$LOCAL_MASK\t$EFFECTIVE_MASK
+
+ Where $NAME is the mask type name, $LOCAL_MASK is the mask for the
+ current cgroup, and $EFFECTIVE_MASK is the effective mask for the
+ current cgroup, which is a combination of the masks from the current
+ cgroup and all its ancestors.
+
+ To set a mask, write a string in the following format to the file::
+
+ $NAME $MASK
+
+ For example, to set a mask for the mask_a type, you would write the
+ following to the file::
+
+ # echo "mask_a 0x3000" > misc.mask
+
Migration and Ownership
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst
index a15df4956849..5526daff5d30 100644
--- a/Documentation/arch/arm64/elf_hwcaps.rst
+++ b/Documentation/arch/arm64/elf_hwcaps.rst
@@ -450,3 +450,24 @@ HWCAP3_LSFE
For interoperation with userspace, the kernel guarantees that bits 62
and 63 of AT_HWCAP will always be returned as 0.
+
+5. Masking hwcaps for a group of processes
+--------------------------------
+
+The misc cgroup controller provides a mechanism to mask hwcaps for a specific
+workload. This can be useful for limiting the features available to a
+containerized application.
+
+To mask hwcaps, you can write a mask to the ``misc.mask`` file in the cgroup
+directory. The mask is specified per AT_HWCAP entry (AT_HWCAP, AT_HWCAP2,
+AT_HWCAP3) in the format ``<HWCAP_ENTRY_NAME> <BITMASK>``.
+
+For example, to mask ``HWCAP_FP`` and ``HWCAP_ASIMD`` (which are represented by
+bits 0 and 1 of AT_HWCAP, so a mask of 0x3) for a workload, you would write the
+mask for AT_HWCAP to the ``misc.mask`` file in the new cgroup directory::
+
+ # echo "AT_HWCAP 0x3" > /sys/fs/cgroup/misc/my-workload/misc.mask
+
+Any new processes started in this cgroup will have the specified hwcaps
+masked. You can verify this by reading the ``misc.mask`` file, which will
+show the effective mask for the cgroup.
--
2.52.0.223.gf5cc29aaa4-goog
next prev parent reply other threads:[~2025-12-05 0:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 0:58 [PATCH 0/3] cgroup/misc: Add hwcap masks to the misc controller Andrei Vagin
2025-12-05 0:58 ` [PATCH 1/3] cgroup, binfmt_elf: " Andrei Vagin
2025-12-05 3:40 ` Kees Cook
2025-12-05 10:10 ` Chen Ridong
2025-12-05 0:58 ` Andrei Vagin
2025-12-05 0:58 ` [PATCH 2/3] selftests/cgroup: Add a test for the misc.mask cgroup interface Andrei Vagin
2025-12-05 0:58 ` Andrei Vagin [this message]
2025-12-05 2:52 ` [PATCH 0/3] cgroup/misc: Add hwcap masks to the misc controller Chen Ridong
2025-12-05 6:39 ` Andrei Vagin
2025-12-05 10:04 ` Chen Ridong
2025-12-05 20:19 ` Andrei Vagin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251205005841.3942668-5-avagin@google.com \
--to=avagin@google.com \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=criu@lists.linux.dev \
--cc=hannes@cmpxchg.org \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mkoutny@suse.com \
--cc=tj@kernel.org \
--cc=vipinsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox