Skip to content

Commit 45e576c

Browse files
davidhildenbrandbonzini
authored andcommitted
tpm: mark correct memory region range dirty when clearing RAM
We might not start at the beginning of the memory region. Let's calculate the offset into the memory region via the difference in the host addresses. Acked-by: Stefan Berger <[email protected]> Fixes: ffab1be ("tpm: clear RAM when "memory overwrite" requested") Cc: Marc-André Lureau <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: "Michael S. Tsirkin" <[email protected]> Cc: Eduardo Habkost <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: Igor Mammedov <[email protected]> Cc: Claudio Fontana <[email protected]> Cc: Thomas Huth <[email protected]> Cc: "Alex Bennée" <[email protected]> Cc: Peter Xu <[email protected]> Cc: Laurent Vivier <[email protected]> Cc: Stefan Berger <[email protected]> Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Peter Xu <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 77ae230 commit 45e576c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hw/tpm/tpm_ppi.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ void tpm_ppi_reset(TPMPPI *tpmppi)
3030
guest_phys_blocks_init(&guest_phys_blocks);
3131
guest_phys_blocks_append(&guest_phys_blocks);
3232
QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
33+
hwaddr mr_offs = block->host_addr -
34+
(uint8_t *)memory_region_get_ram_ptr(block->mr);
35+
3336
trace_tpm_ppi_memset(block->host_addr,
3437
block->target_end - block->target_start);
3538
memset(block->host_addr, 0,
3639
block->target_end - block->target_start);
37-
memory_region_set_dirty(block->mr, 0,
40+
memory_region_set_dirty(block->mr, mr_offs,
3841
block->target_end - block->target_start);
3942
}
4043
guest_phys_blocks_free(&guest_phys_blocks);

0 commit comments

Comments
 (0)