Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2278882imm; Thu, 27 Sep 2018 10:08:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WcgJ0Fobuhh6ZXq46eftaZ6dDNIy05I5BGnpLoEscXtlG+XbL5s3PWmZqodPGVSzo8HdS X-Received: by 2002:a62:2459:: with SMTP id r86-v6mr12518284pfj.31.1538068087797; Thu, 27 Sep 2018 10:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538068087; cv=none; d=google.com; s=arc-20160816; b=xWGTs19msXtx3PRHRDJXy49fPM9RBAvdVpjkqJSe43rc/jpOHv6S+tzF7c1g4++dmH Xrt+HVs5xdiv29u30kUYb0fpzMjl2Ib2R6YwWKIp7EV8d/qZ2j0A2IytAPcJQ9C/K3vA WXs31sCCDOwRJgD5NfZeqvWAM1afGccquq3/7PP1qJG++x3Si8tol4EGFvFJoETKrrC2 P7NwDcegtmIerRRjHjw4U/DMNc4kRWEH/2sLTI+j3IKDPSMOGBGSFIHje/4BZguZc/Rx HnbNYq7VrqHyTagIrx9xoo3CMnTvr0skL1TZqVOfpNRSwjK5vitTUl1zgQAN5zWYZiEO 76tA== 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=I7d1XweSsZ9GysFeOCFsCEsQdbfaijTveIcAQfAPaUE=; b=gxw7eA82Ouj2ykU9T0YV8VeLe2Tcg5yPP7ZFBcRi0KEPr+2e9hb+ngWpZs1wLwXqDD irmwVxWWXlDze/Lhl53u9pDn+Caqahmqj/bPOjshzL7ZdPry6cVAplwNgVW9k9GBQTnp rApiFIvu1wlwBsHc+IqemTti+KkA4ij5BA45C1xYE1GsgS2l9d/4lCfCUfpHUn/rBsYq zEUb/bgwMc+nVlPgFQdfL9286I6ufdA80FndhSSPqI2L9OXnx2SKrWrAq+HJrmVNaaAR N7mZEQyMMPA7QYofYF84BXDiEcwl7eYs54RTBb6D7VM968+2O5Bzd43nEGOcoAHx3RKQ Kc7w== 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 i64-v6si2595871pfg.119.2018.09.27.10.07.51; Thu, 27 Sep 2018 10:08:07 -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 S1728654AbeI0X0g (ORCPT + 99 others); Thu, 27 Sep 2018 19:26:36 -0400 Received: from terminus.zytor.com ([198.137.202.136]:41999 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727335AbeI0X0g (ORCPT ); Thu, 27 Sep 2018 19:26:36 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w8RH7DI5102241 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Sep 2018 10:07:13 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w8RH7DVU102238; Thu, 27 Sep 2018 10:07:13 -0700 Date: Thu, 27 Sep 2018 10:07:13 -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, bp@suse.de, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, puwen@hygon.cn Reply-To: bp@suse.de, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, puwen@hygon.cn In-Reply-To: <654dd12876149fba9561698eaf9fc15d030301f8.1537533369.git.puwen@hygon.cn> References: <654dd12876149fba9561698eaf9fc15d030301f8.1537533369.git.puwen@hygon.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/kvm: Add Hygon Dhyana support to KVM Git-Commit-ID: b8f4abb652146ddde04ab6e2a80e8cde27ff4470 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: b8f4abb652146ddde04ab6e2a80e8cde27ff4470 Gitweb: https://git.kernel.org/tip/b8f4abb652146ddde04ab6e2a80e8cde27ff4470 Author: Pu Wen AuthorDate: Sun, 23 Sep 2018 17:36:31 +0800 Committer: Borislav Petkov CommitDate: Thu, 27 Sep 2018 18:28:59 +0200 x86/kvm: Add Hygon Dhyana support to KVM The Hygon Dhyana CPU has the SVM feature as AMD family 17h does. So enable the KVM infrastructure support to it. Signed-off-by: Pu Wen Signed-off-by: Borislav Petkov Reviewed-by: Borislav Petkov Cc: pbonzini@redhat.com Cc: rkrcmar@redhat.com Cc: tglx@linutronix.de Cc: mingo@redhat.com Cc: hpa@zytor.com Cc: x86@kernel.org Cc: thomas.lendacky@amd.com Cc: kvm@vger.kernel.org Link: https://lkml.kernel.org/r/654dd12876149fba9561698eaf9fc15d030301f8.1537533369.git.puwen@hygon.cn --- arch/x86/include/asm/kvm_emulate.h | 4 ++++ arch/x86/include/asm/virtext.h | 5 +++-- arch/x86/kvm/emulate.c | 11 ++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 0f82cd91cd3c..93c4bf598fb0 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h @@ -364,6 +364,10 @@ struct x86_emulate_ctxt { #define X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx 0x21726574 #define X86EMUL_CPUID_VENDOR_AMDisbetterI_edx 0x74656273 +#define X86EMUL_CPUID_VENDOR_HygonGenuine_ebx 0x6f677948 +#define X86EMUL_CPUID_VENDOR_HygonGenuine_ecx 0x656e6975 +#define X86EMUL_CPUID_VENDOR_HygonGenuine_edx 0x6e65476e + #define X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 0x756e6547 #define X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 0x6c65746e #define X86EMUL_CPUID_VENDOR_GenuineIntel_edx 0x49656e69 diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h index 0116b2ee9e64..e05e0d309244 100644 --- a/arch/x86/include/asm/virtext.h +++ b/arch/x86/include/asm/virtext.h @@ -83,9 +83,10 @@ static inline void cpu_emergency_vmxoff(void) */ static inline int cpu_has_svm(const char **msg) { - 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) { if (msg) - *msg = "not amd"; + *msg = "not amd or hygon"; return 0; } diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 106482da6388..34edf198708f 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2711,7 +2711,16 @@ static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx) return true; - /* default: (not Intel, not AMD), apply Intel's stricter rules... */ + /* Hygon ("HygonGenuine") */ + if (ebx == X86EMUL_CPUID_VENDOR_HygonGenuine_ebx && + ecx == X86EMUL_CPUID_VENDOR_HygonGenuine_ecx && + edx == X86EMUL_CPUID_VENDOR_HygonGenuine_edx) + return true; + + /* + * default: (not Intel, not AMD, not Hygon), apply Intel's + * stricter rules... + */ return false; }