[patch 0/3] x86/fpu/xsave: Add XSAVEC support and XGETBV1 utilization

From: Thomas Gleixner
Date: Mon Apr 04 2022 - 08:11:30 EST


This series adds:

1) XSAVEC support

Hypervisors expose XSAVEC but not XSAVES to guests, but the kernel
does not support XSAVEC. Which means it cannot make use of the
compacted storage format.

2) Utilize XGETBV1

XGETBV1 reads a bitmap which contains the current active XSTATE
components. This bitmap can be used to optimize the behaviour of
XSAVES and XSAVEC by requesting only the active components to be
saved.

While the init optimization of XSAVEC and XSAVES skips writing the
state of components which are inactive, the buffer layout is still
providing the space for the inactive, but requested to save
components. Which is suboptimal in terms of prefetch and dTLB when
the active component bitmap is sparse.

Thanks,

tglx
---
include/asm/cpufeatures.h | 2
kernel/fpu/xstate.c | 145 +++++++++++++++++++++++++++++++++++++---------
kernel/fpu/xstate.h | 42 ++++++++++---
3 files changed, 152 insertions(+), 37 deletions(-)