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: 9695191 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 5101D601E9 for ; Sun, 23 Apr 2017 17:36:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50415209D8 for ; Sun, 23 Apr 2017 17:36:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44A7326530; Sun, 23 Apr 2017 17:36:40 +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 B61DF209D8 for ; Sun, 23 Apr 2017 17:36:39 +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=DS7+4fU8+ykybJSdWbSzF4wORWh33oaKx6btOd5u+4Y=; b=FkpQ5bmKp/dwQ8JAJyAZR4ys6R R09hsc6Y8NZ7YoCHTDfsxNiZMihRu/xdwt57gwDntAdqxnBXpp5ganngS+6FkQVJXR45YnVjrY1be gKadVBO2yfseTAkZJ6byxu530W2T95epIZh7NWsyysdyDbv4OSpfJASqmmeVRuxVtS0/vZgqZ1Ako 95ger2PBY0KV9z3/oXDTjHh+lJvvLv/9JW5YPLNl1VzInCTkZ9jXRpuWKI0oOawif7ni98pujw2xA 0ZleTqUv6VDzAopCRWHSSpXvwpW6fyd068a2eP5/rudqW3pqdAPMXvYTZyS1kKn7iZlP3xMiWGGJe tr7n3tkw==; 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 1d2LR7-00025D-GW; Sun, 23 Apr 2017 17:36:37 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LLa-0002ZO-G3 for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:30:54 +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=REOsK2MhBZC7+R+mch3UCsp5xoqzS5LWPAGE/1NJv8E=; b=h2IgnJfFLWo4eSsbQUvP8NQfU NJiu36zAeso9A/we1gPA2zgmidgLASiyhKDdyvo1JPo9U6nA75MZj7dUMaMyb0K1aVKP6Ed/vYYGF x9AzfAhD3k1yJ6ZGn2JK/oZaQ0Bj7IJG5wfGBDZDfwgRKdkVw8k/Qdx6mVay+2vcpSAJBHExqfLSp conT4RoOkP0JJP+UjMhtQoKDs1XSadvu2qq9G4I0Pbf9687+Zr6qFqBYhWRavBbtLEI2fNMWCUaj0 0wC9BVHg8KlhQt+gQq9uOynBBSIDy/bXZd/7+R7eFXDA8p8rHbsTHSI1VFFvmq9iilTVZBUaowYCg rbLQkK14w==; Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LB2-0005sX-7O for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:20:02 +0000 Received: by mail-wm0-x235.google.com with SMTP id r190so50548617wme.1 for ; Sun, 23 Apr 2017 10:19:40 -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=lTzklgXGCZI5Ufmm7v5i88cRivFZxeUiumOmeYcbJhwl0ODODfJQQb0qFWhG1upsNx A9DaUBnLZ4IScA8gIN8y1q4Phj4JxM2qT5ooQOycBGyBd+PQ/kMs48DChOv6trKLth0a l9gf/FB52Mqhd4+w/tU9fM470GlosGp1J+NUFTfsD5bGFbNMybczVe/ZlA8XzSXN4oyd FgQ+B/uzcq3+IoYXaTrWYN/SXatLyJmwUsxziEkecFSGhQTyJmzBJCpuuGNWzWqw7krR uHiRRx6AiF1QgU3GHwS1kiAkYEwuw/gce6AoBNbGG/smWZCdS+R06aH+K1CKocqTWPN6 sr1A== X-Gm-Message-State: AN3rC/4RlR5OOgyYZb2GzrDCpKSWJrPNx9LWNbErrrauiLZE1xIGQvCG rFpIXdb3bWd1B25D 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_132000_478858_2E33CB79 X-CRM114-Status: GOOD ( 12.46 ) 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. 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