From patchwork Wed Jan 9 13:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 10754189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16694746 for ; Wed, 9 Jan 2019 13:55:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02D9C28FDA for ; Wed, 9 Jan 2019 13:55:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C8C2902C; Wed, 9 Jan 2019 13:54:59 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9FB9429021 for ; Wed, 9 Jan 2019 13:54:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ciTXs0x80fnktNa6pzcqCZb2zJ+pLD9lMp+1yIDfcnc=; b=ZpRVW+gDcpHlgI ubGuUiUJDxoi0EW4chBoiHC7ymPuzmRlR+2wR2hm3uGLRXkRlVsOi248TCb8r45Z3FE1ssP8Wp15s YhHFTBq75Msof0roe1m+OVBe2eobihmyETx9AnDg1ND5bBEoyqnZ8whAb4vOnuXV/X7llZgoq0R4U Wd3EFQ5XKaG1eYzykfL3mO9XzwY+XPfqXOaWafIjg+NmTuXR0mej6IEPQbEWHlnsSyh6TKWZlxmZm cQCV5VhW2LN0LKmqxb96fbX+ZqycfCphMsIoWtk4GBrd+fSFcM/mdduWil3j84/n4+bbEGQzSHUw9 qW9U4cd/cQfvWs1aUvrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghEJt-0003a4-VY; Wed, 09 Jan 2019 13:54:57 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghEJq-0003Yo-S2 for linux-arm-kernel@lists.infradead.org; Wed, 09 Jan 2019 13:54:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6E8B280D; Wed, 9 Jan 2019 05:54:52 -0800 (PST) Received: from filthy-habits.cambridge.arm.com (filthy-habits.cambridge.arm.com [10.1.196.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FC9C3F6CF; Wed, 9 Jan 2019 05:54:51 -0800 (PST) From: Marc Zyngier To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/3] arm64: KVM: Allow direct function calls on VHE Date: Wed, 9 Jan 2019 13:54:32 +0000 Message-Id: <20190109135435.178664-1-marc.zyngier@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190109_055454_907302_E72A3D0D X-CRM114-Status: GOOD ( 12.71 ) 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: Christoffer Dall 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 It recently appeared that the nasty hack we use to call a HYP function on a non-VHE system has an interesting side effect on VHE: We wrap any such call into a hypercall, losing any form of type checking between the caller and the callee. This isn't a big deal if you can guarantee to write code that is always 100% correct, but it appears that I'm not you. In order to restore some sanity, let's use the following property: On a VHE system, it is always possible to call any function directly as they live in the same address space. We can thus always emit a direct call, and use a static key to flip from one to the other. As a bonus, this also sanitizes !VHE systems as we always generate code for noth revisions of the architecture. Marc Zyngier (3): arm/arm64: KVM: Introduce kvm_call_hyp_ret() arm64: KVM: Allow for direct call of HYP functions when using VHE arm64: KVM: Drop VHE-specific HYP call stub arch/arm/include/asm/kvm_host.h | 3 +++ arch/arm64/include/asm/kvm_host.h | 31 ++++++++++++++++++++++++++++++- arch/arm64/kvm/debug.c | 2 +- arch/arm64/kvm/hyp.S | 3 --- arch/arm64/kvm/hyp/hyp-entry.S | 12 ------------ virt/kvm/arm/arm.c | 2 +- virt/kvm/arm/vgic/vgic-v3.c | 4 ++-- 7 files changed, 37 insertions(+), 20 deletions(-)