powerpc/pseries: add support for local secure storage called Platform Keystore(PKS)
cover powerpc/pseries: add support for local secure storage called Platform Keystore(PKS)
PowerVM provides an isolated Platform Keystore(PKS) storage allocation for each partition with individually managed access controls to store sensitive information securely. Linux Kernel can access this storage by interfacing with hypervisor using a new set of hypervisor calls.
PowerVM guest secure boot intend to use Platform Keystore for the purpose of storing public keys. Secure boot requires public keys to be able to verify the grub and boot kernel. To allow authenticated
manipulation of keys, it supports variables to store key authorities
- PK/KEK and code signing keys - db. It also supports denied list to disallow booting even if signed with valid key. This is done via denied list database - dbx or sbat. These variables would be stored in PKS, and are managed and controlled by firmware.
The purpose of this patchset is to add support for users to read/write/add/delete variables required for secure boot on PowerVM.
Nayna Jain (2):
pseries: define driver for Platform Keystore
pseries: define sysfs interface to expose PKS variables
Documentation/ABI/testing/sysfs-pksvar | 77 +++ arch/powerpc/include/asm/hvcall.h | 13 +- arch/powerpc/include/asm/pks.h | 84 +++ arch/powerpc/platforms/pseries/Kconfig | 17 + arch/powerpc/platforms/pseries/Makefile | 2 + arch/powerpc/platforms/pseries/pks.c | 494 ++++++++++++++++++ arch/powerpc/platforms/pseries/pksvar-sysfs.c | 356 +++++++++++++ 7 files changed, 1042 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-pksvar create mode 100644 arch/powerpc/include/asm/pks.h create mode 100644 arch/powerpc/platforms/pseries/pks.c create mode 100644 arch/powerpc/platforms/pseries/pksvar-sysfs.c
Signature · 1 line
2.27.0
RFC PATCH 1/2 pseries: define driver for Platform Keystore
PowerVM provides an isolated Platform Keystore(PKS) storage allocation for each partition with individually managed access controls to store sensitive information securely. It provides a new set of hypervisor calls for Linux kernel to access PKS storage.
Define PKS driver using H_CALL interface to access PKS storage.
--- arch/powerpc/include/asm/hvcall.h | 13 +- arch/powerpc/include/asm/pks.h | 84 ++++ arch/powerpc/platforms/pseries/Kconfig | 10 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/pks.c | 494 ++++++++++++++++++++++++ 5 files changed, 601 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/include/asm/pks.h create mode 100644 arch/powerpc/platforms/pseries/pks.c
arch/powerpc/include/asm/hvcall.h +12 -1
@@ -97,6 +97,7 @@#define H_OP_MODE -73#define H_COP_HW -74#define H_STATE -75 +#define H_IN_USE -77#define H_UNSUPPORTED_FLAG_START -256#define H_UNSUPPORTED_FLAG_END -511#define H_MULTI_THREADS_ACTIVE -9005
@@ -321,9 +322,19 @@#define H_SCM_UNBIND_ALL 0x3FC#define H_SCM_HEALTH 0x400#define H_SCM_PERFORMANCE_STATS 0x418 +#define H_PKS_GET_CONFIG 0x41C +#define H_PKS_SET_PASSWORD 0x420 +#define H_PKS_GEN_PASSWORD 0x424 +#define H_PKS_GET_OBJECT_LABELS 0x428 +#define H_PKS_WRITE_OBJECT 0x42C +#define H_PKS_GEN_KEY 0x430 +#define H_PKS_READ_OBJECT 0x434 +#define H_PKS_REMOVE_OBJECT 0x438 +#define H_PKS_CONFIRM_OBJECT_FLUSHED 0x43C#define H_RPT_INVALIDATE 0x448#define H_SCM_FLUSH 0x44C -#define MAX_HCALL_OPCODE H_SCM_FLUSH +#define H_PKS_SB_SIGNED_UPDATE 0x454 +#define MAX_HCALL_OPCODE H_PKS_SB_SIGNED_UPDATE/* Scope args for H_SCM_UNBIND_ALL */ #define H_UNBIND_SCOPE_ALL (0x1)
arch/powerpc/include/asm/pks.h new file +84 -0
84 lines not on this page · raw message
arch/powerpc/platforms/pseries/Kconfig +10 -0
@@ -147,6 +147,16 @@ config IBMEBUS help Bus device driver for GX bus based adapters. +config PSERIES_PKS + depends on PPC_PSERIES + tristate "Support for the Platform Key Storage" + help + PowerVM provides an isolated Platform Keystore(PKS) storage + allocation for each partition with individually managed + access controls to store sensitive information securely. Select + this config to enable operating system interface to hypervisor to + access this space. + config PAPR_SCM depends on PPC_PSERIES && MEMORY_HOTPLUG && LIBNVDIMM tristate "Support for the PAPR Storage Class Memory interface"
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -33,3 +33,4 @@ obj-$(CONFIG_SUSPEND) += suspend.o obj-$(CONFIG_PPC_VAS) += vas.o obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o +obj-$(CONFIG_PSERIES_PKS) += pks.o
arch/powerpc/platforms/pseries/pks.c new file +494 -0
494 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC PATCH 2/2 pseries: define sysfs interface to expose PKS variables
In reply to Nayna JainPowerVM guest secure boot intend to use Platform Keystore(PKS) for the purpose of storing public keys to verify digital signature.
Define sysfs interface to expose PKS variables to userspace to allow read/write/add/delete operations. Each variable is shown as a read/write attribute file. The size of the file represents the size of the current content of the variable.
create_var and delete_var attribute files are always present which allow users to create/delete variables. These are write only attributes.The design has tried to be compliant with sysfs semantic to represent single value per attribute. Thus, rather than mapping a complete data structure representation to create_var, it only accepts a single formatted string to create an empty variable.
The sysfs interface is designed such as to expose PKS configuration properties, operating system variables and firmware variables. Current version exposes configuration and operating system variables. The support for exposing firmware variables will be added in the future version.
Example of pksvar sysfs interface:
# cd /sys/firmware/pksvar/ # ls config os
# cd config
# ls -ltrh total 0 -r--r--r-- 1 root root 64K Jan 21 17:55 version -r--r--r-- 1 root root 64K Jan 21 17:55 used_space -r--r--r-- 1 root root 64K Jan 21 17:55 total_size -r--r--r-- 1 root root 64K Jan 21 17:55 supported_policies -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_size -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_label_size -r--r--r-- 1 root root 64K Jan 21 17:55 flags
# cd os
# ls -ltrh total 0 -rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 104 Jan 21 17:56 var3 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:56 delete_var --w------- 1 root root 64K Jan 21 17:56 create_var
1. Read variable
# hexdump -C GLOBAL_db 00000000 00 00 00 00 a1 59 c0 a5 e4 94 a7 4a 87 b5 ab 15 |.....Y.....J....| 00000010 5c 2b f0 72 3f 03 00 00 00 00 00 00 23 03 00 00 |\+.r?.......#...| .... 00000330 02 a8 e8 ed 0f 20 60 3f 40 04 7c a8 91 21 37 eb |..... `?@.|..!7.| 00000340 f3 f1 4e |..N| 00000343
2. Write variable
cat /tmp/data.bin > <variable_name>
3. Create variable
# echo "var1" > create_var # ls -ltrh total 0 -rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 104 Jan 21 17:56 var3 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:56 delete_var --w------- 1 root root 64K Jan 21 17:57 create_var -rw------- 1 root root 0 Jan 21 17:57 var1.tmp
Current design creates a zero size temporary variable. This implies it is not yet persisted to PKS. Only once data is written to newly created temporary variable and if it is successfully stored in the PKS, that the variable is permanent. The temporary variable will get removed on reboot. The code currently doesn't remove .tmp suffix immediately when persisted. The future version will fix this.
To avoid the additional .tmp semantic, alternative option is to consider any zero size variable as temporary variable. This option is under evaluation. This would avoid any runtime sysfs magic to replace .tmp variable with real variable.
Also, the formatted string to pass to create_var will have following format in the future version:
<variable_name>:<comma-separated-policy strings>
4. Delete variable
# echo "var3" > delete_var # ls -ltrh total 0 -rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:57 create_var -rw------- 1 root root 0 Jan 21 17:57 var1.tmp --w------- 1 root root 64K Jan 21 17:58 delete_var
The var3 file is removed at runtime, if variable is successfully removed from the PKS storage.
NOTE: We are evaluating two design for userspace interface: using the sysfs or defining a new filesystem based. Any feedback on this sysfs based approach would be highly appreciated. We have tried to follow one value per attribute semantic. If that or any other semantics aren't followed properly, please let us know.
--- Documentation/ABI/testing/sysfs-pksvar | 77 ++++ arch/powerpc/platforms/pseries/Kconfig | 7 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/pksvar-sysfs.c | 356 ++++++++++++++++++ 4 files changed, 441 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-pksvar create mode 100644 arch/powerpc/platforms/pseries/pksvar-sysfs.c
Documentation/ABI/testing/sysfs-pksvar new file +77 -0
@@ -0,0 +1,77 @@ +What: /sys/firmware/pksvar +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: This directory is created if the POWER firmware supports + Platform Keystore (PKS). It exposes interface for reading/writing + variables which are persisted in PKS. + +What: /sys/firmware/pksvar/config +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: This directory lists the configuration properties of Platform + Keystore. + +What: /sys/firmware/pksvar/os +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: This directory lists all the variables owned by operating system + users and stored in Platform Keystore. + +What: /sys/firmware/pksvar/config/version +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: A value indicating version of Firmware Platform Keystore. + +What: /sys/firmware/pksvar/config/used_space +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifying amount of space used in Platform Keystore. + +What: /sys/firmware/pksvar/config/total_size +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifying total size of Platform Keystore. + +What: /sys/firmware/pksvar/config/supported_policies +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifying policies supported by Platform Keystore semantics. + +What: /sys/firmware/pksvar/config/max_object_size +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifies the maximum object size that can be supported. + +What: /sys/firmware/pksvar/config/max_object_label_size +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifies the maximum object label size that is supported. + +What: /sys/firmware/pksvar/config/flags +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: The value specifies the flags supported by Platform Keystore. + +What: /sys/firmware/pksvar/os/<attribute_file> +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: A read-write file indicating the variable stored in the Platform Keystore. + The size of the file represents the size of the actual data stored for + this variable in PKS. + +What: /sys/firmware/pksvar/os/create_var +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: A write only file used to create new variables. The user should write + formatted string containing name to this file. It creates at runtime + zero size read-write <variable-name>.tmp temporary attribute file. The + temporary variable name is not persisted to Platform Keystore until + data is updated to it. + +What: /sys/firmware/pksvar/os/delete_var +Date: August 2022 +Contact: Nayna Jain <[email protected]> +Description: A write only file used to delete existing variable. The user should + write variable name to this file. If the variable is successfully + deleted from Platform Keystore, the corresponding attribute file is + also removed at runtime.
arch/powerpc/platforms/pseries/Kconfig +7 -0
@@ -157,6 +157,13 @@ config PSERIES_PKS this config to enable operating system interface to hypervisor to access this space. +config PSERIES_PKS_SYSFS + depends on PSERIES_PKS + tristate "Support for sysfs interface the Platform Key Storage" + help + Enable sysfs based user interace to add/delete/modify variables + stored in Platform Keystore. + config PAPR_SCM depends on PPC_PSERIES && MEMORY_HOTPLUG && LIBNVDIMM tristate "Support for the PAPR Storage Class Memory interface"
arch/powerpc/platforms/pseries/Makefile +1 -0
@@ -34,3 +34,4 @@ obj-$(CONFIG_PPC_VAS) += vas.o obj-$(CONFIG_ARCH_HAS_CC_PLATFORM) += cc_platform.o obj-$(CONFIG_PSERIES_PKS) += pks.o +obj-$(CONFIG_PSERIES_PKS_SYSFS) += pksvar-sysfs.o
arch/powerpc/platforms/pseries/pksvar-sysfs.c new file +356 -0
356 lines not on this page · raw message
Signature · 1 line
2.27.0
Quoted 14 lines · Nayna Jain
PowerVM provides an isolated Platform Keystore(PKS) storage allocation for each partition with individually managed access controls to store sensitive information securely. Linux Kernel can access this storage by interfacing with hypervisor using a new set of hypervisor calls.
PowerVM guest secure boot intend to use Platform Keystore for the purpose of storing public keys. Secure boot requires public keys to be able to verify the grub and boot kernel. To allow authenticated
manipulation of keys, it supports variables to store key authorities
- PK/KEK and code signing keys - db. It also supports denied list to disallow booting even if signed with valid key. This is done via denied list database - dbx or sbat. These variables would be stored in PKS, and are managed and controlled by firmware.
Quoted 2 lines
The purpose of this patchset is to add support for users to read/write/add/delete variables required for secure boot on PowerVM.
Ok, this is like the 3rd or 4th different platform-specific proposal for this type of functionality. I think we need to give up on platform-specific user/kernel apis on this (random sysfs/securityfs files scattered around the tree), and come up with a standard place for all of this.
Please work with the other developers of the other drivers for this to make this unified so that userspace has a chance to use this in a sane manner.
thanks,
greg k-h
Hi Greg,
Quoted 5 lines
Ok, this is like the 3rd or 4th different platform-specific proposal for this type of functionality. I think we need to give up on platform-specific user/kernel apis on this (random sysfs/securityfs files scattered around the tree), and come up with a standard place for all of this.
I agree that we do have a number of platforms exposing superficially similar functionality. Indeed, back in 2019 I had a crack at a unified
approach: [1] [2].
Looking back at it now, I am not sure it ever would have worked because the semantics of the underlying firmware stores are quite different. Here are the ones I know about:
- OpenPower/PowerNV Secure Variables:
* Firmware semantics:
- flat variable space
- variables are fixed in firmware, can neither be created nor destroyed
- variable names are ASCII
- no concept of policy/attributes
* Current kernel interface semantics:
- names are case sensitive
- directory per variable
- (U)EFI variables:
* Firmware semantics:
- flat variable space
- variables can be created/destroyed but the semantics are fiddly
[3]
- variable names are UTF-16 + UUID
- variables have 32-bit attributes
* efivarfs interface semantics:
- file per variable
- attributes are the first 4 bytes of the file
- names are partially case-insensitive (UUID part) and partially case-sensitive ('name' part)
* sysfs interface semantics (as used by CONFIG_GOOGLE_SMI)
- directory per variable
- attributes are a separate sysfs file
- to create a variable you write a serialised structure to /sys/firmware/efi/vars/new_var, to delete a var you write to .../del_var
- names are case-sensitive including the UUID
- PowerVM Partition Key Store Variables:
* Firmware semantics:
- _not_ a flat space, there are 3 domains ("consumers"): firmware, bootloader and OS (not yet supported by the patch set)
- variables can be created and destroyed but the semantics are fiddly and fiddly in different ways to UEFI [4]
- variable names are arbitrary byte strings: the hypervisor permits names to contain nul and /.
- variables have 32-bit attributes ("policy") that don't align with UEFI attributes
* No stable kernel interface yet
Even if we could come up with some stable kernel interface features (e.g. decide if we want file per variable vs directory per variable), I don't know how easy it would be to deal with the underlying semantic differences - I think userspace would still need substantial per-platform knowledge.
Or have I misunderstood what you're asking for? (If you want them all to live under /sys/firmware, these ones all already do...)
Kind regards,
Daniel
[1]: https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-May/190735.html
[2]: discussion continues at https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-June/191365.html
[3]: https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-June/191496.html
[4]: An unsigned variable cannot be updated, it can only be deleted
(unless it was created with the immutable policy) and then re-created. A signed variable, on the other hand, can be updated and the only way to delete it is to submit a validly signed empty update.
Quoted 68 lines · Daniel Axtens
Hi Greg,
Quoted 5 lines
Ok, this is like the 3rd or 4th different platform-specific proposal for this type of functionality. I think we need to give up on platform-specific user/kernel apis on this (random sysfs/securityfs files scattered around the tree), and come up with a standard place for all of this.
I agree that we do have a number of platforms exposing superficially similar functionality. Indeed, back in 2019 I had a crack at a unified
approach: [1] [2].Looking back at it now, I am not sure it ever would have worked because the semantics of the underlying firmware stores are quite different. Here are the ones I know about:
- OpenPower/PowerNV Secure Variables:
* Firmware semantics:
- flat variable space
- variables are fixed in firmware, can neither be created nor destroyed
- variable names are ASCII
- no concept of policy/attributes* Current kernel interface semantics:
- names are case sensitive
- directory per variable- (U)EFI variables:
* Firmware semantics:
- flat variable space
- variables can be created/destroyed but the semantics are fiddly
[3]
- variable names are UTF-16 + UUID
- variables have 32-bit attributes* efivarfs interface semantics:
- file per variable
- attributes are the first 4 bytes of the file
- names are partially case-insensitive (UUID part) and partially case-sensitive ('name' part)* sysfs interface semantics (as used by
CONFIG_GOOGLE_SMI)
- directory per variable
- attributes are a separate sysfs file
- to create a variable you write a serialised structure to/sys/firmware/efi/vars/new_var, to delete a var you write to.../del_var
- names are case-sensitive including the UUID- PowerVM Partition Key Store Variables:
* Firmware semantics:
- _not_ a flat space, there are 3 domains ("consumers"): firmware, bootloader and OS (not yet supported by the patch set)
- variables can be created and destroyed but the semantics are fiddly and fiddly in different ways to UEFI [4]
- variable names are arbitrary byte strings: the hypervisor permits names to contain nul and /.
- variables have 32-bit attributes ("policy") that don't align with UEFI attributes* No stable kernel interface yet
Quoted 8 lines
Even if we could come up with some stable kernel interface features (e.g. decide if we want file per variable vs directory per variable), I don't know how easy it would be to deal with the underlying semantic differences - I think userspace would still need substantial per-platform knowledge.
Or have I misunderstood what you're asking for? (If you want them all to live under
/sys/firmware, these ones all already do...)
I want them to be unified in some way, right now there are lots of proposals for the same type of thing, but in different places (sysfs, securityfs, somewhere else), and with different names.
Please work together.
thanks,
greg k-h
Quoted 3 lines · Nayna Jain
Nayna Jain (2):
pseries: define driver for Platform Keystore
pseries: define sysfs interface to expose PKS variables
Hi Folks,
There another feature that we might want to consider in the naming here:
Quoted 1 line
Protection Keys for Supervisor pages is also called PKS. It's also not entirely impossible that powerpc might want to start using this code at some point, just like what happened with the userspace protection keys[1].
I don't think it's the end of the world either way, but it might save a hapless user or kernel developer some confusion if we can avoid including two "PKS" features in the kernel. I just wanted to make sure we were aware of the other's existence. :)
Re: [RFC PATCH 2/2] pseries: define sysfs interface to expose PKS variables
In reply to Nayna JainHi Nayna,
Quoted 62 lines · Nayna Jain
PowerVM guest secure boot intend to use Platform Keystore(PKS) for the purpose of storing public keys to verify digital signature.
Define sysfs interface to expose PKS variables to userspace to allow read/write/add/delete operations. Each variable is shown as a read/write attribute file. The size of the file represents the size of the current content of the variable.
create_varanddelete_varattribute files are always present which allow users to create/delete variables. These are write only attributes.The design has tried to be compliant with sysfs semantic to represent single value per attribute. Thus, rather than mapping a complete data structure representation tocreate_var, it only accepts a single formatted string to create an empty variable.The sysfs interface is designed such as to expose PKS configuration properties, operating system variables and firmware variables. Current version exposes configuration and operating system variables. The support for exposing firmware variables will be added in the future version.
Example of pksvar sysfs interface:
# cd /sys/firmware/pksvar/ # ls config os# cd config# ls -ltrh total 0(quoted diff) +0
-7-r--r--r-- 1 root root 64K Jan 21 17:55 version -r--r--r-- 1 root root 64K Jan 21 17:55 used_space -r--r--r-- 1 root root 64K Jan 21 17:55 total_size -r--r--r-- 1 root root 64K Jan 21 17:55 supported_policies -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_size -r--r--r-- 1 root root 64K Jan 21 17:55 max_object_label_size -r--r--r-- 1 root root 64K Jan 21 17:55 flags# cd os# ls -ltrh total 0(quoted diff) +0
-8-rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 104 Jan 21 17:56 var3 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:56 delete_var --w------- 1 root root 64K Jan 21 17:56 create_var1. Read variable
# hexdump -C GLOBAL_db 00000000 00 00 00 00 a1 59 c0 a5 e4 94 a7 4a 87 b5 ab 15 |.....Y.....J....| 00000010 5c 2b f0 72 3f 03 00 00 00 00 00 00 23 03 00 00 |\+.r?.......#...| .... 00000330 02 a8 e8 ed 0f 20 60 3f 40 04 7c a8 91 21 37 eb |..... `?@.|..!7.| 00000340 f3 f1 4e |..N| 00000343
Quoted 7 lines
2. Write variable
cat
/tmp/data.bin> <variable_name>3. Create variable
# echo "var1" > create_var
It would be easier to understand if the user could create a new variable like a regular new file, something like:
# cat /tmp/data.bin > var1
but I understand there are also comma-seperated-policy-strings which should go somewhere; not sure how this fits (or if there are other examples for similar interfaces in other sysfs parts).
Quoted 24 lines
# ls -ltrh total 0(quoted diff) +0
-9-rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 104 Jan 21 17:56 var3 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:56 delete_var --w------- 1 root root 64K Jan 21 17:57 create_var -rw------- 1 root root 0 Jan 21 17:57 var1.tmpCurrent design creates a zero size temporary variable. This implies it is not yet persisted to PKS. Only once data is written to newly created temporary variable and if it is successfully stored in the PKS, that the variable is permanent. The temporary variable will get removed on reboot. The code currently doesn't remove .tmp suffix immediately when persisted. The future version will fix this.
To avoid the additional .tmp semantic, alternative option is to consider any zero size variable as temporary variable. This option is under evaluation. This would avoid any runtime sysfs magic to replace .tmp variable with real variable.
Quoted 6 lines
Also, the formatted string to pass to
create_varwill have following format in the future version:
<variable_name>:<comma-separated-policy strings>4. Delete variable
# echo "var3" > delete_var
If it's possible here, I think it would be easier to understand (and use) if you implement unlink(), so deleting var3 would be:
# rm var3
(and then there's no need for the special 'delete_var' entry.)
-Dov
Quoted 30 lines
# ls -ltrh total 0(quoted diff) +0
-8-rw------- 1 root root 104 Jan 21 17:56 var4 -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_PK -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_KEK -rw------- 1 root root 76 Jan 21 17:56 GLOBAL_dbx -rw------- 1 root root 831 Jan 21 17:56 GLOBAL_db --w------- 1 root root 64K Jan 21 17:57 create_var -rw------- 1 root root 0 Jan 21 17:57 var1.tmp --w------- 1 root root 64K Jan 21 17:58 delete_varThe var3 file is removed at runtime, if variable is successfully removed from the PKS storage.
NOTE: We are evaluating two design for userspace interface: using the sysfs or defining a new filesystem based. Any feedback on this sysfs based approach would be highly appreciated. We have tried to follow one value per attribute semantic. If that or any other semantics aren't followed properly, please let us know.
Signed-off-by Nayna Jain <[email protected]>--- Documentation/ABI/testing/sysfs-pksvar | 77 ++++ arch/powerpc/platforms/pseries/Kconfig | 7 + arch/powerpc/platforms/pseries/Makefile | 1 + arch/powerpc/platforms/pseries/pksvar-sysfs.c | 356 ++++++++++++++++++ 4 files changed, 441 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-pksvar create mode 100644 arch/powerpc/platforms/pseries/pksvar-sysfs.c