Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp514713imm; Wed, 29 Aug 2018 05:47:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdalOvkzNJ5xnBySl2DsagKyspS/GifIw+osH2oOmg94Nyg+R3YrNVopRqyKF6RKn+KSBEA4 X-Received: by 2002:a17:902:6684:: with SMTP id e4-v6mr2088643plk.50.1535546844075; Wed, 29 Aug 2018 05:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535546844; cv=none; d=google.com; s=arc-20160816; b=T4CBRYq5gR4urNLu/mlJf0S1DUXlGYLqDWB/mMitumwIidZbcZFD9XdKN8m1NA3L+1 wHwKovK9qqRvsKFuLJS/9fOn2C+eItT1N3qIi9JTJ2Xm3w80aKWOCtOCDomu8pf49aPC cAgTPKn6ve7BMeYhjr/wgaNBguEfGfA+PU31a2aIDB8jBrF8/TMnfMBazrbekHbDxXRx Sdat1w2bZMZ7DoJ3gAec2BkMoLlvEMLQrw5woD5RK78PEpRQO6dL3Tr8SPzC3pjwfJv3 Xwr/kCo4RTNfT6h1sTSPN4cZBIEws0Jg+6dFW1zQLXw3W/PhVbLRIJio0FuYJAaJiRGG kZHA== 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=r4JwmCazE9ZRx3Pmvc+TJyU9buo+E9AW2QTm3xf9Swg=; b=gw51qEZ0D1bIm05I2ouYQ4Q73J59y43Pn45w8mUK0mf7FU9acp8b4ErKmwIPRawHGm Q44mLvPzaGDrM6QWzwjSgV4G7hmn4hDFmBYUQEwe5vF6rtkx7hNa3/PY4Rw3TGEIEaKq AdRqItN818OKsX8Y/xo4IO5OL0MRbBBbSa73o5x3lS9/DMxfbmV/hi3GKkncl7Znnj+i 0tBYTv2c4CSuK0mIJPfjpsqQu/2nQkGeeFmq0vpMCWw9N5bT+j0i07qbaFbxEIhTWz3Z WYTtRJBm6isOvzFTN0JXsxxvxbwlf+VMzAIwLUBM8GF0ysSCsahqlKV2pdNznmb0Me60 0/Ug== 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 y10-v6si3789745pgf.312.2018.08.29.05.47.08; Wed, 29 Aug 2018 05:47:24 -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 S1728697AbeH2QmI (ORCPT + 99 others); Wed, 29 Aug 2018 12:42:08 -0400 Received: from smtp17.cstnet.cn ([159.226.251.17]:49743 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727452AbeH2QmI (ORCPT ); Wed, 29 Aug 2018 12:42:08 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-09 (Coremail) with SMTP id swCowACnq49SlYZbvZ3_BA--.102S2; Wed, 29 Aug 2018 20:45:10 +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 v5 11/16] x86/kvm: enable Hygon support to KVM infrastructure Date: Wed, 29 Aug 2018 20:45:05 +0800 Message-Id: <37fd42bcf50eccfc3aad18051492144056e2f0fb.1535459013.git.pu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42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43 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 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 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