From patchwork Mon Jan 9 06:24:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 90338 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp706886qgi; Sun, 8 Jan 2017 22:27:10 -0800 (PST) X-Received: by 10.98.87.142 with SMTP id i14mr7211431pfj.85.1483943230378; Sun, 08 Jan 2017 22:27:10 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id o65si63246625pfb.265.2017.01.08.22.27.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jan 2017 22:27:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1cQTQA-0003aR-Jm; Mon, 09 Jan 2017 06:27:06 +0000 Received: from outprodmail02.cc.columbia.edu ([128.59.72.51]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTP8-0001xH-8d for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 06:26:06 +0000 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 v096PXmd005357 for ; Mon, 9 Jan 2017 01:25:37 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id CAED380 for ; Mon, 9 Jan 2017 01:25:37 -0500 (EST) Received: from sendprodmail02.cc.columbia.edu (sendprodmail02.cc.columbia.edu [128.59.72.14]) by hazelnut (Postfix) with ESMTP id 9984D87 for ; Mon, 9 Jan 2017 01:25:37 -0500 (EST) Received: from mail-qk0-f197.google.com (mail-qk0-f197.google.com [209.85.220.197]) by sendprodmail02.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096PbGs041703 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:25:37 -0500 Received: by mail-qk0-f197.google.com with SMTP id a16so37629616qkc.6 for ; Sun, 08 Jan 2017 22:25:37 -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=pfM71ARpcDc3ZCBShi5EFDn7jzS4wweUy/DuNvuGAHM=; b=l66NhVdB7sMlVq9ucAa41JyE/3H1IMke+ZHi5k4m00LvsggCkgCTSdFvMw/rFbnJ8/ cz5ba/oeDlFs7Gcy96NPfBU5+jgeS/DQ1fBgtmaHms9Io3ugVD9Gry3oRPzSaNUyYEJC /sMaEO4/ufaqNk7iT/NkDVimiMKvPuIqBPkD0IpriPvAQ8X+S8OkHGFSx53ucFVq/ksM f7i80D6oMnkHzcgrpjQPXFIR7ttpk4ZEzkL8C8yEgk/Akhsv/tIjkPBJTB7eYovXyQWm XKjKmuxVlt9zE7H41iRYJn+GMi1TiZNXVCs2wMhplh8lgtPCJrtwNdY6xvtPdK/ga7io nQyw== X-Gm-Message-State: AIkVDXL6Gcc3kDDeguomM8QgKICxZ7X2lgbL+m5Ag7BkKCK/5UHLx8aOGGU1lQpcJfbySS+aHC0c75voO/Nm4Scr8RkeQbwA9IiPPlLin5vusKuSFH76VAc1sVV2fchqXghYLtAkFGfSZ7GOZ8jwaa7Pg/oNrrt1ZA7yGw== X-Received: by 10.200.50.2 with SMTP id x2mr12023204qta.291.1483943137256; Sun, 08 Jan 2017 22:25:37 -0800 (PST) X-Received: by 10.200.50.2 with SMTP id x2mr12023185qta.291.1483943137110; Sun, 08 Jan 2017 22:25:37 -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.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:25:36 -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 05/55] KVM: arm64: Add vcpu_mode_el2 primitive to support nesting Date: Mon, 9 Jan 2017 01:24:01 -0500 Message-Id: <1483943091-1364-6-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170108_222602_556899_46CDE11A X-CRM114-Status: GOOD ( 10.84 ) X-Spam-Score: -5.3 (-----) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-5.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [128.59.72.51 listed in list.dnswl.org] 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.220.197 listed in dnsbl.sorbs.net] -3.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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+patch=linaro.org@lists.infradead.org From: Christoffer Dall When running a nested hypervisor we occasionally have to figure out if the mode we are switching into is the virtual EL2 mode or a regular EL0/1 mode. Signed-off-by: Christoffer Dall Signed-off-by: Jintack Lim --- arch/arm/include/asm/kvm_emulate.h | 6 ++++++ arch/arm64/include/asm/kvm_emulate.h | 12 ++++++++++++ 2 files changed, 18 insertions(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index 9a8a45a..399cd75e 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h @@ -77,6 +77,12 @@ static inline bool vcpu_mode_is_32bit(const struct kvm_vcpu *vcpu) return 1; } +/* We don't support nesting on arm */ +static inline bool vcpu_mode_el2(const struct kvm_vcpu *vcpu) +{ + return false; +} + static inline unsigned long *vcpu_pc(struct kvm_vcpu *vcpu) { return &vcpu->arch.ctxt.gp_regs.usr_regs.ARM_pc; diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index f5ea0ba..830be2e 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -143,6 +143,18 @@ static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu) return mode != PSR_MODE_EL0t; } +static inline bool vcpu_mode_el2(const struct kvm_vcpu *vcpu) +{ + u32 mode; + + if (vcpu_mode_is_32bit(vcpu)) + return false; + + mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK; + + return mode == PSR_MODE_EL2h || mode == PSR_MODE_EL2t; +} + static inline u32 kvm_vcpu_get_hsr(const struct kvm_vcpu *vcpu) { return vcpu->arch.fault.esr_el2;