xstate.c (f0dccc9da4c0fda049e99326f85db8c242fd781f) | xstate.c (50f408d96d4d1a945d2c50c5fd8ed400883edf0e) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * xsave/xrstor support. 4 * 5 * Author: Suresh Siddha <suresh.b.siddha@intel.com> 6 */ 7#include <linux/compat.h> 8#include <linux/cpu.h> --- 1347 unchanged lines hidden (view full) --- 1356 1357 /* Move xfeature 'i' into its normal location */ 1358 memmove(xbuf + xstate_comp_offsets[i], 1359 xbuf + xstate_supervisor_only_offsets[i], 1360 xstate_sizes[i]); 1361 } 1362} 1363 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * xsave/xrstor support. 4 * 5 * Author: Suresh Siddha <suresh.b.siddha@intel.com> 6 */ 7#include <linux/compat.h> 8#include <linux/cpu.h> --- 1347 unchanged lines hidden (view full) --- 1356 1357 /* Move xfeature 'i' into its normal location */ 1358 memmove(xbuf + xstate_comp_offsets[i], 1359 xbuf + xstate_supervisor_only_offsets[i], 1360 xstate_sizes[i]); 1361 } 1362} 1363 |
1364/** 1365 * copy_dynamic_supervisor_to_kernel() - Save dynamic supervisor states to 1366 * an xsave area 1367 * @xstate: A pointer to an xsave area 1368 * @mask: Represent the dynamic supervisor features saved into the xsave area 1369 * 1370 * Only the dynamic supervisor states sets in the mask are saved into the xsave 1371 * area (See the comment in XFEATURE_MASK_DYNAMIC for the details of dynamic 1372 * supervisor feature). Besides the dynamic supervisor states, the legacy 1373 * region and XSAVE header are also saved into the xsave area. The supervisor 1374 * features in the XFEATURE_MASK_SUPERVISOR_SUPPORTED and 1375 * XFEATURE_MASK_SUPERVISOR_UNSUPPORTED are not saved. 1376 * 1377 * The xsave area must be 64-bytes aligned. 1378 */ 1379void copy_dynamic_supervisor_to_kernel(struct xregs_state *xstate, u64 mask) 1380{ 1381 u64 dynamic_mask = xfeatures_mask_dynamic() & mask; 1382 u32 lmask, hmask; 1383 int err; 1384 1385 if (WARN_ON_FPU(!boot_cpu_has(X86_FEATURE_XSAVES))) 1386 return; 1387 1388 if (WARN_ON_FPU(!dynamic_mask)) 1389 return; 1390 1391 lmask = dynamic_mask; 1392 hmask = dynamic_mask >> 32; 1393 1394 XSTATE_OP(XSAVES, xstate, lmask, hmask, err); 1395 1396 /* Should never fault when copying to a kernel buffer */ 1397 WARN_ON_FPU(err); 1398} 1399 1400/** 1401 * copy_kernel_to_dynamic_supervisor() - Restore dynamic supervisor states from 1402 * an xsave area 1403 * @xstate: A pointer to an xsave area 1404 * @mask: Represent the dynamic supervisor features restored from the xsave area 1405 * 1406 * Only the dynamic supervisor states sets in the mask are restored from the 1407 * xsave area (See the comment in XFEATURE_MASK_DYNAMIC for the details of 1408 * dynamic supervisor feature). Besides the dynamic supervisor states, the 1409 * legacy region and XSAVE header are also restored from the xsave area. The 1410 * supervisor features in the XFEATURE_MASK_SUPERVISOR_SUPPORTED and 1411 * XFEATURE_MASK_SUPERVISOR_UNSUPPORTED are not restored. 1412 * 1413 * The xsave area must be 64-bytes aligned. 1414 */ 1415void copy_kernel_to_dynamic_supervisor(struct xregs_state *xstate, u64 mask) 1416{ 1417 u64 dynamic_mask = xfeatures_mask_dynamic() & mask; 1418 u32 lmask, hmask; 1419 int err; 1420 1421 if (WARN_ON_FPU(!boot_cpu_has(X86_FEATURE_XSAVES))) 1422 return; 1423 1424 if (WARN_ON_FPU(!dynamic_mask)) 1425 return; 1426 1427 lmask = dynamic_mask; 1428 hmask = dynamic_mask >> 32; 1429 1430 XSTATE_OP(XRSTORS, xstate, lmask, hmask, err); 1431 1432 /* Should never fault when copying from a kernel buffer */ 1433 WARN_ON_FPU(err); 1434} 1435 |
|
1364#ifdef CONFIG_PROC_PID_ARCH_STATUS 1365/* 1366 * Report the amount of time elapsed in millisecond since last AVX512 1367 * use in the task. 1368 */ 1369static void avx512_status(struct seq_file *m, struct task_struct *task) 1370{ 1371 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); --- 36 unchanged lines hidden --- | 1436#ifdef CONFIG_PROC_PID_ARCH_STATUS 1437/* 1438 * Report the amount of time elapsed in millisecond since last AVX512 1439 * use in the task. 1440 */ 1441static void avx512_status(struct seq_file *m, struct task_struct *task) 1442{ 1443 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); --- 36 unchanged lines hidden --- |