Received: by 10.223.185.116 with SMTP id b49csp82624wrg; Thu, 15 Feb 2018 17:04:45 -0800 (PST) X-Google-Smtp-Source: AH8x2267XkC13imhz1D/FszMZo+/a48+FaCEwIEZvW70JQc3dAFMcsU6txBazmBg3sKqSrtzQGUd X-Received: by 10.98.139.153 with SMTP id e25mr4165101pfl.53.1518743085717; Thu, 15 Feb 2018 17:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518743085; cv=none; d=google.com; s=arc-20160816; b=uwzeYPQsgVvrp9x1pzrN4bKLkx2K8Cp3jMWcSJ+RNOXf/A2UILlFCfmk9l1/hwXCxM D+x9YfXfsXtC5iuXLTlMIOTqZ4XCHSEEroxfhz/1FB59ong7IJIYMOt9j/x943AsU9c6 CmNfUdl4bKsJAx1uW07DmtV+1t+hI6cTCrhEOoKcNfpiv3CZYINS6HyEROLIY3EkCYNI Ejwsqk05vskteI1IVuJMUQKSfjJkTFxXefQiraHQKuGgRCeIG5NzOqNdEg9X9ijrKSer kGtSq3ptLhUK7G4RWjITqv183MCk9YEONxj5lUW4fIr6YyqEzwX6ods5pXmxUE7v/7hm jocA== 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=0bvr9oovb6P5lzZc5BV41DbSMEkkozz70rGB2SpDa18=; b=reuHCQt0knw9RlPKBmkr9MBabs69jgU/AtK8oVJ3AZwsyy+riuIrV0wUGB6rYBXExU IiX1q5830v+9qopomOatRwSyy2QKEJk0oD2GmN4hWxc1AiprFQmNQU0Mbk+fjSeTsAg0 cFxMd1FXC/4v4S8nzc1Nep9eHlZHQg/fFVZ1T7888K2dQs9oq+K1aDE1zsBTegB0ZQ8G Ih6kuvphLA5Tw+o/AGgfECrkn3tMIID/VX/OXIfHcdtDBHilw6p9Tjb3azX+n4B6SrPy 5Y+wPO7Hdd4Wd8qzdlUoU/pU8MYy0tH0TVGY9EWCH2IhREG3Q+zkM43fwVdTlkWBsB+b nTRw== 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 l19si407688pgc.239.2018.02.15.17.04.13; Thu, 15 Feb 2018 17:04:45 -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 S1424156AbeBOPmV (ORCPT + 99 others); Thu, 15 Feb 2018 10:42:21 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33248 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424093AbeBOPmR (ORCPT ); Thu, 15 Feb 2018 10:42:17 -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 2A41FFB6; Thu, 15 Feb 2018 15:42:17 +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.15 081/202] [Variant 2/Spectre-v2] arm64: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling Date: Thu, 15 Feb 2018 16:16:21 +0100 Message-Id: <20180215151717.705732110@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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: 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