From: "Jan Beulich" Subject: Re: [PATCH v2 2/4] xen: introduce grant_map_exists Date: Mon, 06 Oct 2014 15:56:36 +0100 Message-ID: <5432C9C4020000780003C866@mail.emea.novell.com> References: <1412347845-27755-2-git-send-email-stefano.stabellini@eu.citrix.com> <54326D50020000780003C589@mail.emea.novell.com> <5432891E020000780003C678@mail.emea.novell.com> <5432B7B3020000780003C775@mail.emea.novell.com> <5432BCF4020000780003C7E0@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xb9iL-0005Za-PU for xen-devel@lists.xenproject.org; Mon, 06 Oct 2014 14:56:41 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 06.10.14 at 16:34, wrote: > On Mon, 6 Oct 2014, Jan Beulich wrote: >> >>> On 06.10.14 at 15:46, wrote: >> > On Mon, 6 Oct 2014, Jan Beulich wrote: >> >> >>> On 06.10.14 at 15:08, wrote: >> >> > The other approach to do this, that I avoided because it is slower (2 >> >> > spinlocks instead of 1), is to use the existing mapcount function. >> >> > mapcount is based on: >> >> > >> >> > for ( handle = 0; handle < lgt->maptrack_limit; handle++ ) >> >> > >> >> > do you think it is better? >> >> >> >> No, that's worse: This is the Dom0 side of things, and the loop >> >> bound would still be controlled by that same command line option. >> >> >> >> So between the two, the original solution would be better, and >> >> maybe enforcing a lower limit on DomU-s might actually be an >> >> option. >> > >> > What about keeping track of the highest ref number actually used so far? >> > I could use that as upper limit instead of the theoretical max. It would >> > also make the execution faster. >> >> But the loops are already using a value on the order of the high >> watermark, not the theoretical one. I.e. you're not alway looping >> for a long time, it is just possible for this to happen. > > OK, I understand. > > The default max value is 32 pages that lead to 16384 iterations in > grant_map_exists. Should I reduce it? > > Given the simple operations in the loop, the function shouldn't actually > be so slow to be a security risk. It should take less that 0.1 > milliseconds to complete. I don't think there's problem with the default (i.e. no reason to reduce that value). But bumping the limit via command line option should still result in a secure system. Therefore I think the limit should be split to separate Dom0 and DomU ones (e.g. along the lines of the "extra_guest_irqs=" option), and the DomU limit should then get bounded more strictly. (And I wonder btw whether things work right even without your patch if passing a sufficiently big value to "gnttab_max_nr_frames=".) Jan