From nobody Fri Apr 26 14:10:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1619801072; cv=none; d=zohomail.com; s=zohoarc; b=OLzSZZ7F/NN3tQg/OG1slOhHlnAr0nskcJzemicSrEmReXzHHpMrCpHMa1rDgDjPUikKHyDt6vqKAgLxahN4jyFwAG9qFnFJKPu/HX4QEOjxJoiSNh0g+MXIU+LjxJH3Y3wbwme9Qrci1y64CgU7+Ij2dBeIPFoggO64iFadWp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619801072; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=7yymIT72BI6w9bvHlUzekghaA2GoIRqXqe3k5rNaKsE=; b=NZoehnWpUaf1NiSEcKMFJxF1yKs0928/L7GOJ75ftWiTFJjUEpkjcgCbEV4pmiB/cXqfMouH039q9encPqfn/HOdBe/gXI8zvDePZie7ipX75lMZHp1F9HdQbtdih3wxr2G1OzyYNm268i5qQyMHh1Ww5GFNtgjw4g60no5LBec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1619801072341587.6618142363354; Fri, 30 Apr 2021 09:44:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.120711.228294 (Exim 4.92) (envelope-from ) id 1lcWFR-0007Lt-Tx; Fri, 30 Apr 2021 16:44:13 +0000 Received: by outflank-mailman (output) from mailman id 120711.228294; Fri, 30 Apr 2021 16:44:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcWFR-0007Lm-Qp; Fri, 30 Apr 2021 16:44:13 +0000 Received: by outflank-mailman (input) for mailman id 120711; Fri, 30 Apr 2021 16:44:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lcWFQ-0007Lf-67 for xen-devel@lists.xenproject.org; Fri, 30 Apr 2021 16:44:12 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1e71f58f-8a63-4e42-8d4b-e313e17a0d16; Fri, 30 Apr 2021 16:44:10 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1e71f58f-8a63-4e42-8d4b-e313e17a0d16 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1619801049; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=e1KPcgRLFVQq5UZPI+bESTLR9EztIF3MH6R2OTRSZm8=; b=JIEYHmS/CWvUnAGWY19Yz8AB6GkeNEmREJ72VIE2DbdyyacWtG33ymvP vsjUkeR0XYjPZ024CdhcIo9OAkq576KYZXWjvsOPHDTZPfsHx8ssPNdbd CnGxKv7IzhdaVs/bpxQEl6bOZNt67q9ulSgjw2V3nPvefrT46e5NAt4aF A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ajdkoYHch+jGte0LjBFzdAYVx8ARTXSnIvuO0PKRTJ3IFxUdXd1pQIuQayVN8G6AX+QSf/nRiz 78ELuRJgdxB0EiCVec9bghLLdUYCnaIB80tD66ebuDJwC70HJj8znYcc94XSuYkxT81LPfJTgI 5uz/QvTFujSXq9yMSl+l1PujZWb7DKkjg6Z9JBmiBrdYSZ1cAHraTNp0LNpfN/NM3UpIPKskmn ZUtXFkQnLxpMd/2T5k4GGOiRR2O81RORlPrh7WgDzVQ+bXGmcvOEw/yXqzwaIKSjEVHQeVjHNm AOc= X-SBRS: 5.1 X-MesageID: 42934256 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:Gk9oB6BdXmLW4fblHeh2sceALOonbusQ8zAX/mhsVB1YddGZnc iynPIdkST5kioVRWtIo729EYOHRm7R8oMw3JkJMd6ZLWzbkUaLDKUn14vtxDX8Bzbzn9Q26Y 5Me7VzYeeeMXFUlsD/iTPXL/8F4P2qtJ+lnv3fyXAFd3AJV4hF4x1iAgiWVm1aLTMnObMDGJ CR5tVKqlObEBx6Uu2BCmQYRO+GntXXlfvdCiIuPQIt6wWFkFqTmd3HOiWfty1+bxp/hY0M3E KAuAz/66WlvZiAu2Xh/l6W1bt6sp/MztNCAeaFl8QaLC794zzYGbhJavm5kx0e5M2p9VY2gP nAyi1QQ/hb2jfqUUye5TvrxgX63z4l5xbZuCClqEqmm+PVbnYeKaN69OZkWyqc0WUMlpVA9Z gO+GSju59eHXr77VzAzumNbT5GvA6Ju3Y4+NRj6EB3YM8lR5J6i5cQx09RGIdoJlOA1KkXVN NjC8zR/59tADWnRkGcumFuxeqlVWgoEiGHRVAfuteU3yI+pgEB83cl X-IronPort-AV: E=Sophos;i="5.82,263,1613451600"; d="scan'208";a="42934256" From: Anthony PERARD To: CC: Stefano Stabellini , Paul Durrant , , Anthony PERARD Subject: [PATCH] xen: Free xenforeignmemory_resource at exit Date: Fri, 30 Apr 2021 17:37:42 +0100 Message-ID: <20210430163742.469739-1-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" From: Anthony PERARD Because Coverity complains about it and this is one leak that Valgrind reports. Signed-off-by: Anthony PERARD Acked-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 9 ++++++--- include/hw/xen/xen_common.h | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 7ce672e5a5c3..47ed7772fa39 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -109,6 +109,7 @@ typedef struct XenIOState { shared_iopage_t *shared_page; shared_vmport_iopage_t *shared_vmport_page; buffered_iopage_t *buffered_io_page; + xenforeignmemory_resource_handle *fres; QEMUTimer *buffered_io_timer; CPUState **cpu_by_vcpu_id; /* the evtchn port for polling the notification, */ @@ -1254,6 +1255,9 @@ static void xen_exit_notifier(Notifier *n, void *data) XenIOState *state =3D container_of(n, XenIOState, exit); =20 xen_destroy_ioreq_server(xen_domid, state->ioservid); + if (state->fres !=3D NULL) { + xenforeignmemory_unmap_resource(xen_fmem, state->fres); + } =20 xenevtchn_close(state->xce_handle); xs_daemon_close(state->xenstore); @@ -1321,7 +1325,6 @@ static void xen_wakeup_notifier(Notifier *notifier, v= oid *data) static int xen_map_ioreq_server(XenIOState *state) { void *addr =3D NULL; - xenforeignmemory_resource_handle *fres; xen_pfn_t ioreq_pfn; xen_pfn_t bufioreq_pfn; evtchn_port_t bufioreq_evtchn; @@ -1333,12 +1336,12 @@ static int xen_map_ioreq_server(XenIOState *state) */ QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_bufioreq !=3D 0); QEMU_BUILD_BUG_ON(XENMEM_resource_ioreq_server_frame_ioreq(0) !=3D 1); - fres =3D xenforeignmemory_map_resource(xen_fmem, xen_domid, + state->fres =3D xenforeignmemory_map_resource(xen_fmem, xen_domid, XENMEM_resource_ioreq_server, state->ioservid, 0, 2, &addr, PROT_READ | PROT_WRITE, 0); - if (fres !=3D NULL) { + if (state->fres !=3D NULL) { trace_xen_map_resource_ioreq(state->ioservid, addr); state->buffered_io_page =3D addr; state->shared_page =3D addr + TARGET_PAGE_SIZE; diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 82e56339dd7e..a8118b41acfb 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -134,6 +134,12 @@ static inline xenforeignmemory_resource_handle *xenfor= eignmemory_map_resource( return NULL; } =20 +static inline int xenforeignmemory_unmap_resource( + xenforeignmemory_handle *fmem, xenforeignmemory_resource_handle *fres) +{ + return 0; +} + #endif /* CONFIG_XEN_CTRL_INTERFACE_VERSION < 41100 */ =20 #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000 --=20 Anthony PERARD