Received: by 10.223.185.116 with SMTP id b49csp2300874wrg; Thu, 15 Feb 2018 09:29:14 -0800 (PST) X-Google-Smtp-Source: AH8x2271VB7WskE3sepfzLJtqFCaI9jR72hz2iz0F/1o/u2kJv5zPQRjPkIEMuo8lgw1gR4A6LEG X-Received: by 10.99.125.74 with SMTP id m10mr2875418pgn.354.1518715754254; Thu, 15 Feb 2018 09:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518715754; cv=none; d=google.com; s=arc-20160816; b=C4RCZKVedKvC3nF8E684u94q1VTDwJmkgs2zexeU/tbqPoLx31mv6fTAuwgtJ53EyS KV7ucakmrN/dKgMn8WmZ+Dmxa+ncrR6sFIMqeLeovrr4JC5DyXnudGcMsodiaOPsB4iW sSiPBOqFfutJowHDEF1+tjusuu+Mrb0NvqijMY8Nq51lX41EnZm8NILM2Lv4Uyaw8w6L ht6IAuZG6wyCzr5RAw8mDetx/mSpKYU3k98G1XtiMDeXzEsT2tSxvCilep5n+EULMTTf 8/fG7K6MU3pw8/V558AnSBgT6VuKO7XL1SjE55BykrxzUlDB+QkIvPmItWviB14oVb6P b2CA== 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=aIVFRr3V4NKkHJJKq5E0ZtgPqFrVxyxmTAgegRS3uzw=; b=uMI67f/vZH7ySNthpsPiQK8Kzu3kfbXooPMjYBE79dudTv9M6sThoPSbbmeJlP2nM2 ynA2ydorpKa2xiP5MDS1WpkH7BLvkMgXLh2TgDFlBogwZPBOfM9kZYZXraxkjJIJuZH8 g8ztMt4muXKbDMDPdMFTh6hlFnLVPD64PLsCuAnNmQok/c/WrAM5a1G/2nDA9zV9LR9H O5MCPBY5vE7+VudpmDRn3T+MVQrB+Y5CqQNHyhD5zsYN3d1QASOSsimIASDIAZ0XWZ1E 51MvHVoCezEx4irkXt1D1BXYMk7iigrmMdk23teyg9h1i9Tt1QT7EosOvYWnY0d0/7Dd O6Zg== 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 z1-v6si1668035plb.178.2018.02.15.09.28.59; Thu, 15 Feb 2018 09:29: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; 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 S1165072AbeBOPeT (ORCPT + 99 others); Thu, 15 Feb 2018 10:34:19 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:57120 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165004AbeBOPeP (ORCPT ); Thu, 15 Feb 2018 10:34:15 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B9E210FD; Thu, 15 Feb 2018 15:34:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon Subject: [PATCH 4.14 088/195] [Variant 2/Spectre-v2] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Thu, 15 Feb 2018 16:16:19 +0100 Message-Id: <20180215151710.112283299@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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: Ard Biesheuvel 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 @@ -64,10 +65,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 @@ -100,6 +102,20 @@ alternative_endif 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