From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C429DC432C3 for ; Thu, 14 Nov 2019 20:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D95020725 for ; Thu, 14 Nov 2019 20:35:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ig7fLC+a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbfKNUfb (ORCPT ); Thu, 14 Nov 2019 15:35:31 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23571 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726533AbfKNUfb (ORCPT ); Thu, 14 Nov 2019 15:35:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573763729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wz78dwaxpm4rR8noHiumwhs8zmjexVrjlYPQCaWOjVU=; b=Ig7fLC+aaD9hzvPqnq14vgAR7KQzjL9NTnDPpHXuomtizCiktEmT1ZnEHX934/ZBIu8B3e wNuR8HHz0OBxQ0/9yQhmKJynbJ58ydkSDDxYdD7si7t8HrPVLigDqNBwtO28NmsIjv3J0F jj1GSfFY/UhuBp15+z3SvdR/ETgZtC8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-326-jUVu9U6sOhSbba59QKGGZw-1; Thu, 14 Nov 2019 15:35:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9D80100550E; Thu, 14 Nov 2019 20:35:24 +0000 (UTC) Received: from treble (ovpn-121-52.rdu2.redhat.com [10.10.121.52]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A025F8164; Thu, 14 Nov 2019 20:35:19 +0000 (UTC) Date: Thu, 14 Nov 2019 14:35:17 -0600 From: Josh Poimboeuf To: Pawan Gupta Cc: Waiman Long , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Mark Gross , Tony Luck Subject: Re: [PATCH] x86/speculation: Fix incorrect MDS/TAA mitigation status Message-ID: <20191114203517.su2roiygk4htkpc3@treble> References: <20191113193350.24511-1-longman@redhat.com> <20191114201258.GA18745@guptapadev.amr> MIME-Version: 1.0 In-Reply-To: <20191114201258.GA18745@guptapadev.amr> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: jUVu9U6sOhSbba59QKGGZw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 14, 2019 at 12:12:58PM -0800, Pawan Gupta wrote: > On Wed, Nov 13, 2019 at 02:33:50PM -0500, Waiman Long wrote: > > For MDS vulnerable processors with TSX support, enabling either MDS > > or TAA mitigations will enable the use of VERW to flush internal > > processor buffers at the right code path. IOW, they are either both > > mitigated or both not mitigated. However, if the command line options > > are inconsistent, the vulnerabilites sysfs files may not report the > > mitigation status correctly. > >=20 > > For example, with only the "mds=3Doff" option: > >=20 > > vulnerabilities/mds:Vulnerable; SMT vulnerable > > vulnerabilities/tsx_async_abort:Mitigation: Clear CPU buffers; SMT vu= lnerable > >=20 > > The mds vulnerabilities file has wrong status in this case. > >=20 > > Change taa_select_mitigation() to sync up the two mitigation status > > and have them turned off if both "mds=3Doff" and "tsx_async_abort=3Doff= " > > are present. > >=20 > > Signed-off-by: Waiman Long > > --- > > arch/x86/kernel/cpu/bugs.c | 17 +++++++++++++++-- > > 1 file changed, 15 insertions(+), 2 deletions(-) > >=20 > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > > index 4c7b0fa15a19..418d41c1fd0d 100644 > > --- a/arch/x86/kernel/cpu/bugs.c > > +++ b/arch/x86/kernel/cpu/bugs.c > > @@ -304,8 +304,12 @@ static void __init taa_select_mitigation(void) > > =09=09return; > > =09} > > =20 > > -=09/* TAA mitigation is turned off on the cmdline (tsx_async_abort=3Do= ff) */ > > -=09if (taa_mitigation =3D=3D TAA_MITIGATION_OFF) > > +=09/* > > +=09 * TAA mitigation via VERW is turned off if both > > +=09 * tsx_async_abort=3Doff and mds=3Doff are specified. > > +=09 */ > > +=09if (taa_mitigation =3D=3D TAA_MITIGATION_OFF && > > +=09 mds_mitigation =3D=3D MDS_MITIGATION_OFF) > > =09=09goto out; > > =20 > > =09if (boot_cpu_has(X86_FEATURE_MD_CLEAR)) > > @@ -339,6 +343,15 @@ static void __init taa_select_mitigation(void) > > =09if (taa_nosmt || cpu_mitigations_auto_nosmt()) > > =09=09cpu_smt_disable(false); > > =20 > > +=09/* > > +=09 * Update MDS mitigation, if necessary, as the mds_user_clear is > > +=09 * now enabled for TAA mitigation. > > +=09 */ > > +=09if (mds_mitigation =3D=3D MDS_MITIGATION_OFF && > > +=09 boot_cpu_has_bug(X86_BUG_MDS)) { > > +=09=09mds_mitigation =3D MDS_MITIGATION_FULL; > > +=09=09mds_select_mitigation(); >=20 > This will cause a confusing print in dmesg from previous and this call > to mds_select_mitigation(). >=20 > =09"MDS: Vulnerable" > =09"MDS: Mitigation: Clear CPU buffers" >=20 > Maybe delay MDS mitigation print till TAA is evaluated. Since they're so intertwined it might make sense to just combine the two mitigations into a single function. --=20 Josh