Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3214406imu; Mon, 28 Jan 2019 00:28:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN5YOhrOaG3CxhYi1e/kCN7ndUPod0VFUSY2MhnIduNa3hCuPZfx5uxzrenalpJasdzbclGY X-Received: by 2002:a17:902:981:: with SMTP id 1mr20372155pln.142.1548664098377; Mon, 28 Jan 2019 00:28:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548664098; cv=none; d=google.com; s=arc-20160816; b=tDPgOIH5+k43Ds97M7+hJFQ7voe16RkyT6H29S62Lv7/1ncOt4YtX6f5VoGGWXR1hv tT0cj43iJzv5Bk4PmPvWfoiqSHR3ZP3Np3ENOj3hUvfJAXBnuUP8f6xCJBWUwfmLjPxv Uc9ULqmRLpBB9iueDBpGKA6xeWFwsduvbZmnJqNEOWFVENNaIcq/ri2CfZog4CZCVbPa Wfdw2sOa0sAlZunWKZhDChDCpWantSdHqg0+B4HUNiHXCraabZ+cwWzPxsnr70wacFcc BCxduNWZ1c2m9i6vWXtNJR1x2N6aVWYtjsNhkfXtGoCaQ6FIAOzpIv7MbU8yLjz2szBA iU4w== 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:in-reply-to :mime-version:user-agent:date:message-id:organization:from :references:cc:to:subject:reply-to:dkim-signature; bh=Ai7blyowJ2j+dSzy/4760bLhpzysP1SImAKTnUQ7Pqs=; b=QLfgN76G1oO6EBWu8XdLfaAYXvLzD25/VgWq6d3+mtYTy/29zo7x00GkiMa12w+X6F FQlX4Ffz0Y1WIgs69YHwRvAoZQq3pHsyodohWFvxXRReQU6q1soO/LmG3d9I5CawVv7/ 4AkxJekZOMURwoaRxjJG/d6/2B+SyLtoCl5tWVpFI6qXG+NI3Wp2wHaS5G6inW2F45pc vjYjmfRfYJxKX6fs+ll0bOQeIezlvxi6eUNHUbLAm+I7+DF6DzP5/f14iA2F1SjFOqzQ e14LQ2RTnX5Ytq8oBQ6XRqCNHIWVTroLtkVkIeGu1dNWCVhrxPy1MtYe349/AX/+E8XB W6+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=JsrI9Aox; 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 i63si31638086pgc.116.2019.01.28.00.28.03; Mon, 28 Jan 2019 00:28:18 -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-2018-07-02 header.b=JsrI9Aox; 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 S1726884AbfA1I10 (ORCPT + 99 others); Mon, 28 Jan 2019 03:27:26 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:39774 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfA1I1Z (ORCPT ); Mon, 28 Jan 2019 03:27:25 -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 x0S8O1fH038278; Mon, 28 Jan 2019 08:26:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=reply-to : subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Ai7blyowJ2j+dSzy/4760bLhpzysP1SImAKTnUQ7Pqs=; b=JsrI9AoxbrD1sE06sBNKwigX7sFC2w6tR+Fc9lFqcYqeTLUHZte0HmBdteGAIWYxraPU l2MQ7uuDa0w6TSezG2EUNBSrTI9SibNuVZv3hgUZvHTZJDxg1g199VpbwtpgzfzqCtqw aKJxnRPKZM9S9Fc4BzA7uE5f5nlPj+3Hj/ax1ZZt21m+CZRMPxh0Se5zmKRbvnCRHok2 chwIj10AFPyJVgi91nAKsDCYozov0Yf+/LEsNifO2lU07KKH0e7EUb+FzN2kuFHfdpQ8 Ec86UJWymo+x+l1iIN1p3kKTPJgUetLh7iz7VuhfbTw5HKM009p/bSgZe3dYe/VSwt0s Hg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2q8g6qvhn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Jan 2019 08:26:57 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0S8Qtul011364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Jan 2019 08:26:55 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0S8Qsg0026129; Mon, 28 Jan 2019 08:26:54 GMT Received: from [192.168.0.118] (/171.117.190.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Jan 2019 00:26:54 -0800 Reply-To: zhenzhong.duan@oracle.com Subject: Re: [PATCH] x86/speculation: Update TIF_SPEC_IB before ibpb barrier To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, konrad.wilk@oracle.com, x86@kernel.org, srinivas.eeda@oracle.com, bp@suse.de, tim.c.chen@linux.intel.com, peterz@infradead.org, hpa@zytor.com References: <48a105d3-fa32-40e4-9775-37d49f42eac0@default> From: Zhenzhong Duan Organization: Oracle Message-ID: <0aa09e77-1454-9eaf-ef67-b00518e6f2d2@oracle.com> Date: Mon, 28 Jan 2019 16:28:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9149 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=499 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901280070 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/1/26 2:03, Thomas Gleixner wrote: > On Fri, 25 Jan 2019, Thomas Gleixner wrote: >> On Wed, 23 Jan 2019, Thomas Gleixner wrote: >> >>> On Fri, 18 Jan 2019, Zhenzhong Duan wrote: >>> >>>> When a task is set for updating TIF_SPEC_IB throuth SECCOMP by others >>>> and it's scheduled in the first time, a stale TIF_SPEC_IB value is >>>> picked in cond_ibpb(). This is due to TIF_SPEC_IB is updated later at >>>> __switch_to_xtra(). >>>> >>>> Add an extra call to speculation_ctrl_update_tif() to update it before >>>> IBPB barrier. >>> >>> Errm. No. It adds that call to speculation_ctrl_update_tif() for every >>> mm switch, most of the time for nothing. >>> >>> If at all, and we discussed that before and decided not to worry about it >>> (because it gets fixed up on the next context switch), then you want to >>> handle ibpb() from there: >> >> Actually we need to do that. It's not only the scheduled in first >> problem. That whole thing might become completely stale in either >> direction. Care to whip up a patch? > > Bah, nonsense. Brain was clearly still out for lunch and I confused IBPB > and STIBP for a moment. cond_ibpb() is the thing issues in switch_mm() and > that is not leaving a stale MSR around because we only write to it when we > need the barrier. The bit is not stale because the barrier is only issued > with the write. The bit has not to be cleared. > > So the only 'issue' what happens is that switch_to() either issues a > barrier too much or misses one. That's really not a problem. Ok, yes, the purpose of this patch is to avoid the one missed barrier. Thanks for your reply. Zhenzhong