Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2777193imm; Mon, 10 Sep 2018 06:24:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYpd2WDqUYmniqjYfXVitayQ1nmjNVlLeBUeIRozH3a1eI6SoYe4p8ySwbRjY4nGN2w6LGL X-Received: by 2002:a17:902:9a01:: with SMTP id v1-v6mr21854041plp.20.1536585858549; Mon, 10 Sep 2018 06:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536585858; cv=none; d=google.com; s=arc-20160816; b=w59O6T2pszoXdX9wMcYqrjT+sBermTUgEqiRhkisPUyBh8c/kqcoJKaOVOdzE1KxkZ xa0vHebeEk4hJ5xu9l/eLA/G1oTI8VcHWhCJOWvjbEnWvWSRV+BYosSjSHjldx7T2pB6 nWp80y2kwjRpuEuy0vj6gqDY6Z9GX/PS8erFn/pQoleyizeRWlIdkEcSjUbI4gseVR0o HxXoy6kp8UERp+EbH4Kg/fK5FheOBHR3Vl+tuW6yXzhcdWRkc1deSx/kpJG+4W/Mc8b/ mwTVhuPIMoTQ9cVUJB+xF6kLSjEPE2DLrsDKYyox/7XqoGpQj+ooXT2EgkQ0VidHOA/T rxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=qAIoLVRwujybZmhNGJcCqRKA692au6BdYrrc0sHoGgA=; b=QXt+PLuT/XvEzTUKp9Wuwi+w8ep2UlSYDCePYEz6Tw8mZ0p7ZyF8wJaa/ZNKoohujD YhMEGwsEfOoz1amQNEzxyKNb9md486y2bcyX+G5NH/om3HZJ8/T8joco4E2ZtPH14010 FCW6dxafYWR23gH72HGDgTa0dWUgQdPTfHM/CQ3qYECWOPgQahn2/C+LYccbm/ZKbXIJ Y/Tv4Zmt+9q0mNiVqkQTD/oTTHksWuUAiZGHtSplRYN+MURbfa4aMWIt1dm5cYG0oONj sqQwWfRp44JIOlJdo0WDWzB6wtnmU4e8Yx5CBXObInPLhZtNlDNMMcrES3TDXyyT6rU4 0urA== 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 j14-v6si17749829pgb.496.2018.09.10.06.23.32; Mon, 10 Sep 2018 06:24:18 -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 S1728814AbeIJSME (ORCPT + 99 others); Mon, 10 Sep 2018 14:12:04 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:52218 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728020AbeIJSME (ORCPT ); Mon, 10 Sep 2018 14:12:04 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-10 (Coremail) with SMTP id tACowACHE+73bpZbAwiaCQ--.1664S2; Mon, 10 Sep 2018 21:17:47 +0800 (CST) From: Pu Wen To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Pu Wen Subject: [PATCH v6 09/16] x86/bugs: Add mitigation to spectre and no meltdown for Hygon Dhyana Date: Mon, 10 Sep 2018 21:17:40 +0800 Message-Id: <191ce6b53269e90fdc26ee49ef337b905bd7d99c.1536550550.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4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VWxJrUvcSsGvfC2KfnxnUUI43 ZEXa7VUbKLvtUUUUU== X-Originating-IP: [182.150.46.145] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Hygon Dhyana CPU has the same speculative execution as AMD family 17h, so share AMD spectre mitigation code for Hygon Dhyana. Also Hygon Dhyana is not affected by meltdown vulnerability as AMD, so add the exception for Hygon Dhyana. Signed-off-by: Pu Wen --- arch/x86/kernel/cpu/bugs.c | 6 ++++-- arch/x86/kernel/cpu/common.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 40bdaea..726010d 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -312,8 +312,9 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) } if (cmd == SPECTRE_V2_CMD_RETPOLINE_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON && boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { - pr_err("retpoline,amd selected but CPU is not AMD. Switching to AUTO select\n"); + pr_err("retpoline,amd selected but CPU is not AMD or Hygon. Switching to AUTO select\n"); return SPECTRE_V2_CMD_AUTO; } @@ -371,7 +372,8 @@ static void __init spectre_v2_select_mitigation(void) return; retpoline_auto: - if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) { + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD || + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) { retpoline_amd: if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) { pr_err("Spectre mitigation: LFENCE not serializing, switching to generic retpoline\n"); diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 44c4ef3..851cbe7 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -963,6 +963,7 @@ static const __initconst struct x86_cpu_id cpu_no_speculation[] = { static const __initconst struct x86_cpu_id cpu_no_meltdown[] = { { X86_VENDOR_AMD }, + { X86_VENDOR_HYGON }, {} }; -- 2.7.4