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: 9695179 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 02EBE601E9 for ; Sun, 23 Apr 2017 17:35:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02E50209D8 for ; Sun, 23 Apr 2017 17:35:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB65E26530; Sun, 23 Apr 2017 17:35:34 +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 A00A9209D8 for ; Sun, 23 Apr 2017 17:35:34 +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=KgBthZhsipJN7WOFfFGtV0ztSqaXu1Pulc9kuvkmg7E=; b=sqR7GKbEzrCvZyG5SeZcpODtGy 5fAxqooD+kyz9zTeZIhyMsfgGDcfFbYrWJG552BqntLkiu/clyRX1poAt+IPMr4fJr8AZylxt1sOn Oj2nIoO21i4W0xDJmgBx1Q9Xtbh49SVjKboRF2yKlaQrcFYUbcHIC6EDugN1FnnbQxs4f290IAnH+ zGnuKSocsQBAHmG4x/X62UziINu9j4o2CzjykOUSprn2IQfbAcWOlqNAtfbLxZgfKRKcrZX029TQ0 31vWfWkGrmbWsdm3OKGNpjKROORoLb9YUBrfdrrnD3vMplegrY/5fm2p14Ssd0+Kd3E5H6EQh/oBm IlLgvqsw==; 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 1d2LQ5-0000o4-RO; Sun, 23 Apr 2017 17:35:33 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LMT-0002ZO-2n for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:31:49 +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=WZ+pYME4Vavjdj3VQiY8kxdALo+u5k7ZHIKKtAKQG8Y=; b=D06N9dnoVVwV1QAuKT1F5dMVI +nVgzIvcdv2agWKcpYkeQEBmSpZke3B3XIK3Teb6RoxSipuqLC3QFLcv/CDOxEQ4HJt6cRh1fXP+c OfQia1mo1vKtAC3ymrY2ujzX6z1a7eDPhEDWtxn67Et06Ef4WGMSdAANvvT0Fikd1kTcSEim51WCJ eG3rGm1lztQUyYUnnT06kM7sX0p7aap+NFMgxohUNCRUzEXnXI0cREc/QcKbLEVkFEsP4hsFJxyJa LMXkslSpVGkhIahg6/VMPq15fOZ7NNIFYOZz1Z1/thvK+gNconuzouTyhlZrZQbE7oduH/oblqo4H neQOywtyg==; Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L22-0005CM-4S for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:10:42 +0000 Received: by mail-wm0-x22c.google.com with SMTP id m123so50340017wma.0 for ; Sun, 23 Apr 2017 10:10:21 -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=aJA13Roo12J+Ek0pEn7+V5kyw4JNKBqu9pXenpY5sw/d9+399wQ4eMFZflVvIDjZQr dL+7ivd9Hn+aeqO8Qv8kF39LDY35LG0bYR5LBdGSAMoBBOZNDJDZBpjfP/qqt/quT99R Iio/VTf/wdv4xoYfCYnMb+4LpP6VwisnslerLi2iHGvuwa5VYQSnEt8CbzqblZkDx+me Jw8xsJKU6N9WcLb3OoqP3LsPxCHKIEA93Hx1wS9l6nT60FUQ5rcktfTJ+rnqhR89/dAf mERGHME2HlNaSKW/mwYQSY1aHEimwCmbjkL+Eoz017A1ogi1PPXREKEUMsQdjFlefc4x s4Ug== X-Gm-Message-State: AN3rC/48JmCpoNU1OlRnC0dqxaZBpxcCjhAOM2VHs5+lkAs/GU+s4Trt vkRw6bWo6KwPf3OK 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_131042_289447_1E040F8D X-CRM114-Status: GOOD ( 12.41 ) 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 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 */