Received: by 10.192.165.156 with SMTP id m28csp244481imm; Tue, 17 Apr 2018 09:24:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx48OWKy/7ZcqCADIz+ElDAZ8IZqVQjaonM8c4RnceRuiq2AqbtPYHy7Sv2h/BqALl7yc8n7p X-Received: by 2002:a17:902:41:: with SMTP id 59-v6mr1073135pla.345.1523982298209; Tue, 17 Apr 2018 09:24:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982298; cv=none; d=google.com; s=arc-20160816; b=jXun5NWMqNuzb07F9IDBtW1EOLJ06dA/3Evpe1Qdil6D2qTfeaQlcZImRlPrs5VRPz 3SlH2yU4qmTBG+dkqcax2WI9j74UpjvzuHPTYDrrTfRu9dedz5MWNTkOA8QTkJtXCnUr W38ViZeVHIv6cM5P157Fq7yCh4MD9BYDQ3Qb9vizVETJPD29OAtHPXviKxRF4MI2587H Nu5Mcub8uir+Hwn0pFjFTTCBTvohxvWGG3qqYtODKPJLHYoUi/zBSx6B5yfePzY53omX IylSJ+QobJSpKMC8pVWTdXtu6kvXd9ZoGLYpz3w5GjRQ0VxWARtCy2N5pDkIR2u2ZVRt XWMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bqu8DOh3L0m5Nm4VeIRvCvjsFjDIjiAr2RH1ZTSS+Mk=; b=TeVigm+WrcNp2/h5xdOLdXieeCbvnl6UfRGznplDfSvZDmIC0oomQnwG3hFhhoDLyN gekfJSqj3ngNNJVMw9fBM/mE2BzwmLW0gfuSE2tqr1RThS13sjjb+uFJukS0KtRL+Em7 6proEvHyWsKwVXRgt0N5lonk2BQXO0v/bBNAKD2s1mCO5lHJ7eBwrMhj07pkxtDEihv0 0W3h5CjcRSeejG62I6kvHSkw494HxrI6lWG16mn4Vszd0dEMIfwPUOWIHaZ+xQe7i4ol mcopgzZAXlNXl9F++ZsPXn9ckqdVDF8/DIMIZMM2uXDiRWC3Xh36i30BLbmhNPYzC7ta 7bAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si14857624pld.2.2018.04.17.09.24.44; Tue, 17 Apr 2018 09:24:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755798AbeDQQWk (ORCPT + 99 others); Tue, 17 Apr 2018 12:22:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36168 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755646AbeDQQJk (ORCPT ); Tue, 17 Apr 2018 12:09:40 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6F337C00; Tue, 17 Apr 2018 16:09:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Ard Biesheuvel , Christoffer Dall , Marc Zyngier , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 44/66] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Tue, 17 Apr 2018 17:59:17 +0200 Message-Id: <20180417155647.792347331@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland From: Marc Zyngier commit f72af90c3783d924337624659b43e2d36f1b36b4 upstream. We want SMCCC_ARCH_WORKAROUND_1 to be fast. As fast as possible. So let's intercept it as early as we can by testing for the function call number as soon as we've identified a HVC call coming from the guest. Tested-by: Ard Biesheuvel Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/hyp/hyp-entry.S | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) --- a/arch/arm64/kvm/hyp/hyp-entry.S +++ b/arch/arm64/kvm/hyp/hyp-entry.S @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -79,10 +80,11 @@ alternative_endif lsr x0, x1, #ESR_ELx_EC_SHIFT cmp x0, #ESR_ELx_EC_HVC64 + ccmp x0, #ESR_ELx_EC_HVC32, #4, ne b.ne el1_trap - mrs x1, vttbr_el2 // If vttbr is valid, the 64bit guest - cbnz x1, el1_trap // called HVC + mrs x1, vttbr_el2 // If vttbr is valid, the guest + cbnz x1, el1_hvc_guest // called HVC /* Here, we're pretty sure the host called HVC. */ ldp x0, x1, [sp], #16 @@ -101,6 +103,20 @@ alternative_endif 2: eret +el1_hvc_guest: + /* + * Fastest possible path for ARM_SMCCC_ARCH_WORKAROUND_1. + * The workaround has already been applied on the host, + * so let's quickly get back to the guest. We don't bother + * restoring x1, as it can be clobbered anyway. + */ + ldr x1, [sp] // Guest's x0 + eor w1, w1, #ARM_SMCCC_ARCH_WORKAROUND_1 + cbnz w1, el1_trap + mov x0, x1 + add sp, sp, #16 + eret + el1_trap: /* * x0: ESR_EC