linux/Documentation/ABI/stable
Jarkko Sakkinen 50468e4313 x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node
== Problem ==

The amount of SGX memory on a system is determined by the BIOS and it
varies wildly between systems.  It can be as small as dozens of MB's
and as large as many GB's on servers.  Just like how applications need
to know how much regular RAM is available, enclave builders need to
know how much SGX memory an enclave can consume.

== Solution ==

Introduce a new sysfs file:

	/sys/devices/system/node/nodeX/x86/sgx_total_bytes

to enumerate the amount of SGX memory available in each NUMA node.
This serves the same function for SGX as /proc/meminfo or
/sys/devices/system/node/nodeX/meminfo does for normal RAM.

'sgx_total_bytes' is needed today to help drive the SGX selftests.
SGX-specific swap code is exercised by creating overcommitted enclaves
which are larger than the physical SGX memory on the system.  They
currently use a CPUID-based approach which can diverge from the actual
amount of SGX memory available.  'sgx_total_bytes' ensures that the
selftests can work efficiently and do not attempt stupid things like
creating a 100,000 MB enclave on a system with 128 MB of SGX memory.

== Implementation Details ==

Introduce CONFIG_HAVE_ARCH_NODE_DEV_GROUP opt-in flag to expose an
arch specific attribute group, and add an attribute for the amount of
SGX memory in bytes to each NUMA node:

== ABI Design Discussion ==

As opposed to the per-node ABI, a single, global ABI was considered.
However, this would prevent enclaves from being able to size
themselves so that they fit on a single NUMA node.  Essentially, a
single value would rule out NUMA optimizations for enclaves.

Create a new "x86/" directory inside each "nodeX/" sysfs directory.
'sgx_total_bytes' is expected to be the first of at least a few
sgx-specific files to be placed in the new directory.  Just scanning
/proc/meminfo, these are the no-brainers that we have for RAM, but we
need for SGX:

	MemTotal:       xxxx kB // sgx_total_bytes (implemented here)
	MemFree:        yyyy kB // sgx_free_bytes
	SwapTotal:      zzzz kB // sgx_swapped_bytes

So, at *least* three.  I think we will eventually end up needing
something more along the lines of a dozen.  A new directory (as
opposed to being in the nodeX/ "root") directory avoids cluttering the
root with several "sgx_*" files.

Place the new file in a new "nodeX/x86/" directory because SGX is
highly x86-specific.  It is very unlikely that any other architecture
(or even non-Intel x86 vendor) will ever implement SGX.  Using "sgx/"
as opposed to "x86/" was also considered.  But, there is a real chance
this can get used for other arch-specific purposes.

[ dhansen: rewrite changelog ]

Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211116162116.93081-2-jarkko@kernel.org
2021-12-09 07:02:22 -08:00
..
firewire-cdev docs: ABI: cleanup several ABI documents 2020-10-30 13:14:29 +01:00
o2cb ABI: o2cb: add an obsolete file for /sys/o2cb 2021-09-28 12:48:15 +02:00
procfs-audit_loginuid audit: drop /proc/PID/loginuid documentation Format field 2021-04-01 18:32:24 -04:00
syscalls
sysfs-acpi-pmprofile docs: ABI: cleanup several ABI documents 2020-10-30 13:14:29 +01:00
sysfs-bus-firewire docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-bus-fsl-mc bus: fsl-mc: add autorescan sysfs 2021-01-27 15:13:53 +01:00
sysfs-bus-mhi bus: mhi: core: Introduce sysfs entries for MHI 2020-10-02 11:33:47 +02:00
sysfs-bus-nvmem docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-bus-usb docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-bus-vmbus docs: typo fixes in Documentation/ABI/ 2021-05-13 09:13:25 -06:00
sysfs-bus-w1 docs: ABI: cleanup several ABI documents 2020-10-30 13:14:29 +01:00
sysfs-bus-xen-backend docs: typo fixes in Documentation/ABI/ 2021-05-13 09:13:25 -06:00
sysfs-class-backlight docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-class-infiniband ABI: sysfs-class-infiniband: use wildcards on What definitions 2021-09-21 18:31:16 +02:00
sysfs-class-rfkill docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-class-tpm ABI: sysfs-class-tpm: use wildcards for pcr-* nodes 2021-09-21 18:31:15 +02:00
sysfs-class-ubi UBI: Add ro-mode sysfs attribute 2016-05-24 15:15:26 +02:00
sysfs-class-udc Documentation: ABI: sysfs-class-udc: remove duplicated entry 2017-06-13 13:21:04 +03:00
sysfs-devices ABI: sysfs-devices: add /dev ABI 2021-09-28 12:48:15 +02:00
sysfs-devices-node x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node 2021-12-09 07:02:22 -08:00
sysfs-devices-system-cpu topology: Represent clusters of CPUs within a die 2021-10-15 11:25:15 +02:00
sysfs-devices-system-xen_memory xen/balloon: add runtime control for scrubbing ballooned out pages 2018-09-14 08:51:10 -04:00
sysfs-driver-aspeed-vuart drivers/tty/serial/8250: Make Aspeed VUART SIRQ polarity configurable 2019-10-04 15:05:20 +02:00
sysfs-driver-dma-idxd dmanegine: idxd: add software command status 2021-07-28 17:56:55 +05:30
sysfs-driver-dma-ioatdma docs: ABI: sysfs-driver-dma-ioatdma: what starts with /sys 2020-11-02 13:45:37 +01:00
sysfs-driver-firmware-zynqmp docs: ABI: fix syntax to be parsed using ReST notation 2020-10-30 13:12:39 +01:00
sysfs-driver-ib_srp docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-driver-mlxreg-io docs: ABI: fix documentation warning in sysfs-driver-mlxreg-io 2021-10-22 10:57:11 +02:00
sysfs-driver-qla2xxx
sysfs-driver-speakup speakup: Make dectlk flush timeout configurable 2021-02-04 17:05:48 +01:00
sysfs-driver-usb-usbtmc usb: usbtmc: Remove sysfs group TermChar and auto_abort 2018-09-20 13:04:03 +02:00
sysfs-driver-w1_ds28e04 docs: w1: convert to ReST and add to the kAPI group of docs 2019-07-31 14:16:17 -06:00
sysfs-driver-w1_ds28ea00 docs: w1: convert to ReST and add to the kAPI group of docs 2019-07-31 14:16:17 -06:00
sysfs-driver-w1_ds2438 w1: ds2438: support for writing to offset register 2021-05-21 14:51:33 +02:00
sysfs-firmware-efi-vars docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-firmware-opal-dump docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-firmware-opal-elog docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-fs-orangefs Orangefs: kernel client part 6 2015-10-03 11:39:59 -04:00
sysfs-hypervisor-xen docs: ABI: stable: make files ReST compatible 2020-10-30 13:07:01 +01:00
sysfs-kernel-notes docs: stable-ABI: Document /sys/kernel/notes 2020-09-16 12:17:47 -06:00
sysfs-module ABI: stable/sysfs-module: document version and srcversion 2021-09-28 12:48:14 +02:00
sysfs-transport-srp scsi_transport_srp: Add periodic reconnect support 2013-11-08 14:43:16 -08:00
thermal-notification thermal: Add event notification to thermal framework 2011-01-12 00:08:35 -05:00
vdso docs: ABI: vdso: use the right format for ABI 2020-10-30 13:12:53 +01:00