Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1938584ybd; Sun, 23 Jun 2019 20:34:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcx6sZ0vNU9Ypfsu1cWO+XGJ9817tNBmIyWO8qeWkIKUSE3X0Bgh/JbfvhHsbRYM9QV+Ua X-Received: by 2002:a17:902:e6:: with SMTP id a93mr103253461pla.175.1561347268771; Sun, 23 Jun 2019 20:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561347268; cv=none; d=google.com; s=arc-20160816; b=QhEBCJsj31awtiYQiRdLUHtjn9jqHjmx7HccRapNv+nDZNEuO55gW8KWCPSORtbSL0 GRCWfeX3ycg+ienqCyfuaV8gS0n5bo8LXrytkVAEN4DFxK+huHwj9QQhMMdx8L0e7bg5 dO61Nv7plLR6WYYK13ajs8yC5eAAR3lvL8ktCpD5GmkXJAwbYlbOK1L3dBd7s2XhYYqz XAWEAVYRM3wQkTMDpWMPaTQczAS1ktmLeP+zNKO3RpqbsiHgiljtJnIQo9W7kBfHvYOh 0XjA1KFsEXWaDyPyEZuh6U9pOghnCMX44HZlPMiLiamjnOajli8Ow3qlcvs8VKZhPFaF +ePg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=A3YM+cC+Wq0vJZp4sQYiwht/JgO/4EqsOgjUe2E6whU=; b=OSdBNUGkcBepVIWIaei9X55lU3XhgkG++ntt6K4wnYYw6wJnvba2AucHMok4ogod7q 3GpWVDuVSqFL811sAs7+9CLMy4vtBYE3VHQwLdu+DczvdN5+mwv6E97T9rJUKUrTabs/ vm/mAdlMsj31zx4JOEbTViJTodTz/m68mTfhemRTzadckBVdUgyxloJ3L/TTcLkgaCt7 bMZbSr5Xc5iFaAQ8JrySk5j1ZOCOXROejR6jWcxRXelvs6YIJYMZi8VLrZPce0hHMr7d m35tkTT1gKuS29mm1qntkDLTRkNKrszeWVt0qbu4HXUJfE6HJreAU9iQO1DGXO4RKObJ bx+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=TxOpWlKI; 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 m42si4796869pje.31.2019.06.23.20.34.13; Sun, 23 Jun 2019 20:34:28 -0700 (PDT) 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=TxOpWlKI; 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 S1727690AbfFXDcR (ORCPT + 99 others); Sun, 23 Jun 2019 23:32:17 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35815 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbfFXDcM (ORCPT ); Sun, 23 Jun 2019 23:32:12 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5O3Spk8089796; Mon, 24 Jun 2019 03:31:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=A3YM+cC+Wq0vJZp4sQYiwht/JgO/4EqsOgjUe2E6whU=; b=TxOpWlKIsnVIPPJ5kkbrvBXIpgqsCreVVDXDNp4OmOfQMc37slpjNz1uOtLiLlDzWuqu +ohtQCwjzqAjnnnH7U6ytnTh0ZcepCtB9v21i60i9eeNfvCk7xkZoNgvpRJ9j21km0L0 pDkQWMKTpu23rsuKD7OlIbtv/nL89oyNgqAvPaoQg9p6jLWHGAPSPL/YcAYGS7Is5XAw y0Yi+65kNHmKp3qQ6Dhp62zWQwfqe4vytQ4oArtVx7cDYx+ASkBClX4ycWqogwu6JCS3 IM1kcg39neXmA0B+UMRNlLHibqDHOh+SNqoRNII583OBiCoBsDJccWxOTdT1U4mRIspw Cw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2t9brsuudb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2019 03:31:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5O3TnFJ082269; Mon, 24 Jun 2019 03:31:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2t99f3201a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Jun 2019 03:31:44 +0000 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 x5O3Vb8g019004; Mon, 24 Jun 2019 03:31:39 GMT Received: from z2.cn.oracle.com (/10.182.69.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 23 Jun 2019 20:31:37 -0700 From: Zhenzhong Duan To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, mingo@kernel.org, bp@alien8.de, x86@kernel.org, hpa@zytor.com, jgross@suse.com, ndesaulniers@google.com, gregkh@linuxfoundation.org, Zhenzhong Duan Subject: [PATCH] x86/speculation/mds: Avoid clearing CPU buffers in native machine with old microcode Date: Sun, 23 Jun 2019 11:35:03 +0800 Message-Id: <1561260904-29669-1-git-send-email-zhenzhong.duan@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9297 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=838 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906240027 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9297 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=893 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906240027 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 22dd8365088b ("x86/speculation/mds: Add mitigation mode VMWERV") add an internal mitigation mode VWWERV which enables the invocation of the CPU buffer clearing even if X86_FEATURE_MD_CLEAR is not set. This wastes a few CPU cycles for native machine with an old microcode unnecessorily. Avoid it by checking if it's running in native machine. Signed-off-by: Zhenzhong Duan --- arch/x86/kernel/cpu/bugs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 03b4cc0..03f5a77 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -233,7 +233,9 @@ static void x86_amd_ssb_disable(void) static void __init mds_select_mitigation(void) { - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) { + if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off() || + (hypervisor_is_type(X86_HYPER_NATIVE) && + !boot_cpu_has(X86_FEATURE_MD_CLEAR))) { mds_mitigation = MDS_MITIGATION_OFF; return; } -- 1.8.3.1