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: 9694987 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 77E8D60245 for ; Sun, 23 Apr 2017 17:12:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6192026530 for ; Sun, 23 Apr 2017 17:12:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56797265B9; Sun, 23 Apr 2017 17:12: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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 0678C26530 for ; Sun, 23 Apr 2017 17:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162729AbdDWRL5 (ORCPT ); Sun, 23 Apr 2017 13:11:57 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:33996 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162710AbdDWRKT (ORCPT ); Sun, 23 Apr 2017 13:10:19 -0400 Received: by mail-wm0-f42.google.com with SMTP id r190so4712073wme.1 for ; Sun, 23 Apr 2017 10:10:18 -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=CyQ6xgxjBrVBERKSz320zIR8QItJPmTzkT5kmMD1bGekBz6EDaXm0zhpVCYeDhC6Pt vhsHZI5MYtKiJe1Di6HOF7E+D3MYSr07QTVK72HyIZ1AT2Gs7GML66wU0fFYDrRCe2Qy 1kdDtzQtjKYTzN5FAGBkL1T5qiOsDg1bE4rMt7J2wZnt0a38OANogbootI2TI4AyTZEX E2GboPLaW8Zhdbcm38/5Xtad0AA2WCzLlMGJq+jGE1M10Pi0vpR20lwKaETQs/zbXmEm TovOvG27Eu7FeCBmCQhtSDT2sGEU7eOBtE5zkHLuVh8phbjFVPczPrzEoDJP4H11+VGI blGA== X-Gm-Message-State: AN3rC/4/jJNz7eN+lrYmNmRpMsLHwJQy4ujtUKqZT0gwkUPevjeGtJer ziyvbGboa11Hli/A 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?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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: /*