Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp818780pxb; Thu, 17 Feb 2022 15:43:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyos8AliKQWhy0oeDwup5maIacDaqZ0W4CKlz0MF0ebP9uub0/jilVNtb6G+ChhZAZMRmgO X-Received: by 2002:a17:903:291:b0:14d:522c:fe3d with SMTP id j17-20020a170903029100b0014d522cfe3dmr5001553plr.100.1645141402186; Thu, 17 Feb 2022 15:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645141402; cv=none; d=google.com; s=arc-20160816; b=Z0o//mMJdjSvHYOgcgn4AQRIeade8ngHp7Md4MRaNb+hjseVhfKFrsGPv7OZ0X0DGg jBMCZOINFt5c+Pp0vCsq/Y2H17n9aZCOAqtoG8Nvk89RhMK1Tz6lgpJr6JR75yIuL0mJ BK09DKNj+z4sz/9kJci4hEiyJaFbesV4x6gbpzzKhBuzSkKGlOc9MmOsbgVQJ9oQ9X8f cAi/SLohTW+iOSmYliB/tKh9aqqm7arJ+41qL/sX2zhzqHO0bBvI+UHFMbppMDnNcemW 68Ihfth/yKYhIbMkK+5NL8+OXDNZP+nzDUcqrF9QmiGgGczLeUZv45vLEoAfok5bM8AO zdvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GEMXnFkd4n8W4nnufiYYxj/WrSmsnfwoOjRtO415OSw=; b=ryPIGljcpqMeLe172NThB16IviOQIGxnFFYN9C+U6IV0c4O+PrTB1Tl9w4iC8VH8O5 pSNk5EoiocF7Pf/ks9G9w7jdp2ZHOSf/0eYBXjkPmVXDiI4jFTag/lQiFTmQPP5iurf3 xqEQS0EgDRyNyNPAlRM8xcQYog2VfgB/o+ApW8givn3xPR73XaKVnSr1kCQUF9CGCRAc xvdy2EQmQVNm2nadhZBTK2K0+hKm0SNtaJ2qoomg3ktvdfMmmlMo8DPcNrsURQl51dij kj+Fmdwn934YZlggwsR/DIb5aAeM2sE5AQBsvqtOpsRujObleGKwdL66/2fp7AIbcmAm km+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=hWwBcxGU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e13si12279576plo.543.2022.02.17.15.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:43:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=hWwBcxGU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A658733EB6; Thu, 17 Feb 2022 15:20:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243249AbiBQQbU (ORCPT + 99 others); Thu, 17 Feb 2022 11:31:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235842AbiBQQbS (ORCPT ); Thu, 17 Feb 2022 11:31:18 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B372F1B061E for ; Thu, 17 Feb 2022 08:31:02 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4DAEF1EC0304; Thu, 17 Feb 2022 17:30:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1645115457; 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:in-reply-to:in-reply-to: references:references; bh=GEMXnFkd4n8W4nnufiYYxj/WrSmsnfwoOjRtO415OSw=; b=hWwBcxGUB+kqzgL3CyVJ2V8lnTPpzOsDp4vJrTz4/KLjoqnDT6s41R+qYoZEs6ZJZRlTfA 4ItbM1plYVjIYXzza2mYFtb/HbTowU1rjokxcx7dqjD1S469xkmvzychTlU/HjSaXOuQwN j1duv9I48k8O7xZyJN5uvOgsJRB9X88= Date: Thu, 17 Feb 2022 17:30:57 +0100 From: Borislav Petkov To: Jue Wang Cc: Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH] x86/mce: work around an erratum on fast string copy instructions. Message-ID: References: <20220216215313.1707663-1-juew@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220216215313.1707663-1-juew@google.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 16, 2022 at 01:53:13PM -0800, Jue Wang wrote: > Subject: Re: [PATCH] x86/mce: work around an erratum on fast string copy When sending a new version of the patch, make sure you add it to the subject so that I know which one is the newest: [PATCH -v] x86/mce: Work around an erratum with fast string copy instructions > +static noinstr bool quirk_skylake_repmov(void) > +{ > + u64 mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); > + u64 misc_enable = __rdmsr(MSR_IA32_MISC_ENABLE); > + > + // Only applies the quirk to local machine checks, i.e., no broadcast > + // sync is needed. > + if ((mcgstatus & MCG_STATUS_LMCES) && > + unlikely(misc_enable & MSR_IA32_MISC_ENABLE_FAST_STRING)) { > + u64 mc1_status = mce_rdmsrl(MSR_IA32_MCx_STATUS(1)); > + > + // The blob of logic below is checking for a software > + // recoverable data fetch error. > + if ((mc1_status & > + (MCI_STATUS_VAL | MCI_STATUS_OVER | MCI_STATUS_UC | MCI_STATUS_EN | > + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | MCI_STATUS_PCC | > + MCI_STATUS_AR | MCI_STATUS_S)) == > + (MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | > + MCI_STATUS_ADDRV | MCI_STATUS_MISCV | > + MCI_STATUS_AR | MCI_STATUS_S)) { > + msr_clear_bit(MSR_IA32_MISC_ENABLE, > + MSR_IA32_MISC_ENABLE_FAST_STRING_BIT); With CONFIG_KASAN=y and CONFIG_DEBUG_ENTRY=y: vmlinux.o: warning: objtool: quirk_skylake_repmov()+0x4d: call to msr_clear_bit() leaves .noinstr.text section You're going to have to use the mce_{rd,wr}msrl() routines. > + mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); > + mce_wrmsrl(MSR_IA32_MCx_STATUS(1), 0); > + pr_err_once("Errata detected, disable fast string copy instructions.\n"); > + return true; > + } > + } > + return false; > +} -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette