From patchwork Sun Apr 23 17:08:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695091 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 7D86460245 for ; Sun, 23 Apr 2017 17:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A68526538 for ; Sun, 23 Apr 2017 17:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E4FC269A3; Sun, 23 Apr 2017 17:16:53 +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=unavailable 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 1AF1826538 for ; Sun, 23 Apr 2017 17:16:52 +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=x8JlP753caFOsaO/TMFd6UvmJyFG8UsGYWdms5tNhz4=; b=nQBGtzyDIC8HcTIQpBWoMDVwBv m3XYCNnxfmLDK9ks2ZhUiL288uVqu9arBXfkRAuUFIVvDqeMfKCbW03VyUNzFOxYzuoYXc90jG4RP 9IWlM2JST//HDpo+CKHvqLkZpkliNz/WV4nVBVcys/wz4dKBn7uXta/NTHvira4k3p3glB/n3Xjfa Deqsm5ZitkFV09lA/nci7sqXesdOwRH42gkBTWMgCwNdstvryozWjtxlfjFz9PUOukjEwZDIAPIBp G/NIJwpq8TXCjFmVD0q8URD+EAxLtBUsnSGz1A3W9VUM0Dvm4pfGFFkZOTSXx4KlWlycsEpCXPZhz Mq3Ujiug==; 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 1d2L7z-0005aY-Qb; Sun, 23 Apr 2017 17:16:51 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L1w-00060o-Ao for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:10:38 +0000 Received: by mail-wm0-x230.google.com with SMTP id u65so7505039wmu.1 for ; Sun, 23 Apr 2017 10:10:15 -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=Q0yLbT6pWsCIjdeTvoIh9zq6j8OdA9H9z5xEsozjG8c=; b=iqo6pnOx0s6jhvl/vM+yilT9z4HWedz+TZAevuS+0V09h74CY2o3j0FB9s1Icl1MgT PCnC0LKXlb0q9kMzosHQyUNi1noC8M21xCxRKAD2tuMLvJhGOg0l5y4UjSppnEJ0KsVT MY9cafzQDYWbiZ/1RzD4P2NgdEPh6XB5Clcag= 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=Q0yLbT6pWsCIjdeTvoIh9zq6j8OdA9H9z5xEsozjG8c=; b=TsGJ3hh8b8pN3o2sE6FEIel6DLh9yPnyRaUZCjclgErq/m3nxCAhjaPu6elHYkqZ0U /5R7RhLqsO7ul3k7bou6IY21GXNq2EOnVRF9u4ebOkvflPNYgAp7ZnuIuuj85syl2ZyJ qJ7sHPzHrV6dY+KGQ8kOU9taYgOaMgSg0NtfnHFO5qModrTTpsNPmRFPI5Ec6NFRDDE6 eyK83UrV42H4ZeFsGq1HM6uwyqW603yXrgZtQIUMxsWZFI91I0rYg3WkfXddDYmJ51Eo RVBL/mLiUisYH38x7bGksmzlSd9y0rpfwgSyRMH3yh7CEZJQqH0hPvNPSQq96yXzRAjo rZpQ== X-Gm-Message-State: AN3rC/7TuU+j18094nJ3KSMCeA8C5CMQtbw8vIDPpxHvt7M9YG2g8vUG XY+aGmSFNRXw2Mt2Ff1Dvw== X-Received: by 10.80.183.146 with SMTP id h18mr132491ede.39.1492967414449; Sun, 23 Apr 2017 10:10:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:13 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 41/79] arm64: hyp-stub: Implement HVC_RESET_VECTORS stub hypercall Date: Sun, 23 Apr 2017 19:08:51 +0200 Message-Id: <20170423170929.27334-42-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_101036_588824_C6851C06 X-CRM114-Status: GOOD ( 10.43 ) 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 Let's define a new stub hypercall that resets the HYP configuration to its default: hyp-stub vectors, and MMU disabled. Of course, for the hyp-stub itself, this is a trivial no-op. Hypervisors will have a bit more work to do. Acked-by: Catalin Marinas Reviewed-by: James Morse Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/virt.h | 9 +++++++++ arch/arm64/kernel/hyp-stub.S | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h index 1569c3a..435514c 100644 --- a/arch/arm64/include/asm/virt.h +++ b/arch/arm64/include/asm/virt.h @@ -44,6 +44,14 @@ */ #define HVC_SOFT_RESTART 2 +/* + * HVC_RESET_VECTORS - Restore the vectors to the original HYP stubs + */ +#define HVC_RESET_VECTORS 3 + +/* Max number of HYP stub hypercalls */ +#define HVC_STUB_HCALL_NR 4 + /* Error returned when an invalid stub number is passed into x0 */ #define HVC_STUB_ERR 0xbadca11 @@ -70,6 +78,7 @@ extern u32 __boot_cpu_mode[2]; void __hyp_set_vectors(phys_addr_t phys_vector_base); phys_addr_t __hyp_get_vectors(void); +void __hyp_reset_vectors(void); /* Reports the availability of HYP mode */ static inline bool is_hyp_mode_available(void) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index f53e8b8..8226fd9 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -73,8 +73,11 @@ el1_sync: mov x1, x3 br x4 // no return +3: cmp x0, #HVC_RESET_VECTORS + beq 9f // Nothing to reset! + /* Someone called kvm_call_hyp() against the hyp-stub... */ -3: ldr x0, =HVC_STUB_ERR + ldr x0, =HVC_STUB_ERR 9: eret ENDPROC(el1_sync) @@ -127,3 +130,9 @@ ENTRY(__hyp_set_vectors) hvc #0 ret ENDPROC(__hyp_set_vectors) + +ENTRY(__hyp_reset_vectors) + mov x0, #HVC_RESET_VECTORS + hvc #0 + ret +ENDPROC(__hyp_reset_vectors)