Received: by 10.223.176.5 with SMTP id f5csp1215670wra; Fri, 2 Feb 2018 13:17:41 -0800 (PST) X-Google-Smtp-Source: AH8x227PB3R3SXUmC6yTJ9Zu1c6I5pIVEB+ogdrM0nNSmZtAJZj1A8GU8wTETj08ykdesDz3HD8k X-Received: by 2002:a17:902:20c8:: with SMTP id v8-v6mr35997934plg.226.1517606261177; Fri, 02 Feb 2018 13:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517606261; cv=none; d=google.com; s=arc-20160816; b=ovOPeBOykUQdZ3D9ZB01NUDb+ssJfVrBXbnrwwrhUI1xMqDW0pIKtdOSpik7MgJEqk yXpi8B/Mya1VgyrQ2GIPNdq57Z+3vX6l4P2maEfiIa/LtJixtZplkM+BexOND1pAgv3R Ux+Liu2z54SqYHbQoLtKWd116S9CUiyMI6z9wSWcm7kjEG+lD2EB03URU/h2dSwDQred NXhOf8YGG7b7DmaT42mlMg+xW3qzNJzbsnJCmpMS8y/BFQTO6QCap01OCLjuROQrq97I kGVdM0nApWLv9tTpFxvzViC+ivEhK/39khbR+taA4YAhLlOV+ZUMzq1g9WKXUQnIXWAk lzCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:user-agent :in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=6zuCK6GTuungBvTZDOI6FgEYKui63UmKhgQlU+QNjaA=; b=Ik2ozytuOmb6QkiPSIXS+QULPZZ5cKzC+4SGIl+XTJqs2uiXDEgV+Idc1TCNCbMJAN JKvwwWEKvb3kLQN5WqG+rYjXV5PgxblsdK1Rdp+bSaVda56bVWhPwwRDq8pg05EIUpxS Eix+jdNVoaZbmluaFHg6v9h0lrNT7u8pjXSFWKcMBfO+0OkHZZ/h4bkhhGLUjf77sk/T 4mEY6V1kNOg7zsv6xvqm9+KdtOgrE0SFf7vDxy4pVFondNrOv8qQldoPOs3iSBK/UNSX OQV6WAZ2lWZASJLP/X5pSv3/7jz2tuMO1t3MEvyfBctx66pclUVbLfsXJP2XhP1F+nf6 i92g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=OrqXwhQh; 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 e93-v6si2424072plk.580.2018.02.02.13.17.26; Fri, 02 Feb 2018 13:17:41 -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=OrqXwhQh; 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 S1752111AbeBBUah (ORCPT + 99 others); Fri, 2 Feb 2018 15:30:37 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:43714 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbeBBUaa (ORCPT ); Fri, 2 Feb 2018 15:30:30 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w12KR0fO078952; Fri, 2 Feb 2018 20:29:00 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 : content-transfer-encoding; s=corp-2017-10-26; bh=6zuCK6GTuungBvTZDOI6FgEYKui63UmKhgQlU+QNjaA=; b=OrqXwhQhNWCy3eAKyfdJ4vjXbTFvzG91EIosB72vPL0f7luy7/6004a+eVphe5u2O6UZ 2tr8PCBYrxKqHdEILWxT1XqIBd1El/uV3HRe1ZpZaLxHFIee95NYaIqk7cPJnlP2Ucm0 fBMQpbz96CHo12vzMcV+27JsbryuoiK56pVekMULGOXJluBoTx7JnEDYm34X0CpI5BEr setWJHwREYVV+5j0VfI2ytUaiIQM1hGYNHxRbutmlOoiYx4Hu3Z1uyK5w5qw++1xJdsR S6rtGDoEOpdpTfYDRNEplM/VrcT0WuRBtjAKh8ugW4BPsUrlrvcLenhiZVESS5kYCRJE 2Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2fvv0p0u9j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Feb 2018 20:29:00 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w12KSxQT023220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Feb 2018 20:29:00 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w12KSxta009361; Fri, 2 Feb 2018 20:28:59 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Feb 2018 12:28:59 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 3BB6F6A0A42; Fri, 2 Feb 2018 15:28:57 -0500 (EST) Date: Fri, 2 Feb 2018 15:28:57 -0500 From: Konrad Rzeszutek Wilk To: David Woodhouse Cc: KarimAllah Ahmed , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Ashok Raj , Asit Mallick , Dave Hansen , Arjan Van De Ven , Tim Chen , Linus Torvalds , Andrea Arcangeli , Andi Kleen , Thomas Gleixner , Dan Williams , Jun Nakajima , Andy Lutomirski , Greg KH , Paolo Bonzini , Peter Zijlstra Subject: Re: [PATCH v6 2/5] KVM: x86: Add IBPB support Message-ID: <20180202202857.GI28192@char.us.oracle.com> References: <1517522386-18410-1-git-send-email-karahmed@amazon.de> <1517522386-18410-3-git-send-email-karahmed@amazon.de> <20180202174932.GR28192@char.us.oracle.com> <1517594544.31953.62.camel@infradead.org> <20180202195601.GD28192@char.us.oracle.com> <1517602575.31953.74.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1517602575.31953.74.camel@infradead.org> User-Agent: Mutt/1.8.3 (2017-05-23) Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8793 signatures=668661 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-1802020245 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 02, 2018 at 08:16:15PM +0000, David Woodhouse wrote: >=20 >=20 > On Fri, 2018-02-02 at 14:56 -0500, Konrad Rzeszutek Wilk wrote: > > On Fri, Feb 02, 2018 at 06:02:24PM +0000, David Woodhouse wrote: > > >=20 > > > On Fri, 2018-02-02 at 12:49 -0500, Konrad Rzeszutek Wilk wrote: > > > >=20 > > > > >=20 > > > > > @@ -625,7 +629,12 @@ static inline int __do_cpuid_ent(struct > > > > > kvm_cpuid_entry2 *entry, u32 function, > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (!g_phys_= as) > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0g_phys_as =3D phys_as; > > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->eax =3D= g_phys_as | (virt_as << 8); > > > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->ebx =3D en= try->edx =3D 0; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->edx =3D 0; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* IBPB isn't nec= essarily present in hardware cpuid>=A0=A0*/ > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0if (boot_cpu_has(= X86_FEATURE_IBPB)) > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0entry->ebx |=3D F(IBPB); > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0entry->ebx &=3D k= vm_cpuid_8000_0008_ebx_x86_features; > > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0cpuid_mask(&entry= ->ebx, CPUID_8000_0008_EBX); > > > > It is with x86/pti nowadays. I think you can remove that comment. > > > In this code we use the actual CPUID instruction, then filter stuff= out > > > of it (with &=3D kvm_cpuid_XXX_x86_features and then cpuid_mask() t= o turn > > > off any bits which were otherwise present in the hardware and *woul= d* > > > have been supported by KVM, but which the kernel has decided to pre= tend > > > are not present. > > >=20 > > > Nothing would *set* the IBPB bit though, since that's a "virtual" b= it > > > on Intel hardware. The comment explains why we have that |=3D F(IBP= B), > > > and if the comment wasn't true, we wouldn't need that code either. > > > > But this seems wrong. That is on Intel CPUs we will advertise on > > AMD leaf that the IBPB feature is available. > >=20 > > Shouldn't we just check to see if the machine is AMD before advertisi= ng > > this bit? >=20 > No. The AMD feature bits give us more fine-grained support for exposing > IBPB or IBRS alone, so we expose those bits on Intel too. But but.. that runs smack against the idea of exposing a platform that is as close to emulating the real hardware as possible. As in I would never expect an Intel CPU to expose the IBPB on the 0x8000_= 0008 leaf. Hence KVM (nor any hypervisor) should not do it either. Unless Intel is doing it? Did I miss a new spec update?