Received: by 10.192.165.148 with SMTP id m20csp3656155imm; Mon, 30 Apr 2018 04:14:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoh2YLO6DlKVqo3sZuKcjagS6hSRVVZ6gGUBjBIxXeKJF0FUm6/n+kisFGI5elKa3yESB02 X-Received: by 2002:a63:7c0b:: with SMTP id x11-v6mr7776972pgc.384.1525086879731; Mon, 30 Apr 2018 04:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525086879; cv=none; d=google.com; s=arc-20160816; b=H2/qzEWH6WO9dgJ7g7AGKQs1qqCpr0qS/BueF6rt8o5IUg1pfBV5VmYWdJiRRWi08h QypKYhFzJRVyuJ5f478WY3lGveeModdkt9dCJ6zjwzirQ8sC+n/dqFr1QCVoCvyvCpHo LXkQ1jxdUtLBWDtHWGmGIqilBSwLulBpILUEUoA3LAVhfbQDv1WuR3HfDLTDmePBy1Tu lArmbbdeKKw0I53yg+2yjHdCbN0/ROd6Rtnhc9JnFrhn2YEYGLxRLchlth6mmrbZfDKw jM6F2ZOfzuK3O4A9HbXXGGPQ/S4X0kzsYoIXRKwZxbN9om50AoeBoGq6HbTDpqW0ZjZR fzsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=S084DhkIyz0OinKZQ18N9O2WweA3A2kaD6bmzokV65g=; b=rvdwJEbMFy8U47QNmN4gN2Goff5klT8lTW/m4yVzowz0hVMw05rv/NNHykafSAge3s 8GodOAR2FXnsqnFIaVvxo9s1O50djANQT5kLlTb/LcutDjtCnGzekmOKlL9ra/fzRsBM 6Y89OWCAkVL3V1Elpab9gpNH5qeR/83cZGWGvjYh+RStDsE35CTLA0uhthbzcum2MFxT IAwG/ZI2ZehZv4m3ileX9iwo5b9jaErPr7fEqj+W92Xe8xnYRCqBnMAugLTR046kJ0Ic GZpCjJMiGKijkfMBgjqka/73ITKtx0qXm4CWX83qzE9j4Xh624kvqayu41hLP1NU76wy dKOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si6655182plp.550.2018.04.30.04.14.25; Mon, 30 Apr 2018 04:14:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbeD3LOK (ORCPT + 99 others); Mon, 30 Apr 2018 07:14:10 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752472AbeD3LOI (ORCPT ); Mon, 30 Apr 2018 07:14:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7FC3B15BF; Mon, 30 Apr 2018 04:14:08 -0700 (PDT) Received: from [10.1.206.53] (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8E2D33F487; Mon, 30 Apr 2018 04:14:06 -0700 (PDT) Subject: Re: [PATCH v2 10/17] kvm: arm64: Dynamic configuration of VTCR and VTTBR mask To: Suzuki K Poulose , linux-arm-kernel@lists.infradead.org Cc: ard.biesheuvel@linaro.org, kvm@vger.kernel.org, marc.zyngier@arm.com, catalin.marinas@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kristina.martsenko@arm.com, pbonzini@redhat.com, kvmarm@lists.cs.columbia.edu References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> <1522156531-28348-11-git-send-email-suzuki.poulose@arm.com> From: Julien Grall Message-ID: <1c7cca39-ab37-711a-85af-7bd2162ae8ec@arm.com> Date: Mon, 30 Apr 2018 12:14:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1522156531-28348-11-git-send-email-suzuki.poulose@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Suzuki, The algos in this patch looks good to me. A couple of NIT below. On 27/03/18 14:15, Suzuki K Poulose wrote: > diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h > index b0c8417..176551c 100644 > --- a/arch/arm64/include/asm/kvm_arm.h > +++ b/arch/arm64/include/asm/kvm_arm.h > @@ -124,6 +124,8 @@ > #define VTCR_EL2_VS_8BIT (0 << VTCR_EL2_VS_SHIFT) > #define VTCR_EL2_VS_16BIT (1 << VTCR_EL2_VS_SHIFT) > > +#define VTCR_EL2_T0SZ(x) TCR_T0SZ((x)) NIT: The inner parentheses should not be necessary. [...] > +/* > + * VTCR_EL2:SL0 indicates the entry level for Stage2 translation. > + * Interestingly, it depends on the page size. > + * See D.10.2.110, VTCR_EL2, in ARM DDI 0487B.b > + * > + * ----------------------------------------- > + * | Entry level | 4K | 16K/64K | > + * ------------------------------------------ > + * | Level: 0 | 2 | - | > + * ------------------------------------------ > + * | Level: 1 | 1 | 2 | > + * ------------------------------------------ > + * | Level: 2 | 0 | 1 | > + * ------------------------------------------ > + * | Level: 3 | - | 0 | > + * ------------------------------------------ > + * > + * That table roughly translates to : > + * > + * SL0(PAGE_SIZE, Entry_level) = SL0_BASE(PAGE_SIZE) - Entry_Level > + * > + * Where SL0_BASE(4K) = 2 and SL0_BASE(16K) = 3, SL0_BASE(64K) = 3, provided > + * we take care of ruling out the unsupported cases and > + * Entry_Level = 4 - Number_of_levels. > + * > + */ > +#define VTCR_EL2_SL0(levels) \ > + ((VTCR_EL2_TGRAN_SL0_BASE - (4 - (levels))) << VTCR_EL2_SL0_SHIFT) > +/* > + * ARM VMSAv8-64 defines an algorithm for finding the translation table > + * descriptors in section D4.2.8 in ARM DDI 0487B.b. > + * > + * The algorithm defines the expectaions on the BaseAddress (for the page NIT: s/expectaions/expectations/ Cheers, -- Julien Grall