Received: by 10.223.185.116 with SMTP id b49csp4224143wrg; Mon, 26 Feb 2018 13:32:07 -0800 (PST) X-Google-Smtp-Source: AH8x2250YEkgKSSSjDe5v4ev4xJ5bUib+a2Ojf/ZejIkcJ2pLgDUTJAqjN+DnIOAUj+W/8+ytBs9 X-Received: by 2002:a17:902:22cc:: with SMTP id o12-v6mr12076091plg.280.1519680727416; Mon, 26 Feb 2018 13:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519680727; cv=none; d=google.com; s=arc-20160816; b=BEgBj/VwPf+VEgBU/PmsYpiC9ExiUSQsF2N7mBtwchIk+bKtLeAtDR8X28T6ohTQMy 9YwtdmPa9qErpxAMlJhYbwzGIQKA1Gw7DTnUVZGM/diypDOVRqFbG/h2AKH9/gn5Kui7 KFJxCf4XkzTUbPwl632MEX3EOjrGQrdzMIO6yCthNJMDfAVRVA8g1JlxmhH3p18Na0h3 NGwBoOJUxlatWzmkrxMmI90C8haGTOD9LliY5+hwoABMVFCCox/yYaEyPuhNuoH5khOa Cw4nC24H8H/CUGWey/W4sHFtnvsvc8UZPjvSdHPyS4tIfUyOgotAlAKliLZ2T0JTHTZD 1BVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=vMJYev+yWg7Lx2Tn1rlizmjALpwMusHBwra1nNh/TnA=; b=XgG/6D67h5H3xf1BJFhzmUni7hy5Ij0mkX/RwU6AlpedaDO8QYpSW6eJctA9nlzzFL 55/OR5QCcybnHQQq1WWC+qtgRRE8bKlc5oySQv/c0Y2YLt27ILbsnCkfQ+OLb3D7MEZA 7pxLYxmxTbvQLkcBxvH034MqsnoBLD4J48nxx1aTRT2LfDJ+nF6B1L43NGyAhu1kYr0u nR+GHDRkR/phjP7TXPjWPWtB9Mh7p5iAzL+wQnXx0GMhJHaxeAWPwm68Mk5+3EU16DMP HF7lw5hdIDSIpcItmbqK+WC75RH2+a3AK1LB1PPZXYgUxft10DiiFlRbgqJxAp17fgof mzRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=GTqtEFDH; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q22si7421251pfj.50.2018.02.26.13.31.50; Mon, 26 Feb 2018 13:32:07 -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=@oracle.com header.s=corp-2017-10-26 header.b=GTqtEFDH; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813AbeBZVax (ORCPT + 99 others); Mon, 26 Feb 2018 16:30:53 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:51646 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751165AbeBZVav (ORCPT ); Mon, 26 Feb 2018 16:30:51 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1QLRTTJ025342; Mon, 26 Feb 2018 21:30:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=vMJYev+yWg7Lx2Tn1rlizmjALpwMusHBwra1nNh/TnA=; b=GTqtEFDH7Iv8HpQUKSILDG1JV8vKEXnFceBsCad2hvwSZZmK9VBLphEYbE7R0GkCGzh3 ZT4jy7ueaHybxL8zvPYzTp81qXsS88XjhBf/SonUET/JlaySx5E2TZGIkf6fv+OzScwy JhiYN//ziNb1mlESIFijRvePYG+IiXkP0qbqTWudm9zPfqeB0uvdUIca/OReFU7CBBai mDMi98ViFT3CZDCd/pxInfW8FT03LKDeeoDcPEuOUfcnjE0M7nZZE1b/AC9n9XafIOSv fdZsk/9JNkAtOBJDX6lEI2uk866RqtVajPj/P5mFM5p12Owakydnho7AXTB9+g3S/kJl CA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2gcsax0ahd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2018 21:30:21 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1QLULIr028386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 26 Feb 2018 21:30:21 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1QLUK3h008774; Mon, 26 Feb 2018 21:30:20 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Feb 2018 13:30:20 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 903D66A09E6; Mon, 26 Feb 2018 16:30:19 -0500 (EST) Date: Mon, 26 Feb 2018 16:30:19 -0500 From: Konrad Rzeszutek Wilk To: Borislav Petkov , x86@kernel.org, mingo@redhat.com, tglx@linutronix.de Cc: Paolo Bonzini , Wanpeng Li , LKML , kvm , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: X86: Allow userspace to define the microcode version Message-ID: <20180226213019.GE9497@char.us.oracle.com> References: <20180226114409.GD4377@pd.tnic> <46cecef2-b0fb-b0c2-bbf3-983328d52763@redhat.com> <20180226121509.GE4377@pd.tnic> <24cd527d-5287-f0be-ffe8-eab341bf1d94@redhat.com> <3866d359-0ef8-6a99-6254-84890be62b93@redhat.com> <20180226122205.GG4377@pd.tnic> <20180226143912.GC22024@char.us.oracle.com> <20180226193711.GS4377@pd.tnic> <20180226205130.GZ22024@char.us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180226205130.GZ22024@char.us.oracle.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8816 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802260269 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 26, 2018 at 03:51:30PM -0500, Konrad Rzeszutek Wilk wrote: > On Mon, Feb 26, 2018 at 08:37:11PM +0100, Borislav Petkov wrote: > > On Mon, Feb 26, 2018 at 09:39:12AM -0500, Konrad Rzeszutek Wilk wrote: > > > diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c > > > index d19e903214b4..87d044ce837f 100644 > > > --- a/arch/x86/kernel/cpu/intel.c > > > +++ b/arch/x86/kernel/cpu/intel.c > > > @@ -144,6 +144,13 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c) > > > { > > > int i; > > > > > > + /* > > > + * We know that the hypervisor lie to us on the microcode version so > > > + * we may as well trust that it is running the correct version. > > > + */ > > > + if (boot_cpu_has(X86_FEATURE_HYPERVISOR)) > > > > I guess > > > > cpu_has(c, X86_FEATURE_HYPERVISOR) > > > > since we're passing a ptr to the current CPU. > > Ah yes. Let me fix it up and repost. I've posted it (but I can't seem to find it on LKML). Here it is in this thread. Also adding ingo + tglrx From 6abac2ccf105d57d60c094950e32139e435cbefe Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Mon, 26 Feb 2018 09:35:01 -0500 Subject: [PATCH v2] x86/spectre_v2: Don't check bad microcode versions when running under hypervisors. As: 1) We know they lie about the env anyhow (host mismatch) 2) Even if the hypervisor (Xen, KVM, VMWare, etc) provided a valid "correct" value, it all gets to be very murky when migration happens (do you provide the "new" microcode of the machine?). And in reality the cloud vendors are the ones that should make sure that the microcode that is running is correct and we should just sing lalalala and trust them. CC: stable@vger.kernel.org CC: Ingo Molnar CC: "H. Peter Anvin" CC: x86@kernel.org Cc: Tom Lendacky Cc: Andi Kleen Cc: Borislav Petkov Cc: Masami Hiramatsu Cc: Arjan van de Ven Cc: David Woodhouse Signed-off-by: Konrad Rzeszutek Wilk --- v2: Change comments to be more in line with the state of the world. v3: Use cpu_has instead of boot_cpu_has per Borislav's review. --- arch/x86/kernel/cpu/intel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index d19e903214b4..4aa9fd379390 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -144,6 +144,13 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c) { int i; + /* + * We know that the hypervisor lie to us on the microcode version so + * we may as well hope that it is running the correct version. + */ + if (cpu_has(c, X86_FEATURE_HYPERVISOR)) + return false; + for (i = 0; i < ARRAY_SIZE(spectre_bad_microcodes); i++) { if (c->x86_model == spectre_bad_microcodes[i].model && c->x86_stepping == spectre_bad_microcodes[i].stepping) -- 2.13.4