From: Ian Campbell Subject: Re: [PATCH v2 4/6] xen/arm: implement get/put_page_type Date: Mon, 23 Jul 2012 17:08:07 +0100 Message-ID: <1343059687.5797.74.camel@zakaz.uk.xensource.com> References: <1342796758-4958-1-git-send-email-stefano.stabellini@eu.citrix.com> <1342796758-4958-4-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1342796758-4958-4-git-send-email-stefano.stabellini@eu.citrix.com> 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: "xen-devel@lists.xensource.com" , "Tim.Deegan@xen.org" List-Id: xen-devel@lists.xenproject.org On Fri, 2012-07-20 at 16:05 +0100, Stefano Stabellini wrote: > Add a basic get_page_type and put_page_type implementation: the > implementation is similar to the x86 one, without all the code to handle > shadow pagetables and other unneeded features. > > Also remove PGT_shared_page, that is unused. I suppose it'll come back some day? Is the existing page sharing stuff completely contained within the x86 arch code and not in generic code at all? > +int get_page_type(struct page_info *page, unsigned long type) > +{ > + unsigned long nx, x, y = page->u.inuse.type_info; > + > + for ( ; ; ) > + { > + x = y; > + nx = x + 1; > + if ( unlikely((nx & PGT_count_mask) == 0) ) > + { > + printk("Type count overflow on pfn %lx", page_to_mfn(page)); > + return -EINVAL; > + } > + else if ( (x & PGT_count_mask) == 0 ) > + { > + struct domain *d = page_get_owner(page); > + > + if ( (x & PGT_type_mask) != type ) > + { > + /* > + * On type change we check to flush stale TLB entries. This > + * may be unnecessary (e.g., page was GDT/LDT) but those > + * circumstances should be very rare. > + */ > + cpumask_t mask; > + > + cpumask_copy(&mask, d->domain_dirty_cpumask); > + > + /* Don't flush if the timestamp is old enough */ > + tlbflush_filter(mask, page->tlbflush_timestamp); > + > + if ( unlikely(!cpumask_empty(&mask)) ) > + { > + perfc_incr(need_flush_tlb_flush); > + flush_tlb_mask(&mask); > + } > + > + /* We lose existing type and validity. */ > + nx &= ~(PGT_type_mask | PGT_validated); > + nx |= type; > + > + /* No special validation needed for writable pages. */ > + /* Page tables and GDT/LDT need to be scanned for validity. */ There is no GDT/LDT on ARM. And do we really need PGT_validated when there is no direct paging support? (Hrm, maybe I'm confused about what PGT_validated means). In fact, do the types make any sense at all for ARM? Is PGT_writable is really only meaningful when you have direct paging? Ian.