Received: by 10.223.176.5 with SMTP id f5csp1209150wra; Fri, 2 Feb 2018 13:10:24 -0800 (PST) X-Google-Smtp-Source: AH8x224pm5zF1cvpgS7+iy3QzL0ukG/EiTXpybMnkj79megCSGLKnF7Ep/HujBsbd1wW09+1jdh+ X-Received: by 10.98.87.2 with SMTP id l2mr40562880pfb.46.1517605824760; Fri, 02 Feb 2018 13:10:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517605824; cv=none; d=google.com; s=arc-20160816; b=vklcWqQ4ilw1LEQ2tkJiYPwLiqsLJeOtQWZOlfKt/zAn0wKb/c/V33v8fGWFUbeB8N TFAeVax03VCiekf0Xjj8wn/s+yYYBlimpwQjbY5R6pdoTORaTQPQPdth8rTkjPVjlASH KGMSHbUBC4rzqqphgQ6+wXA9+YwT5xaSbpKDeV0o2RNqgO+hwEFp/qRr1avODYNOxcJw fsXfllBuaPuXRJLQygL2a6ktyzUDC3BV/Uqy0xtCMLhaSmLmBHFK2jLm3/lnEu0Rersc Br7G+ywHoe5/ikMEQTZt8yl8fhXdEprVkHKi99QNti1Ao7MTEgaNurANb8J5driHZYL5 1MnQ== 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=/+TeL7BPNhw0iejxJ0Tum35tjS+7L9qnxZdLnd4T9ak=; b=lruDId0K8wnBzzv3g/rTAS7SFhchiaRShqx4exgC8QMt6yHWS92Xr4byjPVrVYM9TA GtQdfBy/iuUEqdCIbcGGO5VeFNYROEQ14DCu0jDKDaU2TO2JDMtQkdtJ4RVxAD9c4C3+ bB+JTWWTVfBNG26s57mkq48AaMDn2O50YnOeF3y4ok8e/RUNtkUvXfyEwXuz8w6R3SaO uf7HldP+6ixzCsx2bQ5SXwYzLz8wf5RfTbsQQ1bV/32TkauY5MmwtNtO33nWFdy842Kc JJ2bp/jDXzT8tRUvB28HlCv0Xq5V8H9dHPUjsMQPMM42G5kUz6bh9ScAeTZ/yPGy/o42 wl1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=umOlgpnV; 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 g92-v6si2397676plg.555.2018.02.02.13.09.59; Fri, 02 Feb 2018 13:10:24 -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=umOlgpnV; 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 S1754396AbeBBT4s (ORCPT + 99 others); Fri, 2 Feb 2018 14:56:48 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:35118 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752907AbeBBT4k (ORCPT ); Fri, 2 Feb 2018 14:56:40 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w12Jg0ha081559; Fri, 2 Feb 2018 19:56:09 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=/+TeL7BPNhw0iejxJ0Tum35tjS+7L9qnxZdLnd4T9ak=; b=umOlgpnVTuWMI1qkIE5s19auViP+ESoNJVHQg9qyu0WsvgERyvgWvYbw5i9FfQ+BzAlq /eQoLcO/O77iKgSAfeVjPd7xrNDPSXMLCDYLVoSSlSwVjpfbAz6HL6y7p5Av1sEDtiXY 2WTmP08zQWr8U2qDKVRZKDhIQwXkW4PZk8gwS1YR+4LIA8l/Hh4N1ER01DYtZn0uTy35 njXnzZnMxOISs5nJVu1vtjCy8TYvI8Esvmn2yRV/RfSL9Fjv7X7dXVWXHZ3V0HoToRMc zHk2Tn9mIpnFb/xRBo+982YwdNKxZ5WucOGjA3M1RkHQX9YYWZHhjSuluNFkmeb+q/Ue +A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2fvuuw0tng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 02 Feb 2018 19:56:09 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w12Ju7pG022015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Feb 2018 19:56:08 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w12Ju64C030192; Fri, 2 Feb 2018 19:56:06 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Feb 2018 11:56:06 -0800 Received: by char.us.oracle.com (Postfix, from userid 1000) id 7D5816A0A42; Fri, 2 Feb 2018 14:56:01 -0500 (EST) Date: Fri, 2 Feb 2018 14:56:01 -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: <20180202195601.GD28192@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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1517594544.31953.62.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-1802020237 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 06:02:24PM +0000, David Woodhouse wrote: > On Fri, 2018-02-02 at 12:49 -0500, Konrad Rzeszutek Wilk wrote: > > > @@ -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 entry-= >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 necessa= rily present in hardware cpuid> */ > > > +=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 kvm_c= puid_8000_0008_ebx_x86_features; > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0cpuid_mask(&entry->eb= x, CPUID_8000_0008_EBX); > >=20 > > It is with x86/pti nowadays. I think you can remove that comment. >=20 > 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() to tu= rn > off any bits which were otherwise present in the hardware and *would* > have been supported by KVM, but which the kernel has decided to pretend > are not present. >=20 > Nothing would *set* the IBPB bit though, since that's a "virtual" bit > on Intel hardware. The comment explains why we have that |=3D F(IBPB), > 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. Shouldn't we just check to see if the machine is AMD before advertising this bit?