sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget7/translations/zh_CN/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/zh_TW/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/it_IT/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/ja_JP/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/ko_KR/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget7/translations/sp_SP/admin-guide/hw-vuln/core-schedulingmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhhQ/var/lib/git/docbuild/linux/Documentation/admin-guide/hw-vuln/core-scheduling.rsthKubhsection)}(hhh](htitle)}(hCore Schedulingh]hCore Scheduling}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hXCore scheduling support allows userspace to define groups of tasks that can share a core. These groups can be specified either for security usecases (one group of tasks don't trust another), or for performance usecases (some workloads may benefit from running on the same core as they don't need the same hardware resources of the shared core, or may prefer different cores if they do share hardware resource needs). This document only describes the security usecase.h]hXCore scheduling support allows userspace to define groups of tasks that can share a core. These groups can be specified either for security usecases (one group of tasks don’t trust another), or for performance usecases (some workloads may benefit from running on the same core as they don’t need the same hardware resources of the shared core, or may prefer different cores if they do share hardware resource needs). This document only describes the security usecase.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hSecurity usecaseh]hSecurity usecase}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hXA cross-HT attack involves the attacker and victim running on different Hyper Threads of the same core. MDS and L1TF are examples of such attacks. The only full mitigation of cross-HT attacks is to disable Hyper Threading (HT). Core scheduling is a scheduler feature that can mitigate some (not all) cross-HT attacks. It allows HT to be turned on safely by ensuring that only tasks in a user-designated trusted group can share a core. This increase in core sharing can also improve performance, however it is not guaranteed that performance will always improve, though that is seen to be the case with a number of real world workloads. In theory, core scheduling aims to perform at least as good as when Hyper Threading is disabled. In practice, this is mostly the case though not always: as synchronizing scheduling decisions across 2 or more CPUs in a core involves additional overhead - especially when the system is lightly loaded. When ``total_threads <= N_CPUS/2``, the extra overhead may cause core scheduling to perform more poorly compared to SMT-disabled, where N_CPUS is the total number of CPUs. Please measure the performance of your workloads always.h](hXA cross-HT attack involves the attacker and victim running on different Hyper Threads of the same core. MDS and L1TF are examples of such attacks. The only full mitigation of cross-HT attacks is to disable Hyper Threading (HT). Core scheduling is a scheduler feature that can mitigate some (not all) cross-HT attacks. It allows HT to be turned on safely by ensuring that only tasks in a user-designated trusted group can share a core. This increase in core sharing can also improve performance, however it is not guaranteed that performance will always improve, though that is seen to be the case with a number of real world workloads. In theory, core scheduling aims to perform at least as good as when Hyper Threading is disabled. In practice, this is mostly the case though not always: as synchronizing scheduling decisions across 2 or more CPUs in a core involves additional overhead - especially when the system is lightly loaded. When }(hhhhhNhNubhliteral)}(h``total_threads <= N_CPUS/2``h]htotal_threads <= N_CPUS/2}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh, the extra overhead may cause core scheduling to perform more poorly compared to SMT-disabled, where N_CPUS is the total number of CPUs. Please measure the performance of your workloads always.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubeh}(h]security-usecaseah ]h"]security usecaseah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hUsageh]hUsage}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK!ubh)}(hXzCore scheduling support is enabled via the ``CONFIG_SCHED_CORE`` config option. Using this feature, userspace defines groups of tasks that can be co-scheduled on the same core. The core scheduler uses this information to make sure that tasks that are not in the same group never run simultaneously on a core, while doing its best to satisfy the system's scheduling requirements.h](h+Core scheduling support is enabled via the }(hj%hhhNhNubh)}(h``CONFIG_SCHED_CORE``h]hCONFIG_SCHED_CORE}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%ubhX< config option. Using this feature, userspace defines groups of tasks that can be co-scheduled on the same core. The core scheduler uses this information to make sure that tasks that are not in the same group never run simultaneously on a core, while doing its best to satisfy the system’s scheduling requirements.}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK"hjhhubh)}(hCore scheduling can be enabled via the ``PR_SCHED_CORE`` prctl interface. This interface provides support for the creation of core scheduling groups, as well as admission and removal of tasks from created groups::h](h'Core scheduling can be enabled via the }(hjEhhhNhNubh)}(h``PR_SCHED_CORE``h]h PR_SCHED_CORE}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjEubh prctl interface. This interface provides support for the creation of core scheduling groups, as well as admission and removal of tasks from created groups:}(hjEhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK(hjhhubh literal_block)}(h#include int prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5);h]h#include int prctl(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5);}hjgsbah}(h]h ]h"]h$]h&]hhuh1jehhhK,hjhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hoption: ``PR_SCHED_CORE`` h](hterm)}(hoption:h]hoption:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK2hj|ubh definition)}(hhh]h)}(h``PR_SCHED_CORE``h]h)}(hjh]h PR_SCHED_CORE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1hhhhK2hjubah}(h]h ]h"]h$]h&]uh1jhj|ubeh}(h]h ]h"]h$]h&]uh1jzhhhK2hjwubj{)}(hX<arg2: Command for operation, must be one off: - ``PR_SCHED_CORE_GET`` -- get core_sched cookie of ``pid``. - ``PR_SCHED_CORE_CREATE`` -- create a new unique cookie for ``pid``. - ``PR_SCHED_CORE_SHARE_TO`` -- push core_sched cookie to ``pid``. - ``PR_SCHED_CORE_SHARE_FROM`` -- pull core_sched cookie from ``pid``. h](j)}(harg2:h]harg2:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK:hjubj)}(hhh](h)}(h'Command for operation, must be one off:h]h'Command for operation, must be one off:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjubh bullet_list)}(hhh](h list_item)}(h:``PR_SCHED_CORE_GET`` -- get core_sched cookie of ``pid``.h]h)}(hjh](h)}(h``PR_SCHED_CORE_GET``h]hPR_SCHED_CORE_GET}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh -- get core_sched cookie of }(hjhhhNhNubh)}(h``pid``h]hpid}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK7hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hC``PR_SCHED_CORE_CREATE`` -- create a new unique cookie for ``pid``.h]h)}(hjh](h)}(h``PR_SCHED_CORE_CREATE``h]hPR_SCHED_CORE_CREATE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh# -- create a new unique cookie for }(hjhhhNhNubh)}(h``pid``h]hpid}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK8hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h@``PR_SCHED_CORE_SHARE_TO`` -- push core_sched cookie to ``pid``.h]h)}(hjRh](h)}(h``PR_SCHED_CORE_SHARE_TO``h]hPR_SCHED_CORE_SHARE_TO}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjTubh -- push core_sched cookie to }(hjThhhNhNubh)}(h``pid``h]hpid}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhjTubh.}(hjThhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK9hjPubah}(h]h ]h"]h$]h&]uh1jhjubj)}(hE``PR_SCHED_CORE_SHARE_FROM`` -- pull core_sched cookie from ``pid``. h]h)}(hD``PR_SCHED_CORE_SHARE_FROM`` -- pull core_sched cookie from ``pid``.h](h)}(h``PR_SCHED_CORE_SHARE_FROM``h]hPR_SCHED_CORE_SHARE_FROM}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh -- pull core_sched cookie from }(hjhhhNhNubh)}(h``pid``h]hpid}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK:hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhK7hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jzhhhK:hjwhhubj{)}(h;arg3: ``pid`` of the task for which the operation applies. h](j)}(harg3:h]harg3:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhK=hjubj)}(hhh]h)}(h4``pid`` of the task for which the operation applies.h](h)}(h``pid``h]hpid}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh- of the task for which the operation applies.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK=hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jzhhhK=hjwhhubj{)}(hXarg4: ``pid_type`` for which the operation applies. It is one of ``PR_SCHED_CORE_SCOPE_``-prefixed macro constants. For example, if arg4 is ``PR_SCHED_CORE_SCOPE_THREAD_GROUP``, then the operation of this command will be performed for all tasks in the task group of ``pid``. h](j)}(harg4:h]harg4:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKChjubj)}(hhh]h)}(hX ``pid_type`` for which the operation applies. It is one of ``PR_SCHED_CORE_SCOPE_``-prefixed macro constants. For example, if arg4 is ``PR_SCHED_CORE_SCOPE_THREAD_GROUP``, then the operation of this command will be performed for all tasks in the task group of ``pid``.h](h)}(h ``pid_type``h]hpid_type}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%ubh/ for which the operation applies. It is one of }(hj%hhhNhNubh)}(h``PR_SCHED_CORE_SCOPE_``h]hPR_SCHED_CORE_SCOPE_}(hj;hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%ubh4-prefixed macro constants. For example, if arg4 is }(hj%hhhNhNubh)}(h$``PR_SCHED_CORE_SCOPE_THREAD_GROUP``h]h PR_SCHED_CORE_SCOPE_THREAD_GROUP}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%ubhZ, then the operation of this command will be performed for all tasks in the task group of }(hj%hhhNhNubh)}(h``pid``h]hpid}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj%ubh.}(hj%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK@hj"ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jzhhhKChjwhhubj{)}(harg5: userspace pointer to an unsigned long long for storing the cookie returned by ``PR_SCHED_CORE_GET`` command. Should be 0 for all other commands. h](j)}(harg5:h]harg5:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKGhjubj)}(hhh]h)}(huserspace pointer to an unsigned long long for storing the cookie returned by ``PR_SCHED_CORE_GET`` command. Should be 0 for all other commands.h](hNuserspace pointer to an unsigned long long for storing the cookie returned by }(hjhhhNhNubh)}(h``PR_SCHED_CORE_GET``h]hPR_SCHED_CORE_GET}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh- command. Should be 0 for all other commands.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKFhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jzhhhKGhjwhhubeh}(h]h ]h"]h$]h&]uh1juhjhhhhhNubh)}(hIn order for a process to push a cookie to, or pull a cookie from a process, it is required to have the ptrace access mode: `PTRACE_MODE_READ_REALCREDS` to the process.h](h|In order for a process to push a cookie to, or pull a cookie from a process, it is required to have the ptrace access mode: }(hjhhhNhNubhtitle_reference)}(h`PTRACE_MODE_READ_REALCREDS`h]hPTRACE_MODE_READ_REALCREDS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh to the process.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKIhjhhubh)}(hhh](h)}(hBuilding hierarchies of tasksh]hBuilding hierarchies of tasks}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKNubh)}(hX;The simplest way to build hierarchies of threads/processes which share a cookie and thus a core is to rely on the fact that the core-sched cookie is inherited across forks/clones and execs, thus setting a cookie for the 'initial' script/executable/daemon will place every spawned child in the same core-sched group.h]hX?The simplest way to build hierarchies of threads/processes which share a cookie and thus a core is to rely on the fact that the core-sched cookie is inherited across forks/clones and execs, thus setting a cookie for the ‘initial’ script/executable/daemon will place every spawned child in the same core-sched group.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjhhubeh}(h]building-hierarchies-of-tasksah ]h"]building hierarchies of tasksah$]h&]uh1hhjhhhhhKNubh)}(hhh](h)}(hCookie Transferralh]hCookie Transferral}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKVubh)}(hXhTransferring a cookie between the current and other tasks is possible using PR_SCHED_CORE_SHARE_FROM and PR_SCHED_CORE_SHARE_TO to inherit a cookie from a specified task or a share a cookie with a task. In combination this allows a simple helper program to pull a cookie from a task in an existing core scheduling group and share it with already running tasks.h]hXhTransferring a cookie between the current and other tasks is possible using PR_SCHED_CORE_SHARE_FROM and PR_SCHED_CORE_SHARE_TO to inherit a cookie from a specified task or a share a cookie with a task. In combination this allows a simple helper program to pull a cookie from a task in an existing core scheduling group and share it with already running tasks.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKWhjhhubeh}(h]cookie-transferralah ]h"]cookie transferralah$]h&]uh1hhjhhhhhKVubeh}(h]usageah ]h"]usageah$]h&]uh1hhhhhhhhK! referencedKubh)}(hhh](h)}(hDesign/Implementationh]hDesign/Implementation}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjChhhhhK^ubh)}(hEach task that is tagged is assigned a cookie internally in the kernel. As mentioned in `Usage`_, tasks with the same cookie value are assumed to trust each other and share a core.h](hXEach task that is tagged is assigned a cookie internally in the kernel. As mentioned in }(hjThhhNhNubh reference)}(h`Usage`_h]hUsage}(hj^hhhNhNubah}(h]h ]h"]h$]h&]nameUsagerefidj<uh1j\hjTresolvedKubhT, tasks with the same cookie value are assumed to trust each other and share a core.}(hjThhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK_hjChhubh)}(hX?The basic idea is that, every schedule event tries to select tasks for all the siblings of a core such that all the selected tasks running on a core are trusted (same cookie) at any point in time. Kernel threads are assumed trusted. The idle task is considered special, as it trusts everything and everything trusts it.h]hX?The basic idea is that, every schedule event tries to select tasks for all the siblings of a core such that all the selected tasks running on a core are trusted (same cookie) at any point in time. Kernel threads are assumed trusted. The idle task is considered special, as it trusts everything and everything trusts it.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjChhubh)}(hXDuring a schedule() event on any sibling of a core, the highest priority task on the sibling's core is picked and assigned to the sibling calling schedule(), if the sibling has the task enqueued. For rest of the siblings in the core, highest priority task with the same cookie is selected if there is one runnable in their individual run queues. If a task with same cookie is not available, the idle task is selected. Idle task is globally trusted.h]hXDuring a schedule() event on any sibling of a core, the highest priority task on the sibling’s core is picked and assigned to the sibling calling schedule(), if the sibling has the task enqueued. For rest of the siblings in the core, highest priority task with the same cookie is selected if there is one runnable in their individual run queues. If a task with same cookie is not available, the idle task is selected. Idle task is globally trusted.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjChhubh)}(hXOnce a task has been selected for all the siblings in the core, an IPI is sent to siblings for whom a new task was selected. Siblings on receiving the IPI will switch to the new task immediately. If an idle task is selected for a sibling, then the sibling is considered to be in a `forced idle` state. I.e., it may have tasks on its on runqueue to run, however it will still have to run idle. More on this in the next section.h](hXOnce a task has been selected for all the siblings in the core, an IPI is sent to siblings for whom a new task was selected. Siblings on receiving the IPI will switch to the new task immediately. If an idle task is selected for a sibling, then the sibling is considered to be in a }(hjhhhNhNubj)}(h `forced idle`h]h forced idle}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh state. I.e., it may have tasks on its on runqueue to run, however it will still have to run idle. More on this in the next section.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKphjChhubh)}(hhh](h)}(hForced-idling of hyperthreadsh]hForced-idling of hyperthreads}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKxubh)}(hXSThe scheduler tries its best to find tasks that trust each other such that all tasks selected to be scheduled are of the highest priority in a core. However, it is possible that some runqueues had tasks that were incompatible with the highest priority ones in the core. Favoring security over fairness, one or more siblings could be forced to select a lower priority task if the highest priority task is not trusted with respect to the core wide highest priority task. If a sibling does not have a trusted task to run, it will be forced idle by the scheduler (idle thread is scheduled to run).h]hXSThe scheduler tries its best to find tasks that trust each other such that all tasks selected to be scheduled are of the highest priority in a core. However, it is possible that some runqueues had tasks that were incompatible with the highest priority ones in the core. Favoring security over fairness, one or more siblings could be forced to select a lower priority task if the highest priority task is not trusted with respect to the core wide highest priority task. If a sibling does not have a trusted task to run, it will be forced idle by the scheduler (idle thread is scheduled to run).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjhhubh)}(hWhen the highest priority task is selected to run, a reschedule-IPI is sent to the sibling to force it into idle. This results in 4 cases which need to be considered depending on whether a VM or a regular usermode process was running on either HT::h]hWhen the highest priority task is selected to run, a reschedule-IPI is sent to the sibling to force it into idle. This results in 4 cases which need to be considered depending on whether a VM or a regular usermode process was running on either HT:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubjf)}(h HT1 (attack) HT2 (victim) A idle -> user space user space -> idle B idle -> user space guest -> idle C idle -> guest user space -> idle D idle -> guest guest -> idleh]h HT1 (attack) HT2 (victim) A idle -> user space user space -> idle B idle -> user space guest -> idle C idle -> guest user space -> idle D idle -> guest guest -> idle}hjsbah}(h]h ]h"]h$]h&]hhuh1jehhhKhjhhubh)}(hXNote that for better performance, we do not wait for the destination CPU (victim) to enter idle mode. This is because the sending of the IPI would bring the destination CPU immediately into kernel mode from user space, or VMEXIT in the case of guests. At best, this would only leak some scheduler metadata which may not be worth protecting. It is also possible that the IPI is received too late on some architectures, but this has not been observed in the case of x86.h]hXNote that for better performance, we do not wait for the destination CPU (victim) to enter idle mode. This is because the sending of the IPI would bring the destination CPU immediately into kernel mode from user space, or VMEXIT in the case of guests. At best, this would only leak some scheduler metadata which may not be worth protecting. It is also possible that the IPI is received too late on some architectures, but this has not been observed in the case of x86.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]forced-idling-of-hyperthreadsah ]h"]forced-idling of hyperthreadsah$]h&]uh1hhjChhhhhKxubh)}(hhh](h)}(h Trust modelh]h Trust model}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXCore scheduling maintains trust relationships amongst groups of tasks by assigning them a tag that is the same cookie value. When a system with core scheduling boots, all tasks are considered to trust each other. This is because the core scheduler does not have information about trust relationships until userspace uses the above mentioned interfaces, to communicate them. In other words, all tasks have a default cookie value of 0. and are considered system-wide trusted. The forced-idling of siblings running cookie-0 tasks is also avoided.h]hXCore scheduling maintains trust relationships amongst groups of tasks by assigning them a tag that is the same cookie value. When a system with core scheduling boots, all tasks are considered to trust each other. This is because the core scheduler does not have information about trust relationships until userspace uses the above mentioned interfaces, to communicate them. In other words, all tasks have a default cookie value of 0. and are considered system-wide trusted. The forced-idling of siblings running cookie-0 tasks is also avoided.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hOnce userspace uses the above mentioned interfaces to group sets of tasks, tasks within such groups are considered to trust each other, but do not trust those outside. Tasks outside the group also don't trust tasks within.h]hOnce userspace uses the above mentioned interfaces to group sets of tasks, tasks within such groups are considered to trust each other, but do not trust those outside. Tasks outside the group also don’t trust tasks within.}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h] trust-modelah ]h"] trust modelah$]h&]uh1hhjChhhhhKubeh}(h]design-implementationah ]h"]design/implementationah$]h&]uh1hhhhhhhhK^ubh)}(hhh](h)}(hLimitations of core-schedulingh]hLimitations of core-scheduling}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjDhhhhhKubh)}(hCore scheduling tries to guarantee that only trusted tasks run concurrently on a core. But there could be small window of time during which untrusted tasks run concurrently or kernel could be running concurrently with a task not trusted by kernel.h]hCore scheduling tries to guarantee that only trusted tasks run concurrently on a core. But there could be small window of time during which untrusted tasks run concurrently or kernel could be running concurrently with a task not trusted by kernel.}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjDhhubh)}(hhh](h)}(hIPI processing delaysh]hIPI processing delays}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjchhhhhKubh)}(hXCore scheduling selects only trusted tasks to run together. IPI is used to notify the siblings to switch to the new task. But there could be hardware delays in receiving of the IPI on some arch (on x86, this has not been observed). This may cause an attacker task to start running on a CPU before its siblings receive the IPI. Even though cache is flushed on entry to user mode, victim tasks on siblings may populate data in the cache and micro architectural buffers after the attacker starts to run and this is a possibility for data leak.h]hXCore scheduling selects only trusted tasks to run together. IPI is used to notify the siblings to switch to the new task. But there could be hardware delays in receiving of the IPI on some arch (on x86, this has not been observed). This may cause an attacker task to start running on a CPU before its siblings receive the IPI. Even though cache is flushed on entry to user mode, victim tasks on siblings may populate data in the cache and micro architectural buffers after the attacker starts to run and this is a possibility for data leak.}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjchhubeh}(h]ipi-processing-delaysah ]h"]ipi processing delaysah$]h&]uh1hhjDhhhhhKubeh}(h]limitations-of-core-schedulingah ]h"]limitations of core-schedulingah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h8Open cross-HT issues that core scheduling does not solveh]h8Open cross-HT issues that core scheduling does not solve}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h 1. For MDSh]h 1. For MDS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXCore scheduling cannot protect against MDS attacks between the siblings running in user mode and the others running in kernel mode. Even though all siblings run tasks which trust each other, when the kernel is executing code on behalf of a task, it cannot trust the code running in the sibling. Such attacks are possible for any combination of sibling CPU modes (host or guest mode).h]hXCore scheduling cannot protect against MDS attacks between the siblings running in user mode and the others running in kernel mode. Even though all siblings run tasks which trust each other, when the kernel is executing code on behalf of a task, it cannot trust the code running in the sibling. Such attacks are possible for any combination of sibling CPU modes (host or guest mode).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]for-mdsah ]h"] 1. for mdsah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h 2. For L1TFh]h 2. For L1TF}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXCore scheduling cannot protect against an L1TF guest attacker exploiting a guest or host victim. This is because the guest attacker can craft invalid PTEs which are not inverted due to a vulnerable guest kernel. The only solution is to disable EPT (Extended Page Tables).h]hXCore scheduling cannot protect against an L1TF guest attacker exploiting a guest or host victim. This is because the guest attacker can craft invalid PTEs which are not inverted due to a vulnerable guest kernel. The only solution is to disable EPT (Extended Page Tables).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hFor both MDS and L1TF, if the guest vCPU is configured to not trust each other (by tagging separately), then the guest to guest attacks would go away. Or it could be a system admin policy which considers guest to guest attacks as a guest problem.h]hFor both MDS and L1TF, if the guest vCPU is configured to not trust each other (by tagging separately), then the guest to guest attacks would go away. Or it could be a system admin policy which considers guest to guest attacks as a guest problem.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hX!Another approach to resolve these would be to make every untrusted task on the system to not trust every other untrusted task. While this could reduce parallelism of the untrusted tasks, it would still solve the above issues while allowing system processes (trusted tasks) to share a core.h]hX!Another approach to resolve these would be to make every untrusted task on the system to not trust every other untrusted task. While this could reduce parallelism of the untrusted tasks, it would still solve the above issues while allowing system processes (trusted tasks) to share a core.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]for-l1tfah ]h"] 2. for l1tfah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h/3. Protecting the kernel (IRQ, syscall, VMEXIT)h]h/3. Protecting the kernel (IRQ, syscall, VMEXIT)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKubh)}(hXjUnfortunately, core scheduling does not protect kernel contexts running on sibling hyperthreads from one another. Prototypes of mitigations have been posted to LKML to solve this, but it is debatable whether such windows are practically exploitable, and whether the performance overhead of the prototypes are worth it (not to mention, the added code complexity).h]hXjUnfortunately, core scheduling does not protect kernel contexts running on sibling hyperthreads from one another. Prototypes of mitigations have been posted to LKML to solve this, but it is debatable whether such windows are practically exploitable, and whether the performance overhead of the prototypes are worth it (not to mention, the added code complexity).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h](protecting-the-kernel-irq-syscall-vmexitah ]h"]/3. protecting the kernel (irq, syscall, vmexit)ah$]h&]uh1hhjhhhhhKubeh}(h]8open-cross-ht-issues-that-core-scheduling-does-not-solveah ]h"]8open cross-ht issues that core scheduling does not solveah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hOther Use casesh]hOther Use cases}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj<hhhhhKubh)}(hThe main use case for Core scheduling is mitigating the cross-HT vulnerabilities with SMT enabled. There are other use cases where this feature could be used:h]hThe main use case for Core scheduling is mitigating the cross-HT vulnerabilities with SMT enabled. There are other use cases where this feature could be used:}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj<hhubj)}(hhh](j)}(hpIsolating tasks that needs a whole core: Examples include realtime tasks, tasks that uses SIMD instructions etc.h]h)}(hpIsolating tasks that needs a whole core: Examples include realtime tasks, tasks that uses SIMD instructions etc.h]hpIsolating tasks that needs a whole core: Examples include realtime tasks, tasks that uses SIMD instructions etc.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj^ubah}(h]h ]h"]h$]h&]uh1jhj[hhhhhNubj)}(hGang scheduling: Requirements for a group of tasks that needs to be scheduled together could also be realized using core scheduling. One example is vCPUs of a VM.h]h)}(hGang scheduling: Requirements for a group of tasks that needs to be scheduled together could also be realized using core scheduling. One example is vCPUs of a VM.h]hGang scheduling: Requirements for a group of tasks that needs to be scheduled together could also be realized using core scheduling. One example is vCPUs of a VM.}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjvubah}(h]h ]h"]h$]h&]uh1jhj[hhhhhNubeh}(h]h ]h"]h$]h&]jjuh1jhhhKhj<hhubeh}(h]other-use-casesah ]h"]other use casesah$]h&]uh1hhhhhhhhKubeh}(h]core-schedulingah ]h"]core schedulingah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}usage]j^asrefids}nameids}(jjjjj?j<jj j7j4jAj>jjj9j6jjjjj9j6jjj jj1j.jju nametypes}(jjj?jj7jAjj9jjj9jj j1juh}(jhjhj<jj jj4jj>jCjjj6jjjDjjcj6jjjjjj.j jj<u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.