From patchwork Tue Oct 3 03:11:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9981509 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 BE84260384 for ; Tue, 3 Oct 2017 03:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B18AE2887F for ; Tue, 3 Oct 2017 03:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A64D428882; Tue, 3 Oct 2017 03:15:18 +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 66B882887F for ; Tue, 3 Oct 2017 03:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752048AbdJCDOi (ORCPT ); Mon, 2 Oct 2017 23:14:38 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:53452 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbdJCDMD (ORCPT ); Mon, 2 Oct 2017 23:12:03 -0400 Received: by mail-it0-f45.google.com with SMTP id 85so9735879ith.2 for ; Mon, 02 Oct 2017 20:12:03 -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=doKpyldKiLqDze95CYheHUZ8wtP981YEDeRaxkkTTxg=; b=MAUbKe96FBUhZXqBB4J17hfCmI0Tpqa8k7Pel32KIK97q1zqG+i5u21ZD1mX/xAtyD ryqwcnC8pnEb9jn/ndVz5gVt9V1QOqe7Ep8+8CDPqCzKp7l1Zbp2Zfh4x9Jk11iM/ppV 9es4xneeZ+UZg7JeEIBoINUwuo1GiDWoK7fsk= 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=doKpyldKiLqDze95CYheHUZ8wtP981YEDeRaxkkTTxg=; b=OnH8sYkgirnJmala0Hg1RivKdmi7JSt09/Bj4ubz5Zg5UUArxbjp0FxOC1AjokX35N s/QvTQMcgBpTNQPCYHLfd97zEGGhHy7fFmpGpIVAfOk4koeir+LNJetCwFgBn61aaNwh ei4x7Ur2Z19Xk3rAQhpT9gevOwaxEp36mD0bm1IFsrlbaooq64erqC5u80UYPf9kFFPk bU9tzJqRW3vmX0oND8lfPB6yVpuyit8gH8T+ft6I1ZBM43oZwE81Zl1qcGDsXfxv8nUv bkoqsVjSpoNTZktW3YskQ/8AHU7iPR8nO2ikwathCc3QBcCD8teGt+aHW/ULkaTTrPg/ IwIA== X-Gm-Message-State: AMCzsaVDXxfB0kBs7qf9xTDPJPSPHo6nexTI5eVT8DopACGXu1nSxe0h WzvRyovCAoyc0qazjHv3h+mYfA== X-Google-Smtp-Source: AOwi7QAyarKfepfRlHu+t4fIb7cDCs39OOZNS4REGPwB9qsTpaIl50ZfHOYIzRfIHr/ElANKSpzXsw== X-Received: by 10.36.131.4 with SMTP id d4mr20873589ite.43.1507000323254; Mon, 02 Oct 2017 20:12:03 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 20:12:02 -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 22/31] KVM: arm64: Emulate AT S1E2 instructions Date: Mon, 2 Oct 2017 22:11:04 -0500 Message-Id: <1507000273-3735-20-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 AT S1E2 instructions by issuing the corresponding S1E1 instructions in EL2. We set the physical EL1 registers and the HCR_EL2 register as described in the AT instruction emulation overview. Signed-off-by: Jintack Lim --- arch/arm64/kvm/sys_regs.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index a82274f..cb46db5 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1641,6 +1641,21 @@ static bool handle_s1e01(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return true; } +static bool handle_s1e2(struct kvm_vcpu *vcpu, struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt; + bool el2_format; + int sys_encoding = sys_insn(p->Op0, p->Op1, p->CRn, p->CRm, p->Op2); + + /* See the '1. EL2 AT instructions: S1E2x' table */ + ctxt->hw_sys_regs = ctxt->shadow_sys_regs; + el2_format = !vcpu_el2_e2h_is_set(vcpu); + + kvm_call_hyp(__kvm_at_insn, vcpu, p->regval, el2_format, sys_encoding); + return true; +} + /* * AT instruction emulation * @@ -1716,8 +1731,8 @@ static bool handle_s1e01(struct kvm_vcpu *vcpu, struct sys_reg_params *p, SYS_INSN_TO_DESC(AT_S1E0W, handle_s1e01, NULL), SYS_INSN_TO_DESC(AT_S1E1RP, handle_s1e01, NULL), SYS_INSN_TO_DESC(AT_S1E1WP, handle_s1e01, NULL), - SYS_INSN_TO_DESC(AT_S1E2R, NULL, NULL), - SYS_INSN_TO_DESC(AT_S1E2W, NULL, NULL), + SYS_INSN_TO_DESC(AT_S1E2R, handle_s1e2, NULL), + SYS_INSN_TO_DESC(AT_S1E2W, handle_s1e2, NULL), SYS_INSN_TO_DESC(AT_S12E1R, NULL, NULL), SYS_INSN_TO_DESC(AT_S12E1W, NULL, NULL), SYS_INSN_TO_DESC(AT_S12E0R, NULL, NULL),