x86/amd_nb: Check vendor in AMD-only functions
authorPu Wen <puwen@hygon.cn>
Tue, 25 Sep 2018 14:45:01 +0000 (22:45 +0800)
committerBorislav Petkov <bp@suse.de>
Thu, 27 Sep 2018 16:28:58 +0000 (18:28 +0200)
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 <puwen@hygon.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
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
arch/x86/kernel/amd_nb.c

index fddb6d26239f59f5c679617f310f290a1161a9cb..1ae4e5791afafbe56c188cf14a3223e06f724869 100644 (file)
@@ -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))
index b481b95bd8f6b9e439c5d72e42af21b18d250af4..b51c6b183a3538fcbd83ff6e1d435da3f70436da 100644 (file)
@@ -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)