tpm, tpm_vtpm_proxy: boot-time TPM
Subsystems (4)
Jarkko Sakkinen
maintainerRFC PATCH 1/1 tpm, tpm_vtpm_proxy: boot-time TPM
From: Jarkko Sakkinen <[email protected]>
Provide a kernel command-line parameter named as supplicant, which contains a path to an TPM emulator binary. When defind, the kernel will launch the program during boot-time.
This feature is most useful in feature testing e.g., in environments where other means are not possible, such as CI runners. Its original use case highlights also quite well of its applicability for pre-production
hardware: it was used to provide a TPM implemnentation for a RISC-V SoC running on FPGA with no TPM HW implementation at the time.
---
Bumped into this in my archives so thought to make it available just in case anyone is interested.
--- .../admin-guide/kernel-parameters.txt | 14 +++++ drivers/char/tpm/tpm_vtpm_proxy.c | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +14 -0
@@ -7230,6 +7230,20 @@ defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_vtpm_proxy.supplicant= [TPM] + When defined, this field must contain a legit path to a + program emulating a TPM chip, which will be started + during the driver initialization, thus providing a + mechanism for the user space have an emulated TPM from + the get go. Kernel prepares the process with a file + pre-opened file descriptor in the index 3 for + /dev/vtpmx. + + An emulator can optionally provide support for + localities by reacting to the vendor command defined + by the driver: 0x20001000. Its payload is a single + byte containing the new locality. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot up
drivers/char/tpm/tpm_vtpm_proxy.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.39.5
Dear Jarkko,
Am 16.07.25 um 14:18 schrieb Jarkko Sakkinen:
Quoted 1 line
From: Jarkko Sakkinen <[email protected]>
Congratulations on the new(?) job! Big thanks to that company to do upstream Linux kernel work.
Quoted 2 lines
Provide a kernel command-line parameter named as
supplicant, which contains a path to an TPM emulator binary. When defind, the kernel will
defin*e*d
Quoted 6 lines
launch the program during boot-time.
This feature is most useful in feature testing e.g., in environments where other means are not possible, such as CI runners. Its original use case highlights also quite well of its applicability for pre-production
hardware: it was used to provide a TPM implemnentation for a RISC-V SoC
implementation
Quoted 6 lines
running on FPGA with no TPM HW implementation at the time.
Signed-off-by Jarkko Sakkinen <[email protected]>---
Bumped into this in my archives so thought to make it available just in case anyone is interested.
Do you have such a TPM emulator binary?
Thank you for upstreaming this.
Quoted 89 lines
--- .../admin-guide/kernel-parameters.txt | 14 +++++ drivers/char/tpm/tpm_vtpm_proxy.c | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+)Documentation/admin-guide/kernel-parameters.txt +14
-0@@ -7230,6 +7230,20 @@ defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_vtpm_proxy.supplicant= [TPM] + When defined, this field must contain a legit path to a + program emulating a TPM chip, which will be started + during the driver initialization, thus providing a + mechanism for the user space have an emulated TPM from + the get go. Kernel prepares the process with a file + pre-opened file descriptor in the index 3 for + /dev/vtpmx. + + An emulator can optionally provide support for + localities by reacting to the vendor command defined + by the driver: 0x20001000. Its payload is a single + byte containing the new locality. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot updrivers/char/tpm/tpm_vtpm_proxy.c +44
-0@@ -51,6 +51,8 @@ struct proxy_dev {#define VTPM_PROXY_FLAGS_ALL (VTPM_PROXY_FLAG_TPM2)static struct workqueue_struct *workqueue; +static char *supplicant; +module_param (supplicant, charp,0 );static void vtpm_proxy_delete_device (struct proxy_dev *proxy_dev);@@ -678,6 +680,55 @@ static const struct file_operations vtpmx_fops = { .llseek = noop_llseek, }; +static int vtpmx_supplicant_setup (struct subprocess_info *info,struct cred *new) +{ +struct vtpm_proxy_new_dev dev = { .flags =VTPM_PROXY_FLAG_TPM2 }; +struct file *file =vtpm_proxy_create_device (&dev); + +if (IS_ERR (file)) +return PTR_ERR (file); + +fd_install (dev.fd, file); +return 0 ; +} + +static void vtpmx_supplicant_cleanup (struct subprocess_info *info) +{ +} + +static int vtpmx_supplicant_init (void ) +{ +static const char *const argv[] = { supplicant,NULL }; +struct subprocess_info *info; +int ret; + +if (!supplicant) +return 0 ; + + info =call_usermodehelper_setup (argv[0 ], (char **)argv,NULL , +GFP_KERNEL , vtpmx_supplicant_setup, + vtpmx_supplicant_cleanup,NULL ); +if (!info) +return -ENOMEM ; + + ret =call_usermodehelper_exec (info,UMH_KILLABLE |UMH_NO_WAIT ); +if (ret) +return ret; + +return 0 ; +} + +static int vtpmx_init (void ) +{ +int ret; +
drivers/char/tpm/tpm_vtpm_proxy.c static const struct file_operations vtpmx_fops = { · line 734
Quoted 10 lines
drivers/char/tpm/tpm_vtpm_proxy.c +7
-0+ ret =vtpmx_supplicant_init (); +if (ret) +return ret; + +return misc_register (&vtpmx_miscdev); +} +static struct miscdevice vtpmx_miscdev = { .minor =MISC_DYNAMIC_MINOR , .name ="vtpmx" ,
Kind regards,
Paul
Jarkko Sakkinen
maintainerQuoted 14 lines · Paul Menzel
Dear Jarkko,
Am 16.07.25 um 14:18 schrieb Jarkko Sakkinen:
Quoted 1 line
From: Jarkko Sakkinen <[email protected]>
Congratulations on the new(?) job! Big thanks to that company to do upstream Linux kernel work.
Quoted 2 lines
Provide a kernel command-line parameter named as
supplicant, which contains a path to an TPM emulator binary. When defind, the kernel willdefin*e*d
Quoted 8 lines
Quoted 6 lines
launch the program during boot-time.
This feature is most useful in feature testing e.g., in environments where other means are not possible, such as CI runners. Its original use case highlights also quite well of its applicability for pre-production
hardware: it was used to provide a TPM implemnentation for a RISC-V SoCimplementation
Thanks for the corrections!
I think also the code changes are actually half-broken or missing some of the stuff. I'm glad that I remebered to use RFC tag ;-)
Quoted 11 lines
Quoted 7 lines
running on FPGA with no TPM HW implementation at the time.
Signed-off-by Jarkko Sakkinen <[email protected]>---
Bumped into this in my archives so thought to make it available just in case anyone is interested.Do you have such a TPM emulator binary?
Thank you for upstreaming this.
It was like internal project within research group but e.g, MS TPM emulator [1] is pretty easy to wrap and wire with a program that does three functions:
1. Feeds the emulator with incoming data coming from the client through socket provided by vtpmx.
2. Writes the data coming from the emulator back to the client.
3. Handles TPM2_CC_LOCALITY.
MS TPM 2.0 emulator is quite generic and abstracted out code, so you can almost just take the source files, ignore the build files, and meld it into your own thing and it will envetually work, if you spend a few afternoons on it :-)
[1] https://github.com/microsoft/ms-tpm-20-ref
BR, Jarkko
Randy Dunlap
reviewer(mostly nits, along with Paul's comments)
Quoted 4 lines · Jarkko Sakkinen
From: Jarkko Sakkinen <[email protected]>
Provide a kernel command-line parameter named as
supplicant, which contains a path to an TPM emulator binary. When defind, the kernel will
to a TPM
Quoted 3 lines
launch the program during boot-time.
This feature is most useful in feature testing e.g., in environments
testing, e.g.,
Quoted 19 lines
where other means are not possible, such as CI runners. Its original use case highlights also quite well of its applicability for pre-production
hardware: it was used to provide a TPM implemnentation for a RISC-V SoC running on FPGA with no TPM HW implementation at the time.Signed-off-by Jarkko Sakkinen <[email protected]>---
Bumped into this in my archives so thought to make it available just in case anyone is interested.--- .../admin-guide/kernel-parameters.txt | 14 +++++ drivers/char/tpm/tpm_vtpm_proxy.c | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+)Documentation/admin-guide/kernel-parameters.txt +0
-0
Documentation/admin-guide/kernel-parameters.txt line 7234
Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -7230,6 +7230,20 @@ defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_vtpm_proxy.supplicant= [TPM] + When defined, this field must contain a legit path to a
legitimate
or valid
Documentation/admin-guide/kernel-parameters.txt line 7238
Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4
-0+ program emulating a TPM chip, which will be started + during the driver initialization, thus providing a + mechanism for the user space have an emulated TPM from + the get go. Kernel prepares the process with a file
get-go.
or just don't use slang terms.
Documentation/admin-guide/kernel-parameters.txt line 7249
Quoted 11 lines
Documentation/admin-guide/kernel-parameters.txt +8
-0+ pre-opened file descriptor in the index 3 for + /dev/vtpmx. + + An emulator can optionally provide support for + localities by reacting to the vendor command defined + by the driver: 0x20001000. Its payload is a single + byte containing the new locality. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot up
thanks.
Signature · 1 line
~Randy
Jarkko Sakkinen
maintainerQuoted 53 lines · Randy Dunlap
(mostly nits, along with Paul's comments)
Quoted 4 lines · Jarkko Sakkinen
From: Jarkko Sakkinen <[email protected]>
Provide a kernel command-line parameter named as
supplicant, which contains a path to an TPM emulator binary. When defind, the kernel willto a TPM
Quoted 3 lines
launch the program during boot-time.
This feature is most useful in feature testing e.g., in environments
testing, e.g.,Quoted 19 lines
where other means are not possible, such as CI runners. Its original use case highlights also quite well of its applicability for pre-production
hardware: it was used to provide a TPM implemnentation for a RISC-V SoC running on FPGA with no TPM HW implementation at the time.Signed-off-by Jarkko Sakkinen <[email protected]>---
Bumped into this in my archives so thought to make it available just in case anyone is interested.--- .../admin-guide/kernel-parameters.txt | 14 +++++ drivers/char/tpm/tpm_vtpm_proxy.c | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+)Documentation/admin-guide/kernel-parameters.txt +0
-0Documentation/admin-guide/kernel-parameters.txt line 7234
Quoted 5 lines
Documentation/admin-guide/kernel-parameters.txt +2
-0@@ -7230,6 +7230,20 @@ defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_vtpm_proxy.supplicant= [TPM] + When defined, this field must contain a legit path to alegitimate
or validDocumentation/admin-guide/kernel-parameters.txt line 7238
Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +4
-0+ program emulating a TPM chip, which will be started + during the driver initialization, thus providing a + mechanism for the user space have an emulated TPM from + the get go. Kernel prepares the process with a fileget-go.or just don't use slang terms.
Quoted 16 lines
Documentation/admin-guide/kernel-parameters.txt line 7249
Quoted 11 lines
Documentation/admin-guide/kernel-parameters.txt +8
-0+ pre-opened file descriptor in the index 3 for + /dev/vtpmx. + + An emulator can optionally provide support for + localities by reacting to the vendor command defined + by the driver: 0x20001000. Its payload is a single + byte containing the new locality. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot upthanks.
Signature · 1 line
~Randy
Thank you for reviewing this (especially given how bad shape it was)!
BR, Jarkko
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Jarkko,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on char-misc/char-misc-next char-misc/char-misc-linus linus/master v6.16-rc6 next-20250716] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jarkko-Sakkinen/tpm-tpm_vtpm_proxy-boot-time-TPM/20250716-201945 base: char-misc/char-misc-testing patch link: https://lore.kernel.org/r/20250716121823.173949-1-jarkko%40kernel.org patch subject: [RFC PATCH] tpm, tpm_vtpm_proxy: boot-time TPM config: s390-randconfig-001-20250717 (https://download.01.org/0day-ci/archive/20250717/[email protected]/config) compiler: s390-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250717/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/char/tpm/tpm_vtpm_proxy.c: In function 'vtpmx_supplicant_init':
>> drivers/char/tpm/tpm_vtpm_proxy.c:699:39: error: initializer element is not constant
static const char * const argv[] = { supplicant, NULL };
^~~~~~~~~~
drivers/char/tpm/tpm_vtpm_proxy.c:699:39: note: (near initialization for 'argv[0]')
drivers/char/tpm/tpm_vtpm_proxy.c: In function 'vtpmx_init':
>> drivers/char/tpm/tpm_vtpm_proxy.c:727:24: error: 'vtpmx_miscdev' undeclared (first use in this function); did you mean 'vtpmx_init'?
return misc_register(&vtpmx_miscdev);
^~~~~~~~~~~~~
vtpmx_init
drivers/char/tpm/tpm_vtpm_proxy.c:727:24: note: each undeclared identifier is reported only once for each function it appears in
At top level:
>> drivers/char/tpm/tpm_vtpm_proxy.c:719:12: warning: 'vtpmx_init' defined but not used [-Wunused-function] static int vtpmx_init(void)
^~~~~~~~~~
vim +699 drivers/char/tpm/tpm_vtpm_proxy.c
696
697 static int vtpmx_supplicant_init(void)
698 {
> 699 static const char * const argv[] = { supplicant, NULL };
700 struct subprocess_info *info;
701 int ret;
702
703 if (!supplicant)
704 return 0;
705
706 info = call_usermodehelper_setup(argv[0], (char **)argv, NULL,
707 GFP_KERNEL, vtpmx_supplicant_setup,
708 vtpmx_supplicant_cleanup, NULL);
709 if (!info)
710 return -ENOMEM;
711
712 ret = call_usermodehelper_exec(info, UMH_KILLABLE | UMH_NO_WAIT);
713 if (ret)
714 return ret;
715
716 return 0;
717 }
718
> 719 static int vtpmx_init(void)
720 {
721 int ret;
722
723 ret = vtpmx_supplicant_init();
724 if (ret)
725 return ret;
726
> 727 return misc_register(&vtpmx_miscdev); 728 }
729
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki