Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2976007imm; Sun, 19 Aug 2018 09:15:29 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxEZaCuGohWLbw1GTeifOS5kU6TONJjthj7e/eyTn6ydLz3et4mEL09spD6d6aXi35L5TMP X-Received: by 2002:a62:1314:: with SMTP id b20-v6mr44926338pfj.230.1534695329405; Sun, 19 Aug 2018 09:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534695329; cv=none; d=google.com; s=arc-20160816; b=0XtMA0O6PgEGdnpqNhHq3D877WD8bIXclf10lOwY1t/mhBzFMKkTitO02wxjiErISx O5bR7gDAUPREqUHSWTMLs6FTAVp1rx5J1SnCsZ+Ymo67bwR9vFkOREMScrpqh4qbAydq hPySqfTJrTRmyFfUU/VTBC6tRti9WQnnFberOIU5/7oIRzo3M/wC5yOOjUw9m142kA7r 1YChkeevHrwj3NvOwfD97SOs6XbAWmt3iu8VNgnLhhmMZsT1/U+HzOx7JlSqRWe1F3WS y2/NnmXG32bEURwtcq/gKm+sVwvuvCTq5XfjZvyAn6cbcDvzfof9wTl56lfFsMbtJukq lItg== 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:arc-authentication-results; bh=9ELjdK2On9y8XwKO8MzhMgfrGyaO2aoJpcnD/0ap140=; b=h5buBwHjbf0ZrZCdKb3upFWDsrcXPzPua7N/b3cAkuYO3VjZnUxt/UDKyFn8Hs9Sq2 wmDv0hRZ2CXyl1oVqWV2Ynpzf+Wal3voE3zae7D73ZMILt0CE4zdkCd6Uwu1E3jICwvO cHqaPDVNqNZ6NJbnBe1Se+sEyE1nwXxgRLdiEe+bSBwie8BNiKwYOzQHUlB/DXw/lcUS LS/9h3T5UawuEEzKwzOJ+RgYK/D5t7dEtdGqtlWb3H8QUxEU7H/m4crouw6NQ1bjIaHL +uh2BaRQzI/Dl8orXjD/Zijq6YBrzBnOZYkREhO/gsLiCXZ2sbwhaC4tjcEzv4MjoA4U 2pXA== 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 q8-v6si7108175pfh.353.2018.08.19.09.15.14; Sun, 19 Aug 2018 09:15:29 -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 S1726755AbeHSTZ7 (ORCPT + 99 others); Sun, 19 Aug 2018 15:25:59 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:54316 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726589AbeHSTZ7 (ORCPT ); Sun, 19 Aug 2018 15:25:59 -0400 Received: from localhost.localdomain (unknown [110.184.154.248]) by APP-10 (Coremail) with SMTP id tACowACHjMQ5l3lb5cywAg--.303S2; Mon, 20 Aug 2018 00:13:50 +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 v4 11/16] x86/kvm: enable Hygon support to KVM infrastructure Date: Mon, 20 Aug 2018 00:13:25 +0800 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: tACowACHjMQ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ating-IP: [110.184.154.248] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hygon Dhyana CPU has the SVM feature as AMD family 17h does. Add Hygon support in the KVM infrastructure. 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 4c4f426..1ab7758 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