Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2468142pxj; Mon, 10 May 2021 03:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQqQBaOYzp/MEkw81ZSpe92QHtyMdM6OfgQ2nz5vtpo/xe3i+vH2RK2+UYT6cftxJr33bU X-Received: by 2002:a05:6e02:4c4:: with SMTP id f4mr21256561ils.272.1620643818298; Mon, 10 May 2021 03:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643818; cv=none; d=google.com; s=arc-20160816; b=baKene0dh/hK+RGaudTyS+GjQ6TOs0X65FeBW29cIyzEwOX/dUWVMVZLprpLTXhpOJ aIIUm1AgMSg9oifPKQerpf9t9mHsQAHMq9gu86sfCLG+OKigdbexqVzRtehfbXOfrLse d8Gtv+9/kztdtssgriIqGnnGO2cEYkjErJlC+uBHoAR92vLY5m3KuYFfIxtJ2BYWMAUw myALbtmpIyu3fYFWLSCyFEuXrG1EqJF4nnspbva0S1WAg52qFYxp/DcFk0Gc4DLp5uP5 XGeA0vvckbxc7EExnv+a72c6vTBGFOlN4Xjutb81w5To+2qhd+eC24icTO47PmB1jRVU ExVQ== 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=yZKmgGXAcFnD0/kv4gyu1qxZwKWbbrNdVWzU9nA6BBQ=; b=A2wkW62sFEBaFZ1KVmD9iyIDHFe09MCENz8fMahurVXQWU4zwbP85wOuAUbOdK8lzW Zz5ZvGJCl0XsIXQ4z+y7jcEt0dYrL9L82nAXyTMD0CHGGzkSHPvMZJR47e8SFkRKGnRL 1pP5icE+12IUlKmFBK+19f7h8Zj90CzWiDweX5/r5ff4ril4NlwLe/CN8iE01RUpb9S0 cOeCL+aF1kjwD5M+2KO8CDj6blamFqIgUnyWxnpcfAYd4pHQamBskqit2v0nXgDbCa8J DtteAM52epJVwDp0eFhARL0xiwv5P2773PVkiaqG2DSZAxtOwyLFuvOwhjYReRIyekFn P+rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WfiN325m; 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 l24si14352192ioh.105.2021.05.10.03.50.05; Mon, 10 May 2021 03:50:18 -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=WfiN325m; 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 S231811AbhEJKsH (ORCPT + 99 others); Mon, 10 May 2021 06:48:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48608 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232689AbhEJKj5 (ORCPT ); Mon, 10 May 2021 06:39:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0D59661954; Mon, 10 May 2021 10:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642644; bh=gxq7gGt4IgZfu9p1k1PTXhjCiVRyzyxBGCeCGeOgUXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WfiN325maFB4JbLWfPsPcdbpCbUN5m299RrB6Zym1xTfUfHFkH7UoM3z6EGmKYVzo AUbK1fHiUU2d9683cdbduAaRoBmGgRjWgVIkhalYzw75Z9tEmyx1fkKyUrqhLBLZba QpVux18HZsUl6sj7pIaEnLaRdnSljfc/hVDo7hvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Thomas Gleixner Subject: [PATCH 5.4 161/184] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Date: Mon, 10 May 2021 12:20:55 +0200 Message-Id: <20210510101955.392151859@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510101950.200777181@linuxfoundation.org> References: <20210510101950.200777181@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/kernel/cpu/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1826,7 +1826,7 @@ static void setup_getcpu(int cpu) unsigned long cpudata = vdso_encode_cpunode(cpu, early_cpu_to_node(cpu)); struct desc_struct d = { }; - if (boot_cpu_has(X86_FEATURE_RDTSCP)) + if (boot_cpu_has(X86_FEATURE_RDTSCP) || boot_cpu_has(X86_FEATURE_RDPID)) write_rdtscp_aux(cpudata); /* Store CPU and node number in limit. */