Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1370343imm; Sun, 23 Sep 2018 02:37:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV61NEDnBEfN7Im4FygptuqIxfR1/Q3GVPK7bUIxFs+4a4w294wv6W8hmy7lbywNDjZOsFwcc X-Received: by 2002:a63:4f64:: with SMTP id p36-v6mr5046790pgl.210.1537695439901; Sun, 23 Sep 2018 02:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537695439; cv=none; d=google.com; s=arc-20160816; b=ioUc37VISeE7KN0f7lRr39JnW0VfYxdaRimMSgPYy5GFYpA6RDLELtaE0CgnbXsvq9 FZiMs2+upgy1Jopisi9CB/yUxJI3WBybESFGmcvhFxpjQOU5xa1F8vR3/BAFJLTSEJF1 1WhTRtVrI+FkL7tixSnxEbNtJDfBGBYwkS1PmQW4nx6ExOhcZD7WvpTv9Hd9Xmozdvc3 ETsOzk3JT2mEEI49wsxfFmfBQDW3z+x65ywGq+cqVlAZ9kx4ulSSKH1Gx4CO2ZHoopNG beTFMPmZsAnipL5nH9TMg0+qlvyEIABj/drYKU2IJwqxXAC5l95cWS3IYcmzu7/K6cOi Dk+g== 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=yBNyJ5B/q8SHZpkGNJWoB662pb/BtmPdWlK1pzOTmf4=; b=mHqsbZPjWAFjstFzjtMxUlZDS1nLUjUwbN4ZHiEsi5lV4Bm9nzSTwtoOMgTMpgAYYW t6bcV/e15RGlAZivPdgo+sckRjJeA3RH4KiVMFYFLXr1xVW4kAx774Wabvmr+Z/Z0bNi eiCoSCoAasRmv81KIPj91pCEV5sWKUDpWb9I8eOty8LOXxE/7697juFkv48eb8GWcRt4 kPCpzfKzz9Bx6wSEAImB49GBaS1tC4rURgp5wL86xzDgIZjxeB33eqpgUuvPoL3QSXKC 4eJ7tdDAN8MyUjkkLoDVnDq7/BSjvpDAxGx2qlIq0SK6sLZQQT9PEsBjjo3QpKSitgXs lKpg== 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 23-v6si30350795pgr.493.2018.09.23.02.37.04; Sun, 23 Sep 2018 02:37:19 -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 S1726376AbeIWPdk (ORCPT + 99 others); Sun, 23 Sep 2018 11:33:40 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:49639 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726052AbeIWPdk (ORCPT ); Sun, 23 Sep 2018 11:33:40 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-01 (Coremail) with SMTP id qwCowAA3Pb2hXqdbK1yzDA--.4S2; Sun, 23 Sep 2018 17:36:38 +0800 (CST) From: Pu Wen To: bp@alien8.de, pbonzini@redhat.com, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, kvm@vger.kernel.org, Pu Wen Subject: [PATCH v8 11/16] x86/kvm: Add Hygon Dhyana support to KVM infrastructure Date: Sun, 23 Sep 2018 17:36:31 +0800 Message-Id: <654dd12876149fba9561698eaf9fc15d030301f8.1537533369.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: qwCowAA3Pb2hXqdbK1yzDA--.4S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww4xKr1UtFW7uFy8Cw17ZFb_yoW5JF1fpF ZrGFs7ZFs5KrsIk34DGrnrZw1UuFs8Kw18Kry5u34FqF4jvayxXr4Fkw15Aa17Aaykua4r KFy8W3WkJa1fZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02 628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_ GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAF wI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf 9x0JUD-B_UUUUU= 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. Signed-off-by: Pu Wen Reviewed-by: Borislav Petkov --- 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