Received: by 10.192.165.148 with SMTP id m20csp4171324imm; Tue, 8 May 2018 04:17:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8FQ9xrUuRIhIE8VrYcMv9Ls9Q/zRrlJ1c01G4EX8pn/XoJ7dwqFA0OXtBEoAvJ3c3lduq X-Received: by 2002:a65:66c6:: with SMTP id c6-v6mr32237771pgw.127.1525778241503; Tue, 08 May 2018 04:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525778241; cv=none; d=google.com; s=arc-20160816; b=jasnjGZCmN596BE5/gkLTwvCrbQZgrH2osRlDQIPNnVUrdwXEk2UJWxWt/0E5Tzlfn +GRI9Was77r4heATMBjAR0wun+GTWFOr7YrFZhtQyJxXohjHZxnRL8asnD5BLBI8uVrS uqrOz7bQZMZhAH+np2+sFbbChU1udJHFc0PXaZ3ec1A2ZAZBfMi/yk1I1Hg1mMl3XAbU qVhxhG+n7DnerAZoVpREpAzOsJ9sIzqWfiaZmvm04DGk6r8Lqf8pdrroUL2jxpCbXoW0 UZiUUVgGoR/L+URPShB1b/XDmMZMAkr2qsIRTInQibftzDyVBoU3BFyHGqbaY8g+qsxv WjOg== 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=BOx3QXkwCjC/LtDzoWtT8uroAlSdfQHkMpTQjZxiRDs=; b=RVE+pQymUpPCEuIfvpPkKM/LPbxsFt9aP0EVAGQQMSwsVQaYND2/ETGkyiT/oANT/W 1QRbj+oYeL88SFCNHoEsqao/jdREs3uDGayoi5e3mOBmISrTnsqdb8gpOXjpzb28sFqp /71IwUWZVLDBKsMDqgPdGmXFpQ83H5/EOfbTMKkuiMg7Xble9xvoYBAfrcTh9Quhv38j Sj4K7cxIRabHxIu9zENFiOEX/pHqWW7kuHZWKUwQ0z0QTMVmsC12azqWCX+BxsJgB316 IJBmPHyzMEIyE/TULv4I+N9XH8dpYQ3306TaWqxK6+hhpmt9o4HSczBzsPjQ1Mgi8ZQ7 6sAA== 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 y67-v6si19161553pgb.35.2018.05.08.04.17.06; Tue, 08 May 2018 04:17:21 -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 S1753152AbeEHLQy (ORCPT + 99 others); Tue, 8 May 2018 07:16:54 -0400 Received: from foss.arm.com ([217.140.101.70]:56556 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbeEHLQw (ORCPT ); Tue, 8 May 2018 07:16:52 -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 8B3F11529; Tue, 8 May 2018 04:16:52 -0700 (PDT) Received: from [10.1.206.73] (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0CE6B3F318; Tue, 8 May 2018 04:16:49 -0700 (PDT) Subject: Re: [PATCH v2 11/17] kvm: arm64: Configure VTCR per VM To: James Morse Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> <1522156531-28348-12-git-send-email-suzuki.poulose@arm.com> <1175bc06-14b1-63e4-7b99-55c22db1c451@arm.com> From: Suzuki K Poulose Message-ID: Date: Tue, 8 May 2018 12:16:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1175bc06-14b1-63e4-7b99-55c22db1c451@arm.com> Content-Type: text/plain; charset=us-ascii; 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 On 03/05/18 15:39, James Morse wrote: > Hi Suzuki, > > On 27/03/18 14:15, Suzuki K Poulose wrote: >> We set VTCR_EL2 very early during the stage2 init and don't >> touch it ever. This is fine as we had a fixed IPA size. This >> patch changes the behavior to set the VTCR for a given VM, >> depending on its stage2 table. The common configuration for >> VTCR is still performed during the early init as we have to >> retain the hardware access flag update bits (VTCR_EL2_HA) >> per CPU (as they are only set for the CPUs which are capabile). >> The bits defining the number of levels in the page table (SL0) >> and and the size of the Input address to the translation (T0SZ) >> are programmed for each VM upon entry to the guest. > > >> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h >> index 596f8e4..9f3c8b8 100644 >> --- a/arch/arm64/include/asm/kvm_host.h >> +++ b/arch/arm64/include/asm/kvm_host.h >> @@ -392,10 +392,12 @@ int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu, >> >> static inline void __cpu_init_stage2(void) >> { >> - u32 parange = kvm_call_hyp(__init_stage2_translation); >> + u32 ps; >> >> - WARN_ONCE(parange < 40, >> - "PARange is %d bits, unsupported configuration!", parange); >> + kvm_call_hyp(__init_stage2_translation); >> + ps = id_aa64mmfr0_parange_to_phys_shift(read_sysreg(id_aa64mmfr0_el1)); > > Doesn't id_aa64mmfr0_parange_to_phys_shift() expect you do to the mask and shift > for it? This will always hit the default case. Good catch ! The error case was not hit on the system I tested, as it was indeed having 48bit PA. I should have done more testing with Juno where it is 40bit PA (which doesn't really allow different phys-shift ranges). I will change the helper to extract the parange and the convert it. Also, rename it to : id_aa64mmfr0_phys_shift() Cheers Suzuki > > >> + WARN_ONCE(ps < 40, >> + "PARange is %d bits, unsupported configuration!", ps); >> } > > > > Thanks, > > James >