Message ID | 20230326224426.3918167-2-ninad@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | Add support for TPM devices over I2C bus | expand |
On Sun, 26 Mar 2023 at 22:44, Ninad Palsule <ninad@linux.ibm.com> wrote: > > This is a documentation change for I2C TPM device support. > > Qemu already supports devices attached to ISA and sysbus. > This drop adds support for the I2C bus attached TPM devices. > > Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> > > --- > V2: > > Incorporated Stephen's review comments > - Added example in the document. > > --- > V4: > Incorporate Cedric & Stefan's comments > > - Added example for ast2600-evb > - Corrected statement about arm virtual machine. > > --- > V6: > Incorporated review comments from Stefan. > --- > docs/specs/tpm.rst | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst > index 535912a92b..590e670a9a 100644 > --- a/docs/specs/tpm.rst > +++ b/docs/specs/tpm.rst > @@ -21,12 +21,16 @@ QEMU files related to TPM TIS interface: > - ``hw/tpm/tpm_tis_common.c`` > - ``hw/tpm/tpm_tis_isa.c`` > - ``hw/tpm/tpm_tis_sysbus.c`` > + - ``hw/tpm/tpm_tis_i2c.c`` > - ``hw/tpm/tpm_tis.h`` > > Both an ISA device and a sysbus device are available. The former is > used with pc/q35 machine while the latter can be instantiated in the > Arm virt machine. > > +An I2C device support is also provided which can be instantiated in the Arm > +based emulation machines. This device only supports the TPM 2 protocol. > + > CRB interface > ------------- > > @@ -348,6 +352,34 @@ In case an Arm virt machine is emulated, use the following command line: > -drive if=pflash,format=raw,file=flash0.img,readonly=on \ > -drive if=pflash,format=raw,file=flash1.img > > +In case a ast2600-evb bmc machine is emulated and want to use TPM device > +attached to I2C bus, use the following command line: > + > +.. code-block:: console > + > + qemu-system-arm -M ast2600-evb -nographic \ > + -kernel arch/arm/boot/zImage \ > + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ > + -initrd rootfs.cpio \ > + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ > + -tpmdev emulator,id=tpm0,chardev=chrtpm \ > + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e For testing, use this command to load the driver to the correct address: echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device (I don't know how specific we want to make the instructions, but adding a line like above would help others from having to re-discover the command). > + > +In case a Rainier bmc machine is emulated and want to use TPM device > +attached to I2C bus, use the following command line: > + > +.. code-block:: console > + > + qemu-system-arm -M rainier-bmc -nographic \ > + -kernel ${IMAGEPATH}/fitImage-linux.bin \ > + -dtb ${IMAGEPATH}/aspeed-bmc-ibm-rainier.dtb \ > + -initrd ${IMAGEPATH}/obmc-phosphor-initramfs.rootfs.cpio.xz \ > + -drive file=${IMAGEPATH}/obmc-phosphor-image.rootfs.wic.qcow2,if=sd,index=2\ > + -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443\ > + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ > + -tpmdev emulator,id=tpm0,chardev=chrtpm \ > + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e > + I'd drop this example, the above one is enough. > In case SeaBIOS is used as firmware, it should show the TPM menu item > after entering the menu with 'ESC'. > > -- > 2.37.2 >
On 3/27/23 09:47, Joel Stanley wrote: > On Sun, 26 Mar 2023 at 22:44, Ninad Palsule <ninad@linux.ibm.com> wrote: >> >> This is a documentation change for I2C TPM device support. >> >> Qemu already supports devices attached to ISA and sysbus. >> This drop adds support for the I2C bus attached TPM devices. >> >> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> >> >> --- >> V2: >> >> Incorporated Stephen's review comments >> - Added example in the document. >> >> --- >> V4: >> Incorporate Cedric & Stefan's comments >> >> - Added example for ast2600-evb >> - Corrected statement about arm virtual machine. >> >> --- >> V6: >> Incorporated review comments from Stefan. >> --- >> docs/specs/tpm.rst | 32 ++++++++++++++++++++++++++++++++ >> 1 file changed, 32 insertions(+) >> >> diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst >> index 535912a92b..590e670a9a 100644 >> --- a/docs/specs/tpm.rst >> +++ b/docs/specs/tpm.rst >> @@ -21,12 +21,16 @@ QEMU files related to TPM TIS interface: >> - ``hw/tpm/tpm_tis_common.c`` >> - ``hw/tpm/tpm_tis_isa.c`` >> - ``hw/tpm/tpm_tis_sysbus.c`` >> + - ``hw/tpm/tpm_tis_i2c.c`` >> - ``hw/tpm/tpm_tis.h`` >> >> Both an ISA device and a sysbus device are available. The former is >> used with pc/q35 machine while the latter can be instantiated in the >> Arm virt machine. >> >> +An I2C device support is also provided which can be instantiated in the Arm >> +based emulation machines. This device only supports the TPM 2 protocol. >> + >> CRB interface >> ------------- >> >> @@ -348,6 +352,34 @@ In case an Arm virt machine is emulated, use the following command line: >> -drive if=pflash,format=raw,file=flash0.img,readonly=on \ >> -drive if=pflash,format=raw,file=flash1.img >> >> +In case a ast2600-evb bmc machine is emulated and want to use TPM device >> +attached to I2C bus, use the following command line: >> + >> +.. code-block:: console >> + >> + qemu-system-arm -M ast2600-evb -nographic \ >> + -kernel arch/arm/boot/zImage \ >> + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ >> + -initrd rootfs.cpio \ >> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e > > For testing, use this command to load the driver to the correct address: > > echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device > > (I don't know how specific we want to make the instructions, but > adding a line like above would help others from having to re-discover > the command). or/and add an avocado test for it. See tests/avocado/machine_aspeed.py. The avocado framework is a bit fragile when reading from the console but we hope to fix that. Thanks C. > >> + >> +In case a Rainier bmc machine is emulated and want to use TPM device >> +attached to I2C bus, use the following command line: >> + >> +.. code-block:: console >> + >> + qemu-system-arm -M rainier-bmc -nographic \ >> + -kernel ${IMAGEPATH}/fitImage-linux.bin \ >> + -dtb ${IMAGEPATH}/aspeed-bmc-ibm-rainier.dtb \ >> + -initrd ${IMAGEPATH}/obmc-phosphor-initramfs.rootfs.cpio.xz \ >> + -drive file=${IMAGEPATH}/obmc-phosphor-image.rootfs.wic.qcow2,if=sd,index=2\ >> + -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443\ >> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >> + > > I'd drop this example, the above one is enough. > >> In case SeaBIOS is used as firmware, it should show the TPM menu item >> after entering the menu with 'ESC'. >> >> -- >> 2.37.2 >>
Hi Joel, On 3/27/23 2:47 AM, Joel Stanley wrote: > On Sun, 26 Mar 2023 at 22:44, Ninad Palsule <ninad@linux.ibm.com> wrote: >> This is a documentation change for I2C TPM device support. >> >> Qemu already supports devices attached to ISA and sysbus. >> This drop adds support for the I2C bus attached TPM devices. >> >> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> >> >> --- >> V2: >> >> Incorporated Stephen's review comments >> - Added example in the document. >> >> --- >> V4: >> Incorporate Cedric & Stefan's comments >> >> - Added example for ast2600-evb >> - Corrected statement about arm virtual machine. >> >> --- >> V6: >> Incorporated review comments from Stefan. >> --- >> docs/specs/tpm.rst | 32 ++++++++++++++++++++++++++++++++ >> 1 file changed, 32 insertions(+) >> >> diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst >> index 535912a92b..590e670a9a 100644 >> --- a/docs/specs/tpm.rst >> +++ b/docs/specs/tpm.rst >> @@ -21,12 +21,16 @@ QEMU files related to TPM TIS interface: >> - ``hw/tpm/tpm_tis_common.c`` >> - ``hw/tpm/tpm_tis_isa.c`` >> - ``hw/tpm/tpm_tis_sysbus.c`` >> + - ``hw/tpm/tpm_tis_i2c.c`` >> - ``hw/tpm/tpm_tis.h`` >> >> Both an ISA device and a sysbus device are available. The former is >> used with pc/q35 machine while the latter can be instantiated in the >> Arm virt machine. >> >> +An I2C device support is also provided which can be instantiated in the Arm >> +based emulation machines. This device only supports the TPM 2 protocol. >> + >> CRB interface >> ------------- >> >> @@ -348,6 +352,34 @@ In case an Arm virt machine is emulated, use the following command line: >> -drive if=pflash,format=raw,file=flash0.img,readonly=on \ >> -drive if=pflash,format=raw,file=flash1.img >> >> +In case a ast2600-evb bmc machine is emulated and want to use TPM device >> +attached to I2C bus, use the following command line: >> + >> +.. code-block:: console >> + >> + qemu-system-arm -M ast2600-evb -nographic \ >> + -kernel arch/arm/boot/zImage \ >> + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ >> + -initrd rootfs.cpio \ >> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e > For testing, use this command to load the driver to the correct address: > > echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device > > (I don't know how specific we want to make the instructions, but > adding a line like above would help others from having to re-discover > the command). Make sense. Added. > >> + >> +In case a Rainier bmc machine is emulated and want to use TPM device >> +attached to I2C bus, use the following command line: >> + >> +.. code-block:: console >> + >> + qemu-system-arm -M rainier-bmc -nographic \ >> + -kernel ${IMAGEPATH}/fitImage-linux.bin \ >> + -dtb ${IMAGEPATH}/aspeed-bmc-ibm-rainier.dtb \ >> + -initrd ${IMAGEPATH}/obmc-phosphor-initramfs.rootfs.cpio.xz \ >> + -drive file=${IMAGEPATH}/obmc-phosphor-image.rootfs.wic.qcow2,if=sd,index=2\ >> + -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443\ >> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >> + > I'd drop this example, the above one is enough. Removed. > >> In case SeaBIOS is used as firmware, it should show the TPM menu item >> after entering the menu with 'ESC'. >> >> -- >> 2.37.2 >>
Hi Cedric, On 3/27/23 2:52 AM, Cédric Le Goater wrote: > On 3/27/23 09:47, Joel Stanley wrote: >> On Sun, 26 Mar 2023 at 22:44, Ninad Palsule <ninad@linux.ibm.com> wrote: >>> >>> This is a documentation change for I2C TPM device support. >>> >>> Qemu already supports devices attached to ISA and sysbus. >>> This drop adds support for the I2C bus attached TPM devices. >>> >>> Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> >>> >>> --- >>> V2: >>> >>> Incorporated Stephen's review comments >>> - Added example in the document. >>> >>> --- >>> V4: >>> Incorporate Cedric & Stefan's comments >>> >>> - Added example for ast2600-evb >>> - Corrected statement about arm virtual machine. >>> >>> --- >>> V6: >>> Incorporated review comments from Stefan. >>> --- >>> docs/specs/tpm.rst | 32 ++++++++++++++++++++++++++++++++ >>> 1 file changed, 32 insertions(+) >>> >>> diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst >>> index 535912a92b..590e670a9a 100644 >>> --- a/docs/specs/tpm.rst >>> +++ b/docs/specs/tpm.rst >>> @@ -21,12 +21,16 @@ QEMU files related to TPM TIS interface: >>> - ``hw/tpm/tpm_tis_common.c`` >>> - ``hw/tpm/tpm_tis_isa.c`` >>> - ``hw/tpm/tpm_tis_sysbus.c`` >>> + - ``hw/tpm/tpm_tis_i2c.c`` >>> - ``hw/tpm/tpm_tis.h`` >>> >>> Both an ISA device and a sysbus device are available. The former is >>> used with pc/q35 machine while the latter can be instantiated in the >>> Arm virt machine. >>> >>> +An I2C device support is also provided which can be instantiated in >>> the Arm >>> +based emulation machines. This device only supports the TPM 2 >>> protocol. >>> + >>> CRB interface >>> ------------- >>> >>> @@ -348,6 +352,34 @@ In case an Arm virt machine is emulated, use >>> the following command line: >>> -drive if=pflash,format=raw,file=flash0.img,readonly=on \ >>> -drive if=pflash,format=raw,file=flash1.img >>> >>> +In case a ast2600-evb bmc machine is emulated and want to use TPM >>> device >>> +attached to I2C bus, use the following command line: >>> + >>> +.. code-block:: console >>> + >>> + qemu-system-arm -M ast2600-evb -nographic \ >>> + -kernel arch/arm/boot/zImage \ >>> + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ >>> + -initrd rootfs.cpio \ >>> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >>> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >>> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >> >> For testing, use this command to load the driver to the correct address: >> >> echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device >> >> (I don't know how specific we want to make the instructions, but >> adding a line like above would help others from having to re-discover >> the command). > > or/and add an avocado test for it. See tests/avocado/machine_aspeed.py. > > The avocado framework is a bit fragile when reading from the console but > we hope to fix that. I never used it before so it will take little longer. Is it required to merge this i2c work? Thanks for the review. Ninad > > Thanks > > C. > >> >>> + >>> +In case a Rainier bmc machine is emulated and want to use TPM device >>> +attached to I2C bus, use the following command line: >>> + >>> +.. code-block:: console >>> + >>> + qemu-system-arm -M rainier-bmc -nographic \ >>> + -kernel ${IMAGEPATH}/fitImage-linux.bin \ >>> + -dtb ${IMAGEPATH}/aspeed-bmc-ibm-rainier.dtb \ >>> + -initrd ${IMAGEPATH}/obmc-phosphor-initramfs.rootfs.cpio.xz \ >>> + -drive >>> file=${IMAGEPATH}/obmc-phosphor-image.rootfs.wic.qcow2,if=sd,index=2\ >>> + -net nic -net >>> user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443\ >>> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >>> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >>> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >>> + >> >> I'd drop this example, the above one is enough. >> >>> In case SeaBIOS is used as firmware, it should show the TPM menu item >>> after entering the menu with 'ESC'. >>> >>> -- >>> 2.37.2 >>> >
>>>> +In case a ast2600-evb bmc machine is emulated and want to use TPM device >>>> +attached to I2C bus, use the following command line: >>>> + >>>> +.. code-block:: console >>>> + >>>> + qemu-system-arm -M ast2600-evb -nographic \ >>>> + -kernel arch/arm/boot/zImage \ >>>> + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ >>>> + -initrd rootfs.cpio \ >>>> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >>>> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >>>> + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >>> >>> For testing, use this command to load the driver to the correct address: >>> >>> echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device >>> >>> (I don't know how specific we want to make the instructions, but >>> adding a line like above would help others from having to re-discover >>> the command). >> >> or/and add an avocado test for it. See tests/avocado/machine_aspeed.py. >> >> The avocado framework is a bit fragile when reading from the console but >> we hope to fix that. > > I never used it before so it will take little longer. > > Is it required to merge this i2c work? It isn't. C.
On 3/27/23 10:10 AM, Cédric Le Goater wrote: >>>>> +In case a ast2600-evb bmc machine is emulated and want to use TPM >>>>> device >>>>> +attached to I2C bus, use the following command line: >>>>> + >>>>> +.. code-block:: console >>>>> + >>>>> + qemu-system-arm -M ast2600-evb -nographic \ >>>>> + -kernel arch/arm/boot/zImage \ >>>>> + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ >>>>> + -initrd rootfs.cpio \ >>>>> + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ >>>>> + -tpmdev emulator,id=tpm0,chardev=chrtpm \ >>>>> + -device >>>>> tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e >>>> >>>> For testing, use this command to load the driver to the correct >>>> address: >>>> >>>> echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device >>>> >>>> (I don't know how specific we want to make the instructions, but >>>> adding a line like above would help others from having to re-discover >>>> the command). >>> >>> or/and add an avocado test for it. See tests/avocado/machine_aspeed.py. >>> >>> The avocado framework is a bit fragile when reading from the console >>> but >>> we hope to fix that. >> >> I never used it before so it will take little longer. >> >> Is it required to merge this i2c work? > > It isn't. Ok, Thanks. I will continue to check the test frame work and add the test in a separate drop. Ninad > > C. > > >
diff --git a/docs/specs/tpm.rst b/docs/specs/tpm.rst index 535912a92b..590e670a9a 100644 --- a/docs/specs/tpm.rst +++ b/docs/specs/tpm.rst @@ -21,12 +21,16 @@ QEMU files related to TPM TIS interface: - ``hw/tpm/tpm_tis_common.c`` - ``hw/tpm/tpm_tis_isa.c`` - ``hw/tpm/tpm_tis_sysbus.c`` + - ``hw/tpm/tpm_tis_i2c.c`` - ``hw/tpm/tpm_tis.h`` Both an ISA device and a sysbus device are available. The former is used with pc/q35 machine while the latter can be instantiated in the Arm virt machine. +An I2C device support is also provided which can be instantiated in the Arm +based emulation machines. This device only supports the TPM 2 protocol. + CRB interface ------------- @@ -348,6 +352,34 @@ In case an Arm virt machine is emulated, use the following command line: -drive if=pflash,format=raw,file=flash0.img,readonly=on \ -drive if=pflash,format=raw,file=flash1.img +In case a ast2600-evb bmc machine is emulated and want to use TPM device +attached to I2C bus, use the following command line: + +.. code-block:: console + + qemu-system-arm -M ast2600-evb -nographic \ + -kernel arch/arm/boot/zImage \ + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ + -initrd rootfs.cpio \ + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ + -tpmdev emulator,id=tpm0,chardev=chrtpm \ + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e + +In case a Rainier bmc machine is emulated and want to use TPM device +attached to I2C bus, use the following command line: + +.. code-block:: console + + qemu-system-arm -M rainier-bmc -nographic \ + -kernel ${IMAGEPATH}/fitImage-linux.bin \ + -dtb ${IMAGEPATH}/aspeed-bmc-ibm-rainier.dtb \ + -initrd ${IMAGEPATH}/obmc-phosphor-initramfs.rootfs.cpio.xz \ + -drive file=${IMAGEPATH}/obmc-phosphor-image.rootfs.wic.qcow2,if=sd,index=2\ + -net nic -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443\ + -chardev socket,id=chrtpm,path=/tmp/mytpm1/swtpm-sock \ + -tpmdev emulator,id=tpm0,chardev=chrtpm \ + -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e + In case SeaBIOS is used as firmware, it should show the TPM menu item after entering the menu with 'ESC'.
This is a documentation change for I2C TPM device support. Qemu already supports devices attached to ISA and sysbus. This drop adds support for the I2C bus attached TPM devices. Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> --- V2: Incorporated Stephen's review comments - Added example in the document. --- V4: Incorporate Cedric & Stefan's comments - Added example for ast2600-evb - Corrected statement about arm virtual machine. --- V6: Incorporated review comments from Stefan. --- docs/specs/tpm.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)