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: 9504003 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 0AF2C6075F for ; Mon, 9 Jan 2017 06:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F027027FA8 for ; Mon, 9 Jan 2017 06:36:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4251281D2; Mon, 9 Jan 2017 06:36:36 +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.4 required=2.0 tests=BAYES_00, 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 7C21F28112 for ; Mon, 9 Jan 2017 06:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163748AbdAIGgd (ORCPT ); Mon, 9 Jan 2017 01:36:33 -0500 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]:38225 "EHLO outprodmail01.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S939628AbdAIG0C (ORCPT ); Mon, 9 Jan 2017 01:26:02 -0500 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 v096PXLD017324 for ; Mon, 9 Jan 2017 01:26:00 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id C92EC6D 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 B97496D for ; Mon, 9 Jan 2017 01:26:00 -0500 (EST) Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by sendprodmail04.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v096Q0ZS004962 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 9 Jan 2017 01:26:00 -0500 Received: by mail-qk0-f199.google.com with SMTP id d201so85774140qkg.2 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=V42JhcrXEzt4CLU+Tw/Sv2ZH/GiZEXgyLzAE65daRFlSfjTikBG/07rGyPKgPF1rzA OFBAaCcAzW65cmg68mZF7dOvpGmrsAQ0uEPhtBVWyRnw7qTR6v5JqcHLkdGB/ttxlhh3 S5t0R81Jef+RJNkzTVC/9czVPgIP3Gv6pTWzsjLCzUweFOL4Mxxikyw6W9f0/+65bTXv nIYv3lvpkvvLRvZWH8X/qL5oDQlkVc9gXwlOYAyBvQoFyDbiZmRjRJNZvgZIVQa0Y+Az oMxn3wITYh3BfEN7/atzIpxOQcOCxvmROcFLdO/VKh/c2QmIUljCoErBWKJMyN+Ie6Vn vojw== X-Gm-Message-State: AIkVDXKvm7Iz6y1+nCi9QTHuQZezfQ8ddh1mfesQVDW4OqALmWvNwsTuN/873I5c+dRkQPIXl3tRaEJpeWl9eeH6xtoFP0M5u8MRRXRc01s+Lo3oTXyPdkpEuHY1KYLEaQRXcwRLEcstbgs= X-Received: by 10.200.53.71 with SMTP id z7mr71293819qtb.203.1483943160017; 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 Cc: jintack@cs.columbia.edu 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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)); +}