From patchwork Tue Jul 18 16:59: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: 9848981 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 D4673600CC for ; Tue, 18 Jul 2017 17:01:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF2BE2857E for ; Tue, 18 Jul 2017 17:01:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B39F8285BA; Tue, 18 Jul 2017 17:01:30 +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 1360D285D4 for ; Tue, 18 Jul 2017 17:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751500AbdGRRBQ (ORCPT ); Tue, 18 Jul 2017 13:01:16 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:33766 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbdGRRAo (ORCPT ); Tue, 18 Jul 2017 13:00:44 -0400 Received: by mail-io0-f175.google.com with SMTP id 5so16514562iow.0 for ; Tue, 18 Jul 2017 10:00:44 -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=L9cgc0L6RjcLZisZBC8Z3TKkptdPzDjn9YtsY+MrqEY=; b=A8xGIR8cjFvMpb4NlKe88YwCdmdzskf5EnsJ8u0sGEt8agMBtL2HA/rsSbAByz4sGn ovD4D98urI/LmkZTnCAytUvNbCVSa1JmGZQDyILbkbifa3SFr/Hx+lzK694Gdr8cNU6A cOQecI45VFrvYP34/Np9nOMFNFfZfrVInKyZc= 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=L9cgc0L6RjcLZisZBC8Z3TKkptdPzDjn9YtsY+MrqEY=; b=rkeNUJmBpXd0HdWZ5G7Ft5ZBJqVMGAgWZ2Zp0NSt0anFrD7jN8uR+T76085Vh6IDYZ eVbKPUhVXsh7r1fsbkJRTZEqkDDpnk2fp9SoaS2sTCNYhxzK+VF/bQigWJN1x7h89lTT Z1GZ/89h0nEfPdloaVvpTiBt6vQNFjnI7betqkYEvCAPGiCfOdJPR8Cp4n7z2sxsvMt0 e2KoWHgTZvHGWdeooIhMuFEVEoND22CL6TDRrumU3kdy7+fmV3FoPn51uDeQ2XQEfdt2 9r5130KLBh4ifyIhnWlbxw3VDUMzEMcwKribwMlQ8gHSyuqwfl6Xo8thVWv0l6/z6SeJ XpxA== X-Gm-Message-State: AIVw1128Boc1l83YfQK1dqAhXQtFOAHH7m6IT9rPIesaSCd+pc70fcC1 e3Q5wHffn1wAi5BP X-Received: by 10.107.136.220 with SMTP id s89mr2544824ioi.143.1500397242820; Tue, 18 Jul 2017 10:00:42 -0700 (PDT) Received: from node.jintackl-qv26972.kvmarm-pg0.wisc.cloudlab.us (c220g1-030822.wisc.cloudlab.us. [128.104.222.82]) by smtp.gmail.com with ESMTPSA id j96sm1413075ioo.49.2017.07.18.10.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 10:00:42 -0700 (PDT) From: Jintack Lim To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com Cc: corbet@lwn.net, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, mchehab@kernel.org, cov@codeaurora.org, daniel.lezcano@linaro.org, david.daney@cavium.com, mark.rutland@arm.com, suzuki.poulose@arm.com, stefan@hello-penguin.com, andy.gross@linaro.org, wcohen@redhat.com, ard.biesheuvel@linaro.org, shankerd@codeaurora.org, vladimir.murzin@arm.com, james.morse@arm.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jintack Lim Subject: [RFC PATCH v2 38/38] KVM: arm64: Respect the virtual CPTR_EL2.TCPAC setting Date: Tue, 18 Jul 2017 11:59:04 -0500 Message-Id: <1500397144-16232-39-git-send-email-jintack.lim@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500397144-16232-1-git-send-email-jintack.lim@linaro.org> References: <1500397144-16232-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 Forward CPACR_EL1 traps to the virtual EL2 if virtual CPTR_EL2 is configured to trap CPACR_EL1 accesses from EL1. This is for recursive nested virtualization. Signed-off-by: Jintack Lim --- arch/arm64/kvm/sys_regs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 6f67666..ba2966d 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1091,6 +1091,11 @@ static bool access_cpacr(struct kvm_vcpu *vcpu, if (el12_reg(p) && forward_nv_traps(vcpu)) return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu)); + /* Forward this trap to the virtual EL2 if CPTR_EL2.TCPAC is set*/ + if (!el12_reg(p) && !vcpu_mode_el2(vcpu) && + (vcpu_sys_reg(vcpu, CPTR_EL2) & CPTR_EL2_TCPAC)) + return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu)); + /* * When the virtual HCR_EL2.E2H == 1, an access to CPACR_EL1 * in the virtual EL2 is to access CPTR_EL2.