Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2774054imm; Mon, 10 Sep 2018 06:21:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYPmsIgziCBg2/IJHJGA0Madm78kTOF1fdamj8yT4d8mKsnp8TYdDKWD35jJj1Ke4IHiCRp X-Received: by 2002:a62:778c:: with SMTP id s134-v6mr23729576pfc.189.1536585701236; Mon, 10 Sep 2018 06:21:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536585701; cv=none; d=google.com; s=arc-20160816; b=kSUNunvyo13/Oeo+wgHaRFrH3U6+3/4eITsms0O+QztHe611fI++i32zqYjGM/1SS5 mcJqpAWMTar8l7MrP0T1Cc3WmjsqIqwq1KNm2gzknZDOj+nIDKEWTf89DRLCQx3JpaLP uN1TKMa8WgPt9mnCG7aVq1jQD9C689mS5j5slbY1DTfyXq2iuYGWwbo/Zl/jcaunwMa3 pJAVEk9w+dpxSIBCGkgk7ZNvuaRuvhF0tD4aV2VrtHWoVBuoyrcdzXgiRA9/zpZkTM7B WmTcd8EIJudXqxCzY5AzE/g95QArH51AZ0dLFeBO8OOgZbLgTH8j1OyZu/3rG/yMmFJk b9uw== 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=FYN7ywK1XeQGBHbCK6WB52FIDbaUv1wo/CrliTi9VPU=; b=VEAmSdDxk23pDE4LOCsVN5vN2Di9duS/i2VTrsHWouCxoHVOjGUulCb79twELs0bu4 rfT0MZMvNS8XeaLAAaQbxF+tHv0IdxBQulXzOdSxZ6iIB/7Gi6R0gH/cN8S89WaQk60c apdwWTNewRfYbjh+2CxTGhO7kHBO9D8Afiw3vhC7B6QftDNj7lM4dvdUZ2h1Le7zhyPz bahjP68IW6oxGgrzODYiabbY1bPvQ7JoKIf6xzFfq+iP5gfny+kdUDFP1SjZFtTOWMjj TWCOKGSSy4nULZ9dBdpNNYwjP30f/zwvfBdsZu0/l3ANJkfMTio6FLp01GXDQEq4Jy80 SZVg== 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 w3-v6si18495940pgw.135.2018.09.10.06.21.26; Mon, 10 Sep 2018 06:21:41 -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 S1728860AbeIJSMc (ORCPT + 99 others); Mon, 10 Sep 2018 14:12:32 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:52354 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728513AbeIJSMb (ORCPT ); Mon, 10 Sep 2018 14:12:31 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-10 (Coremail) with SMTP id tACowACnfe8Wb5Zbtg2aCQ--.1831S2; Mon, 10 Sep 2018 21:18:19 +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, rkrcmar@redhat.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kvm@vger.kernel.org, Pu Wen Subject: [PATCH v6 11/16] x86/kvm: Add Hygon Dhyana support to KVM infrastructure Date: Mon, 10 Sep 2018 21:18:12 +0800 Message-Id: <25464d1d78acb6320c5791f3da84def07fb223ad.1536550550.git.puwen@hygon.cn> X-M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iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43 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 SVM feature as AMD family 17h does. So enable the KVM infrastructure support to it. Reviewed-by: Borislav Petkov Signed-off-by: Pu Wen --- 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 0f82cd9..93c4bf5 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 0116b2e..e05e0d3 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 106482d..34edf19 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; } -- 2.7.4