Received: by 10.223.185.116 with SMTP id b49csp3491050wrg; Mon, 26 Feb 2018 00:28:14 -0800 (PST) X-Google-Smtp-Source: AH8x227irf/fjWfMP4qEuGZO5quNxuTWOwbEqsWRnOeRvntLtUKClCj45fi8ZPWa9CVhXfbH75rL X-Received: by 10.98.200.131 with SMTP id i3mr9894645pfk.40.1519633694737; Mon, 26 Feb 2018 00:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633694; cv=none; d=google.com; s=arc-20160816; b=oLBFCKan137RdMPDnsNP53y3RpiFhyiqC32PAd8MVR0Mw9jaKUuJ+6QupI9mDphdXD aSXDcREWB/Tx+xTQ/UCu/GM9jyq27VVpcd8xZDaagZ95zbSGLU4m5RYW5TnNM7/Pe+PK p/vdJHnyyNH3FaUSDAc/dXiuh5ptRChXc4bRDXHWwik2oQ6hVXf58ioW+FnyPE4CQ87j JkApwbTjqzvrNzQDJb3Q95aH4X5hNhkmKzegpveg9hIXpXElWj4ihjFtTmNcT3qKO57n GURyNAhaFKsWr8ofgXWRj8+0UGDuXDcueRtTyRPPrw30HqKxulIdRf7zVwJvKl74lnc5 Z78A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=Q4srWKhQmzakL386X3i/07Ryr3OxnebsQneBfbWxx7tmBanpHEbbNTafmqR0P4agwm GYok/eaLEbZhGitP0MTHCM/BfVn5XCwPuN2hWDeZz3UVKC2jmzx7R8fW16YWbInqEpQm W78MW2yPUIlyXwywsdgN83FW7N7TEqTtv4cWRDndlqxgNPdkvkANC/QMe7MCmqtoZqge LPIuXyaFaMdoX22fyflzvPDyu9LxqPL6qHgtYnnaBlNeJKQDppkwrz/MK4wByYqIRcXk RbpwewYsIn2yu6Uw2XMunHvxBqc3jxwVlMNx/Vh4QSbnjGaugR5gvl0RTKbw5VDoZ4qX aWRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CYKbZ8pn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p20-v6si6630638plo.643.2018.02.26.00.28.00; Mon, 26 Feb 2018 00:28:14 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=CYKbZ8pn; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbeBZI0X (ORCPT + 99 others); Mon, 26 Feb 2018 03:26:23 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:32913 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752391AbeBZI0O (ORCPT ); Mon, 26 Feb 2018 03:26:14 -0500 Received: by mail-pg0-f68.google.com with SMTP id g12so5913663pgs.0 for ; Mon, 26 Feb 2018 00:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=CYKbZ8pnDKagzMCcokfegFOCOhRYPmf2YAjOPU029FgdAmQX73CpGyxaer6cII0oaS voEFKNYHIDz87nM5+wC7Gxn/nncRUADnG1v+jkzMK5FplMC2Q62zdZUhN65W5J3u89pA 5gop4xM+s89hQGsTahh2hI7y/QvemIodSnaoE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=pOBnsCW1dLcDTqq//nvtREVa9PnisjvCSGfKrdUuTZfhL9HwX9wqSxzT2iqSC0WmsX n5XpbiTf6EKg7t8oj7FfLgtBvWhdOSH7vCUUo955OtXdCGRph9BF012pj3+07Y8h3478 iKD+13f4hZvZryDid583KRdomMOXv8wRVkKHTGQOL8dFQRep5fpnc22Ymju3ggHKMuFg V8SsRRPgY9hNXkRn+kaa324SeLWtfyEF23yboVKNhI4/0ECn+XXsZsl+q1D9P+6wLHgJ A1O1CK8O9+6RT5HgjQ3bENn0NpcgF3O1yfTpJgKTR82MWOokj7cPRUtZSAb2QapAv4YU kqpA== X-Gm-Message-State: APf1xPAKU3gOpRrXnKZcuIik5I+sr/AjDbyOu+Z5xsodw37vjNJTqp/e aqN1Pld3HOXOfkQL4ewqNdaOYg== X-Received: by 10.99.121.203 with SMTP id u194mr8076290pgc.232.1519633573562; Mon, 26 Feb 2018 00:26:13 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:26:13 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Christoffer Dall , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 39/52] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Mon, 26 Feb 2018 16:20:13 +0800 Message-Id: <1519633227-29832-40-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit f72af90c3783 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: Will Deacon Signed-off-by: Alex Shi --- arch/arm64/kvm/hyp/hyp-entry.S | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S index 4e92399..4e9d50c 100644 --- 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 -- 2.7.4