From nobody Wed May 8 00:30:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.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 1552640991260837.8005068164061; Fri, 15 Mar 2019 02:09:51 -0700 (PDT) Received: from localhost ([127.0.0.1]:52152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4iqZ-0005cv-9E for importer@patchew.org; Fri, 15 Mar 2019 05:09:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4imV-0002q5-DD for qemu-devel@nongnu.org; Fri, 15 Mar 2019 05:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4igM-0000sH-9o for qemu-devel@nongnu.org; Fri, 15 Mar 2019 04:59:15 -0400 Received: from smtp03.citrix.com ([162.221.156.55]:50757) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4igL-0000qQ-HK for qemu-devel@nongnu.org; Fri, 15 Mar 2019 04:59:14 -0400 X-IronPort-AV: E=Sophos;i="5.58,481,1544486400"; d="scan'208";a="80659663" From: Roger Pau Monne To: Date: Fri, 15 Mar 2019 09:58:47 +0100 Message-ID: <20190315085847.31245-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 162.221.156.55 Subject: [Qemu-devel] [PATCH] xen-mapcache: use MAP_FIXED flag so the mmap address hint is always honored X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Druzhinin , Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Paul Durrant , xen-devel@lists.xenproject.org, Anthony Perard , Paolo Bonzini , Richard Henderson , Roger Pau Monne Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Or if it's not possible to honor the hinted address an error is returned instead. This makes it easier to spot the actual failure, instead of failing later on when the caller of xen_remap_bucket realizes the mapping has not been created at the requested address. Also note that at least on FreeBSD using MAP_FIXED will cause mmap to try harder to honor the passed address. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Anthony PERARD --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: Igor Druzhinin Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: xen-devel@lists.xenproject.org --- hw/i386/xen/xen-mapcache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c index 349f72d00c..0e2870b320 100644 --- a/hw/i386/xen/xen-mapcache.c +++ b/hw/i386/xen/xen-mapcache.c @@ -185,8 +185,14 @@ static void xen_remap_bucket(MapCacheEntry *entry, } =20 if (!dummy) { + /* + * If the caller has requested the mapping at a specific address u= se + * MAP_FIXED to make sure it's honored. Note that with MAP_FIXED at + * least FreeBSD will try harder to honor the passed address. + */ vaddr_base =3D xenforeignmemory_map2(xen_fmem, xen_domid, vaddr, - PROT_READ | PROT_WRITE, 0, + PROT_READ | PROT_WRITE, + vaddr ? MAP_FIXED : 0, nb_pfn, pfns, err); if (vaddr_base =3D=3D NULL) { perror("xenforeignmemory_map2"); --=20 2.17.2 (Apple Git-113)