From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227IlK2yW6HYF11VQdY6FZZ2RLy0NAAiNrdsQwC4gh1sZzWHkNmvyQT+ASQ7UhEd0Fwk6nxC ARC-Seal: i=1; a=rsa-sha256; t=1517186515; cv=none; d=google.com; s=arc-20160816; b=mWdvHlf50wY+L/NpZCAve3L7sYWi9uF1RwkeBwuni2YAZAMsV82H2mgSJwditezzmL 3NtNbmrIxrL3xxpo4zWfw3cFQTbxCS9w41BzgI8w1f64s4sZEHCeHcEOrVLM6/NycNP9 ZPDG1mjV1q5SkkOxRTfIkGTo1OJHtfKshKn2TTFM1zUfhiYTBvdj6dn+h+6zr3qoeRzL 0UX391gXBGT5+TwLxCicY4R4G4fhQpsbSDuHfJVvtTuiaNn3x7YiZ3bkUMrFvTGSOHuc 9kO0KTZwEvjuJJRwrr+1codQ7sV+i5e6RgTKcKZ5VkGtrqxhnFfTJHX1mDIiaHdJLH9H wXKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:content-transfer-encoding:subject:cc:to:from :date:message-id:mime-version:dkim-signature :arc-authentication-results; bh=Gv6n6H3kK9mKXu0I9Rj7+1xJ6vg4rxotTOPNiXhVcRI=; b=Zffx/6rgKcx0ej8DYtOP0SL2ER+TW9RQ0HxlrXcWrbvQr/RBjRFEIMJN1Og0EXWtsK OiCixMp5ZNmoJZvt8InWQDGu3UT7H/iMAedPP+EOz0+7qwvIMd8NOSTq9+lMZa65gLe8 ndUvh3iFUyH+IyV56W+AdHJTV2uXJ3QekC6tPmCO5n0ruv96uqBlD8qn52/QtxWUgbNE N7bFfyHJFLrsnGAuVBR8TApoC4sobfFKwywi8Uk+b6gDUhUndex1Plgng9H7pep97OCJ K9LyBP8mo+2YuWqXcdr0vRbMwUMHd4UYLUGN/Fb/QxiRbDU+PgJkIFGe4r2nmy7VLCkC yL/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=VRwNsSUp; spf=pass (google.com: domain of liran.alon@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=liran.alon@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=VRwNsSUp; spf=pass (google.com: domain of liran.alon@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=liran.alon@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com MIME-Version: 1.0 Message-ID: <6b9a1ec2-5ebd-4624-a825-3f31db5cefb5@default> Date: Sun, 28 Jan 2018 16:39:48 -0800 (PST) From: Liran Alon To: Cc: , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH] x86: vmx: Allow direct access to MSR_IA32_SPEC_CTRL X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8788 signatures=668655 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=639 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801290006 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590865729989295970?= X-GMAIL-MSGID: =?utf-8?q?1590885367445378175?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: ----- dwmw2@infradead.org wrote: > On Sun, 2018-01-28 at 15:21 -0500, Konrad Rzeszutek Wilk wrote: > > >To avoid the overhead of atomically saving and restoring the > MSR_IA32_SPEC_CTRL > > >for guests that do not actually use the MSR, only > add_atomic_switch_msr when a > > >non-zero is written to it. > >=20 > >=20 > > We tried this and found that it was about 3% slower that doing the > > old way of rdmsr and wrmsr. > >=20 > > But that was also with the host doing IBRS=C2=A0 as well. >=20 > The common case will be that neither host nor guest are doing IBRS. > Until the guest touches the MSR we do absolutely *nothing* with it, > which is definitely the fastest option. Windows use IBRS and Microsoft don't have any plans to switch to retpoline. Running a Windows guest should be a pretty common use-case no? In addition, your handle of the first WRMSR intercept could be different. It could signal you to start doing the following: 1. Disable intercept on SPEC_CTRL MSR. 2. On VMEntry, Write vCPU SPEC_CTRL value into physical MSR. 3. On VMExit, read physical MSR into vCPU SPEC_CTRL value. (And if IBRS is used at host, also set physical SPEC_CTRL MSR here to 1) That way, you will both have fastest option as long as guest don't use IBRS and also won't have the 3% performance hit compared to Konrad's proposal. Am I missing something? -Liran