From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v2 6/9] KVM: MMU: Simplify walk_addr_generic() loop Date: Wed, 19 Sep 2012 19:29:10 +0300 Message-ID: <5059F2D6.7040001@redhat.com> References: <1347797235-20732-1-git-send-email-avi@redhat.com> <1347797235-20732-7-git-send-email-avi@redhat.com> <50581A5A.8090206@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Xiao Guangrong Return-path: Received: from mx1.redhat.com ([209.132.183.28]:27306 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753940Ab2ISQ3P (ORCPT ); Wed, 19 Sep 2012 12:29:15 -0400 In-Reply-To: <50581A5A.8090206@linux.vnet.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/18/2012 09:53 AM, Xiao Guangrong wrote: > On 09/16/2012 08:07 PM, Avi Kivity wrote: > >> >> - pt_access = ACC_ALL; >> + pt_access = pte_access = ACC_ALL; >> + ++walker->level; >> >> - for (;;) { >> + do { >> gfn_t real_gfn; >> unsigned long host_addr; >> >> + pt_access &= pte_access; >> + --walker->level; > > Any reason increase walker->level before the loop and decrease here? > Can not use the origin style? :) The original code had if (last_gpte) { ... break; } --walker->level } Since my change moves the check to the last '}', it would include an extra decrement of walker->level. > >> + gfn = gpte_to_gfn_lvl(pte, walker->level); >> + gfn += (addr & PT_LVL_OFFSET_MASK(walker->level)) >> PAGE_SHIFT; >> + >> + if (PTTYPE == 32 && walker->level == PT_DIRECTORY_LEVEL && is_cpuid_PSE36()) >> + gfn += pse36_gfn_delta(pte); >> + >> + ac = write_fault | fetch_fault | user_fault; > > Can use 'access' instead. > 'access' also has other bits set, need to check if we need to mask them off. Will add a separate patch for this. -- error compiling committee.c: too many arguments to function