hw/misc/allwinner-h3-dramc: enforce 64-bit multiply when calculating row mirror address
[qemu/ar7.git] / hw / tpm / tpm_ppi.c
blob6d9c1a3e40ee6f76d0b582d13f5b874742e5eefa
1 /*
2 * tpm_ppi.c - TPM Physical Presence Interface
4 * Copyright (C) 2018 IBM Corporation
6 * Authors:
7 * Stefan Berger <stefanb@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
16 #include "qapi/error.h"
17 #include "cpu.h"
18 #include "sysemu/memory_mapping.h"
19 #include "migration/vmstate.h"
20 #include "tpm_ppi.h"
21 #include "trace.h"
23 void tpm_ppi_reset(TPMPPI *tpmppi)
25 if (tpmppi->buf[0x15a /* movv, docs/specs/tpm.txt */] & 0x1) {
26 GuestPhysBlockList guest_phys_blocks;
27 GuestPhysBlock *block;
29 guest_phys_blocks_init(&guest_phys_blocks);
30 guest_phys_blocks_append(&guest_phys_blocks);
31 QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) {
32 trace_tpm_ppi_memset(block->host_addr,
33 block->target_end - block->target_start);
34 memset(block->host_addr, 0,
35 block->target_end - block->target_start);
36 memory_region_set_dirty(block->mr, 0,
37 block->target_end - block->target_start);
39 guest_phys_blocks_free(&guest_phys_blocks);
43 void tpm_ppi_init(TPMPPI *tpmppi, struct MemoryRegion *m,
44 hwaddr addr, Object *obj)
46 tpmppi->buf = qemu_memalign(qemu_real_host_page_size,
47 HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE));
48 memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi",
49 TPM_PPI_ADDR_SIZE, tpmppi->buf);
50 vmstate_register_ram(&tpmppi->ram, DEVICE(obj));
52 memory_region_add_subregion(m, addr, &tpmppi->ram);