Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp415758pxj; Thu, 20 May 2021 12:17:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8VEETj+NDQnYCmXSBr0wUmhEOLZ+PIsMJazYaekXvCV5GWbIOvXxifdM/f+B1pqbgU87P X-Received: by 2002:a17:907:920e:: with SMTP id ka14mr6266143ejb.193.1621538262620; Thu, 20 May 2021 12:17:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538262; cv=none; d=google.com; s=arc-20160816; b=F8Xa5ge0jgZv1qxlA7/5qT2Lj3GmnkUajh2+bV7CJvgaDA80kYn8x2VZ/NwwXl6wOb i7WxQibc1wX+cS6jFRFSqmEoB0/TqtjBTQpTni342rhzMsDrZ2upjXuKc2LdA0TTumMQ MXXcrC7zaCEgkPxTCo2OULkh8IM9j0ItjZ04fLTBKVVEuWA8PiV83GGim+KDDHWLja3U CW5Nr+c8rG8oJdr9l2w0c+NoWTP6GOgrz1VfEPTck9lx5UssLPDbRYZipcuHIMl3zbgK nRAwQRC2oB6pz1Gu1Zn8X/vq65d0julrekbfO730vVKX6qR6CptuPKVfnnCn5w8/jNpN KBng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tFE3jDJP2zq2T6JZKSpUO/NB57RCmarWP0q3dWedpu8=; b=OwthgvhiNgTo1l2Kke9g8rVFxs7vjMIlJiW+7O70UUmKjePZwhfrMN2bw8Zn9WXcjL vwjGl4zxUxivv2UvlWbIyB+ZUpo6/nwLC71qYr6RKOlGFIc4td8I+g69lkT1AcgrEunz WjE1AAm+ObjehFvyQCvkw/6jWZ94sRwxW2DQpDaQGKv1XFOrdvwAsk6zgjp4PaXUFAPE pdY0+ApK9gJeKCcHluz2SbyP2pptsVTj/bEEeIkb1S6ZmiXYsxyEsXPXg8wxvFPEVRcr MvlhDIggJ/DPHDihostFEml6cWE96yTpT36kWGx4REG6UFHyJbnPk9mPxNoU3+Grruy7 FxRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADnrNaCY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gh7si3399088ejb.387.2021.05.20.12.17.19; Thu, 20 May 2021 12:17:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADnrNaCY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236276AbhETKnx (ORCPT + 99 others); Thu, 20 May 2021 06:43:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:55902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236579AbhETK2r (ORCPT ); Thu, 20 May 2021 06:28:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B10D561C35; Thu, 20 May 2021 09:51:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504266; bh=x1S1tk8e4qo3ieI9GVN1SbYi1rrOISifk0sPD6tKviQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ADnrNaCY96oo2FWov9AxRPFn/RRvfw/ZK1pkQfHcXZWinzyd5nSXCE1nNc4leLpDu yKTALNsJxXO26ES/37WQIA5YDX70DOOZqf99xKRdFGY9Az1kNa535n0SH2iCTjrpVt H2V1W84B1DyYef5n4DjsiRMVQjZ62oUaft5T8Ze0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Thomas Gleixner Subject: [PATCH 4.14 133/323] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Date: Thu, 20 May 2021 11:20:25 +0200 Message-Id: <20210520092124.668398382@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit b6b4fbd90b155a0025223df2c137af8a701d53b3 upstream. Initialize MSR_TSC_AUX with CPU node information if RDTSCP or RDPID is supported. This fixes a bug where vdso_read_cpunode() will read garbage via RDPID if RDPID is supported but RDTSCP is not. While no known CPU supports RDPID but not RDTSCP, both Intel's SDM and AMD's APM allow for RDPID to exist without RDTSCP, e.g. it's technically a legal CPU model for a virtual machine. Note, technically MSR_TSC_AUX could be initialized if and only if RDPID is supported since RDTSCP is currently not used to retrieve the CPU node. But, the cost of the superfluous WRMSR is negigible, whereas leaving MSR_TSC_AUX uninitialized is just asking for future breakage if someone decides to utilize RDTSCP. Fixes: a582c540ac1b ("x86/vdso: Use RDPID in preference to LSL when available") Signed-off-by: Sean Christopherson Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20210504225632.1532621-2-seanjc@google.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/entry/vdso/vma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -342,7 +342,7 @@ static void vgetcpu_cpu_init(void *arg) #ifdef CONFIG_NUMA node = cpu_to_node(cpu); #endif - if (static_cpu_has(X86_FEATURE_RDTSCP)) + if (boot_cpu_has(X86_FEATURE_RDTSCP) || boot_cpu_has(X86_FEATURE_RDPID)) write_rdtscp_aux((node << 12) | cpu); /*