Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp453146ybg; Tue, 28 Jul 2020 10:02:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3gPwQSZo1UWteHjMqGUceP+pIePykL5AgwGzYfOjr2Ps0a3w4ZU0J7zST7vjoL2WXJPoW X-Received: by 2002:a17:906:3a8c:: with SMTP id y12mr25761634ejd.251.1595955729054; Tue, 28 Jul 2020 10:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595955729; cv=none; d=google.com; s=arc-20160816; b=JJgWvFtgLHjW/WPEMNz0unOOPAxlif3yFFAZNSrFVpM90nsu1hv8Z7HCpgbT0dP78a Ob7KteyNfBIvEpxKC7usxbEoLfPuxq3nd3vbSRGJgVTF4F8TuWplQBXyQTwG4MseQJ46 0II3eJYUf1Q5NO2R47H+u8d6kxt7+NggRj42LelEuKvg6sYtsCybGsnrrdR6/d9WjMtq tESWvX36qyKNicKbiIv5AP+rHM5eIPySPCoYNuz6cVoDS0KPq81Rth38megz/18Ng0Pp Nz9bcxZZQz7fCbuJ1Sz2vNBhk5a1nGHLXC0pdbf9nTJ/gnNnJgg0YOSQHcGEikpsJ/vA FM4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:dkim-signature; bh=F9Jio2br5x0+dQwSEOaKxH+4S7VhGTR+ProxmbfGcHY=; b=mumcJ8WnJRSCBkbsZmc7vd314PEd1TL8b6vHDKcopHnvusr0zLJH+8NLCxVR6L6gx+ lyyEvlN6Gh/g+5Eis9CcuTk9nc+ufMgBrnmtotTOLyDhrzTOCyelLQ7y/yZjc0/MqQtf sGsMF2yjo+06KbF/iaI0M9JrhieURG+qQljia8Q3nbtSW1CIbR4i2Wc++Hy2hUTC36KZ Do/lIWGtASUyc6GKVZbN8CPo3t87VHsJ0iqmeNl/566oGbF/fmGnFq9NCNRep5rjnJAw sjG34nyc9lpqgIXX/VtTRFFzSW4g9L3n9scP1tHoSYA1wkP/EkOqnRTxJAoXGyxH2ls6 cb3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@citrix.com header.s=securemail header.b="Z+RemIi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd17si7313124ejb.423.2020.07.28.10.01.45; Tue, 28 Jul 2020 10:02:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@citrix.com header.s=securemail header.b="Z+RemIi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731729AbgG1Q7b (ORCPT + 99 others); Tue, 28 Jul 2020 12:59:31 -0400 Received: from esa1.hc3370-68.iphmx.com ([216.71.145.142]:49540 "EHLO esa1.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731578AbgG1Q71 (ORCPT ); Tue, 28 Jul 2020 12:59:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595955568; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tRrG2kIPRmHZl5KYjBZDnpKOe+a1KAifCS6TcraQCvw=; b=Z+RemIi/6pAEEYTQzK56hTBK9EUNPk1nEZ75Jlzp2fDrA1Uh9N6rix76 9q4w1goHGh99cAAC3+5P4ZSwb+XcIq6IiUaiG0//qC5CnDpxXIqQ2Va66 Ii6yg6GtaZFEkI8bjVfKyb9oKi/r0vDjEAXo2XuS5VJJ+KmKI5t4lUoYW Q=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: ek+XUNwRJ4Q5p4iyKzYjQH2lwOuZGVQ6Lx+zstg9NwpzzjRk2zB+v1/h9r6kuVVwRRNSCQGoXa D8++MW18YDeKCEmXhrvpH1ZyV0JbQvvIgpmIJERE5rrUKGp9cmDKMmPTr4piKhlvofOfDIfJYe 2rK+680bc67sJoyZee3FTviqXiwfbr0qq0/CqTZ5Z0mVPLSMrngigHlxQVYUtTkhCySNVkupEs zSdbmNe7SgW5IpviGcOeDar3EuhU7jdXOS/8qypW3eFImgTAyx5Vym8iTQCHVMYS3dHYj3I2H8 GeI= X-SBRS: 2.7 X-MesageID: 23705708 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,406,1589256000"; d="scan'208";a="23705708" Date: Tue, 28 Jul 2020 18:59:19 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Julien Grall CC: , Juergen Gross , "Stefano Stabellini" , Wei Liu , "Oleksandr Andrushchenko" , David Airlie , Yan Yankovskyi , David Hildenbrand , , Michal Hocko , , Daniel Vetter , , Boris Ostrovsky , Dan Williams , "Dan Carpenter" Subject: Re: [PATCH v3 4/4] xen: add helpers to allocate unpopulated memory Message-ID: <20200728165919.GA7191@Air-de-Roger> References: <20200727091342.52325-1-roger.pau@citrix.com> <20200727091342.52325-5-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 05:48:23PM +0100, Julien Grall wrote: > Hi, > > On 27/07/2020 10:13, Roger Pau Monne wrote: > > To be used in order to create foreign mappings. This is based on the > > ZONE_DEVICE facility which is used by persistent memory devices in > > order to create struct pages and kernel virtual mappings for the IOMEM > > areas of such devices. Note that on kernels without support for > > ZONE_DEVICE Xen will fallback to use ballooned pages in order to > > create foreign mappings. > > > > The newly added helpers use the same parameters as the existing > > {alloc/free}_xenballooned_pages functions, which allows for in-place > > replacement of the callers. Once a memory region has been added to be > > used as scratch mapping space it will no longer be released, and pages > > returned are kept in a linked list. This allows to have a buffer of > > pages and prevents resorting to frequent additions and removals of > > regions. > > > > If enabled (because ZONE_DEVICE is supported) the usage of the new > > functionality untangles Xen balloon and RAM hotplug from the usage of > > unpopulated physical memory ranges to map foreign pages, which is the > > correct thing to do in order to avoid mappings of foreign pages depend > > on memory hotplug. > I think this is going to break Dom0 on Arm if the kernel has been built with > hotplug. This is because you may end up to re-use region that will be used > for the 1:1 mapping of a foreign map. > > Note that I don't know whether hotplug has been tested on Xen on Arm yet. So > it might be possible to be already broken. > > Meanwhile, my suggestion would be to make the use of hotplug in the balloon > code conditional (maybe using CONFIG_ARM64 and CONFIG_ARM)? Right, this feature (allocation of unpopulated memory separated from the balloon driver) is currently gated on CONFIG_ZONE_DEVICE, which I think could be used on Arm. IMO the right solution seems to be to subtract the physical memory regions that can be used for the identity mappings of foreign pages (all RAM on the system AFAICT) from iomem_resource, as that would make this and the memory hotplug done in the balloon driver safe? Thanks, Roger.