From: "Jan Beulich" Subject: Re: [PATCH] [RFC] x86/domctl: Fix getpageframeinfo* handling. Date: Mon, 18 May 2015 14:51:01 +0100 Message-ID: <555A0A65020000780007B338@mail.emea.novell.com> References: <1431946749-18616-1-git-send-email-andrew.cooper3@citrix.com> <5559EC93020000780007B065@mail.emea.novell.com> <5559E822.4050503@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5559E822.4050503@citrix.com> 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: Andrew Cooper Cc: Daniel De Graaf , Keir Fraser , Xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 18.05.15 at 15:24, wrote: > On 18/05/15 12:43, Jan Beulich wrote: >>>>> On 18.05.15 at 12:59, wrote: >>> + if ( unlikely(num > 1024) || >>> + unlikely(num != domctl->u.getpageframeinfo3.num) ) >>> + { >>> + ret = -E2BIG; >>> + break; >>> + } >>> + >>> + for ( i = 0; i < num; ++i ) >>> + { >>> + unsigned long gfn = 0, type = 0; >> gfn's initializer looks pointless (and if anything it should be INVALID_MFN >> or some such). > > It must absolutely be 0 for when we read a 32bit values into it, Ah, of course! > although I realise I do need to extend ~0U to ~0UL for compat guests. Why is ~0 special here? It's not even valid input afaict, and hence there's no point in massaging it in any way. >>> + struct page_info *page; >>> + p2m_type_t t; >>> + >>> + if ( raw_copy_from_guest(&gfn, guest_handle + (i * width), width) ) >>> + { >>> + ret = -EFAULT; >>> + break; >>> + } >>> + >>> + page = get_page_from_gfn(d, gfn, &t, P2M_ALLOC); >>> + >>> + if ( unlikely(!page) || >>> + unlikely(is_xen_heap_page(page)) ) >>> + { >>> + if ( p2m_is_broken(t) ) >>> + type = XEN_DOMCTL_PFINFO_BROKEN; >>> + else >>> + type = XEN_DOMCTL_PFINFO_XTAB; >> Realizing that this was this way in the old code too, would you >> nevertheless mind adding unlikely() and/or flip the if and else >> branches? > > Certainly. > > Does this mean that you are happy in principle with the raw_* use? I'm not particularly happy about it, but for the purpose of code consolidation I think it is acceptable here. Jan