From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Subject: Re: [PATCH] KVM: PPC: E500: Support hugetlbfs Date: Tue, 20 Sep 2011 12:54:34 -0500 Message-ID: <4E78D35A.9000301@freescale.com> References: <1316475344-12033-1-git-send-email-agraf@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: , To: Alexander Graf Return-path: Received: from ch1ehsobe006.messaging.microsoft.com ([216.32.181.186]:46957 "EHLO ch1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752326Ab1ITRzW (ORCPT ); Tue, 20 Sep 2011 13:55:22 -0400 In-Reply-To: <1316475344-12033-1-git-send-email-agraf@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On 09/19/2011 06:35 PM, Alexander Graf wrote: > + /* > + * e500 doesn't implement the lowest tsize bit, > + * or 1K pages. > + */ > + tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1); > + > + /* take the smallest page size that satisfies host and > + guest mapping */ kernel comment style... I don't personally care much, but this leaves a checkpatch complaint for the next person to modify the comment. Such as to make it say "take the largest page size that...". :-) > + asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (psize)); > + tsize = min(21 - lz, tsize); No need to open-code the cntlz and subtract-from-21: tsize = min(ilog2(psize) - 10, tsize); /* * e500 doesn't implement the lowest tsize bit, * or 1K pages. */ tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1); There's still an open-coded subtraction of 10, but that relates more straightforwardly to the definition of tsize (and could be factored out into a size-to-tsize function). > } > > up_read(¤t->mm->mmap_sem); > } > > if (likely(!pfnmap)) { > + unsigned long tsize_pages = 1 << (tsize - 2); 1 << (tsize + 10 - PAGE_SHIFT); > pfn = gfn_to_pfn_memslot(vcpu_e500->vcpu.kvm, slot, gfn); > + pfn &= ~(tsize_pages - 1); > + gvaddr &= ~((tsize_pages << PAGE_SHIFT) - 1); > if (is_error_pfn(pfn)) { Won't the masking of pfn affect is_error_pfn()? -Scott