Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966008AbeAJQVC (ORCPT + 1 other); Wed, 10 Jan 2018 11:21:02 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:44836 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965714AbeAJQVA (ORCPT ); Wed, 10 Jan 2018 11:21:00 -0500 MIME-Version: 1.0 Message-ID: Date: Wed, 10 Jan 2018 08:19:59 -0800 (PST) From: Liran Alon To: Cc: , , , , , , , , , , , Subject: Re: [PATCH 3/8] kvm: vmx: pass MSR_IA32_SPEC_CTRL and MSR_IA32_PRED_CMD down to the guest X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8769 signatures=668652 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1801100228 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: ----- dwmw@amazon.co.uk wrote: > On Wed, 2018-01-10 at 10:41 -0500, Konrad Rzeszutek Wilk wrote: > > On Wed, Jan 10, 2018 at 03:28:43PM +0100, Paolo Bonzini wrote: > > > On 10/01/2018 15:06, Arjan van de Ven wrote: > > > > On 1/10/2018 5:20 AM, Paolo Bonzini wrote: > > > >> * a simple specification that does "IBRS=1 blocks indirect > > branch > > > >> prediction altogether" would actually satisfy the > specification > > just as > > > >> well, and it would be nice to know if that's what the > processor > > actually > > > >> does. > > > >  > > > > it doesn't exactly, not for all. > > > >  > > > > so you really do need to write ibrs again. > > >  > > > Okay, so "always set IBRS=1" does *not* protect against variant > 2.  > > Thanks, > > > > And what is the point of this "always set IBRS=1" then? Are there > > some other things lurking in the shadows? > > Yes. *FUTURE* CPUs will have a mode where you can just set IBRS and > leave it set for ever and not worry about any of this, and the > performance won't even suck. > > Quite why it's still an option you have to set in an MSR, and not > just > a feature bit that they advertise and do it unconditionally, I have > no > idea. But apparently that's the plan. > > But no current hardware will do this; they've done the best they can > do > with microcode already. I'm still a bit confused here (maybe I'm not the only one), but I have the following pending questions: (I really hope someone from Intel will clarify these) (1) On VMEntry, Intel recommends to just restore SPEC_CTRL to guest value (using WRMSR or MSR save/load list) and that's it. As I previously said to Jim, I am missing here a mechanism which should be responsible for hiding host's BHB & RSB from guest. Therefore, guest still have the possibility to info-leak host's kernel module addresses (kvm-intel.ko / kvm.ko / vmlinux). * a) As I currently understand things, the only available solution to this is to issue an IBPB and stuff RSB on every VMEntry before resuming the guest. The IBPB is done to clear host's BTB/BHB and the stuff RSB is done to overwrite all host's RSB entries. * b) Does "IBRS ALL THE TIME" usage change this in some aspect? What is Intel recommendation to handle this info-leak in that usage? (2) On VMExit, Intel recommends to always save guest SPEC_CTRL value, set IBRS to 1 (even if it is already set by guest) and stuff RSB. What exactly does this write of 1 to IBRS do? * a) Does it keep all currently existing BTB/BHB entries created by less-privileged prediction-mode and marks them as were created in less-privileged prediction-mode such that they won't be used in current prediction-mode? * b) Or does it, as Paolo has mentioned multiple times, disables the branch predictor to never consult the BTB/BHB at all as long as IBRS=1? If (b) is true, why is setting IBRS=1 better than just issue an IBPB that clears all entries? At least in that case the host kernel could still benefict branch prediction performance boost. If (a) is true, does "IBRS ALL THE TIME" usage is basically a CPU change to just create all BTB/BHB entries to be tagged with prediction-mode at creation-time and that tag to be compared to current prediction-mode when CPU attempts to use BTB/BHB? Regards, -Liran