From nobody Tue Feb 10 06:44:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1657825459; cv=none; d=zohomail.com; s=zohoarc; b=nptsEOkjWcThVd7QoT9E0H2W5obDXhwsOCSS7mg1aVvoeQ4rC/63CBOugwUdaS52thbEW7I2UZYikYG2CWYdQMoaAAhnvW8vBsaK+rQuibEtiwleXJnfWjtjK2cmgpKcA+Sxs6qJNhia+BFGin2EOeenDe1pWUc2jBz+meDjYmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657825459; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=lbzGY+jIADZtZw967IbA4yLh8WEOgvAyZfxf5ZTRYkU=; b=IW3L3e4O0JJhyNsfCJX9RYgYFwpDe//0nN9kttvSFVyu3JfXnfKXcRwY5RUGgq+fi3WIqlf6SCtHKj0DMOJFRRpbqjnXgwTmxoOFiDqXwdP2tydPlWbQv/AzWgUxK4/MaJ/rv0dgy4n+a7zMMliszUSRAOV7mbdv8Cxj/Lki8kY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657825459673550.9303084181233; Thu, 14 Jul 2022 12:04:19 -0700 (PDT) Received: from localhost ([::1]:35636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oC48I-0007JA-A2 for importer@patchew.org; Thu, 14 Jul 2022 15:04:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oC3ad-0006bW-8x for qemu-devel@nongnu.org; Thu, 14 Jul 2022 14:29:34 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:62330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oC3ab-0008Bn-43 for qemu-devel@nongnu.org; Thu, 14 Jul 2022 14:29:30 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26EGBmsp026608; Thu, 14 Jul 2022 18:29:23 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3h71r1dj05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Jul 2022 18:29:23 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 26EIGssL022689; Thu, 14 Jul 2022 18:29:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3h70465k61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Jul 2022 18:29:22 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 26EISiAR017868; Thu, 14 Jul 2022 18:29:22 GMT Received: from paddy.uk.oracle.com (dhcp-10-175-172-165.vpn.oracle.com [10.175.172.165]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3h70465j62-11; Thu, 14 Jul 2022 18:29:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2021-07-09; bh=lbzGY+jIADZtZw967IbA4yLh8WEOgvAyZfxf5ZTRYkU=; b=QKfllkMWBpFneAJz3bidxaAJgALAUGv8rnMdC1YpQGBND99/POeM4Bq/hcgQ+j72D7J9 5ncKBoz2Cv3in/eWMSCY/tQ/uI9KuNQ4RR6H2GMeMRRzkidNom6ctvpNZg6T8SG5EkWJ Tzc9EHH2mXwOOghZG65xWfUy8Bu1nQLKzXP0eN7yohnwcARKAALoT6IPQ4LFYQLapjWH NBdJfERR5mzFCNrwLtfdZvXJ3gVZJyV7QEUklAg//Ue9jp22nQ9LqRP6g0mEzGuCwBzL qIQhjsqgMnKASiW4JId6qrSJ//wX2ubEKKpGzHEp5eDzPS2NFr/94vqSPabGtc8hyBD4 Qg== From: Joao Martins To: qemu-devel@nongnu.org Cc: Igor Mammedov , Eduardo Habkost , "Michael S. Tsirkin" , Richard Henderson , Alex Williamson , Paolo Bonzini , Ani Sinha , Marcel Apfelbaum , "Dr. David Alan Gilbert" , Suravee Suthikulpanit , Joao Martins Subject: [PATCH v7 10/10] i386/pc: restrict AMD only enforcing of 1Tb hole to new machine type Date: Thu, 14 Jul 2022 19:28:20 +0100 Message-Id: <20220714182820.30970-11-joao.m.martins@oracle.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220714182820.30970-1-joao.m.martins@oracle.com> References: <20220714182820.30970-1-joao.m.martins@oracle.com> X-Proofpoint-ORIG-GUID: JPM34qy5rz7g83pNq3KrOtzT8KPxduf0 X-Proofpoint-GUID: JPM34qy5rz7g83pNq3KrOtzT8KPxduf0 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=205.220.177.32; envelope-from=joao.m.martins@oracle.com; helo=mx0b-00069f02.pphosted.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_MED=-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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1657825462005100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The added enforcing is only relevant in the case of AMD where the range right before the 1TB is restricted and cannot be DMA mapped by the kernel consequently leading to IOMMU INVALID_DEVICE_REQUEST or possibly other kinds of IOMMU events in the AMD IOMMU. Although, there's a case where it may make sense to disable the IOVA relocation/validation when migrating from a non-amd-1tb-aware qemu to one that supports it. Relocating RAM regions to after the 1Tb hole has consequences for guest ABI because we are changing the memory mapping, so make sure that only new machine enforce but not older ones. Signed-off-by: Joao Martins Acked-by: Dr. David Alan Gilbert Acked-by: Igor Mammedov --- hw/i386/pc.c | 6 ++++-- hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ include/hw/i386/pc.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 17613974163e..d13a77025054 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -952,9 +952,10 @@ void pc_memory_init(PCMachineState *pcms, /* * The HyperTransport range close to the 1T boundary is unique to AMD * hosts with IOMMUs enabled. Restrict the ram-above-4g relocation - * to above 1T to AMD vCPUs only. + * to above 1T to AMD vCPUs only. @enforce_amd_1tb_hole is only false = in + * older machine types (<=3D 7.0) for compatibility purposes. */ - if (IS_AMD_CPU(&cpu->env)) { + if (IS_AMD_CPU(&cpu->env) && pcmc->enforce_amd_1tb_hole) { /* Bail out if max possible address does not cross HT range */ if (pc_max_used_gpa(pcms, pci_hole64_size) >=3D AMD_HT_START) { x86ms->above_4g_mem_start =3D AMD_ABOVE_1TB_START; @@ -1904,6 +1905,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) pcmc->has_reserved_memory =3D true; pcmc->kvmclock_enabled =3D true; pcmc->enforce_aligned_dimm =3D true; + pcmc->enforce_amd_1tb_hole =3D true; /* BIOS ACPI tables: 128K. Other BIOS datastructures: less than 4K rep= orted * to be used at the moment, 32K should be enough for a while. */ pcmc->acpi_data_size =3D 0x20000 + 0x8000; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 2a483e8666b4..074571bc03a8 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -446,9 +446,11 @@ DEFINE_I440FX_MACHINE(v7_1, "pc-i440fx-7.1", NULL, =20 static void pc_i440fx_7_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_7_1_machine_options(m); m->alias =3D NULL; m->is_default =3D false; + pcmc->enforce_amd_1tb_hole =3D false; compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len); compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 99ed75371c67..f3aa4694a299 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -383,8 +383,10 @@ DEFINE_Q35_MACHINE(v7_1, "pc-q35-7.1", NULL, =20 static void pc_q35_7_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_7_1_machine_options(m); m->alias =3D NULL; + pcmc->enforce_amd_1tb_hole =3D false; compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len); compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 568c226d3034..9cc3f5d33805 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -118,6 +118,7 @@ struct PCMachineClass { bool has_reserved_memory; bool enforce_aligned_dimm; bool broken_reserved_end; + bool enforce_amd_1tb_hole; =20 /* generate legacy CPU hotplug AML */ bool legacy_cpu_hotplug; --=20 2.17.2