Received: by 10.213.65.68 with SMTP id h4csp3664951imn; Tue, 3 Apr 2018 08:45:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/ys+u2phB+cffWfjvvxydTeznXTZShXLRR3m5Hf4t/4hHYlFHEGDdPrdjUYYjF+ZVawoB X-Received: by 2002:a17:902:ac8a:: with SMTP id h10-v6mr14731594plr.290.1522770351130; Tue, 03 Apr 2018 08:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522770351; cv=none; d=google.com; s=arc-20160816; b=gl/mffOZn0ZFQF8yeCQeXIWx6WGz70U3gphzvVFPfPK1OuC+hRBsL3cHBsHw+iPdL7 s/iMNpDXQep4N5aaaFJQg5HZHp8ANL3nL/N7SZ2CeAlxYJK4y7mY8rYQL1r7g8t2be3G My7L3C1xX9EjDJH2cndKINld+tdGn0+2j2SqCM22P/pYc2rX6c/+PA4JCzxO1xJx2AT7 ZqIXpIPBhJsP+OckP81/6/asstAn3RXEwY+C0rDo53svVxwCi2CLgcFN7shaX9tpydqF Uohd0vqEWUeIPIAmT08XZm34VO0pC7muLBCPM+A6gk7LsG/q8ukvfCSreGmCE6q/Vyg6 ezaA== 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=+4ZA8DMmOaxyWmUqy59mwePU5caJG+e75cZLGXV4Hu8=; b=my437T9nReNTH1hcTKCHGgPPrqL7qGsgrQVXasARPDRuhPZQG1sbCYyGEpcEtKQ/EI yuBPS+pBEtC1hxl+27vl4Jyt2x+OFjD7GD2F/2h0YIx4cIFU/JqgFdmSvjEs2d2IODZU vROCFxr58IvjN4SX/gr2sFZuFgZLILS6+i0JeuROBACH5qQo1s5HbIdQVISERjg9TPrz tilXRAWnF4V18Xwu9qIMfAw3Ie49WerklQY+Ppnc0++TlsC0bT71kTMHkzPbFaken2m8 isQ2NCnUQGynE+KV16BBtOpW4h9jkN2J+g4LsGJSeDK2mmGub9IbUnu1uI0/CZlEAdbQ Gpdw== 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 s8-v6si874098plk.550.2018.04.03.08.45.36; Tue, 03 Apr 2018 08:45:51 -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 S1751584AbeDCPoO (ORCPT + 99 others); Tue, 3 Apr 2018 11:44:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:34598 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbeDCPoN (ORCPT ); Tue, 3 Apr 2018 11:44:13 -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 235E41435; Tue, 3 Apr 2018 08:44:13 -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 A4C293F24A; Tue, 3 Apr 2018 08:44:09 -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> From: Suzuki K Poulose Message-ID: Date: Tue, 3 Apr 2018 16:44:07 +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: 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/04/18 15:58, 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). > > (Nit: capable) > Thanks for spotting, will fix it. > >> 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/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c >> index 870f4b1..5ccd3ae 100644 >> --- a/arch/arm64/kvm/hyp/switch.c >> +++ b/arch/arm64/kvm/hyp/switch.c >> @@ -164,6 +164,12 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) >> static void __hyp_text __activate_vm(struct kvm_vcpu *vcpu) >> { >> struct kvm *kvm = kern_hyp_va(vcpu->kvm); >> + u64 vtcr = read_sysreg(vtcr_el2); >> + >> + vtcr &= ~VTCR_EL2_PRIVATE_MASK; >> + vtcr |= VTCR_EL2_SL0(kvm_stage2_levels(kvm)) | >> + VTCR_EL2_T0SZ(kvm_phys_shift(kvm)); >> + write_sysreg(vtcr, vtcr_el2); >> write_sysreg(kvm->arch.vttbr, vttbr_el2); >> } > > Do we need to set this register for tlb maintenance too? > e.g. tlbi for a 3-level-stage2 vm when a 2-level-stage2 vm's vtcr is loaded... > > (The ARM-ARM has 'Any of the bits of VTCR_EL2 are permitted to be cached in a TLB'.) You're right. We need to set the VTCR for the tlb operations. I think we can do this by hooking it to the __tlb_switch_to_guest() routine. Will address it in the next version. Cheers Suzuki