Preserve TPM log across kexec
Subsystems (4)
cover Preserve TPM log across kexec
This series resolves an issue on PowerVM and KVM on Power where the memory the TPM log was held in may become inaccessible or corrupted after a kexec soft reboot. The solution on these two platforms is to store the whole log in the device tree because the device tree is preserved across a kexec with either of the two kexec syscalls.
Regards,
Stefan
Stefan Berger (2):
powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
tpm: of: If available Use linux,sml-log to get the log and its size
arch/powerpc/kernel/prom_init.c | 8 ++------ drivers/char/tpm/eventlog/of.c | 36 ++++++++++----------------------- 2 files changed, 13 insertions(+), 31 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/kernel/prom_init.c +2 -6
@@ -1956,12 +1956,8 @@ static void __init prom_instantiate_sml(void)reserve_mem (base, size); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-base" , - &base,sizeof (base)); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-size" , - &size,sizeof (size)); - -prom_debug ("sml base = 0x%llx\n" , base); +prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-log" , + (void *)base, size);prom_debug ("sml size = 0x%x\n" , size);prom_debug ("prom_instantiate_sml: end...\n" );
Signature · 1 line
2.43.0
Michael Ellerman
reviewerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 16 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/kernel/prom_init.c +0
-0@@ -1956,12 +1956,8 @@ static void __init prom_instantiate_sml(void)
arch/powerpc/kernel/prom_init.c static void __init prom_instantiate_sml(void) · line 1960
Quoted 10 lines
arch/powerpc/kernel/prom_init.c +2
-6reserve_mem (base, size); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-base" , - &base,sizeof (base)); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-size" , - &size,sizeof (size)); - -prom_debug ("sml base = 0x%llx\n" , base); +prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-log" , + (void *)base, size);
As we discussed via chat, doing it this way sucks the full content of the log back into Open Firmware.
That relies on OF handling such big properties, and also means more memory will be consumed, which can cause problems early in boot.
A better solution is to explicitly add the log to the FDT in the flattening phase.
Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0 -2
@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size allOf: - $ref: tpm-common.yaml#
Documentation/devicetree/bindings/tpm/tpm-common.yaml +13 -1
@@ -25,6 +25,11 @@ properties: base address of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint64 + linux,sml-log: + description: + Content of firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + linux,sml-size: description: size of reserved memory allocated for firmware event log
@@ -53,15 +58,22 @@ dependentRequired: linux,sml-base: ['linux,sml-size'] linux,sml-size: ['linux,sml-base'] -# must only have either memory-region or linux,sml-base +# must only have either memory-region or linux,sml-base/size or linux,sml-log # as well as either resets or reset-gpios dependentSchemas: memory-region: properties: linux,sml-base: false + linux,sml-log: false linux,sml-base: properties: memory-region: false + linux,sml-log: false + linux,sml-log: + properties: + memory-region: false + linux,sml-base: false + linux,sml-size: false resets: properties: reset-gpios: false
cheers
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 31 lines · Michael Ellerman
Quoted 16 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/kernel/prom_init.c +0
-0@@ -1956,12 +1956,8 @@ static void __init prom_instantiate_sml(void)arch/powerpc/kernel/prom_init.c static void __init prom_instantiate_sml(void) · line 1960
Quoted 10 lines
arch/powerpc/kernel/prom_init.c +2
-6reserve_mem (base, size); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-base" , - &base,sizeof (base)); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-size" , - &size,sizeof (size)); - -prom_debug ("sml base = 0x%llx\n" , base); +prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-log" , + (void *)base, size);As we discussed via chat, doing it this way sucks the full content of the log back into Open Firmware.
Quoted 5 lines
That relies on OF handling such big properties, and also means more memory will be consumed, which can cause problems early in boot.
A better solution is to explicitly add the log to the FDT in the flattening phase.
Done.
Quoted 3 lines
Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
See my proposal below.
Quoted 48 lines
The syntax is not very obvious to me, but possibly something like?
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size allOf: - $ref: tpm-common.yaml#Documentation/devicetree/bindings/tpm/tpm-common.yaml +7
-1@@ -25,6 +25,11 @@ properties: base address of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint64 + linux,sml-log: + description: + Content of firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + linux,sml-size: description: size of reserved memory allocated for firmware event log@@ -53,15 +58,22 @@ dependentRequired: linux,sml-base: ['linux,sml-size'] linux,sml-size: ['linux,sml-base'] -# must only have either memory-region or linux,sml-base +# must only have either memory-region or linux,sml-base/size or linux,sml-log # as well as either resets or reset-gpios dependentSchemas: memory-region: properties: linux,sml-base: false + linux,sml-log: false linux,sml-base: properties:
Documentation/devicetree/bindings/tpm/tpm-common.yaml dependentRequired: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +6
-0memory-region: false + linux,sml-log: false + linux,sml-log: + properties: + memory-region: false + linux,sml-base: false + linux,sml-size: false resets: properties: reset-gpios: false
I have been working with this patch here now and it passes the following test:
make dt_binding_check dtbs_check DT_SCHEMA_FILES=tpm/ibm,vtpm.yaml
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +24 -2
@@ -74,8 +74,12 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size +oneOf: + - required: + - linux,sml-base + - linux,sml-size + - required: + - linux,sml-log allOf: - $ref: tpm-common.yaml#
@@ -102,3 +106,21 @@ examples: linux,sml-size = <0xbce10200>; }; }; + - | + soc { + #address-cells = <1>; + #size-cells = <0>; + + tpm@30000003 { + compatible = "IBM,vtpm"; + device_type = "IBM,vtpm"; + reg = <0x30000003>; + interrupts = <0xa0003 0x0>; + ibm,#dma-address-cells = <0x2>; + ibm,#dma-size-cells = <0x2>; + ibm,my-dma-window = <0x10000003 0x0 0x0 0x0 0x10000000>; + ibm,my-drc-index = <0x30000003>; + ibm,loc-code = "U8286.41A.10082DV-V3-C3"; + linux,sml-log = <00 00 00 00 03 00 00>; + }; + };
Documentation/devicetree/bindings/tpm/tpm-common.yaml +5 -0
@@ -30,6 +30,11 @@ properties: size of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint32 + linux,sml-log: + description: + firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + memory-region: description: reserved memory allocated for firmware event log maxItems: 1
Is my patch missing something?
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 120 lines · Stefan Berger
Quoted 5 lines · Michael Ellerman
Stefan Berger <[email protected]> writes:
Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
See my proposal below.
Quoted 45 lines
The syntax is not very obvious to me, but possibly something like?
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size allOf: - $ref: tpm-common.yaml#Documentation/devicetree/bindings/tpm/tpm-common.yaml +7
-1@@ -25,6 +25,11 @@ properties: base address of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint64 + linux,sml-log: + description: + Content of firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + linux,sml-size: description: size of reserved memory allocated for firmware event log@@ -53,15 +58,22 @@ dependentRequired: linux,sml-base: ['linux,sml-size'] linux,sml-size: ['linux,sml-base'] -# must only have either memory-region or linux,sml-base +# must only have either memory-region or linux,sml-base/size or linux,sml-log # as well as either resets or reset-gpios dependentSchemas: memory-region: properties: linux,sml-base: false + linux,sml-log: false linux,sml-base: properties: memory-region: falseDocumentation/devicetree/bindings/tpm/tpm-common.yaml dependentRequired: · line 79
Quoted 10 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +6
-0+ linux,sml-log: false + linux,sml-log: + properties: + memory-region: false + linux,sml-base: false + linux,sml-size: false resets: properties: reset-gpios: falseI have been working with this patch here now and it passes the following test:
make
dt_binding_checkdtbs_checkDT_SCHEMA_FILES=tpm/ibm,vtpm.yamlDocumentation/devicetree/bindings/tpm/ibm,vtpm.yaml +24
-2@@ -74,8 +74,12 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size +oneOf: + - required: + - linux,sml-base + - linux,sml-size + - required: + - linux,sml-log allOf: - $ref: tpm-common.yaml#@@ -102,3 +106,21 @@ examples: linux,sml-size = <0xbce10200>; }; }; + - | + soc { + #address-cells = <1>; + #size-cells = <0>; + + tpm@30000003 { + compatible = "IBM,vtpm"; + device_type = "IBM,vtpm"; + reg = <0x30000003>; + interrupts = <0xa0003 0x0>; + ibm,#dma-address-cells = <0x2>; + ibm,#dma-size-cells = <0x2>; + ibm,my-dma-window = <0x10000003 0x0 0x0 0x0 0x10000000>; + ibm,my-drc-index = <0x30000003>; + ibm,loc-code = "U8286.41A.10082DV-V3-C3"; + linux,sml-log = <00 00 00 00 03 00 00>; + }; + };Documentation/devicetree/bindings/tpm/tpm-common.yaml +0
-0
Documentation/devicetree/bindings/tpm/tpm-common.yaml properties: · line 35
Quoted 6 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +3
-0@@ -30,6 +30,11 @@ properties: size of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint32 + linux,sml-log: + description: + firmware event log
Can you provide a more complete description here please as to what the different between this and the other property? If I was populating a DT I would have absolutely no idea whether or not to use this or the other property, nor how to go about actually populating it.
The "log" in your example doesn't look like an actual log of any sort, but I know nothing about TPMs so I'll take your word for it that that's what a TPM log looks like.
Quoted 8 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +2
-0+ $ref: /schemas/types.yaml#/definitions/uint8-array + memory-region: description: reserved memory allocated for firmware event log maxItems: 1Is my patch missing something?
I think you also need the dependantSchema stuff you had in your original snippet that makes the linux,* properties mutually exclusive with memory-region (or at least something like that).
Please make sure you CC the DT maintainers and list on the v2 and Lukas Wunner too.
Thanks,
Conor.
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 14 lines · Conor Dooley
Quoted 13 lines · Stefan Berger
Quoted 3 lines · Michael Ellerman
Stefan Berger <[email protected]> writes:
Documentation/devicetree/bindings/tpm/tpm-common.yaml +0
-0@@ -30,6 +30,11 @@ properties: size of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint32
Quoted 11 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml properties: · line 35
Quoted 3 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +3
-0+ linux,sml-log: + description: + firmware event logCan you provide a more complete description here please as to what the different between this and the other property? If I was populating a DT I would have absolutely no idea whether or not to use this or the other property, nor how to go about actually populating it.
The "log" in your example doesn't look like an actual log of any sort, but I know nothing about TPMs so I'll take your word for it that that's what a TPM log looks like.
In the example I cannot give a log but only a part of it. The log is in binary format and in case of TPM 2.0 starts with a header followed by log entries about what was measured. I don't think it's necessary to even give the full log header here. You do need some TPM specific knowledge about the 'firmware even log'.
The existing properties are described like this:
linux,sml-base:
description:
base address of reserved memory allocated for firmware event log
$ref: /schemas/types.yaml#/definitions/uint64
linux,sml-size:
description:
size of reserved memory allocated for firmware event log
$ref: /schemas/types.yaml#/definitions/uint32
Would this describe the new property 'better' by prefixing it with 'embedded'?
linux,sml-log:
description:
embedded firmware event log
$ref: /schemas/types.yaml#/definitions/uint8-array
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +2
-0+ $ref: /schemas/types.yaml#/definitions/uint8-array + memory-region: description: reserved memory allocated for firmware event log maxItems: 1
Quoted 6 lines
Quoted 1 line
Is my patch missing something?
I think you also need the dependantSchema stuff you had in your original snippet that makes the linux,* properties mutually exclusive with memory-region (or at least something like that).
I modified my new example now like this:
...
ibm,loc-code = "U9080.HEX.134CA08-V7-C3";
linux,sml-log = <00 00 00 00 03 00 00>;
linux,sml-size = <0xbce10200>; <-- addedThe check fails like this:
# make dt_binding_check dtbs_check DT_SCHEMA_FILES=tpm/ibm,vtpm.yaml
LINT Documentation/devicetree/bindings
CHKDT Documentation/devicetree/bindings/processed-schema.json
SCHEMA Documentation/devicetree/bindings/processed-schema.json
DTEX Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dts
DTC_CHK Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb
/root/linux/Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb: tpm@30000003: 'linux,sml-base' is a dependency of 'linux,sml-size'
from schema $id: http://devicetree.org/schemas/tpm/tpm-common.yaml#
/root/linux/Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb: tpm@30000003: 'linux,sml-base' is a dependency of 'linux,sml-size'
from schema $id: http://devicetree.org/schemas/tpm/ibm,vtpm.yaml#
/root/linux/Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb: tpm@30000003: Unevaluated properties are not allowed ('interrupts', 'linux,sml-log', 'linux,sml-size' were unexpected)
from schema $id: http://devicetree.org/schemas/tpm/ibm,vtpm.yaml#When I modify the existing example like this:
ibm,loc-code = "U8286.41A.10082DV-V3-C3";
linux,sml-base = <0xc60e 0x0>;
linux,sml-size = <0xbce10200>;
linux,sml-log = <00 00 00 00 03 00 00>; <- addedThe check fails like this:
# make dt_binding_check dtbs_check DT_SCHEMA_FILES=tpm/ibm,vtpm.yaml
LINT Documentation/devicetree/bindings
CHKDT Documentation/devicetree/bindings/processed-schema.json
SCHEMA Documentation/devicetree/bindings/processed-schema.json
DTEX Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dts
DTC_CHK Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb
/root/linux/Documentation/devicetree/bindings/tpm/ibm,vtpm.example.dtb: tpm@30000003: More than one condition true in oneOf schema:
{'$filename':
'/root/linux/Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml',
'$id': 'http://devicetree.org/schemas/tpm/ibm,vtpm.yaml#',
'$schema': 'http://devicetree.org/meta-schemas/core.yaml#',
'allOf': [{'$ref': 'tpm-common.yaml#'}],
'oneOf': [{'required': ['linux,sml-base', 'linux,sml-size']},
{'required': ['linux,sml-log']}],
'patternProperties': {'pinctrl-[0-9]+': True},
'properties': {'$nodename': True,
'bootph-all': True,
'bootph-pre-ram': True,
'bootph-pre-sram': True,
'bootph-some-ram': True,
'bootph-verify': True,
'compatible': {'items': [{'enum': ['IBM,vtpm',
'IBM,vtpm20']}],
'maxItems': 1,
'minItems': 1,
'type': 'array'},
'device_type': {'items': [{'enum': ['IBM,vtpm','IBM,vtpm20']}],
'maxItems': 1,
'minItems': 1,
'type': 'array'},
'ibm,#dma-address-cells': {'$ref':
'/schemas/types.yaml#/definitions/uint32-array'},
'ibm,#dma-size-cells': {'$ref':
'/schemas/types.yaml#/definitions/uint32-array'},
'ibm,loc-code': {'$ref':
'/schemas/types.yaml#/definitions/string'},
'ibm,my-dma-window': {'$ref':
'/schemas/types.yaml#/definitions/uint32-array',
'items': {'maxItems': 5,
'minItems': 5},
'maxItems': 1,
'type': 'array'},
'ibm,my-drc-index': {'$ref':
'/schemas/types.yaml#/definitions/uint32'},
'phandle': True,
'pinctrl-names': True,
'reg': {'maxItems': 1, 'minItems': 1},
'secure-status': True,
'status': True},
'required': ['compatible',
'device_type',
'reg',
'interrupts',
'ibm,#dma-address-cells',
'ibm,#dma-size-cells',
'ibm,my-dma-window',
'ibm,my-drc-index',
'ibm,loc-code'],
'select': {'properties': {'compatible': {'contains': {'enum': ['IBM,vtpm',
'IBM,vtpm20']}}},
'required': ['compatible']},
'title': 'IBM Virtual Trusted Platform Module (vTPM)',
'type': 'object',
'unevaluatedProperties': False}
from schema $id: http://devicetree.org/schemas/tpm/ibm,vtpm.yaml#It errors out on bad examples, which is good.
Quoted 2 lines
Please make sure you CC the DT maintainers and list on the v2 and Lukas Wunner too.
Yes, I have them already cc'ed here.
Quoted 3 lines
Thanks,
Conor.
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 43 lines · Stefan Berger
Quoted 14 lines · Conor Dooley
Quoted 13 lines · Stefan Berger
Quoted 3 lines · Michael Ellerman
Stefan Berger <[email protected]> writes:
Documentation/devicetree/bindings/tpm/tpm-common.yaml +0
-0@@ -30,6 +30,11 @@ properties: size of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint32Quoted 11 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml properties: · line 35
Quoted 3 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +3
-0+ linux,sml-log: + description: + firmware event logCan you provide a more complete description here please as to what the different between this and the other property? If I was populating a DT I would have absolutely no idea whether or not to use this or the other property, nor how to go about actually populating it.
The "log" in your example doesn't look like an actual log of any sort, but I know nothing about TPMs so I'll take your word for it that that's what a TPM log looks like.In the example I cannot give a log but only a part of it. The log is in binary format and in case of TPM 2.0 starts with a header followed by log entries about what was measured. I don't think it's necessary to even give the full log header here. You do need some TPM specific knowledge about the 'firmware even log'.
The existing properties are described like this:
linux,sml-base:
description:
base address of reserved memory allocated for firmware event log
$ref: /schemas/types.yaml#/definitions/uint64
Quoted 7 lines
linux,sml-size:
description:
size of reserved memory allocated for firmware event log
$ref: /schemas/types.yaml#/definitions/uint32Would this describe the new property 'better' by prefixing it with 'embedded'?
IMO, no that's not any better. Spell it out so that someone who doesn't know his arse from his elbow when it comes to tpm immediately knows that this means the entire tpm log is inside the dtb. The paragraph you wrote above gives more information about what this property is populated with than the property description does.
Quoted 31 lines
linux,sml-log:
description:
embedded firmware event log
$ref: /schemas/types.yaml#/definitions/uint8-arrayQuoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +2
-0+ $ref: /schemas/types.yaml#/definitions/uint8-array + memory-region: description: reserved memory allocated for firmware event log maxItems: 1Quoted 6 lines
Quoted 1 line
Is my patch missing something?
I think you also need the dependantSchema stuff you had in your original snippet that makes the linux,* properties mutually exclusive with memory-region (or at least something like that).
I modified my new example now like this:
...ibm,loc-code = "U9080.HEX.134CA08-V7-C3"; linux,sml-log = <00 00 00 00 03 00 00>; linux,sml-size = <0xbce10200>; <-- added ibm,loc-code = "U8286.41A.10082DV-V3-C3"; linux,sml-base = <0xc60e 0x0>; linux,sml-size = <0xbce10200>; linux,sml-log = <00 00 00 00 03 00 00>; <- added
Quoted 1 line
It errors out on bad examples, which is good.
Aye, that is covered by your new oneOf for this one binding. The dependantSchema bit in tpm-common.yaml enforces it for all tpm devices. It also covers the memory-region property being mutually exclusive with the linux,sml-{base,size} properties so I think you need to extend that to also cover linux,sml-lof property.
Quoted 4 lines
Quoted 2 lines
Please make sure you CC the DT maintainers and list on the v2 and Lukas Wunner too.
Yes, I have them already cc'ed here.
To: Conor Dooley <[email protected]>
Cc: Michael Ellerman <[email protected]>, [email protected], [email protected], [email protected], [email protected], Lukas Wunner <[email protected]>, [email protected], [email protected],
[email protected], [email protected], [email protected]
You have Lukas, one of the three DT maintainers and not the list as far as I can see. Correct me please if I am wrong.
Thanks,
Conor.
Rob Herring
maintainerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
In reply to Michael EllermanQuoted 31 lines · Michael Ellerman
Quoted 16 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/kernel/prom_init.c +0
-0@@ -1956,12 +1956,8 @@ static void __init prom_instantiate_sml(void)arch/powerpc/kernel/prom_init.c static void __init prom_instantiate_sml(void) · line 1960
Quoted 10 lines
arch/powerpc/kernel/prom_init.c +2
-6reserve_mem (base, size); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-base" , - &base,sizeof (base)); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-size" , - &size,sizeof (size)); - -prom_debug ("sml base = 0x%llx\n" , base); +prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-log" , + (void *)base, size);As we discussed via chat, doing it this way sucks the full content of the log back into Open Firmware.
Quoted 6 lines
That relies on OF handling such big properties, and also means more memory will be consumed, which can cause problems early in boot.
A better solution is to explicitly add the log to the FDT in the flattening phase.
Why can't you just use /reserved-memory here? That should be preserved from one kernel entry to the next.
Quoted 10 lines
Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-0
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 5 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-size
Dropping required properties is an ABI break. If you drop them, an older OS version won't work.
Documentation/devicetree/bindings/tpm/tpm-common.yaml properties: · line 28
Quoted 12 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-0allOf: - $ref: tpm-common.yaml#Documentation/devicetree/bindings/tpm/tpm-common.yaml +1
-0@@ -25,6 +25,11 @@ properties: base address of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint64 + linux,sml-log:
Why is this Linux specific?
Quoted 34 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml +12
-1+ description: + Content of firmware event log + $ref: /schemas/types.yaml#/definitions/uint8-array + linux,sml-size: description: size of reserved memory allocated for firmware event log@@ -53,15 +58,22 @@ dependentRequired: linux,sml-base: ['linux,sml-size'] linux,sml-size: ['linux,sml-base'] -# must only have either memory-region or linux,sml-base +# must only have either memory-region or linux,sml-base/size or linux,sml-log # as well as either resets or reset-gpios dependentSchemas: memory-region: properties: linux,sml-base: false + linux,sml-log: false linux,sml-base: properties: memory-region: false + linux,sml-log: false + linux,sml-log: + properties: + memory-region: false + linux,sml-base: false + linux,sml-size: false resets: properties: reset-gpios: falsecheers
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
https://elixir.bootlin.com/linux/latest/source/arch/powerpc/kernel/prom_init.c#L1959
2) There is an example in the ibm,vtpm.yaml file that has both of these
and the test case still passes the check when the two entries above are removed. I will post v2 with the changes to the DT bindings for linux,sml-log including an example for linux,sml-log. [The test cases fail, as expected, when an additional property is added, such as when linux,sml-base is added when linux,sml-log is there or linux,sml-log is added when linux,sml-base is there.]
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-0allOf: - $ref: tpm-common.yaml#Documentation/devicetree/bindings/tpm/tpm-common.yaml +0
-0@@ -25,6 +25,11 @@ properties: base address of reserved memory allocated for firmware event log $ref: /schemas/types.yaml#/definitions/uint64
Quoted 3 lines
Documentation/devicetree/bindings/tpm/tpm-common.yaml properties: · line 28
Quoted 1 line
Documentation/devicetree/bindings/tpm/tpm-common.yaml +1
-0+ linux,sml-log:Why is this Linux specific?
I am not sure about the criteria when to prefix with 'linux,' and when not to. In this case I did it because it is created by Linux and because of existing linux,sml-base and linux,sml-size.
Rob Herring
maintainerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 37 lines · Stefan Berger
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
Quoted 5 lines
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
Okay, I guess your case is not a ABI break if the kernel is populating it and the same kernel consumes it.
You failed to answer my question on using /reserved-memory. Again, why can't that be used? That is the standard way we prevent chunks of memory from being clobbered. There's already support for describing the TPM log that way anyways. The only reasoning I can see writing out a node for that is harder than just adding a property, but that's not a great argument IMO.
Quoted 7 lines
2) There is an example in the ibm,vtpm.yaml file that has both of these and the test case still passes the check when the two entries above are removed. I will post v2 with the changes to the DT bindings for linux,sml-log including an example for linux,sml-log. [The test cases fail, as expected, when an additional property is added, such as when linux,sml-base is added when linux,sml-log is there or linux,sml-log is added when linux,sml-base is there.]
Sure, removing a required property is never going to break the DT checks. What would break is a client (OS) version that only understands linux,sml-base and can no longer get the log assuming getting the log itself was required.
Rob
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 44 lines · Rob Herring
Quoted 37 lines · Stefan Berger
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
Quoted 5 lines
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
Quoted 4 lines
Okay, I guess your case is not a ABI break if the kernel is populating it and the same kernel consumes it.
You failed to answer my question on using /reserved-memory. Again, why
I am not familiar with /reserved-memory and whether it is supported on the targeted platforms.
Michael Ellerman
reviewerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
In reply to Rob HerringQuoted 42 lines · Rob Herring
Quoted 35 lines · Stefan Berger
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
Quoted 5 lines
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
Quoted 6 lines
Okay, I guess your case is not a ABI break if the kernel is populating it and the same kernel consumes it.
You failed to answer my question on using /reserved-memory. Again, why can't that be used? That is the standard way we prevent chunks of memory from being clobbered.
Yes I think that would mostly work. I don't see support for /reserved-memory in kexec-tools, so that would need fixing I think.
My logic was that the memory is not special. It's just a buffer we allocated during early boot to store the log. There isn't anything else in the system that relies on that memory remaining untouched. So it seemed cleaner to just put the log in the device tree, rather than a pointer to it.
Having the log external to the device tree creates several problems, like the crash kernel region colliding with it, it being clobbered by kexec, etc.
cheers
Rob Herring
maintainerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 50 lines · Michael Ellerman
Quoted 42 lines · Rob Herring
Quoted 35 lines · Stefan Berger
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
Quoted 5 lines
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
Quoted 6 lines
Okay, I guess your case is not a ABI break if the kernel is populating it and the same kernel consumes it.
You failed to answer my question on using /reserved-memory. Again, why can't that be used? That is the standard way we prevent chunks of memory from being clobbered.
Quoted 8 lines
Yes I think that would mostly work. I don't see support for /reserved-memory in kexec-tools, so that would need fixing I think.
My logic was that the memory is not special. It's just a buffer we allocated during early boot to store the log. There isn't anything else in the system that relies on that memory remaining untouched. So it seemed cleaner to just put the log in the device tree, rather than a pointer to it.
My issue is we already have 2 ways to describe the log to the OS. I don't see a good reason to add a 3rd way. (Though it might actually be a 4th way, because the chosen property for the last attempt was accepted to dtschema yet the code has been abandoned.)
If you put the log into the DT, then the memory for the log remains untouched too because the FDT remains untouched. For reserved-memory regions, the OS is free to free them if it knows what the region is and that it is no longer needed. IOW, if freeing the log memory is desired, then the suggested approach doesn't work.
Quoted 4 lines
Having the log external to the device tree creates several problems, like the crash kernel region colliding with it, it being clobbered by kexec, etc.
We have multiple regions to pass/maintain thru kexec, so how does having one less really matter?
Rob
Re: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
Quoted 60 lines · Rob Herring
Quoted 50 lines · Michael Ellerman
Quoted 42 lines · Rob Herring
Quoted 35 lines · Stefan Berger
Quoted 20 lines · Rob Herring
Quoted 19 lines · Michael Ellerman
Quoted 10 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)Also adding the new linux,sml-log property should be accompanied by a change to the device tree binding.
The syntax is not very obvious to me, but possibly something like?
Quoted 13 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml required: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/tpm/ibm,vtpm.yaml +0
-2@@ -74,8 +74,6 @@ required: - ibm,my-dma-window - ibm,my-drc-index - ibm,loc-code - - linux,sml-base - - linux,sml-sizeDropping required properties is an ABI break. If you drop them, an older OS version won't work.
Quoted 5 lines
1) On PowerVM and KVM on Power these two properties were added in the Linux code. I replaced the creation of these properties with creation of linux,sml-log (1/2 in this series). I also replaced the handling of these two (2/2 in this series) for these two platforms but leaving it for powernv systems where the firmware creates these.
Quoted 6 lines
Okay, I guess your case is not a ABI break if the kernel is populating it and the same kernel consumes it.
You failed to answer my question on using /reserved-memory. Again, why can't that be used? That is the standard way we prevent chunks of memory from being clobbered.
Quoted 8 lines
Yes I think that would mostly work. I don't see support for /reserved-memory in kexec-tools, so that would need fixing I think.
My logic was that the memory is not special. It's just a buffer we allocated during early boot to store the log. There isn't anything else in the system that relies on that memory remaining untouched. So it seemed cleaner to just put the log in the device tree, rather than a pointer to it.
Quoted 4 lines
My issue is we already have 2 ways to describe the log to the OS. I don't see a good reason to add a 3rd way. (Though it might actually be a 4th way, because the chosen property for the last attempt was accepted to dtschema yet the code has been abandoned.)
I have a revert for this in my tree...
Quoted 6 lines
If you put the log into the DT, then the memory for the log remains untouched too because the FDT remains untouched. For reserved-memory regions, the OS is free to free them if it knows what the region is and that it is no longer needed. IOW, if freeing the log memory is desired, then the suggested approach doesn't work.
The log, once embedded in the FDT, would stay there forever. The TPM subsystem looks at it when initializing and will look at it again when initializing after a kexec soft reboot.
Quoted 8 lines
Quoted 5 lines
Having the log external to the device tree creates several problems, like the crash kernel region colliding with it, it being clobbered by kexec, etc.
We have multiple regions to pass/maintain thru kexec, so how does having one less really matter?
I had tried it with the newer kexec syscall. Yes, there was a way of doing it but the older kexec call is still around and since that one is also still being used the problems with corrupted memory for example still persisted. So that's why we now embed it in the FDT because both syscalls carry that across unharmed.
Quoted 2 lines
Rob
Jarkko Sakkinen
maintainerRe: [PATCH 1/2] powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
In reply to Stefan BergerQuoted 4 lines · Stefan Berger
linux,sml-base holds the address of a buffer with the TPM log. This buffer may become invalid after a kexec and therefore embed the whole TPM log in linux,sml-log. This helps to protect the log since it is properly carried across a kexec with both of the kexec syscalls.
So, I see only description of the problem but nothing how it gets addressed.
Quoted 15 lines
Signed-off-by Stefan Berger <[email protected]>--- arch/powerpc/kernel/prom_init.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/powerpc/kernel/prom_init.c +0
-1@@ -1956,12 +1956,8 @@ static void __init prom_instantiate_sml(void)reserve_mem (base, size); - prom_setprop(ibmvtpm_node, "/vdevice/vtpm", "linux,sml-base",
arch/powerpc/kernel/prom_init.c static void __init prom_instantiate_sml(void) · line 1963
Quoted 10 lines
arch/powerpc/kernel/prom_init.c +2
-5- &base, sizeof(base)); -prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-size" , - &size,sizeof (size)); - -prom_debug ("sml base = 0x%llx\n" , base); +prom_setprop (ibmvtpm_node,"/vdevice/vtpm" ,"linux,sml-log" , + (void *)base, size);prom_debug ("sml size = 0x%x\n" , size);prom_debug ("prom_instantiate_sml: end...\n" );
BR, Jarkko
PATCH 2/2 tpm: of: If available Use linux,sml-log to get the log and its size
In reply to Stefan BergerIf linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
--- drivers/char/tpm/eventlog/of.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/char/tpm/eventlog/of.c +11 -25
@@ -54,8 +54,8 @@ int tpm_read_log_of(struct tpm_chip *chip)const u32 *sizep;const u64 *basep;struct tpm_bios_log *log; +const void *logp;u32 size; -u64 base; log = &chip->log;if (chip->dev.parent && chip->dev.parent->of_node)
@@ -66,37 +66,23 @@ int tpm_read_log_of(struct tpm_chip *chip)if (of_property_read_bool (np,"powered-while-suspended" )) chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; - sizep =of_get_property (np,"linux,sml-size" ,NULL ); - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (sizep ==NULL && basep ==NULL ) -return tpm_read_log_memory_region (chip); -if (sizep ==NULL || basep ==NULL ) -return -EIO ; - -/* -* For both vtpm/tpm, firmware has log addr and log size in big -* endian format. But in case of vtpm, there is a method called -* sml-handover which is run during kernel init even before -* device tree is setup. This sml-handover function takes care -* of endianness and writes to sml-base and sml-size in little -* endian format. For this reason, vtpm doesn't need conversion -* but physical tpm needs the conversion. -*/ -if (of_property_match_string (np,"compatible" ,"IBM,vtpm" ) <0 && -of_property_match_string (np,"compatible" ,"IBM,vtpm20" ) <0 ) { + logp =of_get_property (np,"linux,sml-log" , &size); +if (logp ==NULL ) { + sizep =of_get_property (np,"linux,sml-size" ,NULL ); + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return tpm_read_log_memory_region (chip); +if (sizep ==NULL || basep ==NULL ) +return -EIO ; + logp =__va (be64_to_cpup ((__force __be64 *)basep)); size =be32_to_cpup ((__force __be32 *)sizep); - base =be64_to_cpup ((__force __be64 *)basep); - }else { - size = *sizep; - base = *basep; } -if (size ==0 ) {dev_warn (&chip->dev,"%s: Event log area empty\n" , __func__);return -EIO ; } - log->bios_event_log =devm_kmemdup (&chip->dev,__va (base), size,GFP_KERNEL ); + log->bios_event_log =devm_kmemdup (&chip->dev, logp, size,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;
Signature · 1 line
2.43.0
Michael Ellerman
reviewerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 5 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
It would be good to mention that powernv platforms (sometimes called Open Power or bare metal) still use linux,sml-base/size, via skiboot.
cheers
Quoted 69 lines
Signed-off-by Stefan Berger <[email protected]>--- drivers/char/tpm/eventlog/of.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-)drivers/char/tpm/eventlog/of.c +11
-25@@ -54,8 +54,8 @@ int tpm_read_log_of(struct tpm_chip *chip)const u32 *sizep;const u64 *basep;struct tpm_bios_log *log; +const void *logp;u32 size; -u64 base; log = &chip->log;if (chip->dev.parent && chip->dev.parent->of_node)@@ -66,37 +66,23 @@ int tpm_read_log_of(struct tpm_chip *chip)if (of_property_read_bool (np,"powered-while-suspended" )) chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; - sizep =of_get_property (np,"linux,sml-size" ,NULL ); - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (sizep ==NULL && basep ==NULL ) -return tpm_read_log_memory_region (chip); -if (sizep ==NULL || basep ==NULL ) -return -EIO ; - -/* -* For both vtpm/tpm, firmware has log addr and log size in big -* endian format. But in case of vtpm, there is a method called -* sml-handover which is run during kernel init even before -* device tree is setup. This sml-handover function takes care -* of endianness and writes to sml-base and sml-size in little -* endian format. For this reason, vtpm doesn't need conversion -* but physical tpm needs the conversion. -*/ -if (of_property_match_string (np,"compatible" ,"IBM,vtpm" ) <0 && -of_property_match_string (np,"compatible" ,"IBM,vtpm20" ) <0 ) { + logp =of_get_property (np,"linux,sml-log" , &size); +if (logp ==NULL ) { + sizep =of_get_property (np,"linux,sml-size" ,NULL ); + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return tpm_read_log_memory_region (chip); +if (sizep ==NULL || basep ==NULL ) +return -EIO ; + logp =__va (be64_to_cpup ((__force __be64 *)basep)); size =be32_to_cpup ((__force __be32 *)sizep); - base =be64_to_cpup ((__force __be64 *)basep); - }else { - size = *sizep; - base = *basep; } -if (size ==0 ) {dev_warn (&chip->dev,"%s: Event log area empty\n" , __func__);return -EIO ; } - log->bios_event_log =devm_kmemdup (&chip->dev,__va (base), size,GFP_KERNEL ); + log->bios_event_log =devm_kmemdup (&chip->dev, logp, size,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;Signature · 1 line
2.43.0
Re: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 9 lines · Michael Ellerman
Quoted 5 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
It would be good to mention that powernv platforms (sometimes called Open Power or bare metal) still use linux,sml-base/size, via skiboot.
Will do in v2.
Re: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
In reply to Stefan BergerQuoted 5 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Those two properties are documented, but linux,sml-log is not, nor can I find patches on the list documenting it.
There should be a patch adding this to tmp-common.yaml.
Cheers,
Conor.
Quoted 70 lines
Signed-off-by Stefan Berger <[email protected]>--- drivers/char/tpm/eventlog/of.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-)drivers/char/tpm/eventlog/of.c +11
-25@@ -54,8 +54,8 @@ int tpm_read_log_of(struct tpm_chip *chip)const u32 *sizep;const u64 *basep;struct tpm_bios_log *log; +const void *logp;u32 size; -u64 base; log = &chip->log;if (chip->dev.parent && chip->dev.parent->of_node)@@ -66,37 +66,23 @@ int tpm_read_log_of(struct tpm_chip *chip)if (of_property_read_bool (np,"powered-while-suspended" )) chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; - sizep =of_get_property (np,"linux,sml-size" ,NULL ); - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (sizep ==NULL && basep ==NULL ) -return tpm_read_log_memory_region (chip); -if (sizep ==NULL || basep ==NULL ) -return -EIO ; - -/* -* For both vtpm/tpm, firmware has log addr and log size in big -* endian format. But in case of vtpm, there is a method called -* sml-handover which is run during kernel init even before -* device tree is setup. This sml-handover function takes care -* of endianness and writes to sml-base and sml-size in little -* endian format. For this reason, vtpm doesn't need conversion -* but physical tpm needs the conversion. -*/ -if (of_property_match_string (np,"compatible" ,"IBM,vtpm" ) <0 && -of_property_match_string (np,"compatible" ,"IBM,vtpm20" ) <0 ) { + logp =of_get_property (np,"linux,sml-log" , &size); +if (logp ==NULL ) { + sizep =of_get_property (np,"linux,sml-size" ,NULL ); + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return tpm_read_log_memory_region (chip); +if (sizep ==NULL || basep ==NULL ) +return -EIO ; + logp =__va (be64_to_cpup ((__force __be64 *)basep)); size =be32_to_cpup ((__force __be32 *)sizep); - base =be64_to_cpup ((__force __be64 *)basep); - }else { - size = *sizep; - base = *basep; } -if (size ==0 ) {dev_warn (&chip->dev,"%s: Event log area empty\n" , __func__);return -EIO ; } - log->bios_event_log =devm_kmemdup (&chip->dev,__va (base), size,GFP_KERNEL ); + log->bios_event_log =devm_kmemdup (&chip->dev, logp, size,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;Signature · 1 line
2.43.0
Jarkko Sakkinen
maintainerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
In reply to Stefan Bergerin short summary: s/Use/use/
Quoted 7 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Signed-off-by Stefan Berger <[email protected]>
So shouldn't this have a fixed tag, or not?
Quoted 56 lines
--- drivers/char/tpm/eventlog/of.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-)drivers/char/tpm/eventlog/of.c +10
-24@@ -54,8 +54,8 @@ int tpm_read_log_of(struct tpm_chip *chip)const u32 *sizep;const u64 *basep;struct tpm_bios_log *log; +const void *logp;u32 size; -u64 base; log = &chip->log;if (chip->dev.parent && chip->dev.parent->of_node)@@ -66,37 +66,23 @@ int tpm_read_log_of(struct tpm_chip *chip)if (of_property_read_bool (np,"powered-while-suspended" )) chip->flags |=TPM_CHIP_FLAG_ALWAYS_POWERED ; - sizep =of_get_property (np,"linux,sml-size" ,NULL ); - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (sizep ==NULL && basep ==NULL ) -return tpm_read_log_memory_region (chip); -if (sizep ==NULL || basep ==NULL ) -return -EIO ; - -/* -* For both vtpm/tpm, firmware has log addr and log size in big -* endian format. But in case of vtpm, there is a method called -* sml-handover which is run during kernel init even before -* device tree is setup. This sml-handover function takes care -* of endianness and writes to sml-base and sml-size in little -* endian format. For this reason, vtpm doesn't need conversion -* but physical tpm needs the conversion. -*/ -if (of_property_match_string (np,"compatible" ,"IBM,vtpm" ) <0 && -of_property_match_string (np,"compatible" ,"IBM,vtpm20" ) <0 ) { + logp =of_get_property (np,"linux,sml-log" , &size); +if (logp ==NULL ) { + sizep =of_get_property (np,"linux,sml-size" ,NULL ); + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return tpm_read_log_memory_region (chip); +if (sizep ==NULL || basep ==NULL ) +return -EIO ; + logp =__va (be64_to_cpup ((__force __be64 *)basep)); size =be32_to_cpup ((__force __be32 *)sizep); - base =be64_to_cpup ((__force __be64 *)basep); - }else { - size = *sizep; - base = *basep; } -
drivers/char/tpm/eventlog/of.c int tpm_read_log_of(struct tpm_chip *chip) · line 88
Quoted 10 lines
drivers/char/tpm/eventlog/of.c +1
-1if (size ==0 ) {dev_warn (&chip->dev,"%s: Event log area empty\n" , __func__);return -EIO ; } - log->bios_event_log =devm_kmemdup (&chip->dev,__va (base), size,GFP_KERNEL ); + log->bios_event_log =devm_kmemdup (&chip->dev, logp, size,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;
Looks pretty good other than that.
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 9 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 6 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Quoted 3 lines
Quoted 1 line
Signed-off-by Stefan Berger <[email protected]>So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
BR, Jarkko
Re: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 10 lines · Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 6 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stefan Berger <[email protected]>So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
Ideally, yes. v3 will have 3 patches and all 3 of them will have to be backported *together* and not applied otherwise if any one of them fails. Can this be 'guaranteed'?
Quoted 2 lines
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 15 lines · Stefan Berger
Quoted 12 lines · Jarkko Sakkinen
Quoted 11 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 7 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Signed-off-by Stefan Berger <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
Ideally, yes. v3 will have 3 patches and all 3 of them will have to be backported *together* and not applied otherwise if any one of them fails. Can this be 'guaranteed'?
All of them will end up to stable if the following conditions hold:
- All have a fixes tag.
- All have "Cc: [email protected]".
- We agree in the review process that they are all legit fixes.
BR, Jarkko
Michael Ellerman
reviewerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
In reply to Stefan BergerQuoted 13 lines · Stefan Berger
Quoted 12 lines · Jarkko Sakkinen
Quoted 11 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 7 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Signed-off-by Stefan Berger <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
Ideally, yes. v3 will have 3 patches and all 3 of them will have to be backported *together* and not applied otherwise if any one of them fails. Can this be 'guaranteed'?
You can use Depends-on: <previous commit SHA> to indicate the relationship.
cheers
Jarkko Sakkinen
maintainerRe: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 18 lines · Michael Ellerman
Quoted 17 lines · Stefan Berger
Quoted 15 lines · Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 6 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Quoted 3 lines
Quoted 1 line
Signed-off-by Stefan Berger <[email protected]>So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
Quoted 7 lines
Quoted 3 lines
Ideally, yes. v3 will have 3 patches and all 3 of them will have to be backported *together* and not applied otherwise if any one of them fails. Can this be 'guaranteed'?
You can use Depends-on: <previous commit SHA> to indicate the relationship.
cheers
Thanks, I've missed depends-on tag.
Stefan, please add also "Cc: [email protected]" just to make sure that I don't forget to add it.
Right, and since these are so small scoped commits, and bug fixes in particular, it is also possible to do PR during the release cycle.
BR, Jarkko
Re: [PATCH 2/2] tpm: of: If available Use linux,sml-log to get the log and its size
Quoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · Michael Ellerman
Quoted 20 lines · Stefan Berger
Quoted 10 lines · Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
in short summary: s/Use/use/
Quoted 6 lines · Stefan Berger
If linux,sml-log is available use it to get the TPM log rather than the pointer found in linux,sml-base. This resolves an issue on PowerVM and KVM on Power where after a kexec the memory pointed to by linux,sml-base may have been corrupted. Also, linux,sml-log has replaced linux,sml-base and linux,sml-size on these two platforms.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Stefan Berger <[email protected]>So shouldn't this have a fixed tag, or not?
In English: do we want this to be backported to stable kernel releases or not?
Ideally, yes. v3 will have 3 patches and all 3 of them will have to be backported *together* and not applied otherwise if any one of them fails. Can this be 'guaranteed'?
Quoted 8 lines
Quoted 3 lines
You can use Depends-on: <previous commit SHA> to indicate the relationship.
cheers
Thanks, I've missed depends-on tag.
Stefan, please add also "Cc: [email protected]" just to make sure that I don't forget to add it.
Yeah, once we know whether this is the way forward or not... I posted v2 as RFC to figure this out.
v2's 2/3 patch will only apply to 6.8. To avoid any inconsistencies between code and bindings we cannot even go further back with this series (IFF it's the way forward at all). So I am inclined to remove the Fixes tags. I also find little under Documentation about the Depends-on tag and what it's supposed to be formatted like -- a commit hash of 1/3 appearing in 2/3 for example? The commit hash is not stable at this point so I couldn't created it.
Quoted 4 lines
Right, and since these are so small scoped commits, and bug fixes in particular, it is also possible to do PR during the release cycle.
BR, Jarkko
Quoted 6 lines · Stefan Berger
This series resolves an issue on PowerVM and KVM on Power where the memory the TPM log was held in may become inaccessible or corrupted after a kexec soft reboot. The solution on these two platforms is to store the whole log in the device tree because the device tree is preserved across a kexec with either of the two kexec syscalls.
FYI: This was the previous attempt that didn't work with the older kexec syscall: https://lore.kernel.org/lkml/[email protected]/T/#m158630d214837e41858b03d4b025e6f96cb8f251
Quoted 11 lines
Regards,
StefanStefan Berger (2):
powerpc/prom_init: Replace linux,sml-base/sml-size with linux,sml-log
tpm: of: If available Use linux,sml-log to get the log and its sizearch/powerpc/kernel/prom_init.c | 8 ++------ drivers/char/tpm/eventlog/of.c | 36 ++++++++++----------------------- 2 files changed, 13 insertions(+), 31 deletions(-)
Rob Herring
maintainerQuoted 11 lines · Stefan Berger
Quoted 6 lines · Stefan Berger
This series resolves an issue on PowerVM and KVM on Power where the memory the TPM log was held in may become inaccessible or corrupted after a kexec soft reboot. The solution on these two platforms is to store the whole log in the device tree because the device tree is preserved across a kexec with either of the two kexec syscalls.
FYI: This was the previous attempt that didn't work with the older kexec
syscall: https://lore.kernel.org/lkml/[email protected]/T/#m158630d214837e41858b03d4b025e6f96cb8f251
Doesn't everyone else still need that? Is powerpc the only ones that care about the old kexec syscall?
Rob
Quoted 10 lines · Rob Herring
Quoted 9 lines · Stefan Berger
Quoted 6 lines · Stefan Berger
This series resolves an issue on PowerVM and KVM on Power where the memory the TPM log was held in may become inaccessible or corrupted after a kexec soft reboot. The solution on these two platforms is to store the whole log in the device tree because the device tree is preserved across a kexec with either of the two kexec syscalls.
Quoted 4 lines
Quoted 2 lines
FYI: This was the previous attempt that didn't work with the older kexec
syscall: https://lore.kernel.org/lkml/[email protected]/T/#m158630d214837e41858b03d4b025e6f96cb8f251Doesn't everyone else still need that? Is powerpc the only ones that
Are you referring to the old series with 'that' ? I more or less had to abandon it because it wouldn't solve the problem for the old kexec syscall, so that's why I am embedding the whole log now in the devicetree since the DT is properly carried across the kexec soft reboot on PowerVM and KVM for Power. Maybe other platforms will (have to) follow, but I don't know.
Quoted 3 lines
care about the old kexec syscall?
Rob