Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2521120pxj; Mon, 10 May 2021 05:06:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF0Sq/4pp/d0sRG7Fr2ZvtolugEQGNKN7W3APgL03MMo1QOfS89Xr2qSlee9W1lgRSOjSX X-Received: by 2002:a5d:9a8c:: with SMTP id c12mr17932206iom.166.1620648326119; Mon, 10 May 2021 05:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620648326; cv=none; d=google.com; s=arc-20160816; b=P1mcDBiIIxKcT+KVEXrTJbsaUMVEVhq3JIh/R9g84M1EFMkHLbWEn8VhvoR+GAw8Jf Q8VSuUJsb1+LhUzMohzsDQHTAhEyf3EaZIeokjK0NFRkYQqj3CN8ANptcoh56wlsTbpU DHHuUcDkhMBPN9Bld960FJZQ+xl+FJlXaO7t6I1yWpE9OsUx09Q0jkZ+6RIi91v34ll4 LtYHsWipvqk7IVX9wbyM/84o0EECnH6gXsDyvkXEWJNmXj/VwTX3EGWrRA+R1azp0ypS Dlp0Luq7bASjQhqHJDDIF0bPL6Mt/Jn9jsh03/oAiNYkZt36Hw0Tp6jtXTjCB+8eKLAx 3VDA== 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=3h/K4P89DxyNkLn1w+iU++VTbpKU9NW+LGUxxgDxoG8=; b=cch+O6NkG/QZo3GmkvpXOo9i+WsKHlbNbZTWvTAgqq9w3sYRKzP2OoXibl/dWyrSQ/ DmGpugeqvCjOCX36lhNe6TTI6Ch6Q2DhM1NvKxXF3aniyHgfy33glheaHKELEprajNvr JK8gY8AGhqOVeDYb+uQFYwu5zjUO6Air8eeUPb866rjB0BBuYHX+PBTMIQdibfeCRriJ yaOfVc3EO5VLBiQIhLITUV0XW5y1K1ps9dRFWoABWrjswBGk2M9c7J5yB47NJ0aVQj0W NiG1/oRHdN6R8iCPBNCGi9xvH2WFrN7DY1V0UGZpBuAYGSWFQrc/33/UKlynptYZjoia e/Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ay4/p5YR"; 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 d5si14683091ioq.28.2021.05.10.05.05.12; Mon, 10 May 2021 05:05:26 -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="ay4/p5YR"; 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 S243581AbhEJL4U (ORCPT + 99 others); Mon, 10 May 2021 07:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36852 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235595AbhEJLFl (ORCPT ); Mon, 10 May 2021 07:05:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E42661466; Mon, 10 May 2021 10:55:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644131; bh=tr9yYa5f4GwkbODbc3zriXL7cBsTAh7UDLGF811eowE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ay4/p5YRD2K8ov/wHYSOYE0s9YYo/Id7i13nJzvHFu9/HHzmUAOmpr5YIUOoWa/ke DKl1S8kqiT17a8cVw9ApIMOb1pcKU7CdeWKgxa/aAsiBphHP438xd9hiLePdTkIx2l uXzzNeY9lFRcIg2sYRkEcz1h5i1rOIPlwKgAR7Vw= 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.11 301/342] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Date: Mon, 10 May 2021 12:21:31 +0200 Message-Id: <20210510102020.049655346@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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 @@ -1847,7 +1847,7 @@ static inline 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. */