[PATCH v7 4/6] selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available

2021-03-16 Thread Chang S. Bae
The SIGSTKSZ constant may not represent enough stack size in some architectures as the hardware state size grows. Use getauxval(AT_MINSIGSTKSZ) to increase the stack size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org

[PATCH v7 6/6] selftest/x86/signal: Include test cases for validating sigaltstack

2021-03-16 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised test messages again

[PATCH v7 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-03-16 Thread Chang S. Bae
Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: H.J. Lu Cc: Fenghua Yu Cc: Dave Martin Cc: Michael Ellerman Cc: x...@kernel.org Cc: libc-al...@sourceware.org Cc: linux-a...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ke

[PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-03-16 Thread Chang S. Bae
the kernel allows new source code to discover and use a sufficient alternate signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Reviewed

[PATCH v7 2/6] x86/signal: Introduce helpers to get the maximum signal frame size

2021-03-16 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: x...@kernel.org Cc: linux-kernel

[PATCH v7 1/6] uapi: Define the aux vector AT_MINSIGSTKSZ

2021-03-16 Thread Chang S. Bae
Define the AT_MINSIGSTKSZ in generic Linux. It is already used as generic ABI in glibc's generic elf.h, and this define will prevent future namespace conflicts. In particular, x86 is also using this generic definition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Carlos O'Donell Cc

[PATCH v7 0/6] x86: Improve Minimum Alternate Stack Size

2021-03-16 Thread Chang S. Bae
-1-chang.seok@intel.com/ Chang S. Bae (6): uapi: Define the aux vector AT_MINSIGSTKSZ x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available x86/signal

[PATCH v6 6/6] selftest/x86/signal: Include test cases for validating sigaltstack

2021-02-27 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised test messages again

[PATCH v6 0/6] x86: Improve Minimum Alternate Stack Size

2021-02-27 Thread Chang S. Bae
-chang.seok@intel.com/ [10]: https://lore.kernel.org/lkml/20210203172242.29644-1-chang.seok@intel.com/ Chang S. Bae (6): uapi: Define the aux vector AT_MINSIGSTKSZ x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

[PATCH v6 5/6] x86/signal: Detect and prevent an alternate signal stack overflow

2021-02-27 Thread Chang S. Bae
the kernel allows new source code to discover and use a sufficient alternate signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Reviewed

[PATCH v6 4/6] selftest/sigaltstack: Use the AT_MINSIGSTKSZ aux vector if available

2021-02-27 Thread Chang S. Bae
The SIGSTKSZ constant may not represent enough stack size in some architectures as the hardware state size grows. Use getauxval(AT_MINSIGSTKSZ) to increase the stack size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org

[PATCH v6 3/6] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-02-27 Thread Chang S. Bae
Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: H.J. Lu Cc: Fenghua Yu Cc: Dave Martin Cc: Michael Ellerman Cc: x...@kernel.org Cc: libc-al...@sourceware.org Cc: linux-a...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-ke

[PATCH v6 2/6] x86/signal: Introduce helpers to get the maximum signal frame size

2021-02-27 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: x...@kernel.org Cc: linux-kernel

[PATCH v6 1/6] uapi: Define the aux vector AT_MINSIGSTKSZ

2021-02-27 Thread Chang S. Bae
Define the AT_MINSIGSTKSZ in generic Linux. It is already used as generic ABI in glibc's generic elf.h, and this define will prevent future namespace conflicts. In particular, x86 is also using this generic definition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Carlos O'Donell Cc

[PATCH v4 17/22] x86/cpufeatures/amx: Enumerate Advanced Matrix Extension (AMX) feature bits

2021-02-21 Thread Chang S. Bae
-point (BF16) elements. Here we add AMX to the kernel/user ABI, by enumerating the capability. E.g., /proc/cpuinfo: amx_tile, amx_bf16, amx_int8 Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/cpufeatures.h | 3

[PATCH v4 22/22] x86/fpu/xstate: Introduce boot-parameters to control state component support

2021-02-21 Thread Chang S. Bae
is feature). Rename XFEATURE_MASK_USER_SUPPORTED to XFEATURE_MASK_USER_ENABLED to be aligned with the new parameters. While this cmdline is currently enabled only for AMX, it is intended to be easily enabled to be useful for future XSAVE-enabled features. Signed-off-by: Chang S. Bae Reviewed-

[PATCH v4 21/22] x86/fpu/xstate: Support dynamic user state in the signal handling path

2021-02-21 Thread Chang S. Bae
ify in the signal handler that the signal frame excludes AMX data when the signaled thread has initialized AMX state. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-kselft...@vger.kernel.org --- Changes from v3: * Removed 'no functio

[PATCH v4 16/22] x86/fpu/xstate: Extend the table to map state components with features

2021-02-21 Thread Chang S. Bae
that there will be gaps in the XCR0 feature bit numbers. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v1: * Rebased on the upstream kernel (5.10) --- arch/x86/kernel/fpu/xstate.c | 41

[PATCH v4 20/22] selftest/x86/amx: Include test cases for the AMX state management

2021-02-21 Thread Chang S. Bae
initialized its AMX state. Collect the test cases of validating those operations together, as they share some common setup for the AMX state. These test cases do not depend on AMX compiler support, as they employ userspace-XSAVE directly to access AMX state. Signed-off-by: Chang S. Bae Reviewed

[PATCH v4 08/22] x86/fpu/xstate: Convert the struct fpu 'state' field to a pointer

2021-02-21 Thread Chang S. Bae
to represent the embedded buffer. Every child process will set the pointer on its creation. And the initial task sets it before dealing with soft FPU. No functional change. Suggested-by: Borislav Petkov Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel

[PATCH v4 15/22] x86/fpu/xstate: Support ptracer-induced xstate buffer expansion

2021-02-21 Thread Chang S. Bae
ptrace() may update xstate data before the target task has taken an XFD fault and expanded the xstate buffer. Detect this case and allocate a sufficient buffer to support the request. Also, disable the (now unnecessary) associated first-use fault. Signed-off-by: Chang S. Bae Reviewed-by: Len

[PATCH v4 13/22] x86/fpu/xstate: Update the xstate context copy function to support dynamic states

2021-02-21 Thread Chang S. Bae
to find a component's offset accordingly. When copying an initial value, explicitly check the init_fpstate coverage. If not found, reset the memory in the destination. Otherwise, copy values from init_fpstate. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel

[PATCH v4 14/22] x86/fpu/xstate: Expand the xstate buffer on the first use of dynamic user state

2021-02-21 Thread Chang S. Bae
() xfirstuse_not_detected() The #NM handler induces the xstate buffer expansion to save the first-used states. The XFD feature is enabled only for the compacted format. If the kernel uses the standard format, the buffer has to be always enough for all the states. Signed-off-by: Chang S. Bae Reviewed-by: Len

[PATCH v4 07/22] x86/fpu/xstate: Calculate and remember dynamic xstate buffer sizes

2021-02-21 Thread Chang S. Bae
embedded buffer size by excluding the dynamic user states from the maximum size. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated the changelog. (Borislav Petkov) * Updated the code comment. (Borislav Petkov

[PATCH v4 19/22] x86/fpu/amx: Enable the AMX feature in 64-bit mode

2021-02-21 Thread Chang S. Bae
In 64-bit mode, include the AMX state components in XFEATURE_MASK_USER_SUPPORTED. The XFD feature will be used to dynamically expand the xstate per-task buffer on the first use. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch

[PATCH v4 12/22] x86/fpu/xstate: Update the xstate buffer address finder to support dynamic states

2021-02-21 Thread Chang S. Bae
it for the address finder. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Added the function description in the kernel-doc style. (Borislav Petkov) * Removed 'no functional change' in the changelog. (Borislav Petkov) --- arch/x86

[PATCH v4 06/22] x86/fpu/xstate: Add new variables to indicate dynamic xstate buffer size

2021-02-21 Thread Chang S. Bae
as the user buffer size. No functional change. Those sizes have no difference, as the buffer is not dynamic yet. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Added as a new patch to add

[PATCH v4 05/22] x86/fpu/xstate: Add a new variable to indicate dynamic user states

2021-02-21 Thread Chang S. Bae
. The states are named as 'dynamic' supervisor states. Some define and helper are not named with dynamic supervisor states, so rename them. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated

[PATCH v4 11/22] x86/fpu/xstate: Update the xstate save function to support dynamic states

2021-02-21 Thread Chang S. Bae
Extend copy_xregs_to_kernel() to receive a mask argument of which states to save, in preparation for dynamic user state handling. Update KVM to set a valid fpu->state_mask, so it can continue to share with the core code. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org

[PATCH v4 01/22] x86/fpu/xstate: Modify the initialization helper to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
to configure XCOMP_BV for the compacted format. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Updated the changelog. (Borislav Petkov) * Updated the function comment to use

[PATCH v4 18/22] x86/fpu/amx: Define AMX state components and have it used for boot-time checks

2021-02-21 Thread Chang S. Bae
. The first implementation supports 8KB. Check the XTILEDATA state size dynamically. The feature introduces the new tile register, TMM. Define one register struct only and read the number of registers from CPUID. Cross-check the overall size with CPUID again. Signed-off-by: Chang S. Bae Reviewed

[PATCH v4 10/22] x86/fpu/xstate: Define the scope of the initial xstate data

2021-02-21 Thread Chang S. Bae
but having initial data with zeros. Expand copy_xregs_to_kernel_booting() to receive a mask argument of which states to save. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Removed the helper functions. (Borislav Petkov

[PATCH v4 02/22] x86/fpu/xstate: Modify state copy helpers to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have all the functions copying xstate take a struct fpu * pointer in preparation for dynamic state buffer support. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated the changelog

[PATCH v4 03/22] x86/fpu/xstate: Modify address finders to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have all the functions finding xstate address take a struct fpu * pointer in preparation for dynamic state buffer support. init_fpstate is a special case, which is indicated by a null pointer parameter to get_xsave_addr() and __raw_xsave_addr(). No functional change. Signed-off-by: Chang S. Bae

[PATCH v4 09/22] x86/fpu/xstate: Introduce helpers to manage the xstate buffer dynamically

2021-02-21 Thread Chang S. Bae
new field and helper to initialize the buffer. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Updated code comments. (Borislav Petkov) * Used vzalloc() instead of vmalloc() with memset(). (Borislav Petkov) * Removed the

[PATCH v4 04/22] x86/fpu/xstate: Modify the context restore helper to handle both static and dynamic buffers

2021-02-21 Thread Chang S. Bae
Have the function restoring xstate take a struct fpu * pointer in preparation for dynamic state buffer support. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v3: * Updated

[PATCH v4 00/22] x86: Support Intel Advanced Matrix Extensions

2021-02-21 Thread Chang S. Bae
rnel.org/lkml/20201001203913.9125-1-chang.seok@intel.com/ [5]: https://lore.kernel.org/lkml/20201119233257.2939-1-chang.seok@intel.com/ [6]: https://lore.kernel.org/lkml/20201223155717.19556-1-chang.seok@intel.com/ Chang S. Bae (22): x86/fpu/xstate: Modify the initialization helper t

[PATCH v2] x86/fpu: Use consistent test for X86_FEATURE_XSAVES

2021-02-05 Thread Chang S. Bae
that confusing helper and simply check the feature in the first place -- if XSAVES is available or not. Cleanup only. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Dave Hansen Cc: Borislav Petkov Cc: linux-kernel@vger.kernel.org Cc: x...@kernel.org --- Changes from v1

[PATCH v5 5/5] selftest/x86/signal: Include test cases for validating sigaltstack

2021-02-03 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Borislav Petkov Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised

[PATCH v5 2/5] x86/signal: Introduce helpers to get the maximum signal frame size

2021-02-03 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: Borislav Petkov Cc: x...@kernel.org Cc

[PATCH v5 4/5] x86/signal: Detect and prevent an alternate signal stack overflow

2021-02-03 Thread Chang S. Bae
signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Reviewed-by: Jann Horn Cc: Borislav Petkov Cc: Jann Horn Cc: x...@kernel.org Cc

[PATCH v5 3/5] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-02-03 Thread Chang S. Bae
to the support added for ARM in commit 94b07c1f8c39 ("arm64: signal: Report signal frame size to userspace via auxv"). Reported-by: Florian Weimer Fixes: c2bc11f10a39 ("x86, AVX-512: Enable AVX-512 States Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Br

[PATCH v5 0/5] x86: Improve Minimum Alternate Stack Size

2021-02-03 Thread Chang S. Bae
/lkml/20210115211038.2072-1-chang.seok@intel.com/ Chang S. Bae (5): uapi: Move the aux vector AT_MINSIGSTKSZ define to uapi x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ x86/signal: Detect and prevent an alternate

[PATCH v5 1/5] uapi: Move the aux vector AT_MINSIGSTKSZ define to uapi

2021-02-03 Thread Chang S. Bae
Move the AT_MINSIGSTKSZ definition to generic Linux from arm64. It is already used as generic ABI in glibc's generic elf.h, and this move will prevent future namespace conflicts. In particular, x86 will re-use this generic definition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc

[PATCH] x86/fpu: Use consistent test for X86_FEATURE_XSAVES

2021-02-02 Thread Chang S. Bae
and simply test for what we want to know in the first place -- if we have XSAVES or not. Cleanup only. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Dave Hansen Cc: Borislav Petkov Cc: linux-kernel@vger.kernel.org Cc: x...@kernel.org --- arch/x86/include/asm/fpu

[PATCH v4 4/4] selftest/x86/signal: Include test cases for validating sigaltstack

2021-01-15 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Borislav Petkov Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v3: * Revised

[PATCH v4 3/4] x86/signal: Detect and prevent an alternate signal stack overflow

2021-01-15 Thread Chang S. Bae
signal stack size, this check is still necessary to protect binaries with insufficient alternate signal stack size from data corruption. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Reviewed-by: Jann Horn Cc: Borislav Petkov Cc: Jann Horn Cc: x...@kernel.org Cc

[PATCH v4 1/4] x86/signal: Introduce helpers to get the maximum signal frame size

2021-01-15 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: Borislav Petkov Cc: x...@kernel.org Cc

[PATCH v4 0/4] x86: Improve Minimum Alternate Stack Size

2021-01-15 Thread Chang S. Bae
@intel.com/ [7]: https://lore.kernel.org/lkml/20201119190237.626-1-chang.seok@intel.com/ [8]: https://lore.kernel.org/lkml/20201223015312.4882-1-chang.seok@intel.com/ Chang S. Bae (4): x86/signal: Introduce helpers to get the maximum signal frame size x86/elf: Support a new ELF aux

[PATCH v4 2/4] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2021-01-15 Thread Chang S. Bae
to the support added for ARM in commit 94b07c1f8c39 ("arm64: signal: Report signal frame size to userspace via auxv"). Reported-by: Florian Weimer Fixes: c2bc11f10a39 ("x86, AVX-512: Enable AVX-512 States Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Br

[PATCH v3 21/21] x86/fpu/xstate: Introduce boot-parameters to control some state component support

2020-12-23 Thread Chang S. Bae
is feature). Rename XFEATURE_MASK_USER_SUPPORTED to XFEATURE_MASK_USER_ENABLED to be aligned with the new parameters. While this cmdline is currently enabled only for AMX, it is intended to be easily enabled to be useful for future XSAVE-enabled features. Signed-off-by: Chang S. Bae Reviewed-

[PATCH v3 18/21] x86/fpu/amx: Enable the AMX feature in 64-bit mode

2020-12-23 Thread Chang S. Bae
In 64-bit mode, include the AMX state components in XFEATURE_MASK_USER_SUPPORTED. The XFD feature will be used to dynamically allocate per-task XSAVE buffer on first use. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86

[PATCH v3 09/21] x86/fpu/xstate: Introduce wrapper functions to organize xstate buffer access

2020-12-23 Thread Chang S. Bae
supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog with task->fpu removed. (Boris Petkov) --- arch/x86/include/asm/fpu/internal.h | 10 ++ arch/x86/include/asm/

[PATCH v3 19/21] selftest/x86/amx: Include test cases for the AMX state management

2020-12-23 Thread Chang S. Bae
initialized its AMX state. Collect the test cases of validating those operations together, as they share some common setup for the AMX state. These test cases do not depend on AMX compiler support, as they employ user-space-XSAVE directly to access AMX state. Signed-off-by: Chang S. Bae Reviewed

[PATCH v3 17/21] x86/fpu/amx: Define AMX state components and have it used for boot-time checks

2020-12-23 Thread Chang S. Bae
. The first implementation supports 8KB. Check the XTILEDATA state size dynamically. The feature introduces the new tile register, TMM. Define one register struct only and read the number of registers from CPUID. Cross-check the overall size with CPUID again. Signed-off-by: Chang S. Bae Reviewed

[PATCH v3 15/21] x86/fpu/xstate: Extend the table to map xstate components with features

2020-12-23 Thread Chang S. Bae
that there will be gaps in the XCR0 feature bit numbers. No functional change, until hardware with bit number gaps in XCR0. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v1: * Rebased on the upstream kernel (5.10) --- arch/x86/kernel

[PATCH v3 16/21] x86/cpufeatures/amx: Enumerate Advanced Matrix Extension (AMX) feature bits

2020-12-23 Thread Chang S. Bae
-point (BF16) elements. Here we add AMX to the kernel/user ABI, by enumerating the capability. E.g., /proc/cpuinfo: amx_tile, amx_bf16, amx_int8 Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/cpufeatures.h | 3

[PATCH v3 14/21] x86/fpu/xstate: Support ptracer-induced xstate buffer expansion

2020-12-23 Thread Chang S. Bae
supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog with task->fpu removed. (Boris Petkov) * Updated the code comments. --- arch/x86/kernel/fpu/regset.c |

[PATCH v3 08/21] x86/fpu/xstate: Define the scope of the initial xstate data

2020-12-23 Thread Chang S. Bae
to be large but having initial data with zeros. No functional change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog for clarification. * Updated

[PATCH v3 07/21] x86/fpu/xstate: Introduce helpers to manage dynamic xstate buffers

2020-12-23 Thread Chang S. Bae
r size. No functional change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog with task->fpu removed. (Boris Petkov) * Replaced 'area' wit

[PATCH v3 13/21] x86/fpu/xstate: Expand dynamic context switch buffer on first use

2020-12-23 Thread Chang S. Bae
. No functional change until the kernel enables dynamic user states and XFD. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Changed to enable XFD only when the compacted format is used. * Updated the changelog with task

[PATCH v3 01/21] x86/fpu/xstate: Modify initialization helper to handle both static and dynamic buffers

2020-12-23 Thread Chang S. Bae
(). Also, fpstate_init_xstate() now accepts the state component bitmap to configure XCOMP_BV for the compacted format. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v2

[PATCH v3 06/21] x86/fpu/xstate: Calculate and remember dynamic xstate buffer sizes

2020-12-23 Thread Chang S. Bae
buffer size by excluding the dynamic user states from the maximum xstate size. No functional change, until the kernel enables dynamic buffer support. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from

[PATCH v3 12/21] x86/fpu/xstate: Update xstate context copy function to support dynamic buffer

2020-12-23 Thread Chang S. Bae
S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog with task->fpu removed. (Boris Petkov) --- arch/x86/kernel/fpu/xstate.c | 55 +++- 1 file changed, 41 insertions(+), 14 deleti

[PATCH v3 04/21] x86/fpu/xstate: Modify context switch helpers to handle both static and dynamic buffers

2020-12-23 Thread Chang S. Bae
In preparation for dynamic xstate buffer expansion, update the xstate restore function parameters to equally handle static in-line xstate buffer, as well as dynamically allocated xstate buffer. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc

[PATCH v3 05/21] x86/fpu/xstate: Add a new variable to indicate dynamic user states

2020-12-23 Thread Chang S. Bae
. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Updated the changelog for clarification. --- arch/x86/include/asm/fpu/xstate.h | 12 +++- arch/x86/kernel/fpu/xstate.c | 29 +++-- 2

[PATCH v3 11/21] x86/fpu/xstate: Update xstate buffer address finder to support dynamic xstate

2020-12-23 Thread Chang S. Bae
it for the address finder. No functional change until the kernel enables dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 82 +++- 1 file changed, 52 insertions(+), 30

[PATCH v3 00/21] x86: Support Intel Advanced Matrix Extensions

2020-12-23 Thread Chang S. Bae
-1-chang.seok@intel.com/ Chang S. Bae (21): x86/fpu/xstate: Modify initialization helper to handle both static and dynamic buffers x86/fpu/xstate: Modify state copy helpers to handle both static and dynamic buffers x86/fpu/xstate: Modify address finders to handle both static an

[PATCH v3 02/21] x86/fpu/xstate: Modify state copy helpers to handle both static and dynamic buffers

2020-12-23 Thread Chang S. Bae
In preparation for dynamic xstate buffer expansion, update the xstate copy function parameters to equally handle static in-line buffer, as well as dynamically allocated xstate buffer. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel

[PATCH v3 03/21] x86/fpu/xstate: Modify address finders to handle both static and dynamic buffers

2020-12-23 Thread Chang S. Bae
() and __raw_xsave_addr(). No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- Changes from v2: * Updated the changelog with task->fpu removed. (Boris Petkov) Changes from v1: * Reba

[PATCH v3 10/21] x86/fpu/xstate: Update xstate save function to support dynamic xstate

2020-12-23 Thread Chang S. Bae
ask to select states. KVM used to save all xstate via copy_xregs_to_kernel(). Update KVM to set a valid fpu->state_mask, which will be necessary to correctly handle dynamic state buffers. No functional change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len

[PATCH v3 20/21] x86/fpu/xstate: Support dynamic user state in the signal handling path

2020-12-23 Thread Chang S. Bae
ify in the signal handler that the signal frame excludes AMX data when the signaled thread has initialized AMX state. No functional change until the kernel supports the dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-kse

[PATCH v3 4/4] selftest/x86/signal: Include test cases for validating sigaltstack

2020-12-22 Thread Chang S. Bae
The test measures the kernel's signal delivery with different (enough vs. insufficient) stack sizes. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Borislav Petkov Cc: x...@kernel.org Cc: linux-kselft...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v2: * Revised

[PATCH v3 3/4] x86/signal: Prevent an alternate stack overflow before a signal delivery

2020-12-22 Thread Chang S. Bae
on systems with large XSAVE state. The effort to increase the size typically used for altstacks reduces the frequency of these overflows, but this approach is still useful for legacy binaries. Suggested-by: Jann Horn Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: Jann Horn Cc: x...@kernel.org

[PATCH v3 2/4] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ

2020-12-22 Thread Chang S. Bae
to the support added for ARM in commit 94b07c1f8c39 ("arm64: signal: Report signal frame size to userspace via auxv"). Reported-by: Florian Weimer Fixes: c2bc11f10a39 ("x86, AVX-512: Enable AVX-512 States Context Switch") Signed-off-by: Chang S. Bae Reviewed-by: Len Br

[PATCH v3 1/4] x86/signal: Introduce helpers to get the maximum signal frame size

2020-12-22 Thread Chang S. Bae
, and helper functions for the calculation to be used in a new user interface. Set max_frame_size to a system-wide worst-case value, instead of storing multiple app-specific values. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Acked-by: H.J. Lu Cc: Borislav Petkov Cc: x...@kernel.org Cc

[PATCH v3 0/4] x86: Improve Minimum Alternate Stack Size

2020-12-22 Thread Chang S. Bae
?id=153531 [5]: https://blog.linuxplumbersconf.org/2017/ocw/system/presentations/4671/original/plumbers-dm-2017.pdf [6]: https://lore.kernel.org/lkml/20200929205746.6763-1-chang.seok@intel.com/ [7]: https://lore.kernel.org/lkml/20201119190237.626-1-chang.seok@intel.com/ Chang S. Bae (4

[RFC PATCH 7/8] crypto: x86/aes-kl - Support AES algorithm using Key Locker instructions

2020-12-16 Thread Chang S. Bae
code follows the AES-NI implementation. It has higher priority than the AES-NI as providing key protection. Signed-off-by: Chang S. Bae Cc: Herbert Xu Cc: x...@kernel.org Cc: linux-cry...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/crypto/Makefile | 3 + arch/x86

[RFC PATCH 6/8] selftests/x86: Test Key Locker internal key maintenance

2020-12-16 Thread Chang S. Bae
The test validates the internal key to be the same in all CPUs. It performs the validation again with the Suspend-To-RAM (ACPI S3) state. Signed-off-by: Chang S. Bae Cc: linux-kernel@vger.kernel.org Cc: linux-kselft...@vger.kernel.org --- tools/testing/selftests/x86/Makefile| 2 +- tools

[RFC PATCH 5/8] x86/cpu: Add a config option and a chicken bit for Key Locker

2020-12-16 Thread Chang S. Bae
Add a kernel config option to enable the feature (disabled by default) at compile-time. Also, add a new command-line parameter -- 'nokeylocker' to disable the feature at boot-time. Signed-off-by: Chang S. Bae Cc: x...@kernel.org Cc: linux-...@vger.kernel.org Cc: linux-kernel@vger.kernel.org

[RFC PATCH 4/8] x86/power: Restore Key Locker internal key from the ACPI S3/4 sleep states

2020-12-16 Thread Chang S. Bae
. Disable the feature when the copy fails (or the backup corrupts). The shutdown is considered too noisy. A new key is considerable only when threads can be synchronously suspended. Signed-off-by: Chang S. Bae Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux...@vger.kernel.org --- arch/x86

[RFC PATCH 3/8] x86/msr-index: Add MSRs for Key Locker internal key

2020-12-16 Thread Chang S. Bae
Key Locker internal key in a CPU state can be backed up in a platform register. The backup can be also copied back to a CPU state. This mechanism is useful to restore the key (after system sleep). Add MSRs for the internal key backup, copy, and status check. Signed-off-by: Chang S. Bae Cc: x

[RFC PATCH 8/8] x86/cpu: Support the hardware randomization option for Key Locker internal key

2020-12-16 Thread Chang S. Bae
value to other CPUs. This randomization option is disabled when hardware does not support the key backup. Signed-off-by: Chang S. Bae Cc: Mark Brown Cc: x...@kernel.org Cc: linux-...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/keylocker.h | 2 +- arch/x86/kernel/cpu

[RFC PATCH 2/8] x86/cpu: Load Key Locker internal key at boot-time

2020-12-16 Thread Chang S. Bae
as the load is done. The BIOS may disable the feature. Check the dynamic CPUID bit (KEYLOCKER_CPUID_EBX_AESKLE) at first. Add byte code for LOADIWKEY -- an instruction to load the internal key, in the 'x86-opcode-map.txt' file to avoid objtool's misinterpretation. Signed-off-by: Chang S. Bae Cc: x

[RFC PATCH 1/8] x86/cpufeature: Enumerate Key Locker feature

2020-12-16 Thread Chang S. Bae
-specific CPUID leaf and bits for the feature enablement. Key Locker is on the disabled list, which is useful for compile-time configuration later. Signed-off-by: Chang S. Bae Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86

[RFC PATCH 0/8] x86: Support Intel Key Locker

2020-12-16 Thread Chang S. Bae
/content/dam/develop/external/us/en/documents/343965-intel-key-locker-speci$ Chang S. Bae (8): x86/cpufeature: Enumerate Key Locker feature x86/cpu: Load Key Locker internal key at boot-time x86/msr-index: Add MSRs for Key Locker internal key x86/power: Restore Key Locker internal key from

[PATCH v2 02/22] x86/fpu/xstate: Modify xstate copy helper prototypes to access all the possible areas

2020-11-19 Thread Chang S. Bae
The xstate infrastructure is not flexible to support dynamic areas in task->fpu. Make the xstate copy functions to access task->fpu directly. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/inclu

[PATCH v2 13/22] x86/fpu/xstate: Expand dynamic user state area on first use

2020-11-19 Thread Chang S. Bae
use status and handling #NM trap: xfirstuse_enabled() xfirstuse_not_detected() The #NM handler induces the xstate area expansion to save the first-used states. No functional change until the kernel enables dynamic user states and XFD. Signed-off-by: Chang S. Bae Reviewed-by:

[PATCH v2 22/22] x86/fpu/xstate: Introduce boot-parameters for control some state component support

2020-11-19 Thread Chang S. Bae
at does NOT have AMX compiled into XFEATURE_MASK_USER_ENABLED (assuming the kernel is new enough to support this feature). While this cmdline is currently enabled only for AMX, it is intended to be easily enabled to be useful for future XSAVE-enabled features. Signed-off-by: Chang S. Bae Reviewed-

[PATCH v2 01/22] x86/fpu/xstate: Modify area init helper prototypes to access all the possible areas

2020-11-19 Thread Chang S. Bae
xstate() now accepts the state component bitmap to configure XCOMP_BV. No functional change. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- arch/x86/include/asm/fpu/internal.h | 6 +++--- arch/x86/kernel/fpu/

[PATCH v2 15/22] x86/fpu/xstate: Support ptracer-induced xstate area expansion

2020-11-19 Thread Chang S. Bae
ptrace() may request an update to task->fpu that has not yet been allocated. Detect this case and allocate task->fpu to support the request. Also, disable the (now unnecessary) associated first-use fault. No functional change until the kernel supports dynamic user states. Signed-off-by: C

[PATCH v2 18/22] x86/fpu/amx: Define AMX state components and have it used for boot-time checks

2020-11-19 Thread Chang S. Bae
. The first implementation supports 8KB. Check the XTILEDATA state size dynamically. The feature introduces the new tile register, TMM. Define one register struct only and read the number of registers from CPUID. Cross-check the overall size with CPUID again. Signed-off-by: Chang S. Bae Reviewed

[PATCH v2 07/22] x86/fpu/xstate: Introduce helpers to manage an xstate area dynamically

2020-11-19 Thread Chang S. Bae
igned-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v1: * Removed unneeded interrupt masking (Andy Lutomirski) * Added vmalloc() error tracing (Dave Hansen, PeterZ, and Andy Lutomirski) --- arch/x86/include/asm/fpu/types

[PATCH v2 10/22] x86/fpu/xstate: Update xstate save function for supporting dynamic user xstate

2020-11-19 Thread Chang S. Bae
E's instruction mask to select states. KVM saves xstate in guest_fpu and user_fpu. With the change, the KVM code needs to ensure a valid fpu->state_mask before XSAVE. No functional change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.

[PATCH v2 20/22] selftest/x86/amx: Include test cases for the AMX state management

2020-11-19 Thread Chang S. Bae
has initialized its AMX state. Collect the test cases of validating those operations together, as they share some common setup for the AMX state. These test cases do not depend on AMX compiler support, as they employ user-space-XSAVE directly to access AMX state. Signed-off-by: Chang S. Bae

[PATCH v2 12/22] x86/fpu/xstate: Update xstate context copy function for supporting dynamic area

2020-11-19 Thread Chang S. Bae
ate. No functional change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 55 +++- 1 file changed, 41 insertions(+), 14 deleti

[PATCH v2 06/22] x86/fpu/xstate: Outline dynamic xstate area size in the task context

2020-11-19 Thread Chang S. Bae
nly. No functional change as long as the kernel does not support the dynamic area. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org Cc: k...@vger.kernel.org --- arch/x86/include/asm/processor.h | 10 ++- arch/x86/kernel/fpu/core.c |

[PATCH v2 00/22] x86: Support Intel Advanced Matrix Extensions

2020-11-19 Thread Chang S. Bae
@intel.com/ Chang S. Bae (22): x86/fpu/xstate: Modify area init helper prototypes to access all the possible areas x86/fpu/xstate: Modify xstate copy helper prototypes to access all the possible areas x86/fpu/xstate: Modify address finder prototypes to access all the possible areas

[PATCH v2 11/22] x86/fpu/xstate: Update xstate area address finder for supporting dynamic user xstate

2020-11-19 Thread Chang S. Bae
it for the address finder. No functional change until the kernel enables dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/kernel/fpu/xstate.c | 82 +++- 1 file changed, 52 insertions(+), 30

[PATCH v2 09/22] x86/fpu/xstate: Introduce wrapper functions for organizing xstate area access

2020-11-19 Thread Chang S. Bae
change until the kernel supports dynamic user states. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x...@kernel.org Cc: linux-kernel@vger.kernel.org --- arch/x86/include/asm/fpu/internal.h | 10 ++ arch/x86/include/asm/fpu/xstate.h | 10 ++ arch/x86/include/asm/trace/f

  1   2   3   4   5   6   >