From patchwork Tue Jan 16 15:51:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 10167521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3565E601E7 for ; Tue, 16 Jan 2018 15:55:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 286C328699 for ; Tue, 16 Jan 2018 15:55:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C0D9286A2; Tue, 16 Jan 2018 15:55:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B7D3228699 for ; Tue, 16 Jan 2018 15:55:41 +0000 (UTC) Received: from localhost ([::1]:43320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebTaO-0005yh-Ou for patchwork-qemu-devel@patchwork.kernel.org; Tue, 16 Jan 2018 10:55:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebTWm-0002kK-HD for qemu-devel@nongnu.org; Tue, 16 Jan 2018 10:51:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebTWj-0003sx-9E for qemu-devel@nongnu.org; Tue, 16 Jan 2018 10:51:56 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52182 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ebTWj-0003sQ-40 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 10:51:53 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0GFnjNm102371 for ; Tue, 16 Jan 2018 10:51:52 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fhkkcub6g-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 16 Jan 2018 10:51:52 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Jan 2018 08:51:51 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 16 Jan 2018 08:51:47 -0700 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0GFplWZ11076044; Tue, 16 Jan 2018 08:51:47 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F5F06A03B; Tue, 16 Jan 2018 08:51:47 -0700 (MST) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 896276A03C; Tue, 16 Jan 2018 08:51:46 -0700 (MST) From: Stefan Berger To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 10:51:38 -0500 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1516117900-11382-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1516117900-11382-1-git-send-email-stefanb@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18011615-8235-0000-0000-00000CE0A845 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008389; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000246; SDB=6.00975899; UDB=6.00494662; IPR=6.00755827; BA=6.00005781; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019072; XFM=3.00000015; UTC=2018-01-16 15:51:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011615-8236-0000-0000-00003F45B45A Message-Id: <1516117900-11382-3-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-16_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801160221 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 2/4] acpi: build QEMU table for PPI virtual memory device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, kevin@koconnor.net, stefanb@linux.vnet.ibm.com, lersek@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To avoid having to hard code the base address of the PPI virtual memory device we introduce a QEMU ACPI table that holds the base address, if a TPM 1.2 or 2 is used. This table gives us flexibility to move the base address later on. Signed-off-by: Stefan Berger --- hw/i386/acpi-build.c | 19 +++++++++++++++++++ include/hw/acpi/acpi-defs.h | 8 ++++++++ 2 files changed, 27 insertions(+) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 18b939e..522d6d2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2628,6 +2628,20 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) return true; } +static void build_qemu(GArray *table_data, BIOSLinker *linker, + TPMVersion tpm_version) +{ + AcpiTableQemu *qemu = acpi_data_push(table_data, sizeof(*qemu)); + + if (tpm_version != TPM_VERSION_UNSPEC) { + qemu->tpmppi_addr = TPM_PPI_ADDR_BASE; + qemu->tpm_version = tpm_version; + } + + build_header(linker, table_data, + (void *)qemu, "QEMU", sizeof(*qemu), 1, "QEMU", "CONF"); +} + static void acpi_build(AcpiBuildTables *tables, MachineState *machine) { @@ -2734,6 +2748,11 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) &pcms->acpi_nvdimm_state, machine->ram_slots); } + if (misc.tpm_version != TPM_VERSION_UNSPEC) { + acpi_add_table(table_offsets, tables_blob); + build_qemu(tables_blob, tables->linker, misc.tpm_version); + } + /* Add tables supplied by user (if any) */ for (u = acpi_table_first(); u; u = acpi_table_next(u)) { unsigned len = acpi_table_len(u); diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 80c8099..98764c1 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -573,6 +573,14 @@ struct Acpi20TPM2 { } QEMU_PACKED; typedef struct Acpi20TPM2 Acpi20TPM2; +/* QEMU - Custom QEMU table */ +struct AcpiTableQemu { + ACPI_TABLE_HEADER_DEF + uint32_t tpmppi_addr; + uint8_t tpm_version; /* 1 = 1.2, 2 = 2 */ +}; +typedef struct AcpiTableQemu AcpiTableQemu; + /* DMAR - DMA Remapping table r2.2 */ struct AcpiTableDmar { ACPI_TABLE_HEADER_DEF