From patchwork Tue Oct 3 03:11:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9981515 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 3024360384 for ; Tue, 3 Oct 2017 03:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 233B62887F for ; Tue, 3 Oct 2017 03:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16F5028882; Tue, 3 Oct 2017 03:15:36 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable 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 B923A2887F for ; Tue, 3 Oct 2017 03:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751702AbdJCDOg (ORCPT ); Mon, 2 Oct 2017 23:14:36 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:55843 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751613AbdJCDMG (ORCPT ); Mon, 2 Oct 2017 23:12:06 -0400 Received: by mail-it0-f48.google.com with SMTP id 4so9725872itv.4 for ; Mon, 02 Oct 2017 20:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=47S8qNqPsuZN0XBLR9EU0lVAW7FQrOiP6Qg8ofuMXcY=; b=N9xSKXLsO6RKPrEXuLLZ2vV+CusADsq9GCsMs6MKlZwwL8sn5sZioUCz20qH3ezTiu AjbFyZjcQA6jfbaysKYO2y9z+c0MmaOqE2WHyxiRaJSBgSZg4oJgc1mum4jCnImrfCWu HJ18YtaBP4HufQsWreBMBNbMOWOD7iarIyiM8= 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=47S8qNqPsuZN0XBLR9EU0lVAW7FQrOiP6Qg8ofuMXcY=; b=kaVBpNo8CrYUGnsh+kwi5kre4A8zZjp1WM8n+j8Dzt4HTtK4mYGPBjDEXKuYNEFLkD vHn2TVpL4PQriflEjhj76gxvw95CWXX0Smqj3pW2aTitF6lLHOYuggN+2D2u5ZsK6ANn e7G6C3EQW53l6hUupS8OwZPEJaGvi/CBlFbFOmjRwUPcvZBeQY4U533lfv+4dTFNJYRQ b53LeDPTOD+XjE7q35qlIkaMSTAFDg6oYhHx2DjMrkVkwfdQUjbAIcyZ3EfCNNWdiMdO FVhTxSb6XPOexf5sWCYp2Wn9AiR3xVKgDYDp6M5esZ8Rs5eW9DMYA9sA2jMtyWP8gorf WPsQ== X-Gm-Message-State: AHPjjUiQ+RsvJin7vSMK9NQe20m5ZmGbwfTDsytXIjZbq9HDDSKFHj3K dN83Dws/b2a07eG9o+y3bNsIwQ== X-Google-Smtp-Source: AOwi7QCbl5A8kMvWSrimz8CkjA5UlL+5QTEly155BGqHJqtgy3VMzPmnvIHz3JMRbsjDJ7molpr5EQ== X-Received: by 10.36.77.66 with SMTP id l63mr22561898itb.49.1507000325550; Mon, 02 Oct 2017 20:12:05 -0700 (PDT) Received: from node.jintackl-qv28633.kvmarm-pg0.wisc.cloudlab.us (c220g1-031126.wisc.cloudlab.us. [128.104.222.76]) by smtp.gmail.com with ESMTPSA id h84sm5367193iod.72.2017.10.02.20.12.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 20:12:04 -0700 (PDT) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu Cc: jintack@cs.columbia.edu, pbonzini@redhat.com, rkrcmar@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, linux@armlinux.org.uk, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jintack Lim Subject: [RFC PATCH v2 24/31] KVM: arm64: Emulate TLBI ALLE2(IS) instruction Date: Mon, 2 Oct 2017 22:11:06 -0500 Message-Id: <1507000273-3735-22-git-send-email-jintack.lim@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507000273-3735-1-git-send-email-jintack.lim@linaro.org> References: <1507000273-3735-1-git-send-email-jintack.lim@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Emulate TLBI ALLE2(IS) instruction executed in the virtual EL2. Since we emulate the virtual EL2 in the EL1, we invalidate EL1&0 regime stage 1 TLB entries with setting vttbr_el2 having the VMID of the virtual EL2. Note that we are able to emulate TLBI ALLE2IS precisely by only invalidating stage 1 TLB entries via TLBI VMALL1IS instruction, but to make it simeple, we reuse the existing function, __kvm_tlb_flush_vmid(), which invalidates both of stage 1 and 2 TLB entries. Signed-off-by: Jintack Lim --- arch/arm64/kvm/sys_regs.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 7950ee0..90329b7 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1747,6 +1747,37 @@ static bool handle_s12w(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return handle_s12(vcpu, p, r, true); } +static bool handle_alle2(struct kvm_vcpu *vcpu, struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + struct kvm_s2_mmu *mmu = &vcpu->kvm->arch.mmu; + u64 vttbr = kvm_get_vttbr(&mmu->el2_vmid, mmu); + + /* + * To emulate invalidating all EL2 regime stage 1 TLB entries, + * invalidate EL1&0 regime stage 1 TLB entries with the virtual EL2's + * VMID. + */ + kvm_call_hyp(__kvm_tlb_flush_local_vmid, vttbr); + return true; +} + +static bool handle_alle2is(struct kvm_vcpu *vcpu, struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + struct kvm_s2_mmu *mmu = &vcpu->kvm->arch.mmu; + u64 vttbr = kvm_get_vttbr(&mmu->el2_vmid, mmu); + + /* + * To emulate invalidating all EL2 regime stage 1 TLB entries for all + * PEs, executing TLBI VMALLE1IS is enough. But reuse the existing + * interface for the simplicity; invalidating stage 2 entries doesn't + * affect the correctness. + */ + kvm_call_hyp(__kvm_tlb_flush_vmid, vttbr); + return true; +} + /* * AT instruction emulation * @@ -1830,14 +1861,14 @@ static bool handle_s12w(struct kvm_vcpu *vcpu, struct sys_reg_params *p, SYS_INSN_TO_DESC(AT_S12E0W, handle_s12w, NULL), SYS_INSN_TO_DESC(TLBI_IPAS2E1IS, NULL, NULL), SYS_INSN_TO_DESC(TLBI_IPAS2LE1IS, NULL, NULL), - SYS_INSN_TO_DESC(TLBI_ALLE2IS, NULL, NULL), + SYS_INSN_TO_DESC(TLBI_ALLE2IS, handle_alle2is, NULL), SYS_INSN_TO_DESC(TLBI_VAE2IS, NULL, NULL), SYS_INSN_TO_DESC(TLBI_ALLE1IS, NULL, NULL), SYS_INSN_TO_DESC(TLBI_VALE2IS, NULL, NULL), SYS_INSN_TO_DESC(TLBI_VMALLS12E1IS, NULL, NULL), SYS_INSN_TO_DESC(TLBI_IPAS2E1, NULL, NULL), SYS_INSN_TO_DESC(TLBI_IPAS2LE1, NULL, NULL), - SYS_INSN_TO_DESC(TLBI_ALLE2, NULL, NULL), + SYS_INSN_TO_DESC(TLBI_ALLE2, handle_alle2, NULL), SYS_INSN_TO_DESC(TLBI_VAE2, NULL, NULL), SYS_INSN_TO_DESC(TLBI_ALLE1, NULL, NULL), SYS_INSN_TO_DESC(TLBI_VALE2, NULL, NULL),