Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2029455imm; Sat, 9 Jun 2018 06:33:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI5BUEAc/Q6UFYfbsSm0bXbsQXrhzCzuBL7CWWvpRUNVocRD/MqGn/ztlj9V4SoAbVSWMP6 X-Received: by 2002:a17:902:da4:: with SMTP id 33-v6mr10839662plv.169.1528551202288; Sat, 09 Jun 2018 06:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528551202; cv=none; d=google.com; s=arc-20160816; b=seUP7Rb2+jpQThFet2VGvYQUJ7F1ik4KDvviZFd3T0Yp1C+cOYjg2Ht/oCRRijS2/a debDcSTUzEKQCHG/MHs04ifoFQgwFzcT6TuQsgodPeulHrcnnZ1JOOBqK8OkAZH+ZsgY 8XSSJ5PXlQykfwSudKVlYnLFU90pLGgHojWHOO8m6e3d4haIvUXAOBIfKjvCbQOlgovf KaWebHRNExaU5Q+lD1smtm8vMCRMV1Y5uA9bQGtw8Z1px0TpRP02kGI2Q+C5bJZgKbrP ZH2oXQMOfhWORz1QtvVIqxiMVkk8OSZqRXc72tW7jziA/9XV9q5ypkqp/0KjZNvLvSnG kAFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aI0Wlm4nSLk3QIAL/+JIRqOmzTO5voJsRAEC47wDDDw=; b=bDNgzL7jaqTlBdw4mTCCTDMou9LFBO6/iMqRPIJhOxEkpWAP/+i+v0OfEnWzzOenlD zs7D38MXw/89DShU0x7VeNSyEfqTnAtyQ/vlEBl9Zc6g8th0SndvNcSIhFFpyombTM0s +Of0V6faIlrKmw7eIoxi6pXgMCxjdu4wD24R4rSo98CMqQCd9lfp03V9GuWJcFajZHry 5biFGgE3RAUQubpiqQCusli644T5i2Vz0BFgRdnfKuyBhP5pNIouvh/lrEJkUCDNRvyb g/bU1L2uvUKJDKVBwJ6Wq8saTwaRjx3LIt1QegIi99jwwWY7mr4cANZFjSPmukOrjIOp tSZQ== 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 5-v6si59575641plc.203.2018.06.09.06.33.07; Sat, 09 Jun 2018 06:33:22 -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 S1753444AbeFINac (ORCPT + 99 others); Sat, 9 Jun 2018 09:30:32 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:44125 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753225AbeFINaV (ORCPT ); Sat, 9 Jun 2018 09:30:21 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-01 (Coremail) with SMTP id qwCowAAXTbnQ1Btb701EBA--.1155S2; Sat, 09 Jun 2018 21:23:32 +0800 (CST) From: Pu Wen To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, pbonzini@redhat.com, rkrcmar@redhat.com, zhangpanyong@hygon.cn Cc: thomas.lendacky@amd.com, peterz@infradead.org, tony.luck@intel.com, bp@alien8.de, boris.ostrovsky@oracle.com, jgross@suse.com, rjw@rjwysocki.net, lenb@kernel.org, viresh.kumar@linaro.org, mchehab@kernel.org, trenn@suse.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-x86_64@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-pm@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Pu Wen Subject: [PATCH 06/11] x86/kvm: Add support for Hygon's Dhyana Family 18h processor Date: Sat, 9 Jun 2018 21:23:23 +0800 Message-Id: <1528550603-28351-1-git-send-email-puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: qwCowAAXTbnQ1Btb701EBA--.1155S2 X-Coremail-Antispam: 1UD129KBjvJXoW7AF48Jw17ury5AF45Kr4UJwb_yoW5JF4fpF ZrGFs2qFsYgrsIk34DJrnrZF1Uuws8Kw10gryUu3savF4jvayxXr4Fkw15Ja17Aa95ua4r KFy8ua1kJayfXFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUva14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7Cj xVA2Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a 6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6x kF7I0E14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r4j6FyUMIIF0xvEx4A2jsIE 14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyT uYvjfUw18BUUUUU 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 This patch enables the x86 KVM support to Hygon Family 18h CPU: - Add Hygon CPU VENDOR ID macro for KVM. - Add SVM support in cpu_has_svm(). - Add support in em_syscall_is_enabled(). 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 | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index b24b1c8..a4907e5 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h @@ -362,6 +362,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 b3705ae..fbba814 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2702,7 +2702,13 @@ 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 or Hygon), apply Intel's stricter rules... */ return false; } -- 2.7.4