Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757062AbcDLNDa (ORCPT ); Tue, 12 Apr 2016 09:03:30 -0400 Received: from foss.arm.com ([217.140.101.70]:55391 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756815AbcDLND2 (ORCPT ); Tue, 12 Apr 2016 09:03:28 -0400 Subject: Re: [PATCH 15/17] kvm: arm64: Get rid of fake page table levels To: Christoffer Dall References: <1459787177-12767-1-git-send-email-suzuki.poulose@arm.com> <1459787177-12767-16-git-send-email-suzuki.poulose@arm.com> <20160408150523.GX8961@cbox> <570BB5C9.8040509@arm.com> <20160412121414.GA3039@cbox> Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com From: Suzuki K Poulose Message-ID: <570CF21D.8000600@arm.com> Date: Tue, 12 Apr 2016 14:03:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20160412121414.GA3039@cbox> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2518 Lines: 61 On 12/04/16 13:14, Christoffer Dall wrote: > On Mon, Apr 11, 2016 at 03:33:45PM +0100, Suzuki K Poulose wrote: >> On 08/04/16 16:05, Christoffer Dall wrote: >>> On Mon, Apr 04, 2016 at 05:26:15PM +0100, Suzuki K Poulose wrote: >> >>>> -#if PGDIR_SHIFT > KVM_PHYS_SHIFT >>>> -#define PTRS_PER_S2_PGD_SHIFT 0 >>>> -#else >>>> -#define PTRS_PER_S2_PGD_SHIFT (KVM_PHYS_SHIFT - PGDIR_SHIFT) >>>> -#endif >>>> -#define PTRS_PER_S2_PGD (1 << PTRS_PER_S2_PGD_SHIFT) >>>> +#define STAGE2_PGTABLE_LEVELS ARM64_HW_PGTABLE_LEVELS(KVM_PHYS_SHIFT - 4) >>>> >>>> /* >>>> - * If we are concatenating first level stage-2 page tables, we would have less >>>> - * than or equal to 16 pointers in the fake PGD, because that's what the >>>> - * architecture allows. In this case, (4 - CONFIG_PGTABLE_LEVELS) >>>> - * represents the first level for the host, and we add 1 to go to the next >>>> - * level (which uses contatenation) for the stage-2 tables. > > just noticed: s/contatenation/concatenation/ Thanks for catching that. Will fix it. >>> which case this should be reworded to just state the assumptions and why >>> this is a good assumption. >>> >>> (If my assumptions are wrong here, then there are also weird cases where >>> the host does huge pages at the PMD level and we don't. Not sure I can >>> see the full ramifications of that.) >> >> I am sorry, I didn't get your point about the PMD level. >> > > Right, I expressed that terribly, and I may have gotten myself confused > when writing that. > > My concern is this: if the number of levels between the host and stage-2 > are different, and the host uses huge pmd mappings (either THP or huge > tlb fs), then do we always do the right thing for stage-2 tables, even > if we support the case with more levels in Stage-2 than on the host? Yes. We are safe with PMD (level 2). In the worst case we will have a 2level page table at host and say 4 at stage2. In either case, we have a PMD level (which in host is folded to PGD) and both will use section mapping at level 2 for huge pmd. Also pmd_huge() doesn't care if the PMD is folded or not. So, we are fine with that. I hope that answers your question. > > Thanks for trying to parse my crytptic and potentially nonsensical > questions. No no, they make absolute sense. I had gone through these questions myself initially when I wrote the series, so its good to share them :-). Btw, I have rebased my series to kvmarm and have addressed the comments. I will post them after a round of testing. Cheers Suzuki