From nobody Thu Mar 28 14:41:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668716033; cv=none; d=zohomail.com; s=zohoarc; b=Rdss2LvUWE2jFADvuSEs15k/bQHUxDG8SPw2YGJjDWneLr1jfiR+Rau2zO/G6I/+5lobQGzF9GLBzD1kuIrx7ZelzBPRh1UhyZ+4dSzCIjm0q7hEKmQZv/1HXPVQYqHFccQiv0RCIOMX9lM1Q6Sgwz7t3FabAkaDI7Kj5R6qVY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668716033; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=fdmZMRHggxwRW3/R4sWuvcl+i0ca2F6AxGw2/JsW/zw=; b=b40FiD+DM713ELFiDyNy/dzoJVOokrpfOekvz9+xZWUUrmnLXeK7r759OK09r/mF5gTFk1gP5/pstFoEXVF6Yq319vBvPrWSkBK2fsSav4Sz2/4DO+r6cLR8WkSI5FX4rqPDh5ezAHRECcqV9LYOuMdzKpaStivrr4wjiSaxAHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1668716033712356.4512017827518; Thu, 17 Nov 2022 12:13:53 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-577-lu02jPwIOVeMbRggUiu1Jw-1; Thu, 17 Nov 2022 15:13:48 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76017811E75; Thu, 17 Nov 2022 20:13:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 641DCC2C7D9; Thu, 17 Nov 2022 20:13:43 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1FF1319465A2; Thu, 17 Nov 2022 20:13:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 013B01946595 for ; Thu, 17 Nov 2022 20:13:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DF6502028E8F; Thu, 17 Nov 2022 20:13:41 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AAFAE2024CCA; Thu, 17 Nov 2022 20:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668716032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fdmZMRHggxwRW3/R4sWuvcl+i0ca2F6AxGw2/JsW/zw=; b=PhdNSC4/c/SedC1sSv0eZ6WKyp4V6WGq9JKPfsFtJG6qeLDmYFYYUi7L0b8ycbHUKwvMHg hxtUDYNAw5GksiAu+acmbFyqv83GMhveTZB/Q4kdqWJB/puUdObLWEt6Db8EwuNdwDEvTZ aS5alwBHoKeE/JeR1WKATZs7DqjHRpY= X-MC-Unique: lu02jPwIOVeMbRggUiu1Jw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jonathon Jongsma To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: fix memlock without vIOMMU Date: Thu, 17 Nov 2022 14:13:39 -0600 Message-Id: <20221117201339.277956-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laine@redhat.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668716035323100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When there is no vIOMMU, vfio devices don't need to lock the entire guest memory per-device, but they still need to lock the entire guest memory to share between all vfio devices. This memory accounting is not shared with vDPA devices, so it should be added to the memlock limit separately. Commit 8d5704e2 added support for multiple vfio/vdpa devices but calculated the limits incorrectly when there were both vdpa and vfio devices and no vIOMMU. In this case, the memory lock limit was not increased separately for the vfio devices. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2111317 Signed-off-by: Jonathon Jongsma Reviewed-by: Laine Stump --- src/qemu/qemu_domain.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ef1a9c8c74..8ae458ae45 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9470,10 +9470,14 @@ qemuDomainGetMemLockLimitBytes(virDomainDef *def, */ int factor =3D nvdpa; =20 - if (def->iommu) - factor +=3D nvfio; + if (nvfio || forceVFIO) { + if (nvfio && def->iommu) + factor +=3D nvfio; + else + factor +=3D 1; + } =20 - memKB =3D MAX(factor, 1) * virDomainDefGetMemoryTotal(def) + 1024 = * 1024; + memKB =3D factor * virDomainDefGetMemoryTotal(def) + 1024 * 1024; } =20 return memKB << 10; --=20 2.38.1