Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1346652ybp; Thu, 17 Oct 2019 11:23:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6pqTkH1S9360pj8Eb5HXV7E0F1ty9BrtbG1ZhygS6PiGe59rWIIBTUh0Soyqp/9nmD2CI X-Received: by 2002:a05:6402:21c2:: with SMTP id bi2mr5326294edb.8.1571336610646; Thu, 17 Oct 2019 11:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336610; cv=none; d=google.com; s=arc-20160816; b=oKZcFifxSVuwJOJaMjVNr/I/9XlVovp/eeBMakn1HdKctP28vwUYwDzWTAsiQ+cr8B jlqBYrRF37GbbaiHOcRQiWuQ3NkXZ/QgH+VORRxanHxK5OhdQ255L7APfaAhp2pNBFMC 92S9dTMTLwoNTM22fqU3sxVOPu0sZymL5HBnx49oK5BhrdOy5SVFccRMOa4RsWtcl2nc d/WbWMvCvpcUmiiKynU/UIgdNQO8c1HaN3AUDs1S3NEN5OaEbq1idG5Zrss601XFj08D 4+o0yMzv9M1cU91i5xHcTy/DphmoKTKItiM+BBRC5nXQtgrVvkXMH/XMEA4MmQiV/bTr QTLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SCrsJYfMjrye+fYzNTHm7K+43D6g4fLXwra+yOhVrR8=; b=bEYntdj2pkiLzwQ1I4I1yXWsq6vZsT4GwqKDn5bDQidhT600mHJtWNY4klB+Zy4BjW OIhtBahKTQ+Pl3/zoiUVa2keRnKg1iK7xAsPv2T0d6FVzQWjHxOcJhca4WR2ZAwhG9Ov zexNpyYaugv4xy6ROcramVs6yJx8zFBPiwNX3g5ZmYjMw1CP7ITRJgj6GesVSHO2+4ff wMDFvFEA5V5WbKHEJCneWh9hNi4SP6y/3BPwjusgUpCNYqFxYzz5IPVT95lXTMLy8C1S tIORlMIvVreTNXYGyVznMw6LkOlLc6fXQT+Vz+0r64vVNmR7gj1HKX6K83V/9PrZFIvh fm/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s6O2b8de; 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 e10si1800318ejr.222.2019.10.17.11.23.07; Thu, 17 Oct 2019 11:23:30 -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=@kernel.org header.s=default header.b=s6O2b8de; 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 S2439018AbfJPWCd (ORCPT + 99 others); Wed, 16 Oct 2019 18:02:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:54800 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438600AbfJPV7m (ORCPT ); Wed, 16 Oct 2019 17:59:42 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3438D222BE; Wed, 16 Oct 2019 21:59:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263182; bh=HdPM/9FoLj8uItAc5KmRuQ+e5lvgdJjgzjajg0U+Q1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6O2b8dem6S8ehLrOLrCQDZko2gP1gW/pDUFfwmzraaZwKh/sDr92zdzJLLiWVenA azdb4N5UwMqJ9NGLQyZJO5ddPyyF1TDWIS8j65eLCZ1xerKVO/5lu7GoIZTUtIjdYG rDFuiAngEEFN6LCs2H8jAiOk+XvdeMGeFi/+gnTk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janakarajan Natarajan , Borislav Petkov , Frederic Weisbecker , "H. Peter Anvin" , Ingo Molnar , Thomas Gleixner , "x86@kernel.org" , Zhenzhong Duan , Ingo Molnar Subject: [PATCH 5.3 109/112] x86/asm: Fix MWAITX C-state hint value Date: Wed, 16 Oct 2019 14:51:41 -0700 Message-Id: <20191016214907.369372961@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janakarajan Natarajan commit 454de1e7d970d6bc567686052329e4814842867c upstream. As per "AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions", MWAITX EAX[7:4]+1 specifies the optional hint of the optimized C-state. For C0 state, EAX[7:4] should be set to 0xf. Currently, a value of 0xf is set for EAX[3:0] instead of EAX[7:4]. Fix this by changing MWAITX_DISABLE_CSTATES from 0xf to 0xf0. This hasn't had any implications so far because setting reserved bits in EAX is simply ignored by the CPU. [ bp: Fixup comment in delay_mwaitx() and massage. ] Signed-off-by: Janakarajan Natarajan Signed-off-by: Borislav Petkov Cc: Frederic Weisbecker Cc: Greg Kroah-Hartman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Thomas Gleixner Cc: "x86@kernel.org" Cc: Zhenzhong Duan Cc: Link: https://lkml.kernel.org/r/20191007190011.4859-1-Janakarajan.Natarajan@amd.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/mwait.h | 2 +- arch/x86/lib/delay.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/include/asm/mwait.h +++ b/arch/x86/include/asm/mwait.h @@ -21,7 +21,7 @@ #define MWAIT_ECX_INTERRUPT_BREAK 0x1 #define MWAITX_ECX_TIMER_ENABLE BIT(1) #define MWAITX_MAX_LOOPS ((u32)-1) -#define MWAITX_DISABLE_CSTATES 0xf +#define MWAITX_DISABLE_CSTATES 0xf0 static inline void __monitor(const void *eax, unsigned long ecx, unsigned long edx) --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -113,8 +113,8 @@ static void delay_mwaitx(unsigned long _ __monitorx(raw_cpu_ptr(&cpu_tss_rw), 0, 0); /* - * AMD, like Intel, supports the EAX hint and EAX=0xf - * means, do not enter any deep C-state and we use it + * AMD, like Intel's MWAIT version, supports the EAX hint and + * EAX=0xf0 means, do not enter any deep C-state and we use it * here in delay() to minimize wakeup latency. */ __mwaitx(MWAITX_DISABLE_CSTATES, delay, MWAITX_ECX_TIMER_ENABLE);