From patchwork Mon Feb 26 21:30:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 10243587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F054602A0 for ; Mon, 26 Feb 2018 21:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 852F82A206 for ; Mon, 26 Feb 2018 21:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 793362A3EE; Mon, 26 Feb 2018 21:31:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 115962A206 for ; Mon, 26 Feb 2018 21:31:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751455AbeBZVaw (ORCPT ); Mon, 26 Feb 2018 16:30:52 -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-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: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Paolo Bonzini --- 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)