From owner-freebsd-amd64@freebsd.org Wed Jun 13 10:35:48 2018 Return-Path: Delivered-To: freebsd-amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D363101E361 for ; Wed, 13 Jun 2018 10:35:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id AD7877A0A8 for ; Wed, 13 Jun 2018 10:35:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 712CA101E360; Wed, 13 Jun 2018 10:35:47 +0000 (UTC) Delivered-To: amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5E8C5101E35E; Wed, 13 Jun 2018 10:35:47 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD3667A0A5; Wed, 13 Jun 2018 10:35:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTP id w5DAZZN9025551; Wed, 13 Jun 2018 13:35:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w5DAZZN9025551 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w5DAZZCE025550; Wed, 13 Jun 2018 13:35:35 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 13 Jun 2018 13:35:35 +0300 From: Konstantin Belousov To: current@freebsd.org, amd64@freebsd.org Subject: Ryzen public erratas Message-ID: <20180613103535.GP2493@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 10:35:48 -0000 Today I noted that AMD published the public errata document for Ryzens, https://developer.amd.com/wp-content/resources/55449_1.12.pdf Some of the issues listed there looks quite relevant to the potential hangs that some people still experience with the machines. I wrote a script which should apply the recommended workarounds to the erratas that I find interesting. To run it, kldload cpuctl, then apply the latest firmware update to your CPU, then run the following shell script. Comments indicate the errata number for the workarounds. Please report the results. If the script helps, I will code the kernel change to apply the workarounds. #!/bin/sh # Enable workarounds for erratas listed in # https://developer.amd.com/wp-content/resources/55449_1.12.pdf # 1057, 1109 sysctl machdep.idle_mwait=0 sysctl machdep.idle=hlt for x in /dev/cpuctl*; do # 1021 cpucontrol -m '0xc0011029|=0x2000' $x # 1033 cpucontrol -m '0xc0011020|=0x10' $x # 1049 cpucontrol -m '0xc0011028|=0x10' $x # 1095 cpucontrol -m '0xc0011020|=0x200000000000000' $x done From owner-freebsd-amd64@freebsd.org Wed Jun 13 11:46:38 2018 Return-Path: Delivered-To: freebsd-amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09E9C1001258 for ; Wed, 13 Jun 2018 11:46:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 9DA287D093 for ; Wed, 13 Jun 2018 11:46:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id 5E7A11001255; Wed, 13 Jun 2018 11:46:37 +0000 (UTC) Delivered-To: amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CC421001253; Wed, 13 Jun 2018 11:46:37 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD5627D090; Wed, 13 Jun 2018 11:46:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTP id w5DBkPlW041391; Wed, 13 Jun 2018 14:46:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w5DBkPlW041391 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w5DBkPFv041390; Wed, 13 Jun 2018 14:46:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 13 Jun 2018 14:46:25 +0300 From: Konstantin Belousov To: Johannes Lundberg Cc: current@freebsd.org, amd64@freebsd.org Subject: Re: Ryzen public erratas Message-ID: <20180613114625.GQ2493@kib.kiev.ua> References: <20180613103535.GP2493@kib.kiev.ua> <86602neyil.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86602neyil.fsf@gmail.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 11:46:38 -0000 On Wed, Jun 13, 2018 at 12:06:42PM +0100, Johannes Lundberg wrote: > > Konstantin Belousov writes: > > > Today I noted that AMD published the public errata document for Ryzens, > > https://developer.amd.com/wp-content/resources/55449_1.12.pdf > > > > Some of the issues listed there looks quite relevant to the potential > > hangs that some people still experience with the machines. I wrote > > a script which should apply the recommended workarounds to the erratas > > that I find interesting. > > > > To run it, kldload cpuctl, then apply the latest firmware update to your > > CPU, then run the following shell script. Comments indicate the errata > > number for the workarounds. > > > > Please report the results. If the script helps, I will code the kernel > > change to apply the workarounds. > > > > #!/bin/sh > > > > # Enable workarounds for erratas listed in > > # https://developer.amd.com/wp-content/resources/55449_1.12.pdf > > > > # 1057, 1109 > > sysctl machdep.idle_mwait=0 > > sysctl machdep.idle=hlt > > > > for x in /dev/cpuctl*; do > > # 1021 > > cpucontrol -m '0xc0011029|=0x2000' $x > > # 1033 > > cpucontrol -m '0xc0011020|=0x10' $x > > # 1049 > > cpucontrol -m '0xc0011028|=0x10' $x > > # 1095 > > cpucontrol -m '0xc0011020|=0x200000000000000' $x > > done > > > > Hi > > Thanks for the fix! I'm trying it now on my Ryzen 3 2200G which does > experience some random occasional resets. > > About updating to latest firmware, is this something that's done from BIOS or > from FreeBSD? If the latter, how? >From FreeBSD, install sysutils/devcpu-data then do service microcode_update start and of course, you must flash latest BIOS. The microcode_update must be applied before running this script. From owner-freebsd-amd64@freebsd.org Wed Jun 13 14:53:00 2018 Return-Path: Delivered-To: freebsd-amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A7D881012A2F for ; Wed, 13 Jun 2018 14:53:00 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 3E16A874CD for ; Wed, 13 Jun 2018 14:53:00 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: by mailman.ysv.freebsd.org (Postfix) id E8ED81012A2B; Wed, 13 Jun 2018 14:52:59 +0000 (UTC) Delivered-To: amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8D161012A29; Wed, 13 Jun 2018 14:52:59 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0BFC8874CA; Wed, 13 Jun 2018 14:52:59 +0000 (UTC) (envelope-from gljennjohn@gmail.com) Received: by mail-wm0-x22f.google.com with SMTP id o13-v6so5220491wmf.4; Wed, 13 Jun 2018 07:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=dlugMqoBAywqHlORwN7t9qE5Bs/992NHxpymo7ZrP40=; b=cLZ6J3i+cgmLDF/8YudonxgJaewPlsQjot83ursrsO0t6jmSy5oHjtpBSZZcge9D+K PVME1NPza4NAh+sINx4hHlaDq6YPbWHjPil45R6a6BGj39O4EcnfQkerLtqm52iYoeMr FCfnpKaVO7ce0vRgXNblDBFes//pdxmEVuEINYuddg+dPa4LhEiJIgFcCEOUZig5MDF6 i9ExAXmewj2CpCCpbfISUL6JWtPYlJeYtraXgyicyGEUtJ14GmQtyKVBb36ei2tBlt5A 9BfnIEx0k2nvZELGZHg7Wwbt0kHuVEoRCk3b0FCvv9SqmTRRFZuh8bFvesdOuBMtVMRk vABA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=dlugMqoBAywqHlORwN7t9qE5Bs/992NHxpymo7ZrP40=; b=VoA7nm0+t0N8yH2E9JKjPGAXpmeDSohsJM/nGBYbY7pbuJmENrV471Q5ig1J+bJ4Ny NPXQtrldC530tWINR3NhJUOhKeK4oK/bHtZuP/ouRZuzZGgvLm0d4cvY2TOpjvyMwtq6 dY5ZRK9AnTTa0w/1u03yIldmWqnFYxovyjVopd0jlLr3I0akre44nsGhjF6ZpCsdSrSr i1psBB0foGRFKOSNyFKYhT3h803Djxm3vMxUCdtKMv7PoH79+In8i+/D4uFBpV6b0a+N V1NWqJetHx1Ci+fK+20ihqQUx2NM6Ue5V+kyRQ41jyJbvZsZVDicds+EdHgdMh81ajJ/ iqvg== X-Gm-Message-State: APt69E1tX4B2Re8uTRXmxGEpohAwoJIaQ+5pOuMu9c0eFSXDzFjCyHm8 0QTbkrDm9kzVOp0r+y90WFw= X-Google-Smtp-Source: ADUXVKKIYG0TKYjlgvW0uwdJs7dPk9WeiVI4vWTCTMK1c99XW4jJgRTFQw+l12XKWPkb8mLhSsb1sw== X-Received: by 2002:a1c:934e:: with SMTP id v75-v6mr4149088wmd.52.1528901578077; Wed, 13 Jun 2018 07:52:58 -0700 (PDT) Received: from ernst.home (p5B02381D.dip0.t-ipconnect.de. [91.2.56.29]) by smtp.gmail.com with ESMTPSA id w67-v6sm3795476wmw.0.2018.06.13.07.52.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 07:52:57 -0700 (PDT) Date: Wed, 13 Jun 2018 16:52:56 +0200 From: Gary Jennejohn To: Konstantin Belousov Cc: Johannes Lundberg , amd64@freebsd.org, current@freebsd.org Subject: Re: Ryzen public erratas Message-ID: <20180613165256.2b0dac0d@ernst.home> In-Reply-To: <20180613114625.GQ2493@kib.kiev.ua> References: <20180613103535.GP2493@kib.kiev.ua> <86602neyil.fsf@gmail.com> <20180613114625.GQ2493@kib.kiev.ua> Reply-To: gljennjohn@gmail.com X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2018 14:53:00 -0000 On Wed, 13 Jun 2018 14:46:25 +0300 Konstantin Belousov wrote: > On Wed, Jun 13, 2018 at 12:06:42PM +0100, Johannes Lundberg wrote: > > > > Konstantin Belousov writes: > > > > > Today I noted that AMD published the public errata document for Ryzens, > > > https://developer.amd.com/wp-content/resources/55449_1.12.pdf > > > > > > Some of the issues listed there looks quite relevant to the potential > > > hangs that some people still experience with the machines. I wrote > > > a script which should apply the recommended workarounds to the erratas > > > that I find interesting. > > > > > > To run it, kldload cpuctl, then apply the latest firmware update to your > > > CPU, then run the following shell script. Comments indicate the errata > > > number for the workarounds. > > > > > > Please report the results. If the script helps, I will code the kernel > > > change to apply the workarounds. > > > > > > #!/bin/sh > > > > > > # Enable workarounds for erratas listed in > > > # https://developer.amd.com/wp-content/resources/55449_1.12.pdf > > > > > > # 1057, 1109 > > > sysctl machdep.idle_mwait=0 > > > sysctl machdep.idle=hlt > > > > > > for x in /dev/cpuctl*; do > > > # 1021 > > > cpucontrol -m '0xc0011029|=0x2000' $x > > > # 1033 > > > cpucontrol -m '0xc0011020|=0x10' $x > > > # 1049 > > > cpucontrol -m '0xc0011028|=0x10' $x > > > # 1095 > > > cpucontrol -m '0xc0011020|=0x200000000000000' $x > > > done > > > > > > > Hi > > > > Thanks for the fix! I'm trying it now on my Ryzen 3 2200G which does > > experience some random occasional resets. > > > > About updating to latest firmware, is this something that's done from BIOS or > > from FreeBSD? If the latter, how? > From FreeBSD, install sysutils/devcpu-data then do > service microcode_update start > and of course, you must flash latest BIOS. > > The microcode_update must be applied before running this script. > I added before and after outputs to my version of the script and saw that my BIOS is setting all the relevant bits at start up. So, a BIOS update might help. -- Gary Jennejohn