[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 41/49] acpi: add ACPI memory clear interface
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 41/49] acpi: add ACPI memory clear interface |
Date: |
Tue, 15 Jan 2019 15:06:06 -0500 |
From: Marc-André Lureau <address@hidden>
The interface is described in the "TCG Platform Reset Attack
Mitigation Specification", chapter 6 "ACPI _DSM Function". According
to Laszlo, it's not so easy to implement in OVMF, he suggested to do
it in qemu instead.
See specification documentation for more details, and next commit for
memory clear on reset handling.
The underlying TCG specification is accessible from the following
page.
https://trustedcomputinggroup.org/resource/pc-client-work-group-platform-reset-attack-mitigation-specification-version-1-0/
This patch implements version 1.0.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Tested-by: Stefan Berger <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
docs/specs/tpm.txt | 2 ++
hw/acpi/tpm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/docs/specs/tpm.txt b/docs/specs/tpm.txt
index 424d1511fc..5d8c26b1ad 100644
--- a/docs/specs/tpm.txt
+++ b/docs/specs/tpm.txt
@@ -135,6 +135,8 @@ layout:
+----------+--------+--------+-------------------------------------------+
| next_step| 0x1 | 0x159 | Operation to execute after reboot by |
| | | | firmware. Used by firmware. |
+ +----------+--------+--------+-------------------------------------------+
+ | movv | 0x1 | 0x15a | Memory overwrite variable |
+----------+--------+--------+-------------------------------------------+
The following values are supported for the 'func' field. They correspond
diff --git a/hw/acpi/tpm.c b/hw/acpi/tpm.c
index 9f205378f2..b96459e45b 100644
--- a/hw/acpi/tpm.c
+++ b/hw/acpi/tpm.c
@@ -53,6 +53,16 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)
pprq = aml_name("PPRQ");
pprm = aml_name("PPRM");
+ aml_append(dev,
+ aml_operation_region(
+ "TPP3", AML_SYSTEM_MEMORY,
+ aml_int(TPM_PPI_ADDR_BASE +
+ 0x15a /* movv, docs/specs/tpm.txt */),
+ 0x1));
+ field = aml_field("TPP3", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE);
+ aml_append(field, aml_named_field("MOVV", 8));
+ aml_append(dev, field);
+
/*
* DerefOf in Windows is broken with SYSTEM_MEMORY. Use a dynamic
* operation region inside of a method for getting FUNC[op].
@@ -399,6 +409,51 @@ void tpm_build_ppi_acpi(TPMIf *tpm, Aml *dev)
aml_append(ifctx, aml_return(aml_buffer(1, zerobyte)));
}
aml_append(method, ifctx);
+
+ /*
+ * "TCG Platform Reset Attack Mitigation Specification 1.00",
+ * Chapter 6 "ACPI _DSM Function"
+ */
+ ifctx = aml_if(
+ aml_equal(uuid,
+ aml_touuid("376054ED-CC13-4675-901C-4756D7F2D45D")));
+ {
+ /* standard DSM query function */
+ ifctx2 = aml_if(aml_equal(function, zero));
+ {
+ uint8_t byte_list[1] = { 0x03 }; /* functions 1-2 supported */
+
+ aml_append(ifctx2,
+ aml_return(aml_buffer(sizeof(byte_list),
+ byte_list)));
+ }
+ aml_append(ifctx, ifctx2);
+
+ /*
+ * TCG Platform Reset Attack Mitigation Specification 1.0 Ch.6
+ *
+ * Arg 2 (Integer): Function Index = 1
+ * Arg 3 (Package): Arguments = Package: Type: Integer
+ * Operation Value of the Request
+ * Returns: Type: Integer
+ * 0: Success
+ * 1: General Failure
+ */
+ ifctx2 = aml_if(aml_equal(function, one));
+ {
+ aml_append(ifctx2,
+ aml_store(aml_derefof(aml_index(arguments, zero)),
+ op));
+ {
+ aml_append(ifctx2, aml_store(op, aml_name("MOVV")));
+
+ /* 0: success */
+ aml_append(ifctx2, aml_return(zero));
+ }
+ }
+ aml_append(ifctx, ifctx2);
+ }
+ aml_append(method, ifctx);
}
aml_append(dev, method);
}
--
MST
- [Qemu-devel] [PULL v2 19/49] virtio: split virtio input host bits from virtio-pci, (continued)
- [Qemu-devel] [PULL v2 19/49] virtio: split virtio input host bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 38/49] tpm: allocate/map buffer for TPM Physical Presence interface, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 36/49] hw/misc/edu: add msi_uninit() for pci_edu_uninit(), Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 34/49] globals: Allow global properties to be optional, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 21/49] virtio: split virtio rng bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 22/49] virtio: split virtio balloon bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 42/49] tpm: clear RAM when "memory overwrite" requested, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 24/49] virtio: split vhost user blk bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 32/49] virtio: split virtio crypto bits from virtio-pci.h, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 40/49] acpi: build TPM Physical Presence interface, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 41/49] acpi: add ACPI memory clear interface,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 20/49] virtio: split virtio input bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 43/49] hw: acpi: Fix memory hotplug AML generation error, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 23/49] virtio: split virtio 9p bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 30/49] virtio: split virtio serial bits from virtio-pci, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 49/49] migration: Use strnlen() for fixed-size string, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 44/49] acpi: update expected files, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 45/49] qemu/compiler: Define QEMU_NONSTRING, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 47/49] hw/acpi: Use QEMU_NONSTRING for non NUL-terminated arrays, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 48/49] migration: Fix stringop-truncation warning, Michael S. Tsirkin, 2019/01/15
- [Qemu-devel] [PULL v2 46/49] block/sheepdog: Use QEMU_NONSTRING for non NUL-terminated arrays, Michael S. Tsirkin, 2019/01/15