From patchwork Tue Jul 18 16:58:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 108179 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp6193047qge; Tue, 18 Jul 2017 10:12:22 -0700 (PDT) X-Received: by 10.98.102.85 with SMTP id a82mr2820680pfc.82.1500397942375; Tue, 18 Jul 2017 10:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500397942; cv=none; d=google.com; s=arc-20160816; b=bPFvmrTVuDtc4ufvO5Nq3rLN21BkmDxX458laNvV+HsDKdm9wCXWelbAoxjqqyyV3F E0s8xsb6SWA4XeuBuG251yoDGw7eUtu8wJthUnR8YGq4+TnCdBGYDsGdqRmZiclzufQH xyLhWHzAM155uLMoVK8xNLPpuyXicTCKNE09fWtbWD+MefuGv7NeEW3NtMT0V5ZrMm4K bu5HxoIFJ3OBy0T0T1peMt3wPmjln2fWVcss09st2MxpRMXyRO91wNSJj/R5eaYPKo8C fWBD1qZzKmS0tzFiVSkAVw+IeAanVOzQ52bysta34D+1GhNUFeiT23jXd6Vtosqjyiz5 70JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/mtq4MWeiH7riv+htGWNDtS6ajNnnh73naJGKoVzYsg=; b=CT/bFoJUlL6Gz4wGYXn2gJWuCfqPVap59BEk/bOFPWsOWnE1jaK1lS8Vat2d/9biBL LH22BAoYE5xgEHtWjmJib4Z+SgJNPWN8/Fz5fgmB7FwqyNnuEMalarUQinKCXXwtJih2 zqEQJvTzNCROajml029L3D34KA1ixrjl+ahXurlQ+bDueqqXG1IGKwMyEWjgZBjEz8a4 LUsnx/0hAM/Knzb0JzrCtlTQXWCCJXeY7pqbbC76e2TtzCg5Lko6R5F9iPpzPHg/xwWI XYRLnGf61/43NQyiw5tgUeC6v6zZqbYtZ0jQCDEv5uefiZaVoMyBeycGJfnRR1ll+bm/ Xnjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=gNE+vTeA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c41si2226122plj.2.2017.07.18.10.12.22; Tue, 18 Jul 2017 10:12:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.b=gNE+vTeA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752230AbdGRRMT (ORCPT + 25 others); Tue, 18 Jul 2017 13:12:19 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:36257 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbdGRQ7p (ORCPT ); Tue, 18 Jul 2017 12:59:45 -0400 Received: by mail-io0-f172.google.com with SMTP id z62so17065530ioi.3 for ; Tue, 18 Jul 2017 09:59: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=/mtq4MWeiH7riv+htGWNDtS6ajNnnh73naJGKoVzYsg=; b=gNE+vTeArYEonP4VkfSq7ziNMrR4m6A3Q27qvCK/p2CV5S0kBOmGucSYBNrZ/mc3sq fbJiakhEPJ2YA0E3yHNsFfMTTEUVV9uxQn8Ta+a4fWv7iYl2bKGsQamKAb0a42BPfvL/ +aKXbnIzCUvA2XIr9fuI6IvjXC/FaJc4fX2V4= 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=/mtq4MWeiH7riv+htGWNDtS6ajNnnh73naJGKoVzYsg=; b=P2rp1KI3VdFJ/xBwnqbzbbW6UcVkHLn2FvNdvYJ5yN+ACZ14vXvK1z5cpU1hjJg4Ob uHM1JNjWK74TYvEmJyZFjeUgLZPmKU/W0kC3XWW2NY7oZLYk3xgzhkV096FRjleXgFNx SwiORU4HHqtBkylUG5mPNKNdOzboLGvY+ULg9/JLzqzcdtoAy3UvfaDSY+VVx0mhq1gH F1LABmVI2Huhn2Ao0iA6+SnvfAo8+qS6pM5teYIy8BcyeptmI2KmEYnOiu1Fm5Wb3Gqw N6aOM5tTnoMlO2cw+b04pLHXmjvBZaUsA5T2LEqlvXNGC65qTbKC0yzsCsZiyn86jbZd aDuA== X-Gm-Message-State: AIVw111j13TCq0xjdu5JOCjQUpcr2RAOXkLIglRzc9SWy3tnIAJxMRK8 pPVZgNuvzmcBM+WY X-Received: by 10.107.178.214 with SMTP id b205mr2861682iof.68.1500397184394; Tue, 18 Jul 2017 09:59:44 -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.09.59.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Jul 2017 09:59:43 -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 Subject: [RFC PATCH v2 06/38] KVM: arm64: Add vcpu_mode_el2 primitive to support nesting Date: Tue, 18 Jul 2017 11:58:32 -0500 Message-Id: <1500397144-16232-7-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- arch/arm/include/asm/kvm_emulate.h | 6 ++++++ arch/arm64/include/asm/kvm_emulate.h | 12 ++++++++++++ 2 files changed, 18 insertions(+) -- 1.9.1 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 fe39e68..5d6f3d0 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;