vfio/common: remove spurious tpm-crb-cmd misalignment warning
v5 cover vfio/common: remove spurious tpm-crb-cmd misalignment warning
The CRB command buffer currently is a RAM MemoryRegion and given its base address alignment, it causes an error report on vfio_listener_region_add(). This region could have been a RAM device region, easing the detection of such safe situation but this option was not well received. So let's add a helper function that uses the memory region owner type to detect the situation is safe wrt the assignment. Other device types can be checked here if such kind of problem occurs again.
As TPM devices can be compiled out we need to introduce a stub for TPM_IS_CRB.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/tpm-crb-vfio-v5
History:
v4 -> v5:
- Add sysemu: tpm: Add a stub function for TPM_IS_CRB to fix compilation error if CONFIG_TPM is unset
Eric Auger (2):
sysemu: tpm: Add a stub function for TPM_IS_CRB vfio/common: remove spurious tpm-crb-cmd misalignment warning
hw/vfio/common.c | 27 ++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + include/sysemu/tpm.h | 6 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
PATCH v5 1/2 sysemu: tpm: Add a stub function for TPM_IS_CRB
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use TPM_IS_CRB() even if CONFIG_TPM is unset. So let's add a stub function.
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/sysemu/tpm.h +6 -0
@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Signature · 1 line
2.35.1
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 7 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>
Quoted 21 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 11 lines · Stefan Berger
Quoted 7 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>
... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
Quoted 23 lines
Quoted 21 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Hi,
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (0x1000 - 0x80), 0x80 being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.
We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.
Thanks
Eric
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 39 lines · Eric Auger
Hi,
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (
0x1000-0x80),0x80being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.
Quoted 3 lines
Thanks
Eric
So we put it in system RAM then? But why isn't DMA there allowed?
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Eric Auger
Hi,
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (
0x1000-0x80),0x80being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.
Quoted 4 lines
Quoted 3 lines
Thanks
Eric
So we put it in system RAM then? But why isn't DMA there allowed?
I don't think there is any need and since it violates the alignment check in VFIO we discard the region from DMA mapped ones.
Thanks
Eric
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 45 lines · Eric Auger
Quoted 42 lines · Michael S. Tsirkin
Quoted 41 lines · Eric Auger
Hi,
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (
0x1000-0x80),0x80being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.Thanks
Eric
Quoted 8 lines
Quoted 1 line
So we put it in system RAM then? But why isn't DMA there allowed?
I don't think there is any need and since it violates the alignment check in VFIO we discard the region from DMA mapped ones.
Thanks
Eric
If that's all then we could just check alignment - why are we bothering with a tpm specific hack?
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 46 lines · Michael S. Tsirkin
Quoted 45 lines · Eric Auger
Quoted 43 lines · Michael S. Tsirkin
Quoted 38 lines · Eric Auger
Hi,
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (
0x1000-0x80),0x80being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.Quoted 3 lines
Thanks
Eric
So we put it in system RAM then? But why isn't DMA there allowed?
Quoted 8 lines
Quoted 6 lines
I don't think there is any need and since it violates the alignment check in VFIO we discard the region from DMA mapped ones.
Thanks
Eric
If that's all then we could just check alignment - why are we bothering with a tpm specific hack?
I think Alex prefered to avoid silently skipping the DMA mapping of a region (a possible scenario may be invalid P2P DMA access?). Except if we know this region can be safely ignored, which is the case for the TPM CRB, hence this whitelist.
Eric
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
Re: [PATCH v5 1/2] sysemu: tpm: Add a stub function for TPM_IS_CRB
Quoted 55 lines · Eric Auger
Quoted 52 lines · Michael S. Tsirkin
Quoted 51 lines · Eric Auger
Quoted 39 lines · Michael S. Tsirkin
Quoted 38 lines · Eric Auger
Hi,
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Stefan Berger
Quoted 5 lines · Eric Auger
In a subsequent patch, VFIO will need to recognize if a memory region owner is a TPM CRB device. Hence VFIO needs to use
TPM_IS_CRB()even ifCONFIG_TPMis unset. So let's add a stub function.Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Suggested-by Cornelia Huck <[email protected]>Reviewed-by Stefan Berger <[email protected]>... and now in 7.2 vdpa needs a dependency on tpm too, what a hack :( And what exactly is it about TPM CRB that everyone needs to know about it and skip it? The API does not tell ...
An excerpt of one reply I made at that time:
The spec (CG PC Client Platform TPM Profile (PTP) Specification Family “2.0” Level 00 Revision 01.03 v22, page 100) says that the command/response data "may be defined as large as 3968", which is (
0x1000-0x80),0x80being the size of the control struct. so the size of the region logically is less than a 4kB page, hence our trouble.We learnt in the past Windows driver has some stronger expectation wrt memory mapping. I don't know if those latter would work if we were to enlarge the window by some tricks.
"
Including the control structure, the three memory areas comprise the entirety of the CRB. There are no constraints on how those three memory areas are provided. They can all be in system RAM, or all be in device memory, or any combination.Quoted 4 lines
Quoted 3 lines
Thanks
Eric
So we put it in system RAM then? But why isn't DMA there allowed?
I don't think there is any need and since it violates the alignment check in VFIO we discard the region from DMA mapped ones.
Thanks
Eric
Quoted 8 lines
Quoted 2 lines
If that's all then we could just check alignment - why are we bothering with a tpm specific hack?
I think Alex prefered to avoid silently skipping the DMA mapping of a region (a possible scenario may be invalid P2P DMA access?). Except if we know this region can be safely ignored, which is the case for the TPM CRB, hence this whitelist.
Eric
As a vdpa maintainer I might know (more like trust) TPM can be safely ignored right now, but for sure I won't know if that ever changes nor will I remember why down the road. Nor will TPM maintainers remember to go poke at vdpa if this changes.
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
--- include/sysemu/tpm.h | 6 ++++++ 1 file changed, 6 insertions(+)include/sysemu/tpm.h +6
-0@@ -80,6 +80,12 @@ static inline TPMVersion tpm_get_version(TPMIf *ti)#define tpm_init () (0)#define tpm_cleanup () +/* needed for an alignment check in non-tpm code */ +static inline Object *TPM_IS_CRB (Object *obj) +{ +return NULL ; +} +#endif /* CONFIG_TPM */ #endif /* QEMU_TPM_H */
PATCH v5 2/2 vfio/common: remove spurious tpm-crb-cmd misalignment warning
In reply to Eric AugerThe CRB command buffer currently is a RAM MemoryRegion and given its base address alignment, it causes an error report on vfio_listener_region_add(). This region could have been a RAM device region, easing the detection of such safe situation but this option was not well received. So let's add a helper function that uses the memory region owner type to detect the situation is safe wrt the assignment. Other device types can be checked here if such kind of problem occurs again.
--- hw/vfio/common.c | 27 ++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 27 insertions(+), 1 deletion(-)
hw/vfio/common.c +26 -1
@@ -40,6 +40,7 @@#include "trace.h" #include "qapi/error.h" #include "migration/migration.h" +#include "sysemu/tpm.h" VFIOGroupList vfio_group_list =QLIST_HEAD_INITIALIZER (vfio_group_list);
@@ -861,6 +862,22 @@ static void vfio_unregister_ram_discard_listener(VFIOContainer *container,g_free (vrdl); } +static bool vfio_known_safe_misalignment (MemoryRegionSection *section) +{ +MemoryRegion *mr = section->mr; + +if (!TPM_IS_CRB (mr->owner)) { +return false; + } + +/* this is a known safe misaligned region, just trace for debug purpose */ +trace_vfio_known_safe_misalignment (memory_region_name (mr), + section->offset_within_address_space, + section->offset_within_region, +qemu_real_host_page_size ()); +return true; +} +static void vfio_listener_region_add (MemoryListener *listener,MemoryRegionSection *section) {
@@ -884,7 +901,15 @@ static void vfio_listener_region_add(MemoryListener *listener,if (unlikely ((section->offset_within_address_space & ~qemu_real_host_page_mask ()) != (section->offset_within_region & ~qemu_real_host_page_mask ()))) { -error_report ("%s received unaligned region" , __func__); +if (!vfio_known_safe_misalignment (section)) { +error_report ("%s received unaligned region %s iova=0x%" PRIx64 +" offset_within_region=0x%" PRIx64 +" qemu_real_host_page_size=0x%" PRIxPTR, + __func__,memory_region_name (section->mr), + section->offset_within_address_space, + section->offset_within_region, +qemu_real_host_page_size ()); + }return ; }
hw/vfio/trace-events +1 -0
@@ -100,6 +100,7 @@ vfio_listener_region_add_skip(uint64_t start, uint64_t end) "SKIPPING region_add vfio_spapr_group_attach(int groupfd, int tablefd) "Attached groupfd %d to liobn fd %d" vfio_listener_region_add_iommu(uint64_t start, uint64_t end) "region_add [iommu] 0x%"PRIx64" - 0x%"PRIx64 vfio_listener_region_add_ram(uint64_t iova_start, uint64_t iova_end, void *vaddr) "region_add [ram] 0x%"PRIx64" - 0x%"PRIx64" [%p]" +vfio_known_safe_misalignment(const char *name, uint64_t iova, uint64_t offset_within_region, uintptr_t page_size) "Region \"%s\" iova=0x%"PRIx64" offset_within_region=0x%"PRIx64" qemu_real_host_page_size=0x%"PRIxPTR ": cannot be mapped for DMA" vfio_listener_region_add_no_dma_map(const char *name, uint64_t iova, uint64_t size, uint64_t page_size) "Region \"%s\" 0x%"PRIx64" size=0x%"PRIx64" is not aligned to 0x%"PRIx64" and cannot be mapped for DMA" vfio_listener_region_del_skip(uint64_t start, uint64_t end) "SKIPPING region_del 0x%"PRIx64" - 0x%"PRIx64 vfio_listener_region_del(uint64_t start, uint64_t end) "region_del 0x%"PRIx64" - 0x%"PRIx64
Signature · 1 line
2.35.1
Quoted 5 lines · Eric Auger
The CRB command buffer currently is a RAM MemoryRegion and given its base address alignment, it causes an error report on
vfio_listener_region_add(). This region could have been a RAM device region, easing the detection of such safe situation but this option was not well received.
Eric could you point me at this discussion please? We are now asked to proliferate stuff like this into vdpa as well, this just doesn't scale. I'd like to see whether we can make it a RAM device region after all - was a patch like that posted?
Quoted 35 lines
So let's add a helper function that uses the
memory region owner type to detect the situation is safe wrt the assignment. Other device types can be checked here if such kind of problem occurs again.As TPM devices can be compiled out we need to introduce a stub for
TPM_IS_CRB.Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/tpm-crb-vfio-v5History:
v4 -> v5:
- Add sysemu: tpm: Add a stub function forTPM_IS_CRBto fix compilation error ifCONFIG_TPMis unsetEric Auger (2):
sysemu: tpm: Add a stub function forTPM_IS_CRBvfio/common: remove spurious tpm-crb-cmd misalignment warninghw/vfio/common.c | 27 ++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + include/sysemu/tpm.h | 6 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-)Signature · 1 line
2.35.1
Hi Michael,
Quoted 11 lines · Michael S. Tsirkin
Quoted 5 lines · Eric Auger
The CRB command buffer currently is a RAM MemoryRegion and given its base address alignment, it causes an error report on
vfio_listener_region_add(). This region could have been a RAM device region, easing the detection of such safe situation but this option was not well received.Eric could you point me at this discussion please? We are now asked to proliferate stuff like this into vdpa as well, this just doesn't scale. I'd like to see whether we can make it a RAM device region after all - was a patch like that posted?
The bulk of the discussion happened in
https://lore.kernel.org/all/[email protected]/#r
See exchanges with Peter who was against turning the CRB cmd/response buffer into a RAM device region at that time, hence the current workaround.
You will see there also discussions about the buffer size in
https://lore.kernel.org/all/[email protected]/
Thanks
Eric
Quoted 36 lines
Quoted 36 lines
So let's add a helper function that uses the
memory region owner type to detect the situation is safe wrt the assignment. Other device types can be checked here if such kind of problem occurs again.As TPM devices can be compiled out we need to introduce a stub for
TPM_IS_CRB.Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/tpm-crb-vfio-v5History:
v4 -> v5:
- Add sysemu: tpm: Add a stub function forTPM_IS_CRBto fix compilation error ifCONFIG_TPMis unsetEric Auger (2):
sysemu: tpm: Add a stub function forTPM_IS_CRBvfio/common: remove spurious tpm-crb-cmd misalignment warninghw/vfio/common.c | 27 ++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + include/sysemu/tpm.h | 6 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-)Signature · 1 line
2.35.1