From patchwork Sun Apr 23 17:08:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695001 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 022BC60245 for ; Sun, 23 Apr 2017 17:12:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E00F620564 for ; Sun, 23 Apr 2017 17:12:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4C3F212BE; Sun, 23 Apr 2017 17:12:19 +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 4891720564 for ; Sun, 23 Apr 2017 17:12:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162775AbdDWRMP (ORCPT ); Sun, 23 Apr 2017 13:12:15 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38683 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162770AbdDWRK1 (ORCPT ); Sun, 23 Apr 2017 13:10:27 -0400 Received: by mail-wm0-f48.google.com with SMTP id r190so50453016wme.1 for ; Sun, 23 Apr 2017 10:10:25 -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=WZ+pYME4Vavjdj3VQiY8kxdALo+u5k7ZHIKKtAKQG8Y=; b=ijgUsxgTz9M4MHMlqrkOnE3x92b0sD4w2ZKlZLOMovah55sxv6sXt4YLswH0extg3L XC3mdZujU43DNymC6+6VVe+EBfo/b+1UZANKTb4UUBBkKiddfvqgO5N42ypXYHqixuYo DQ9I0asa/1U8+LWJ2bs0zjtLpq3kQ4/Yq7NYo= 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=WZ+pYME4Vavjdj3VQiY8kxdALo+u5k7ZHIKKtAKQG8Y=; b=Z6ERUTIdzikEy1Q/QC6YGyPv4NvuRlI1CEgG0Re7rPfcrmELSWzhavIgUl1E+nXzog 9+mRI772ydDgbTMQUpl442Py0QkqBTM5160XEdnTVKSAJus1EE6okOP1EqdZI8gOfynq tTCiMP5xQabxv6etty90giiSdaziBWkfJgrJ3jw83IdsWv6Tm3PjAqxrUJ1q/bfGirDL 8dkbFXZ9nO0oQUFTXuo2F8yMGuOCjH5LGELieoFHenCfsqbKy4anW5OlOYOctvxtq4mr 7kT/q4PHflJedAZ8b8zK+sZ+YeirLcAteRCgikpoCCpCOHw0lnIr8f3aSMYwYJlD5ANO 0d1Q== X-Gm-Message-State: AN3rC/6xZbg4tdjsV/WOmjwU7O9A9m6iW9S/BplxgGy9BJ6i3xbpBGoq Vo01JsBMvRNvyNll X-Received: by 10.28.198.65 with SMTP id w62mr6507494wmf.80.1492967419879; Sun, 23 Apr 2017 10:10:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:19 -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 46/79] arm64: KVM: Implement HVC_SOFT_RESTART in the init code Date: Sun, 23 Apr 2017 19:08:56 +0200 Message-Id: <20170423170929.27334-47-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 Another missing stub hypercall is HVC_SOFT_RESTART. It turns out that it is pretty easy to implement in terms of HVC_RESET_VECTORS (since it needs to turn the MMU off). Acked-by: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp-init.S | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp-init.S b/arch/arm64/kvm/hyp-init.S index b7a8f12..0ad34fd 100644 --- a/arch/arm64/kvm/hyp-init.S +++ b/arch/arm64/kvm/hyp-init.S @@ -129,21 +129,36 @@ ENTRY(__kvm_handle_stub_hvc) mrs x0, vbar_el2 b exit +1: cmp x0, #HVC_SOFT_RESTART + b.ne 1f + + /* This is where we're about to jump, staying at EL2 */ + msr elr_el2, x1 + mov x0, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT | PSR_MODE_EL2h) + msr spsr_el2, x0 + + /* Shuffle the arguments, and don't come back */ + mov x0, x2 + mov x1, x3 + mov x2, x4 + b reset + 1: cmp x0, #HVC_RESET_VECTORS b.ne 1f +reset: /* - * Reset kvm back to the hyp stub. + * Reset kvm back to the hyp stub. Do not clobber x0-x4 in + * case we coming via HVC_SOFT_RESTART. */ - /* We're now in idmap, disable MMU */ - mrs x0, sctlr_el2 - ldr x1, =SCTLR_ELx_FLAGS - bic x0, x0, x1 // Clear SCTL_M and etc - msr sctlr_el2, x0 + mrs x5, sctlr_el2 + ldr x6, =SCTLR_ELx_FLAGS + bic x5, x5, x6 // Clear SCTL_M and etc + msr sctlr_el2, x5 isb /* Install stub vectors */ - adr_l x0, __hyp_stub_vectors - msr vbar_el2, x0 + adr_l x5, __hyp_stub_vectors + msr vbar_el2, x5 b exit 1: /* Bad stub call */