Received: by 10.223.176.5 with SMTP id f5csp2829386wra; Mon, 5 Feb 2018 10:32:47 -0800 (PST) X-Google-Smtp-Source: AH8x225I8kjMDxbucTuBE11QCOCSJ+DPy/FbzCVhWyyUaQcxCx+CT8mRI0y7pFPH0SUJ9ZXu87AN X-Received: by 10.99.67.133 with SMTP id q127mr39123563pga.365.1517855567838; Mon, 05 Feb 2018 10:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517855567; cv=none; d=google.com; s=arc-20160816; b=L+oXYETdalsnUSU0pGKb+8HqPHCVbQzVExh4Z0IxyI81xVZ0ZCzSSfdOVgfejGRefX YRLhK/BaoHIYHWkr8drNb9qBhqmvSy3OASQjGjEk1I73+VHRDJ1LTSgwxPmk9/TYrySY EHB/Nd4F4OD+7M04pII/Ly12xW+PbxtCaSjKoC4LYvrXMX4XCJQ/W4GcPL6H2u8Ei3gB vf6l3dWDJ2bcCSNCh9m+IjfFh7fOV654u7bjpQzU8wWskXxq0UMYCWMwnXF0ZulwK9A7 XwmfkeYDSeWZgkaA7pAQd5QYOCFKrFdpRk57ektI1yJNqEOU4wc156tjXbNbEfJ6gUXw tawg== 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=Y16dwcD1cbS4DU/rJguSjJTcl/zDq9J6t1HAvLj7KH8=; b=neu6soszS+HcQnm0ox3sByw+5EYGrJA7ocl/Od9I7pFnUB8MHDo9oIEeKsWkeTL6qE t5TTcTglGbS7ITe3RNR9kXacObsS0uRMWfFIG+9127s7XppfzfYWRIRBw4MSNvXO3wcl wXb1ZqJVSJJW7uWcybkGf6EB0LbT4Yji1QtRz5WTrth6qY9MLzj1Autgi69/XdK7ymL9 ISI3XHKdL+OdQnl7aqZWIZDmiCmswURl/1vH+IYr1Q51ZOFjxUdY2YZbjPfzbKLIvcec zeFXflGs7NdcFItvnfZnmgg0BL/wmUFhw1GD5rHOT6NOPCXIwf0l6YG5gHNzZ4Z0KfHn 01+w== 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 m39-v6si197067plg.372.2018.02.05.10.32.33; Mon, 05 Feb 2018 10:32:47 -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 S1753597AbeBESba (ORCPT + 99 others); Mon, 5 Feb 2018 13:31:30 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52984 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753303AbeBESZ5 (ORCPT ); Mon, 5 Feb 2018 13:25:57 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C076E114C; Mon, 5 Feb 2018 18:25:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams , Thomas Gleixner , Paolo Bonzini , Andrew Honig , kvm@vger.kernel.org, Jim Mattson Subject: [PATCH 4.15 49/60] x86/kvm: Update spectre-v1 mitigation Date: Mon, 5 Feb 2018 10:23:22 -0800 Message-Id: <20180205182216.252016631@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182213.902626065@linuxfoundation.org> References: <20180205182213.902626065@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: Dan Williams dan.j.williams@intel.com commit 085331dfc6bbe3501fb936e657331ca943827600 Commit 75f139aaf896 "KVM: x86: Add memory barrier on vmcs field lookup" added a raw 'asm("lfence");' to prevent a bounds check bypass of 'vmcs_field_to_offset_table'. The lfence can be avoided in this path by using the array_index_nospec() helper designed for these types of fixes. Signed-off-by: Dan Williams Signed-off-by: Thomas Gleixner Acked-by: Paolo Bonzini Cc: Andrew Honig Cc: kvm@vger.kernel.org Cc: Jim Mattson Link: https://lkml.kernel.org/r/151744959670.6342.3001723920950249067.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "kvm_cache_regs.h" #include "x86.h" @@ -898,21 +899,18 @@ static const unsigned short vmcs_field_t static inline short vmcs_field_to_offset(unsigned long field) { - BUILD_BUG_ON(ARRAY_SIZE(vmcs_field_to_offset_table) > SHRT_MAX); + const size_t size = ARRAY_SIZE(vmcs_field_to_offset_table); + unsigned short offset; - if (field >= ARRAY_SIZE(vmcs_field_to_offset_table)) + BUILD_BUG_ON(size > SHRT_MAX); + if (field >= size) return -ENOENT; - /* - * FIXME: Mitigation for CVE-2017-5753. To be replaced with a - * generic mechanism. - */ - asm("lfence"); - - if (vmcs_field_to_offset_table[field] == 0) + field = array_index_nospec(field, size); + offset = vmcs_field_to_offset_table[field]; + if (offset == 0) return -ENOENT; - - return vmcs_field_to_offset_table[field]; + return offset; } static inline struct vmcs12 *get_vmcs12(struct kvm_vcpu *vcpu)