From patchwork Sun Apr 23 17:08:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695201 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 CD635602A7 for ; Sun, 23 Apr 2017 17:39:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCC7625EF7 for ; Sun, 23 Apr 2017 17:39:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DF226530; Sun, 23 Apr 2017 17:39:20 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 4B89E25EF7 for ; Sun, 23 Apr 2017 17:39:20 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=jtWYj4mV0ndhcmcvYGfWp7AsiIjtuenDD/64WVnjQN0=; b=D7d2VHcVkuXdL5u4oERUfi2yAW Jb6bU00GK7GPGZ1jh/Tc6WSFfGeXe8nCo+b3OHHKIa6sJepB0GlURCOdP1NPpKc73VP8rDt/ibt8V 3yZf3Ckhs8fdzNy+6gFF4pNBN4l3ZkMAiQXOODxBjflwi7lWvj0EVut+dR0EgXRui1OumjwyQ2KkC rjjWQ02ictdKQf3RnEhnuq4iow/1XGgLFq2BEqTNZskHy0f64j6H3+PWmokYl2M/+OH3bPRog8SMJ bVqY0Az7cW3I1pUP5oHMeS7K9B0v5Usgpk6/UsojA9bsvKS0Dk1KlDwQXhqY2NzU+P61lxVqR0qhA 2vjLlULw==; 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 1d2LTd-0003QM-E4; Sun, 23 Apr 2017 17:39:13 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LMX-0002ZO-4X for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:31:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AzOiy1TUuks/gyWk8NrRiSy+2OuIHNJ5z6BkMvG0+IQ=; b=ECzUGOpGJCiMyu+nQVWZz8OLA kVvmwI5M2kJOXLCCTB+gICqoOakHNgmfvGNa6odWYnSleexgn43A21pTqqBerd3u73RxRd8Uj1pQ8 ANsab4YrCquJJ33OHuRRF6WY3DOj+hwAxPD3YlkzYAkM0l6p/dcMXrVdBzixFp2zyCmZdUFf6xczu 5bC31a0YKnv4xVZOSwFc01YcuLYxXHg8aB8GIXOewAh1KYalOh/aOQjPUll2WbxtTv8knE6PZ7GmR M8/gQGsyUylUjRdWXj1AiGpxVEi5XAG7NuVSp2xHDlkCHOt70GvCya2Lk06Vx0/6OIk+cJQmPsbVp mlxblltPw==; Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L1z-0005CH-UN for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:10:40 +0000 Received: by mail-wm0-x230.google.com with SMTP id r190so4712075wme.1 for ; Sun, 23 Apr 2017 10:10:19 -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=AzOiy1TUuks/gyWk8NrRiSy+2OuIHNJ5z6BkMvG0+IQ=; b=dlbR4skYWbdo7fHV6G63b8+GqW/OLJeLZ1vdvrygThGQiJNEVK5ISJLYMute/FjXUT uNy28c2MpntFPhPIpakxtHKXYyvZdLcbNekT5VsLQ+ETTtCPAg5Ae5Wrvbo4QC1DyA76 kRxVzYfi7OtXuZWzswoHs5hz80ONyEei2eV2s= 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=AzOiy1TUuks/gyWk8NrRiSy+2OuIHNJ5z6BkMvG0+IQ=; b=pUZsPncfeGvD+PecGQ/EVZwD8JAUti92gdllBkpr1h0sb9B5wjmERMbgKunJNRo0Nt 6A6+3MqC2y9FTh9tn09ZiHxv7CNNbbQCD0zql+O1OwKERVX9fXyl4uGBnYDt8EPAGHBG HmCoYgg0djpDXxIH6hGAwG5l9PcXyzSM4XPjzPbb/HVPaHr7tSujBS2PsAs8a5NESsTH 2ddd4roXJOrvUrBq6ov57exLUvEnzdTARUh2YjfkYdIhnMUUFYcr0zitAOX7imSrh45n rSsL+ZMQ2DjrNJof5B2k6sWTmnCxa13mNXumIM2UGf4PpqUvsGB/dkwONmhj66O8q6VA 88lQ== X-Gm-Message-State: AN3rC/6NeF1KIspj59H8KzWptDU9H5segBYA4GJmOludtXy8u24Wy0HV kKKzGeQzprMLJDO8 X-Received: by 10.28.184.66 with SMTP id i63mr6713834wmf.39.1492967417666; Sun, 23 Apr 2017 10:10:17 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:17 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 44/79] arm64: KVM: Allow the main HYP code to use the init hyp stub implementation Date: Sun, 23 Apr 2017 19:08:54 +0200 Message-Id: <20170423170929.27334-45-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_131040_105858_C5B51990 X-CRM114-Status: GOOD ( 11.74 ) 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: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 From: Marc Zyngier We now have a full hyp-stub implementation in the KVM init code, but the main KVM code only supports HVC_GET_VECTORS, which is not enough. Instead of reinventing the wheel, let's reuse the init implementation by branching to the idmap page when called with a hyp-stub hypercall. Acked-by: Catalin Marinas Reviewed-by: James Morse Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/hyp-entry.S | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S index d8ef788..4f34c59 100644 --- a/arch/arm64/kvm/hyp/hyp-entry.S +++ b/arch/arm64/kvm/hyp/hyp-entry.S @@ -87,10 +87,24 @@ alternative_endif /* Here, we're pretty sure the host called HVC. */ ldp x0, x1, [sp], #16 - cmp x0, #HVC_GET_VECTORS - b.ne 1f - mrs x0, vbar_el2 - b 2f + /* Check for a stub HVC call */ + cmp x0, #HVC_STUB_HCALL_NR + b.hs 1f + + /* + * Compute the idmap address of __kvm_handle_stub_hvc and + * jump there. Since we use kimage_voffset, do not use the + * HYP VA for __kvm_handle_stub_hvc, but the kernel VA instead + * (by loading it from the constant pool). + * + * Preserve x0-x4, which may contain stub parameters. + */ + ldr x5, =__kvm_handle_stub_hvc + ldr_l x6, kimage_voffset + + /* x5 = __pa(x5) */ + sub x5, x5, x6 + br x5 1: /* @@ -99,7 +113,7 @@ alternative_endif kern_hyp_va x0 do_el2_call -2: eret + eret el1_trap: /*