From patchwork Mon Jan 9 06:24:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9503953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1289D60757 for ; Mon, 9 Jan 2017 06:33:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 033D32808F for ; Mon, 9 Jan 2017 06:33:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBEEF2811C; Mon, 9 Jan 2017 06:33:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D0712808F for ; Mon, 9 Jan 2017 06:33:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033908AbdAIGdR (ORCPT ); Mon, 9 Jan 2017 01:33:17 -0500 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]:52272 "EHLO outprodmail02.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939755AbdAIG01 (ORCPT ); Mon, 9 Jan 2017 01:26:27 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096PWuR005289 for ; Mon, 9 Jan 2017 01:26:19 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 7B3177E for ; Mon, 9 Jan 2017 01:26:19 -0500 (EST) Received: from sendprodmail02.cc.columbia.edu (sendprodmail02.cc.columbia.edu [128.59.72.14]) by hazelnut (Postfix) with ESMTP id 56BB27E for ; Mon, 9 Jan 2017 01:26:19 -0500 (EST) Received: from mail-qt0-f200.google.com (mail-qt0-f200.google.com [209.85.216.200]) by sendprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QJX2042708 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:19 -0500 Received: by mail-qt0-f200.google.com with SMTP id l7so63079230qtd.2 for ; Sun, 08 Jan 2017 22:26:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vxhAtWbuAptF38r2ltRNqi8B0IZveh/ZVr7Yan1mX/8=; b=WCyEnF8evBKsniR7a9ZkzFXao31Zn/Nc/7lbbhWmRDxD5n0G2hng+VV5JSsXYEx9m8 kHYTbeoBTbJ//Kuo74AOD7Apx8R90OMpDtEx4ZRPQMHQ7q+1j6Hp6qclHOwxQ4S9R59+ WnMBIXSrRLGtq9o4nSwb3CWINtEl+UzwRB4XVb+NIso3aX0YQNK9CG/INe4L2+WHjTVz 51pjO9fAzrqICkqaumciBAt4f1CaeN5N+wWLHaLndNBUvJnYIyNeJkKut0eUCJrzLy4P tLVyYgY37b19jo7qNtYfp8ZVlRquzySe4tGhJDFgwHWKRTbWl5Zoa8Bf/Aykgjg9el1S RMng== X-Gm-Message-State: AIkVDXIlAzoBV/mnrVeYNbZP/Te7T0ZAvjZebyOKkivNbvoXtBl3ZldZ8mgehyRGLQLbCZTf8RjD1t3JCXWSn6zXUYnFMlJkwxw8GwdEJxo0kO/h8ualez+h66wIJhxWosjBNuxsKHfqnKg= X-Received: by 10.55.138.2 with SMTP id m2mr61054726qkd.115.1483943179013; Sun, 08 Jan 2017 22:26:19 -0800 (PST) X-Received: by 10.55.138.2 with SMTP id m2mr61054704qkd.115.1483943178862; Sun, 08 Jan 2017 22:26:18 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id h3sm8623257qtc.6.2017.01.08.22.26.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:26:18 -0800 (PST) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jintack@cs.columbia.edu Subject: [RFC 37/55] KVM: arm64: Setup vttbr_el2 on each VM entry Date: Mon, 9 Jan 2017 01:24:33 -0500 Message-Id: <1483943091-1364-38-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> References: <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.14 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Now that the vttbr value will be different depending on the VM's exception level, we set it on each VM entry. We only have one mmu instance at this point, but there will be multiple of them when we run nested VMs. Signed-off-by: Christoffer Dall Signed-off-by: Jintack Lim --- arch/arm64/kvm/context.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/kvm/context.c b/arch/arm64/kvm/context.c index a93ffe4..b2c0220 100644 --- a/arch/arm64/kvm/context.c +++ b/arch/arm64/kvm/context.c @@ -18,6 +18,7 @@ #include #include #include +#include struct el1_el2_map { enum vcpu_sysreg el1; @@ -88,6 +89,15 @@ static void create_shadow_el1_sysregs(struct kvm_vcpu *vcpu) s_sys_regs[CPACR_EL1] = cptr_el2_to_cpacr_el1(el2_regs[CPTR_EL2]); } +static void setup_s2_mmu(struct kvm_vcpu *vcpu) +{ + struct kvm_s2_mmu *mmu = &vcpu->kvm->arch.mmu; + struct kvm_s2_vmid *vmid = vcpu_get_active_vmid(vcpu); + + vcpu->arch.hw_vttbr = kvm_get_vttbr(vmid, mmu); + vcpu->arch.hw_mmu = mmu; +} + /* * List of EL1 registers which we allow the virtual EL2 mode to access * directly without trapping and which haven't been paravirtualized. @@ -166,6 +176,8 @@ void kvm_arm_setup_shadow_state(struct kvm_vcpu *vcpu) } vgic_v2_setup_shadow_state(vcpu); + + setup_s2_mmu(vcpu); } /**