From patchwork Sun Apr 23 17:09:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695023 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 D6CD76037F for ; Sun, 23 Apr 2017 17:13:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C143326538 for ; Sun, 23 Apr 2017 17:13:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B637426B39; Sun, 23 Apr 2017 17:13:03 +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 0F3DE265B9 for ; Sun, 23 Apr 2017 17:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163348AbdDWRMk (ORCPT ); Sun, 23 Apr 2017 13:12:40 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38725 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162295AbdDWRKd (ORCPT ); Sun, 23 Apr 2017 13:10:33 -0400 Received: by mail-wm0-f50.google.com with SMTP id r190so50455216wme.1 for ; Sun, 23 Apr 2017 10:10:32 -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=REOsK2MhBZC7+R+mch3UCsp5xoqzS5LWPAGE/1NJv8E=; b=fzDk5w14fgZVLmN61Iyca0sG0VLcHsHcGGGkqFN3h5uozw+ad7XIYuTffgs8CK0lgo 5Mtx3V0SMAglzggQaOwYyda6Zs3sIDAnMH6CzwONR/4WBa8tCHt2qhqJ8XXbARSrlKL2 8PzwNRBX6eyJfmOSxXcy5j+iOttMeB5W//Qlw= 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=REOsK2MhBZC7+R+mch3UCsp5xoqzS5LWPAGE/1NJv8E=; b=Vq5iOQ23MQ0V9rNk5Nhd62b/iUkaM0Puc/eSl3A3RCEv88JJB48iUuIpNemzRo9phY +UCRy7fFmaw/I/GjUtCvpe3M66FX6uAefaVJTFGTwtxWKcXuaG2lkRMP9RB/2QyLM4CM SzmxDG+qJPmnLLO4xv6zdByRWsTH7hJ/xkO4jf/HYXoTST1gC2MHywWnlMsrumEdf0+u XQ1hZUAKU59sLEti0eFP01bEFkbGHXQbsik6sXKoEP6/qByfE/PN65zP8L6wat5iuiYi X6SZNumTErR7ohDlu/I20+zRvaNq+Xkr8gXsnW0Wt1WNgwkv8wcg8274747BkkXhJFPc HmFg== X-Gm-Message-State: AN3rC/4OaH57WgrrnBZpFzngzxPDeyBELZydhPcbpsvWY46gBRS/5Qww KqOX+3j9LBTSpS5l X-Received: by 10.28.104.195 with SMTP id d186mr6598443wmc.111.1492967432071; Sun, 23 Apr 2017 10:10:32 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:31 -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 57/79] ARM: KVM: Allow the main HYP code to use the init hyp stub implementation Date: Sun, 23 Apr 2017 19:09:07 +0200 Message-Id: <20170423170929.27334-58-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. Tested-by: Keerthy Acked-by: Russell King Acked-by: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/hyp/hyp-entry.S | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/arch/arm/kvm/hyp/hyp-entry.S b/arch/arm/kvm/hyp/hyp-entry.S index 1f8db7d..a35baa8 100644 --- a/arch/arm/kvm/hyp/hyp-entry.S +++ b/arch/arm/kvm/hyp/hyp-entry.S @@ -126,11 +126,30 @@ hyp_hvc: */ pop {r0, r1, r2} - /* Check for __hyp_get_vectors */ - cmp r0, #HVC_GET_VECTORS - mrceq p15, 4, r0, c12, c0, 0 @ get HVBAR - beq 1f + /* + * Check if we have a kernel function, which is guaranteed to be + * bigger than the maximum hyp stub hypercall + */ + cmp r0, #HVC_STUB_HCALL_NR + bhs 1f + /* + * Not a kernel function, treat it as a stub hypercall. + * Compute the physical address for __kvm_handle_stub_hvc + * (as the code lives in the idmaped page) and branch there. + * We hijack ip (r12) as a tmp register. + */ + push {r1} + ldr r1, =kimage_voffset + ldr r1, [r1] + ldr ip, =__kvm_handle_stub_hvc + sub ip, ip, r1 +THUMB( add ip, ip, #1) + pop {r1} + + bx ip + +1: push {lr} mov lr, r0 @@ -142,7 +161,7 @@ THUMB( orr lr, #1) blx lr @ Call the HYP function pop {lr} -1: eret + eret guest_trap: load_vcpu r0 @ Load VCPU pointer to r0