From: "Jan Beulich" Subject: Re: [PATCH RFC v2 2/4] x86/mem_access: mem_access and mem_event changes to support PV domains Date: Fri, 25 Jul 2014 08:23:02 +0100 Message-ID: <53D221F60200007800025CED@mail.emea.novell.com> References: <1404787805-4540-1-git-send-email-aravindp@cisco.com> <1404787805-4540-3-git-send-email-aravindp@cisco.com> <53D1367002000078000259C8@mail.emea.novell.com> <97A500D504438F4ABC02EBA81613CC633188B7CF@xmb-aln-x02.cisco.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 1XAZrP-0003n6-8c for xen-devel@lists.xenproject.org; Fri, 25 Jul 2014 07:24:11 +0000 In-Reply-To: <97A500D504438F4ABC02EBA81613CC633188B7CF@xmb-aln-x02.cisco.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: "Aravindh Puthiyaparambil (aravindp)" Cc: "xen-devel@lists.xenproject.org" , KeirFraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org >>> On 25.07.14 at 01:52, wrote: >> > +static int mem_access_set_default(struct domain *d, uint64_t >>*start_page, >>> + xenmem_access_t access) { >>> + struct p2m_domain *p2m = p2m_get_hostp2m(d); >>> + struct page_info *page; >>> + struct page_list_head head; >>> + p2m_access_t a; >>> + int rc = 0, ctr = 0; >>> + >>> + if ( !is_pv_domain(d) ) >>> + return -ENOSYS; >>> + >>> + ASSERT(shadow_mode_enabled(d)); >>> + >>> + rc = p2m_convert_xenmem_access(p2m, access, &a); >>> + if ( rc != 0 ) >>> + return rc; >>> + >>> + /* >>> + * For PV domains we only support r, rw, rx, rx2rw and rwx access >>> + * permissions >>> + */ >>> + switch ( a ) >>> + { >>> + case p2m_access_n: >>> + case p2m_access_w: >>> + case p2m_access_x: >>> + case p2m_access_wx: >>> + case p2m_access_n2rwx: >>> + return -EINVAL; >>> + default: >>> + break; >>> + } >>> + >>> + paging_lock_recursive(d); >>> + >>> + if ( *start_page ) >>> + { >>> + head.next = (struct page_info *)*start_page; >> >>What guarantees that the continuation page is still on d->page_list, or that >>now other page got inserted ahead of it? And anyway you're iterating the list >>without holding d->page_alloc_lock. > > Good point. Should I grab the lock and release it only when the hypercall > completes? If "completes" means after any eventual continuation, then you should be able to answer this with "no" yourself. If "completes" is meant only up to the next continuation, then this wouldn't help you anyway. IOW this needs a more sophisticated solution, or you need to restrict the memory size of guests that can be subject to mem-access handling. Jan