From nobody Fri Apr 19 02:38:38 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581555599208870.4909542893779; Wed, 12 Feb 2020 16:59:59 -0800 (PST) Received: from localhost ([::1]:45670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j22rF-0007HQ-W4 for importer@patchew.org; Wed, 12 Feb 2020 19:59:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41383) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j22qE-0005dB-4R for qemu-devel@nongnu.org; Wed, 12 Feb 2020 19:58:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j22qC-0002ai-Lg for qemu-devel@nongnu.org; Wed, 12 Feb 2020 19:58:53 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:53101 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j22qC-0002YO-7w; Wed, 12 Feb 2020 19:58:52 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48HynM4RDdz9sPK; Thu, 13 Feb 2020 11:58:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1581555527; bh=t0k99hTNO/99CbhZA6anYL5OlCfBcZGL05yN+aGdY6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dtHtnI9GmkX/XvFfCgyRzjdIOKEPTOpxgJEoIguACCutOALelULZ+YFk/L+r1kvPS P+aTx0J93QzPTgKPptDIJErR/eTzX0depcQ4pdBbYigkMzkAiZnU24Dfc41UVHYPZB 2lOFgTw+RwYFKLG5qPRPNxN3HZKtn4mmRrzp0/MY= From: David Gibson To: pair@us.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, clg@kaod.org Subject: [PATCH v2 1/2] spapr: Disable legacy virtio devices for pseries-5.0 and later Date: Thu, 13 Feb 2020 11:58:36 +1100 Message-Id: <20200213005837.131791-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213005837.131791-1-david@gibson.dropbear.id.au> References: <20200213005837.131791-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: mst@redhat.com, aik@ozlabs.ru, paulus@samba.org, mdroth@us.ibm.com, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" PAPR specifies a kind of odd, paravirtualized PCI bus, which looks to the guess mostly like classic PCI, even if some of the individual devices on the bus are PCI Express. One consequence of that is that virtio-pci devices still default to being in transitional mode, though legacy mode is now disabled by default on current q35 x86 machine types. Legacy mode virtio devices aren't really necessary any more, and are causing some problems for future changes. Therefore, for the pseries-5.0 machine type (and onwards), switch to modern-only virtio-pci devices by default. This does mean we no longer support guest kernels prior to 4.0, unless they have modern virtio support backported (which some distro kernels like that in RHEL7 do). Signed-off-by: David Gibson --- hw/ppc/spapr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cb220fde45..6e1e467cc6 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -65,6 +65,7 @@ =20 #include "hw/pci/pci.h" #include "hw/scsi/scsi.h" +#include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-scsi.h" #include "hw/virtio/vhost-scsi-common.h" =20 @@ -4567,7 +4568,14 @@ static void spapr_machine_latest_class_options(Machi= neClass *mc) */ static void spapr_machine_5_0_class_options(MachineClass *mc) { - /* Defaults for the latest behaviour inherited from the base class */ + /* Most defaults for the latest behaviour are inherited from the + * base class, but we need to override the (non ppc specific) + * default behaviour for virtio */ + static GlobalProperty compat[] =3D { + { TYPE_VIRTIO_PCI, "disable-legacy", "on", }, + }; + + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } =20 DEFINE_SPAPR_MACHINE(5_0, "5.0", true); @@ -4578,12 +4586,16 @@ DEFINE_SPAPR_MACHINE(5_0, "5.0", true); static void spapr_machine_4_2_class_options(MachineClass *mc) { SpaprMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] =3D { + { TYPE_VIRTIO_PCI, "disable-legacy", "auto" }, + }; =20 spapr_machine_5_0_class_options(mc); compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len); smc->default_caps.caps[SPAPR_CAP_CCF_ASSIST] =3D SPAPR_CAP_OFF; smc->default_caps.caps[SPAPR_CAP_FWNMI_MCE] =3D SPAPR_CAP_OFF; mc->nvdimm_supported =3D false; + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); } =20 DEFINE_SPAPR_MACHINE(4_2, "4.2", false); --=20 2.24.1 From nobody Fri Apr 19 02:38:38 2024 Delivered-To: importer@patchew.org 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; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581555588861263.51904804980836; Wed, 12 Feb 2020 16:59:48 -0800 (PST) Received: from localhost ([::1]:45666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j22r5-0006t9-LJ for importer@patchew.org; Wed, 12 Feb 2020 19:59:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41384) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j22qD-0005dC-W1 for qemu-devel@nongnu.org; Wed, 12 Feb 2020 19:58:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j22qC-0002as-P5 for qemu-devel@nongnu.org; Wed, 12 Feb 2020 19:58:53 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:43583 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j22qC-0002YR-Ed; Wed, 12 Feb 2020 19:58:52 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48HynM5Vsgz9sSD; Thu, 13 Feb 2020 11:58:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1581555527; bh=NMgpVVTIf0C5p/bvvw12vN4Om6tgaEqAWoWFBQYCm6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bEFnC+/apE2BrrU4/6yqy/rJcD/6jvyybFtQdL2YZnWuLTcph1ry5CNLqk5xa/2qf kksAbLsqOkqjwBQAGIludNY5TMc8RaVRTB2wLeFaaJPLo/1QGiXIhckRGRMGpDFGUm vXEEEhbzoFN5YTEE71yazmh6HQy1+Q0ayADKxxAE= From: David Gibson To: pair@us.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, clg@kaod.org Subject: [PATCH v2 2/2] spapr: Enable virtio iommu_platform=on by default Date: Thu, 13 Feb 2020 11:58:37 +1100 Message-Id: <20200213005837.131791-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200213005837.131791-1-david@gibson.dropbear.id.au> References: <20200213005837.131791-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 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: mst@redhat.com, aik@ozlabs.ru, paulus@samba.org, mdroth@us.ibm.com, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Traditionally, virtio devices don't do DMA by the usual path on the guest platform. In particular they usually bypass any virtual IOMMU the guest has, using hypervisor magic to access untranslated guest physical addresses. There's now the optional iommu_platform flag which can tell virtio devices to use the platform's normal DMA path, including any IOMMUs. That flag was motiviated for the case of hardware virtio implementations, but there are other reasons to want it. Specifically, the fact that the virtio device doesn't use vIOMMU translation means that virtio devices are unsafe to pass to nested guests, or to use with VFIO userspace drivers inside the guest. This is particularly noticeable on the pseries platform which *always* has a guest-visible vIOMMU. Not using the normal DMA path also causes difficulties for the guest side driver when using the upcoming POWER Secure VMs (a.k.a. PEF). While it's theoretically possible to handle this on the guest side, it's really fiddly. Given the other problems with the non-translated virtio device, let's just enable vIOMMU translation for virtio devices by default in the pseries-5.0 (and later) machine types. This does mean the new machine type will no longer support guest kernels older than 4.8, unless they have support for the virtio IOMMU_PLATFORM flag backported (which some distro kernels like RHEL7 do). Signed-off-by: David Gibson --- hw/ppc/spapr.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6e1e467cc6..d4f3dcdda5 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4573,6 +4573,7 @@ static void spapr_machine_5_0_class_options(MachineCl= ass *mc) * default behaviour for virtio */ static GlobalProperty compat[] =3D { { TYPE_VIRTIO_PCI, "disable-legacy", "on", }, + { TYPE_VIRTIO_DEVICE, "iommu_platform", "on", }, }; =20 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); @@ -4588,6 +4589,7 @@ static void spapr_machine_4_2_class_options(MachineCl= ass *mc) SpaprMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); static GlobalProperty compat[] =3D { { TYPE_VIRTIO_PCI, "disable-legacy", "auto" }, + { TYPE_VIRTIO_DEVICE, "iommu_platform", "off", }, }; =20 spapr_machine_5_0_class_options(mc); --=20 2.24.1