From nobody Mon Feb 9 14:34:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619130403; cv=none; d=zohomail.com; s=zohoarc; b=L2LO2t18EppOq2X7wim4eFe4pHeKk1QZ4jg8CLMwWLnJ0rouWpxT2N2a6np1vmvR0R28EamCPPUfhge6fa+5ihpb88xPCm9R+LiBBZUDlZUiv5tn/7puE+4y/Q1R4om5yQOJSuExoadaMAjtzDAERFBbsJUeWlXr/J+lk8ZJiHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619130403; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=919k9q2m+2zrPKFQ+Ec/Cc8wRWCIr42fDB+fDVUPS1k=; b=CCcSUHCVBYT+p2J2AfSHSktMhIVwwXl9pcULzWGJfZPvAzqSVlb1fjXHogPxUsrdN4YsLj93cnlvLE81aVtciKHPNoviz+8iMMSi30CEnGT1CyMTqcsG2uICjBnE6dWDoukEe292R7bDBPPM13JA2NZSNKcYCj7pUUDrHrs9BHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161913040354376.01655304496853; Thu, 22 Apr 2021 15:26:43 -0700 (PDT) Received: from localhost ([::1]:38214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZhmU-0004xd-Fa for importer@patchew.org; Thu, 22 Apr 2021 18:26:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZhkt-0003Q9-KO for qemu-devel@nongnu.org; Thu, 22 Apr 2021 18:25:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZhkp-0003Mf-3Y for qemu-devel@nongnu.org; Thu, 22 Apr 2021 18:25:03 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-522-N_ldELDIM-KfjTjkqIZcVA-1; Thu, 22 Apr 2021 18:24:55 -0400 Received: by mail-ed1-f72.google.com with SMTP id d2-20020aa7d6820000b0290384ee872881so13419949edr.10 for ; Thu, 22 Apr 2021 15:24:55 -0700 (PDT) Received: from redhat.com (212.116.168.114.static.012.net.il. [212.116.168.114]) by smtp.gmail.com with ESMTPSA id t17sm3251124edv.3.2021.04.22.15.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 15:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619130297; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=919k9q2m+2zrPKFQ+Ec/Cc8wRWCIr42fDB+fDVUPS1k=; b=AK6IVIz3cg5kJjP3te0pYdhMQHO+jvTczqMgiIWq+nVl3x/o3w4tdoV+Ue+LVbz+k+8bDd RoFQHFsjfc9ifcFuDrehkysYsSS4dlP473U+B1lKpOmS1x+4qrrJB71Bm/1/8S2kxgc+ub 2q7DFQtU+3YVWYnZT6xDoCjZre/RA7g= X-MC-Unique: N_ldELDIM-KfjTjkqIZcVA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=919k9q2m+2zrPKFQ+Ec/Cc8wRWCIr42fDB+fDVUPS1k=; b=rfa5tdAQpyNuar0yNnvNTj5aSG6pdLkZvgwrAMXf9f1VxCCTLvEVZujZrXfpYL1M++ 2vdazKklLC7F5pMkDRq90cR8dxStimXGhLlXrFa7rIUTi99B0Iq4Nzv67cGV1kutP8j+ br9nN5a1gra4y044/vnHghgphIBFG7xpmH2EGz1LKKxyQUiz5igVBMPFsSaJqPhqUSEO v7sIQ9H+oWqryhil4/Td1eNKy6gOHdyYT9tk5wqexrReVICs+9ERhGEP/p417eUy6qXP 8sIkdc9E73ruHITMCdV1c/H7U/262O9GVTx4Xsu4mqHvjVIQG8YSnKaol6zQ/caNUarK ZIkA== X-Gm-Message-State: AOAM530t4iDAWRTWpXpTZ45VhhXnSoYWjQ6N7g4vWQn+4C+KR6u/B7q/ g2nsveLiRVwxkSrzwnXYueRCm3erPodW+puzZnaCvwYXvW3BpFX5QxFgNxxhYoJz8WLaL8nJeyH QyLvBdFJH5JfY9vU7ZGN+Xa+QMXIDtY3hQs9SfnX4G5i/gJiJyAPxSpTcEvq2 X-Received: by 2002:aa7:d9d7:: with SMTP id v23mr762077eds.281.1619130294339; Thu, 22 Apr 2021 15:24:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDmAhR+5sIHD2BGU4DxxMZCcnMuYO82j6fEU1oVrd2eHEm6wVkbdmhFSX3zkF4ryPSKCh4FQ== X-Received: by 2002:aa7:d9d7:: with SMTP id v23mr762038eds.281.1619130294020; Thu, 22 Apr 2021 15:24:54 -0700 (PDT) Date: Thu, 22 Apr 2021 18:24:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 1/2] amd_iommu: Fix pte_override_page_mask() Message-ID: <20210422222429.183108-2-mst@redhat.com> References: <20210422222429.183108-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210422222429.183108-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Jean-Philippe Brucker , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker AMD IOMMU PTEs have a special mode allowing to specify an arbitrary page size. Quoting the AMD IOMMU specification: "When the Next Level bits [of a pte] are 7h, the size of the page is determined by the first zero bit in the page address, starting from bit 12." So if the lowest bits of the page address is 0, the page is 8kB. If the lowest bits are 011, the page is 32kB. Currently pte_override_page_mask() doesn't compute the right value for this page size and amdvi_translate() can return the wrong guest-physical address. With a Linux guest, DMA from SATA devices accesses the wrong memory and causes probe failure: qemu-system-x86_64 ... -device amd-iommu -drive id=3Dhd1,file=3Dfoo.bin,if= =3Dnone \ -device ahci,id=3Dahci -device ide-hd,drive=3Dhd1,bus=3Dahci.0 [ 6.613093] ata1.00: qc timeout (cmd 0xec) [ 6.615062] ata1.00: failed to IDENTIFY (I/O error, err_mask=3D0x4) Fix the page mask. Signed-off-by: Jean-Philippe Brucker Message-Id: <20210421084007.1190546-1-jean-philippe@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 74a93a5d93..43b6e9bf51 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -860,8 +860,8 @@ static inline uint8_t get_pte_translation_mode(uint64_t= pte) =20 static inline uint64_t pte_override_page_mask(uint64_t pte) { - uint8_t page_mask =3D 12; - uint64_t addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) ^ AMDVI_DEV_PT_ROOT_M= ASK; + uint8_t page_mask =3D 13; + uint64_t addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) >> 12; /* find the first zero bit */ while (addr & 1) { page_mask++; --=20 MST From nobody Mon Feb 9 14:34:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1619130403; cv=none; d=zohomail.com; s=zohoarc; b=fbU1oiB0iLamwaPyVUgMdP97vXYgwTnaeoDL5hYL07KPHFbiVcyr/oC06YU1VLmBWoqxa+ySu/E96SPRxzHArJQSAeyo1BbXMCPwVsehjqO5LPYEp01jxvKB3MnmPUyMVgEfJFn00HfqvqCOa9EuYkm8Ou8Y9l+3wX+kWM8Vre8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619130403; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rAhi6mSwd1RX4WD+1Zv1SP4t5UQUzTU38vJXZ1UaeGQ=; b=gt5EnERlWkaCG+/FKvuzrPy2PyvTuMGlVWKBo4ak4YOs4T8Eb096dKysjZHdQIV3GcIyC+zoYceslrwL2zrDyVYmNvzxL4lproiRqpyJlhw+2+32Yq/hrHYK1U8q37jjOxT+FjpOb0pMVbvih0+hGRrAJTANdBlpZjLhJeQfjg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619130403871254.69142881523362; Thu, 22 Apr 2021 15:26:43 -0700 (PDT) Received: from localhost ([::1]:38246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lZhmU-0004yO-S0 for importer@patchew.org; Thu, 22 Apr 2021 18:26:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZhkv-0003R9-D7 for qemu-devel@nongnu.org; Thu, 22 Apr 2021 18:25:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41261) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lZhkt-0003Ob-1L for qemu-devel@nongnu.org; Thu, 22 Apr 2021 18:25:05 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-tofJlhdcOZqGfXq5kQNJxw-1; Thu, 22 Apr 2021 18:24:58 -0400 Received: by mail-ed1-f70.google.com with SMTP id m18-20020a0564025112b0290378d2a266ebso17504273edd.15 for ; Thu, 22 Apr 2021 15:24:58 -0700 (PDT) Received: from redhat.com (212.116.168.114.static.012.net.il. [212.116.168.114]) by smtp.gmail.com with ESMTPSA id b22sm3127760edv.96.2021.04.22.15.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 15:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619130302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rAhi6mSwd1RX4WD+1Zv1SP4t5UQUzTU38vJXZ1UaeGQ=; b=SEJTcXACNME4cfrW2x1c11Bx9mVl3gJZmNh3a3nC463GJRYh8A+K25VcFxIlMzZI4eDL+x 1MdLNZZ9jZG02m28O+ddiCMbXb6UwXUuKmzFM18OM1tvwmWHs+7I+CKlPimtCCPSY3zpIc Nch7aSEimvkcC2OELGuPgQlwThjvua8= X-MC-Unique: tofJlhdcOZqGfXq5kQNJxw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=rAhi6mSwd1RX4WD+1Zv1SP4t5UQUzTU38vJXZ1UaeGQ=; b=nJ3lw9jg1S5AIdUiPkQXy5VoKggycU9vN++DxThFagV3ni6iOZtGxQYzB8kS6ABpEZ /SsRV5/hvKMqgmP5/P4hbpH7sbPjkm6eojw6weXCSY+GZ1IRRaQc+UcQFw/TYvVjxKPn gQHd8lxgILOAjSmU9+zgD8vUTa4xe5kUuSwPxh7ACySNxaVQzW1gHx+NiX2j9WLQJjuX 70hpPBW1F0eJMToLQQTxGkIYPC8Jat2FdvuiAxOwSkH9cGNX9kr/+qhkPpkUJEm7kwqr U2RVzUdA0arzA2Iy+yebyx0NfkdzMZV5MBUSSuryZODOPsbzBFJa6v7tY7TAZeYj/x5m rCbA== X-Gm-Message-State: AOAM533fSE0FWQIVsOgE7rehkrgpjFFOEyHlcMBtO5dX8ctHguYbVoqx lPZXw1vHixgV2m6/77zgV5yoPw84WaEasFFZpfM9/70NNjvahnLkw/tOFbtmVbACgbQdJHZJo3F s2AZaOCBt5vw+5R0XA312GT80+UuMmoGAC/fcPC5J+IxeQceMblp7MPfxz144 X-Received: by 2002:aa7:dd4d:: with SMTP id o13mr795943edw.53.1619130296855; Thu, 22 Apr 2021 15:24:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAI1vuU2m3KbBRuuL4ivrDq6eVeYQuHQFCg+5CfuAQGnx6W3RkPoSd8Dhuziu9sfuf91psWg== X-Received: by 2002:aa7:dd4d:: with SMTP id o13mr795918edw.53.1619130296602; Thu, 22 Apr 2021 15:24:56 -0700 (PDT) Date: Thu, 22 Apr 2021 18:24:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 2/2] x86: acpi: use offset instead of pointer when using build_header() Message-ID: <20210422222429.183108-3-mst@redhat.com> References: <20210422222429.183108-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210422222429.183108-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , mst@redhat.com, Richard Henderson , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Do the same as in commit (4d027afeb3a97 Virt: ACPI: fix qemu assert due to re-assigned table data a= ddress) for remaining tables that happen to use saved at the beginning pointer to build header to avoid assert when table_data is relocated due to implicit re-size. In this case user is trying to start Windows 10 and getting assert at hw/acpi/bios-linker-loader.c:239: bios_linker_loader_add_checksum: Assertion `start_offset < file->blob->le= n' failed. Fixes: https://bugs.launchpad.net/bugs/1923497 Signed-off-by: Igor Mammedov Message-Id: <20210414084356.3792113-1-imammedo@redhat.com> Cc: mst@redhat.com, qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/aml-build.c | 15 +++++++++------ hw/i386/acpi-build.c | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index d33ce8954a..f0035d2b4a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1830,6 +1830,7 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GA= rray *table_offsets, int i; unsigned rsdt_entries_offset; AcpiRsdtDescriptorRev1 *rsdt; + int rsdt_start =3D table_data->len; const unsigned table_data_len =3D (sizeof(uint32_t) * table_offsets->l= en); const unsigned rsdt_entry_size =3D sizeof(rsdt->table_offset_entry[0]); const size_t rsdt_len =3D sizeof(*rsdt) + table_data_len; @@ -1846,7 +1847,8 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GA= rray *table_offsets, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); } build_header(linker, table_data, - (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id); + (void *)(table_data->data + rsdt_start), + "RSDT", rsdt_len, 1, oem_id, oem_table_id); } =20 /* Build xsdt table */ @@ -1857,6 +1859,7 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GA= rray *table_offsets, int i; unsigned xsdt_entries_offset; AcpiXsdtDescriptorRev2 *xsdt; + int xsdt_start =3D table_data->len; const unsigned table_data_len =3D (sizeof(uint64_t) * table_offsets->l= en); const unsigned xsdt_entry_size =3D sizeof(xsdt->table_offset_entry[0]); const size_t xsdt_len =3D sizeof(*xsdt) + table_data_len; @@ -1873,7 +1876,8 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, GA= rray *table_offsets, ACPI_BUILD_TABLE_FILE, ref_tbl_offset); } build_header(linker, table_data, - (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id); + (void *)(table_data->data + xsdt_start), + "XSDT", xsdt_len, 1, oem_id, oem_table_id); } =20 void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, @@ -2053,10 +2057,9 @@ void build_tpm2(GArray *table_data, BIOSLinker *link= er, GArray *tcpalog, uint64_t control_area_start_address; TPMIf *tpmif =3D tpm_find(); uint32_t start_method; - void *tpm2_ptr; =20 tpm2_start =3D table_data->len; - tpm2_ptr =3D acpi_data_push(table_data, sizeof(AcpiTableHeader)); + acpi_data_push(table_data, sizeof(AcpiTableHeader)); =20 /* Platform Class */ build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2); @@ -2095,8 +2098,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linke= r, GArray *tcpalog, log_addr_offset, 8, ACPI_BUILD_TPMLOG_FILE, 0); build_header(linker, table_data, - tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id, - oem_table_id); + (void *)(table_data->data + tpm2_start), + "TPM2", table_data->len - tpm2_start, 4, oem_id, oem_tabl= e_id); } =20 Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_off= set, diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index de98750aef..daaf8f473e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1816,6 +1816,7 @@ build_hpet(GArray *table_data, BIOSLinker *linker, co= nst char *oem_id, const char *oem_table_id) { Acpi20Hpet *hpet; + int hpet_start =3D table_data->len; =20 hpet =3D acpi_data_push(table_data, sizeof(*hpet)); /* Note timer_block_id value must be kept in sync with value advertise= d by @@ -1824,13 +1825,15 @@ build_hpet(GArray *table_data, BIOSLinker *linker, = const char *oem_id, hpet->timer_block_id =3D cpu_to_le32(0x8086a201); hpet->addr.address =3D cpu_to_le64(HPET_BASE); build_header(linker, table_data, - (void *)hpet, "HPET", sizeof(*hpet), 1, oem_id, oem_table= _id); + (void *)(table_data->data + hpet_start), + "HPET", sizeof(*hpet), 1, oem_id, oem_table_id); } =20 static void build_tpm_tcpa(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, const char *oem_id, const char *oem_table_id) { + int tcpa_start =3D table_data->len; Acpi20Tcpa *tcpa =3D acpi_data_push(table_data, sizeof *tcpa); unsigned log_addr_size =3D sizeof(tcpa->log_area_start_address); unsigned log_addr_offset =3D @@ -1849,7 +1852,8 @@ build_tpm_tcpa(GArray *table_data, BIOSLinker *linker= , GArray *tcpalog, ACPI_BUILD_TPMLOG_FILE, 0); =20 build_header(linker, table_data, - (void *)tcpa, "TCPA", sizeof(*tcpa), 2, oem_id, oem_table= _id); + (void *)(table_data->data + tcpa_start), + "TCPA", sizeof(*tcpa), 2, oem_id, oem_table_id); } =20 #define HOLE_640K_START (640 * KiB) --=20 MST