Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2275808imm; Thu, 27 Sep 2018 10:05:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fhzYKqRqKaVhOcZFrBQbS4D0WbT+4tH5ntA8Kd8bp3ix74JTnlFpGH6IbJ1ahODTTZDl8 X-Received: by 2002:a63:1566:: with SMTP id 38-v6mr11191386pgv.383.1538067925572; Thu, 27 Sep 2018 10:05:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538067925; cv=none; d=google.com; s=arc-20160816; b=yN/c/iVMCffh+JW/72JR/ZTvA0EygrJnRBiVyI0TAaaTfXym9E7WW0/6IYPWeIzIb7 XWDsF6rQOKdIsw8vjkQ3eU7ipL8yTs+Co6fTL/p4wXF1yrFj0yS80MzHRVGi9m4vfSWy DwvBclrxdSFnYInRqY/L6B9OCNzM2CvpLd/BFUdr2s+KLfb98RSru3DTNy4bgYAnQkT5 iaas+CUdiAUnezdS8a3SrbPvfakQmN40Yn1zbHHPUyGJrRBcZ9nw+ePb+am8XNw39I+l ppe+S7uQBj4OTAXwHWCzkoNHTQKUa1aoGw0IMQFZGg45ryDX63TMau+/dysanzmrbxXG v1Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=WP/f7ulpizBoLaku1RMY67cMUHjiGxh+f8AiwPUL9qM=; b=dYcExOoZs5zrnha/UU23BDyYwixqG5obJKlBKL7nKUEVFzJtIuqThJ/tZcmyNEZM4K a2vH04p7XlGm8cPx29K1RL4/sc99Y61GPuheJvpGtN3HnnvZ3t7uOY9VAmZ8kx+1rVzt CG01Nom7eNSghHrCuZZXvRexnfu7MQAT+fyfM41foQ7+J7NRzMLuPH9vlgH3atwffLAw kScG6i/E2POF4vJ+2UulqHrNPRCLQpnGVniTHFE/oxz6Okm1TwwxIgTGw7Po3NtDcrDu 4mSZhN18tgXpSAPRwJxD4dUUeXtZnjQrlR4Zxs5LsqmppJevyju2h8WeZu7AXz8Bt+9s M9jw== ARC-Authentication-Results: i=1; mx.google.com; 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 o66-v6si2532539pfb.125.2018.09.27.10.05.09; Thu, 27 Sep 2018 10:05:25 -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; 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 S1728582AbeI0XXq (ORCPT + 99 others); Thu, 27 Sep 2018 19:23:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52321 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728381AbeI0XXq (ORCPT ); Thu, 27 Sep 2018 19:23:46 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8RH4O4T101729 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Sep 2018 10:04:24 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8RH4OPk101724; Thu, 27 Sep 2018 10:04:24 -0700 Date: Thu, 27 Sep 2018 10:04:24 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Pu Wen Message-ID: Cc: hpa@zytor.com, puwen@hygon.cn, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@suse.de, mingo@kernel.org Reply-To: hpa@zytor.com, puwen@hygon.cn, tglx@linutronix.de, linux-kernel@vger.kernel.org, bp@suse.de, mingo@kernel.org In-Reply-To: <487d8078708baedaf63eb00a82251e228b58f1c2.1537885177.git.puwen@hygon.cn> References: <487d8078708baedaf63eb00a82251e228b58f1c2.1537885177.git.puwen@hygon.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/amd_nb: Check vendor in AMD-only functions Git-Commit-ID: b7a5cb4f220e78490735b2b984ad29b7d8e612a9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_24_48 autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: b7a5cb4f220e78490735b2b984ad29b7d8e612a9 Gitweb: https://git.kernel.org/tip/b7a5cb4f220e78490735b2b984ad29b7d8e612a9 Author: Pu Wen AuthorDate: Tue, 25 Sep 2018 22:45:01 +0800 Committer: Borislav Petkov CommitDate: Thu, 27 Sep 2018 18:28:58 +0200 x86/amd_nb: Check vendor in AMD-only functions Exit early in functions which are meant to run on AMD only but which get run on different vendor (VMs, etc). [ bp: rewrite commit message. ] Signed-off-by: Pu Wen Signed-off-by: Borislav Petkov Cc: bhelgaas@google.com Cc: tglx@linutronix.de Cc: mingo@redhat.com Cc: hpa@zytor.com Cc: x86@kernel.org Cc: thomas.lendacky@amd.com Cc: helgaas@kernel.org Link: https://lkml.kernel.org/r/487d8078708baedaf63eb00a82251e228b58f1c2.1537885177.git.puwen@hygon.cn --- arch/x86/include/asm/amd_nb.h | 3 +++ arch/x86/kernel/amd_nb.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h index fddb6d26239f..1ae4e5791afa 100644 --- a/arch/x86/include/asm/amd_nb.h +++ b/arch/x86/include/asm/amd_nb.h @@ -103,6 +103,9 @@ static inline u16 amd_pci_dev_to_node_id(struct pci_dev *pdev) static inline bool amd_gart_present(void) { + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + return false; + /* GART present only on Fam15h, upto model 0fh */ if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10 || (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model < 0x10)) diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c index b481b95bd8f6..b51c6b183a35 100644 --- a/arch/x86/kernel/amd_nb.c +++ b/arch/x86/kernel/amd_nb.c @@ -264,6 +264,10 @@ bool __init early_is_amd_nb(u32 device) const struct pci_device_id *id; u32 vendor = device & 0xffff; + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) + return false; + device >>= 16; for (id = amd_nb_misc_ids; id->vendor; id++) if (vendor == id->vendor && device == id->device)