From patchwork Sat Mar 30 10:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Wen X-Patchwork-Id: 10878305 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7FB213B5 for ; Sat, 30 Mar 2019 10:54:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B23AA28753 for ; Sat, 30 Mar 2019 10:54:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3A74287CC; Sat, 30 Mar 2019 10:54:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F44728753 for ; Sat, 30 Mar 2019 10:54:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hABbJ-00076Q-P5; Sat, 30 Mar 2019 10:52:37 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hABbJ-00076L-01 for xen-devel@lists.xenproject.org; Sat, 30 Mar 2019 10:52:37 +0000 X-Inumbo-ID: ea5009e0-52d9-11e9-b27e-03beda236fd3 Received: from spam1.hygon.cn (unknown [110.188.70.11]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ea5009e0-52d9-11e9-b27e-03beda236fd3; Sat, 30 Mar 2019 10:52:32 +0000 (UTC) Received: from MK-DB.hygon.cn ([172.23.18.60]) by spam1.hygon.cn with ESMTP id x2UAj44a058160; Sat, 30 Mar 2019 18:45:04 +0800 (GMT-8) (envelope-from puwen@hygon.cn) Received: from cncheex01.Hygon.cn ([172.23.18.10]) by MK-DB.hygon.cn with ESMTP id x2UAismq015141; Sat, 30 Mar 2019 18:44:54 +0800 (GMT-8) (envelope-from puwen@hygon.cn) Received: from pw-vbox.hygon.cn (172.23.18.44) by cncheex01.Hygon.cn (172.23.18.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Sat, 30 Mar 2019 18:45:04 +0800 From: Pu Wen To: Date: Sat, 30 Mar 2019 18:44:56 +0800 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [172.23.18.44] X-ClientProxiedBy: cncheex02.Hygon.cn (172.23.18.12) To cncheex01.Hygon.cn (172.23.18.10) X-MAIL: spam1.hygon.cn x2UAj44a058160 X-DNSRBL: Subject: [Xen-devel] [PATCH v4 15/15] tools/libxc: Add Hygon Dhyana support X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Pu Wen , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add Hygon Dhyana support to caculate the cpuid policies for creating PV or HVM guest by using the code path of AMD. Signed-off-by: Pu Wen Acked-by: Wei Liu --- tools/libxc/xc_cpuid_x86.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 098affe..d0cb9ae 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -234,6 +234,7 @@ struct cpuid_domain_info VENDOR_UNKNOWN, VENDOR_INTEL, VENDOR_AMD, + VENDOR_HYGON, } vendor; bool hvm; @@ -304,6 +305,10 @@ static int get_cpuid_domain_info(xc_interface *xch, uint32_t domid, regs[2] == 0x444d4163U && regs[3] == 0x69746e65U ) info->vendor = VENDOR_AMD; + else if ( regs[1] == 0x6f677948U && /* "HygonGenuine" */ + regs[2] == 0x656e6975U && + regs[3] == 0x6e65476eU ) + info->vendor = VENDOR_HYGON; else info->vendor = VENDOR_UNKNOWN; @@ -568,7 +573,8 @@ static void xc_cpuid_hvm_policy(const struct cpuid_domain_info *info, break; } - if ( info->vendor == VENDOR_AMD ) + if ( info->vendor == VENDOR_AMD || + info->vendor == VENDOR_HYGON ) amd_xc_cpuid_policy(info, input, regs); else intel_xc_cpuid_policy(info, input, regs); @@ -630,7 +636,8 @@ static void xc_cpuid_pv_policy(const struct cpuid_domain_info *info, case 0x80000000: { - unsigned int max = info->vendor == VENDOR_AMD + unsigned int max = (info->vendor == VENDOR_AMD|| + info->vendor == VENDOR_HYGON) ? DEF_MAX_AMDEXT : DEF_MAX_INTELEXT; if ( regs[0] > max ) @@ -736,7 +743,8 @@ static void sanitise_featureset(struct cpuid_domain_info *info) if ( !info->pv64 ) { clear_bit(X86_FEATURE_LM, info->featureset); - if ( info->vendor != VENDOR_AMD ) + if ( info->vendor != VENDOR_AMD && + info->vendor != VENDOR_HYGON ) clear_bit(X86_FEATURE_SYSCALL, info->featureset); } @@ -787,7 +795,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, input[0] = 0x80000000; cpuid(input, regs); - if ( info.vendor == VENDOR_AMD ) + if ( info.vendor == VENDOR_AMD || info.vendor == VENDOR_HYGON ) ext_max = (regs[0] <= DEF_MAX_AMDEXT) ? regs[0] : DEF_MAX_AMDEXT; else ext_max = (regs[0] <= DEF_MAX_INTELEXT) ? regs[0] : DEF_MAX_INTELEXT;