Received: by 10.223.176.5 with SMTP id f5csp3434220wra; Mon, 29 Jan 2018 13:07:29 -0800 (PST) X-Google-Smtp-Source: AH8x227/+ZFUB6h1KoChneKoadnyPG587gH01I8BSPuB/gwXVKnFGBrgoqsAdEJeuOVUuwRsf82b X-Received: by 2002:a17:902:7889:: with SMTP id q9-v6mr2633396pll.114.1517260049079; Mon, 29 Jan 2018 13:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260049; cv=none; d=google.com; s=arc-20160816; b=zU4QQXxvCKEmdCQrAHoWjzdLnTs5z5XLDTD9fpTAARtCqA5zTobxh96l4vyWynN8YA U5n3A9G0rWzzRQHn4cpU1hMouvsvf5XZQ+h9jOH8DoS3VMQufqXZNnSWmiGZCwgQ08Hi Q5HjX1orqoY6TXW8iDiz31emqMZtR6M7oU5mg7djaF03j/tLxBb1GB4N5Ro4DIueH7gL hYeo0QbvuAume9mMmWVjpvwrHvBCm+aXHEVBYbk6ymiK7bHlb+S9TrXxiH1LSSq+296G a8B5sQsuzjmbd7Ow5OJjjzb1nVWw9e4RlBWEGcx7RfRmrd2t5VdaVhEOD/ale5SIVinE 5Z4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ecYGfw8zovGK4A61xKfqnoUHMBagT9qjaCmrwstnHKc=; b=xAvhNpOogwSk9G6rrGyGoaPX5dwNNdHqXEWBoYu4iAGkltRMRCZp3qfSbZxy/5YCRq 2qBkrA54b8y3Hf9u3nNxnL9ohi6zrMJVRhJ/6BEEMk8UbRFtNxy/EROMSQTJnSS8UUhc bbNZDb3CCcvEEjC++JKrwDL0OotjdJgmTpQQy8UThmhXfZNlyaIYofYPXVekhOSwiZsC LC5MCirvleXOlcoC2x2d1qPfHThOPZ+haZq0mvN7N0cA18otyG1iYosYnmTIWxdRlmhi PeG6v9C5H4OpwoYQ9mQvoyfRMrS/He1wsTrLzQI0cChP5sGCkwQ6TqhW63j1XHkQLo5B /AFg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4-v6si308213plb.415.2018.01.29.13.07.14; Mon, 29 Jan 2018 13:07:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751800AbeA2VGw (ORCPT + 99 others); Mon, 29 Jan 2018 16:06:52 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48578 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752755AbeA2UGi (ORCPT ); Mon, 29 Jan 2018 15:06:38 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7D7812F5A; Mon, 29 Jan 2018 13:04:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janakarajan Natarajan , Thomas Gleixner , Davidlohr Bueso Subject: [PATCH 4.9 10/66] Prevent timer value 0 for MWAITX Date: Mon, 29 Jan 2018 13:56:34 +0100 Message-Id: <20180129123840.369359665@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Janakarajan Natarajan commit 88d879d29f9cc0de2d930b584285638cdada6625 upstream. Newer hardware has uncovered a bug in the software implementation of using MWAITX for the delay function. A value of 0 for the timer is meant to indicate that a timeout will not be used to exit MWAITX. On newer hardware this can result in MWAITX never returning, resulting in NMI soft lockup messages being printed. On older hardware, some of the other conditions under which MWAITX can exit masked this issue. The AMD APM does not currently document this and will be updated. Please refer to http://marc.info/?l=kvm&m=148950623231140 for information regarding NMI soft lockup messages on an AMD Ryzen 1800X. This has been root-caused as a 0 passed to MWAITX causing it to wait indefinitely. This change has the added benefit of avoiding the unnecessary setup of MONITORX/MWAITX when the delay value is zero. Signed-off-by: Janakarajan Natarajan Link: http://lkml.kernel.org/r/1493156643-29366-1-git-send-email-Janakarajan.Natarajan@amd.com Signed-off-by: Thomas Gleixner Signed-off-by: Davidlohr Bueso Signed-off-by: Greg Kroah-Hartman --- arch/x86/lib/delay.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -93,6 +93,13 @@ static void delay_mwaitx(unsigned long _ { u64 start, end, delay, loops = __loops; + /* + * Timer value of 0 causes MWAITX to wait indefinitely, unless there + * is a store on the memory monitored by MONITORX. + */ + if (loops == 0) + return; + start = rdtsc_ordered(); for (;;) {