Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2554548pxj; Mon, 10 May 2021 05:49:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzacDj6Du3QIskoEFncrDiOcbZGwVIm0IvxvqNXDO07ar4wGUza7HKP/HV7ZICea7TRp4j7 X-Received: by 2002:a17:906:6789:: with SMTP id q9mr25965826ejp.295.1620650986118; Mon, 10 May 2021 05:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650986; cv=none; d=google.com; s=arc-20160816; b=QScvX3VfZUfLEgsp3uocp+kDmdr7kCFXaohk/T71C4znXspOptJPq+YfWbN0Wpmy0g Fs9XFmiv9xqtGbEcZRWLRcfG5I8hxLxInC5Y1gFUz9atPvKskNh73KMC1n6pVCrvyvCq OqPz6XYwZS5DFzJAY0oh8WoWVqg6zWVgBQb4kBFHRduBo/clQP2u8KHGAnJp5zG0C5fD XiuYJf0vQVoqgux7T+Gx1vCcboVtn3Ur8XCBsLsKyNss4CSug3IiD6Azooy4k171QcGh BNXqtS8lruu869O1762sFm1clSCbb5FplTynydH+TmmHHlgbQtHCohO6xGqrrRWFbatr 211Q== 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=LWMHkCNmMZ+4Rav7JzQNcW72j6dpoICNrDHZBmGMSMA=; b=LSd8wpMmDC/ywt2TeHnm0GSFSAi4cYXh9m0VzHmLMpkO4TFUflgX2DoVCL3NQz8o42 tvpeB9PlMxMerBnWmdXLg6U+MR2fJpr3aDW68Uh4BQnaPJbsIlUAjwH+rBC+mvNBlAEs HKBtkVyu/rpiCgI72KWkoytSUtD+Ex0MvLrqpZhTzc6nezWmt30n41NbwujU57tkmNDW 67z5sN/BEf6qOzraetqBmJTFVoHCp+wVke2BMZzwU07Zi4GuHUJuj5LeMGJrsISuLBF6 JislFUIz7NGhuwBhvWNO7Pa65TUE3b7YLTSwZ+BkNf+dI2AakWl6Mwi08LV976G/GLGM yNuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ws4lI0dI; 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 v25si14250396edl.262.2021.05.10.05.49.15; Mon, 10 May 2021 05:49:46 -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=ws4lI0dI; 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 S1347696AbhEJMgq (ORCPT + 99 others); Mon, 10 May 2021 08:36:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:53674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237455AbhEJLPK (ORCPT ); Mon, 10 May 2021 07:15:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38D986142D; Mon, 10 May 2021 11:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645060; bh=VZ7Xa/rrxmVdvhutqb98FN7+DIyFZ9FsRb3MS3SW7bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ws4lI0dISR49my2rqi8T3m1yY2pG0QBq7IhIjGp4Fo+u7vsIcsOCnweLuiuRaxMbl GPM8dC/v7P2Esmqryuq3iOEYMZLfRmLe6Xr/2gtEVN2GlTSlp3RJ5R59xsAQ/YLFkd L0qH+h3RgQyA7JsPWD5ojbYdbDRXpAeW0+Ybq7Eo= 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.12 334/384] x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported Date: Mon, 10 May 2021 12:22:03 +0200 Message-Id: <20210510102025.800476465@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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 @@ -1850,7 +1850,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. */