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: 9504093 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 A35EA60710 for ; Mon, 9 Jan 2017 06:44:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93447280DE for ; Mon, 9 Jan 2017 06:44:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 860B62811E; Mon, 9 Jan 2017 06:44:56 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00929280DE for ; Mon, 9 Jan 2017 06:44:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQThM-00007g-EM; Mon, 09 Jan 2017 06:44:52 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTgG-0006SB-Sl for linux-arm-kernel@bombadil.infradead.org; Mon, 09 Jan 2017 06:43:45 +0000 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTPh-0002yp-OQ for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 06:26:39 +0000 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q5CP017975 for ; Mon, 9 Jan 2017 01:26:19 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 8E4A881 for ; Mon, 9 Jan 2017 01:26:19 -0500 (EST) Received: from sendprodmail04.cc.columbia.edu (sendprodmail04.cc.columbia.edu [128.59.72.16]) by hazelnut (Postfix) with ESMTP id 5C9DF87 for ; Mon, 9 Jan 2017 01:26:19 -0500 (EST) Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by sendprodmail04.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096QJhf005474 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:19 -0500 Received: by mail-qk0-f197.google.com with SMTP id d201so85777203qkg.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=qjDMDVlvOUOsMXkWi53lfNyIs9nSGdOO9zGBpiSa1hi+yFbQWqRwWLbSjCbrCJMVqy YTvh9Cvg35N9TMvl6Fr24z376AVambnuaTGkW/qI5rU474Ml0WjfXpPrTNcz/wgxvnua TTpp8ucuNqxjooh0P2CMx29mC5/kCeeSfEDR/4tSxG+HgLsJwfYzIDU68DA8ogVni8SB X3SpnC202eIfX+cJRLUjEV3s2QHdHnKUR+RM5PyASZxlAsolMXgOEKuSgpQajSJWZUQn 3flsWRabaDV/eTk8x4MFbUczhgzFt/qCIQH+WqE+8/z9QLBFXtox3pEugJbxblD5UtkN Jg7A== X-Gm-Message-State: AIkVDXKGC6vmt3FIT+GpRuULXF8qixGLw+d2Ua5PIubfpfeP+lzlg5kxlKSj0TLRUM+lmCSkPad/qH9VGSNpeECqGzv2WHy1+FM9/DuevVn2U8KlMUTdSaWEaEIJ9IqvPASHcLb47SS3AJOda/hZCgA0dlrpXmNsKkTZjg== X-Received: by 10.55.138.2 with SMTP id m2mr61054719qkd.115.1483943179012; 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 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.16 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_062638_030069_C345DF81 X-CRM114-Status: GOOD ( 15.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jintack@cs.columbia.edu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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); } /**