Received: by 10.223.185.116 with SMTP id b49csp7396953wrg; Thu, 1 Mar 2018 05:02:08 -0800 (PST) X-Google-Smtp-Source: AG47ELsBx/enZQi1zgRaPMefmAcY92ckTh1TngiZuUsFWFfvm/RmT8Jwao34OevB2RaS0TwhIBVo X-Received: by 10.99.126.14 with SMTP id z14mr1513735pgc.429.1519909328818; Thu, 01 Mar 2018 05:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909328; cv=none; d=google.com; s=arc-20160816; b=VeqLDVcFQ+/x+sKpx6plsebC9HyRnzuHfcZIlKiCpXhr/rFPcLmRb8z/ESkemaFA3s eC4gr4PiTsCPXcdHmoMzmiHx7M6u1LoQ4obSZ3lhQsoGYRaConpgKeoFQIwqhBv36Qw9 lBFO9C3VlGRnIGBK3xkTjIL1yspobREs9/bhegrPyAx62wJ5e7gr1jQoOXv+5j5Nop5L w5e1uU2uq2xOC95pNm5KmiqVi9LD6gXftjChPi8foNuYXs6BDuRZaBBOT5HD+npKqXdZ pbpIHEUFXO6zAlKm3KXzACClDGiBP6aYMEqtT2uxvf5penomVZ0TOSxawzzp9mfw/Z9V qLoA== 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:cc:to:from:dkim-signature:arc-authentication-results; bh=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=I2f8YQ1SgXNkx9GacryaSxkRDOflNb3jRMTwwn2Y74OPaRgkKuwL2e/rCBtRD7FxPK Kg55h2GzvuyshNFAy6TE2D1Qfrt/8p1IQybb92D421da1GjtNGaAEwU7fvh+NMyP5e4B ErcLQNFze1b2tmGGaHNGuiR1NXzaJ6ygisxuHb73bfTFArkX+a0XO55XuHzkrvvSffYX QjR6YseWUm5mKJ+KJ0iEYtmGscJ78T/6AFjfvbJ0/Sq52ElxHCkumOZdjO9xBvb80gp9 TjSWGQWTFT3PEHB6SneZ0anS/Q2w74RTFSOAC/LJkLZiw9HaI9PVeuf5jjLcCn0VhWkP KvKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gD/uH45g; 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 n3-v6si2992743pld.347.2018.03.01.05.01.32; Thu, 01 Mar 2018 05:02:08 -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=gD/uH45g; 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 S1031129AbeCANAj (ORCPT + 99 others); Thu, 1 Mar 2018 08:00:39 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41922 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031123AbeCANAf (ORCPT ); Thu, 1 Mar 2018 08:00:35 -0500 Received: by mail-pl0-f66.google.com with SMTP id k8-v6so3585999pli.8 for ; Thu, 01 Mar 2018 05:00:35 -0800 (PST) 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=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=gD/uH45gJQjkdY3z8SkrUQfQi7/JGBkpWDviFFCxtDiNpFSn2DftipKVeDNFfxnx0j XjwYO8uDP/ncXEdrz77Rk7lXHvN4pUIKPhYJ/1DqChxlxEJAPlddN9iceNqp98Ueqyy3 S7jqfFEl2X14rc9fKk1R0ulLD488F7ag31+kA= 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=Jl8J60UuHWw6QycIueIONGAI64GFje0f/SkXAPYopdo=; b=XOpnzBlGFAnyxoDqIPzvAGsTmNoK005q8pVw9RxuHQQqsdGzLQSxe7/Zhx4wlwa07d v6CSVwAMvC44CuLrY+gPR6XR+dTiX38ymPydSkeBPHxHpgXuxdbNustelEWEFVVhJYC5 iV6C35odUpJcokpfmSJMCmdgppWScJQCjotn/s/d59x4vxE0rquyFmxP01pkVa/o+lal I3186iSClKQoZUNOcGnhTINyd4Ew+4DSxoL62BQr0netzPQZ3sVIXbYVn0EARmrF3KKA XkAJ4EaHM45WT+c8oOSA394KQVi7b1mswc10WZBZeBjYT35SClK6qNpoK6HCZ+HfNiWo Rc4A== X-Gm-Message-State: APf1xPDyloFnteHbuk6gDencD9TJh4cX/oK8D7QC/nuCdPgh76VfX+zC 7LmpaXM2M86jFunJiYtLUZ5ywkhM000= X-Received: by 2002:a17:902:9882:: with SMTP id s2-v6mr1918937plp.196.1519909235300; Thu, 01 Mar 2018 05:00:35 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.05.00.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 05:00:34 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 39/45] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Thu, 1 Mar 2018 20:54:16 +0800 Message-Id: <1519908862-11425-40-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-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