From patchwork Mon Jan 9 06:24:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9503883 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 EA98B60757 for ; Mon, 9 Jan 2017 06:30:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAD10280D0 for ; Mon, 9 Jan 2017 06:30:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF3A12815E; Mon, 9 Jan 2017 06:30:00 +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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5608A280D0 for ; Mon, 9 Jan 2017 06:30:00 +0000 (UTC) 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 1cQTSu-0007y3-Oi; Mon, 09 Jan 2017 06:29:56 +0000 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQTPP-000241-3S for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 06:26:23 +0000 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096PXvG017320 for ; Mon, 9 Jan 2017 01:26:00 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id 96BA884 for ; Mon, 9 Jan 2017 01:26:00 -0500 (EST) Received: from sendprodmail04.cc.columbia.edu (sendprodmail04.cc.columbia.edu [128.59.72.16]) by hazelnut (Postfix) with ESMTP id 72BE98B for ; Mon, 9 Jan 2017 01:26:00 -0500 (EST) Received: from mail-qt0-f199.google.com (mail-qt0-f199.google.com [209.85.216.199]) by sendprodmail04.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q0Kt004950 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:00 -0500 Received: by mail-qt0-f199.google.com with SMTP id q3so52479763qtf.4 for ; Sun, 08 Jan 2017 22:26:00 -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=CKzrFdFjVBSSF1iWng086qCIWJqugNXRdxvr9r4bYVQ=; b=UU5nHy9FqNR6KnMnvWmYZGBhg/XL2C0IGRd0IHZr1/lXApt7x7ekHDnGgvpNLXNa9J pmuH489qqUfKUnT30+oaOUfL0AdfugZKUsh/xJNZkIDj8NBVLSS+G5QMji7NSxqp8rCo jXMaskFWi6Era3SLpjOQwUaaAxHBoJfCPWFpQ6VHS9fPrPmg5hXF6PKS5mNGP85xT373 mUmh4Ul/4LqA2lRpybulqf/tDJYVOJGRZRAdJEEKWw7+kmGvLGTjzF0OOCQJGPVetdFQ 3WYWVW9Oe0RIch2FhUWbFuxVwe3vy5PplQIiXZDrvXSYG/IvyOylf+UuAigIGTUnpC77 B0PA== X-Gm-Message-State: AIkVDXJFzz3sEfqSxb07bp/6tsJVj1sYNicBcjg15NzbzzIKrftv/Iq5QhAEsS+bYVaN3k4JIVyKLIGff6BD7Yo9A4nlj1vnzHnl/tOt4jaHMPpKl1P9B/aR4JdjoSZYur9jviZua01BOr+C254UzIbB2zhrNWSjoc6Z4A== X-Received: by 10.200.53.71 with SMTP id z7mr71293816qtb.203.1483943160016; Sun, 08 Jan 2017 22:26:00 -0800 (PST) X-Received: by 10.200.53.71 with SMTP id z7mr71293795qtb.203.1483943159823; Sun, 08 Jan 2017 22:25:59 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Jan 2017 22:25:59 -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 21/55] KVM: arm64: Forward HVC instruction to the guest hypervisor Date: Mon, 9 Jan 2017 01:24:17 -0500 Message-Id: <1483943091-1364-22-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.16 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170108_222619_809972_27E2A0DA X-CRM114-Status: GOOD ( 17.99 ) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Forward exceptions due to hvc instruction to the guest hypervisor. Signed-off-by: Jintack Lim --- arch/arm64/include/asm/kvm_nested.h | 5 +++++ arch/arm64/kvm/Makefile | 1 + arch/arm64/kvm/handle_exit.c | 11 +++++++++++ arch/arm64/kvm/handle_exit_nested.c | 27 +++++++++++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 arch/arm64/include/asm/kvm_nested.h create mode 100644 arch/arm64/kvm/handle_exit_nested.c diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h new file mode 100644 index 0000000..620b4d3 --- /dev/null +++ b/arch/arm64/include/asm/kvm_nested.h @@ -0,0 +1,5 @@ +#ifndef __ARM64_KVM_NESTED_H__ +#define __ARM64_KVM_NESTED_H__ + +int handle_hvc_nested(struct kvm_vcpu *vcpu); +#endif diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index b342bdd..9c35e9a 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -35,4 +35,5 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/irqchip.o kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arch_timer.o kvm-$(CONFIG_KVM_ARM_PMU) += $(KVM)/arm/pmu.o +kvm-$(CONFIG_KVM_ARM_NESTED_HYP) += handle_exit_nested.o kvm-$(CONFIG_KVM_ARM_NESTED_HYP) += emulate-nested.o diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index a891684..208be16 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -29,6 +29,10 @@ #include #include +#ifdef CONFIG_KVM_ARM_NESTED_HYP +#include +#endif + #define CREATE_TRACE_POINTS #include "trace.h" @@ -42,6 +46,13 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) kvm_vcpu_hvc_get_imm(vcpu)); vcpu->stat.hvc_exit_stat++; +#ifdef CONFIG_KVM_ARM_NESTED_HYP + ret = handle_hvc_nested(vcpu); + if (ret < 0 && ret != -EINVAL) + return ret; + else if (ret >= 0) + return ret; +#endif ret = kvm_psci_call(vcpu); if (ret < 0) { kvm_inject_undefined(vcpu); diff --git a/arch/arm64/kvm/handle_exit_nested.c b/arch/arm64/kvm/handle_exit_nested.c new file mode 100644 index 0000000..a6ce23b --- /dev/null +++ b/arch/arm64/kvm/handle_exit_nested.c @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 - Columbia University + * Author: Jintack Lim + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include + +/* We forward all hvc instruction to the guest hypervisor. */ +int handle_hvc_nested(struct kvm_vcpu *vcpu) +{ + return kvm_inject_nested_sync(vcpu, kvm_vcpu_get_hsr(vcpu)); +}