From patchwork Tue Jun 13 13:19:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyao Li X-Patchwork-Id: 13278732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 389DDC7EE29 for ; Tue, 13 Jun 2023 13:20:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q93wM-0000cT-Lr; Tue, 13 Jun 2023 09:20:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wI-0000bb-Mi for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:03 -0400 Received: from mga03.intel.com ([134.134.136.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wG-0006qJ-OA for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686662400; x=1718198400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pNFH4JwPCYF8TBeuPI1XWTw8Bh3QnsIP8OvvAgHWW74=; b=lvrF9/FxUv++Kc2o+jf3hg5yGxPkxuCmhPwk6yg5HjeNCjTBYAraZKna TvklHN4BIORyxB5jBZSh5wubm8PLt7Wmt2LYDIBYxQUOuuIkDSAR8tud8 NgNdVDYAe3ul38a5pT005fXTo0rO5wQEX2UCWdmTD1/h97CQIggdiwkgP rQPuFpIs8ZJ/qfBFb3MWJIQ47ZRbcqKkMn82OtN62/h8OFXH9XN7vXzQp xdr30t4qT3GFfzcoLlohL5f+zKkqE23MJ3sXZqaGtSZYM+g0DAiCMzd93 BdQ97gDDMXWvZnotkvbgfWERW0BukOe+sEhIHhSOIyqvSeDsgZGFkX0PS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="361696807" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="361696807" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 06:19:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="744680318" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="744680318" Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2023 06:19:52 -0700 From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v2 1/3] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Date: Tue, 13 Jun 2023 09:19:27 -0400 Message-Id: <20230613131929.720453-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613131929.720453-1-xiaoyao.li@intel.com> References: <20230613131929.720453-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=134.134.136.65; envelope-from=xiaoyao.li@intel.com; helo=mga03.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Decrease array index cpuid_i when CPUID leaf 1F is skipped, otherwise it will get an all zero'ed CPUID entry with leaf 0 and subleaf 0. It conflicts with correct leaf 0. Signed-off-by: Xiaoyao Li Reviewed-by:Yang Weijiang --- target/i386/kvm/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index de531842f6b1..afa97799d89a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1956,6 +1956,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } case 0x1f: if (env->nr_dies < 2) { + cpuid_i--; break; } /* fallthrough */ From patchwork Tue Jun 13 13:19:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyao Li X-Patchwork-Id: 13278731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 21B7FC83003 for ; Tue, 13 Jun 2023 13:20:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q93wP-0000ea-CV; Tue, 13 Jun 2023 09:20:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wJ-0000bt-Sk for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:03 -0400 Received: from mga03.intel.com ([134.134.136.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wG-0006qP-O9 for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686662400; x=1718198400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hfFgdff8XTWie2hZuUxnhjyHznpzx7DqvvjD22d3hG0=; b=jo5DaGS7pesLxP2Ix7Bgl8T9G6UqiKv1WVD9MPtt7KuQUteMqjFcaOYn UovAL0hcBIzI/XTNeqxKexUTd09+Od+zFhWnBbAzfu/tItKGkqvm0TB2I eOxH6EDbamZAGMHaN7Wb1V+LeVOteO9PVI5AFb3CyVPOcUKITjkJLCjI5 WpI2c1lgk3hWguJc8cXtaO+bQ4yJBVH1SvafixFb0HPUjPXIRQuqaEi2Q TRFXQRBp3cR+kY6TY5HQwzUmVJH5CD6S+ngQw845h/7HBhRaiwBcfjnae zXjiVPNPBflxhyozq0bKZb4qIsS5Pp+7TOy8tS5seroqOfLQk6+TsQfyF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="361696813" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="361696813" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 06:19:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="744680338" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="744680338" Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2023 06:19:53 -0700 From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v2 2/3] i386/cpuid: Remove subleaf constraint on CPUID leaf 1F Date: Tue, 13 Jun 2023 09:19:28 -0400 Message-Id: <20230613131929.720453-3-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613131929.720453-1-xiaoyao.li@intel.com> References: <20230613131929.720453-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=134.134.136.65; envelope-from=xiaoyao.li@intel.com; helo=mga03.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org No such constraint that subleaf index needs to be less than 64. Signed-off-by: Xiaoyao Li Reviewed-by:Yang Weijiang --- target/i386/kvm/kvm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index afa97799d89a..d7e235ce35a6 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1968,10 +1968,6 @@ int kvm_arch_init_vcpu(CPUState *cs) break; } - if (i == 0x1f && j == 64) { - break; - } - c->function = i; c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX; c->index = j; From patchwork Tue Jun 13 13:19:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoyao Li X-Patchwork-Id: 13278733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B74F4C7EE29 for ; Tue, 13 Jun 2023 13:21:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q93wQ-0000er-JR; Tue, 13 Jun 2023 09:20:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wK-0000c2-Jy for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:05 -0400 Received: from mga03.intel.com ([134.134.136.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q93wJ-0006qJ-1w for qemu-devel@nongnu.org; Tue, 13 Jun 2023 09:20:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686662403; x=1718198403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B5kXUdZwwuuOfUtptKN/wWx9SMd2e3OQhNjQfBpYiqM=; b=Ch73WpI5DmhlWQon3TzUynZL49ltbFjLl6t4cb3YAQObrHpZbpuXapwA eiSbsm6Mm7n1znRbt7EuZ3blThU3fId9rhUizrn4p99AGCXx0kc1ptfMk S3SbeJWGkpmxJYcRdMUj/YVh2sDo23xeuyKmnLc/MVDz6vAbD4Kza32aU vKwihihFANeYFTXcjSuUkIcGzhD2YpwXy/hesjtLfWVaZ4VEbU7ckl5L2 H6hAF3cjmJgjbxImuJSGdy4DJUt6kyds94D5YUEDr+UhFD3nqiIIzkLwN Nim0EYE0i46qg71Ap43Xce9ktelInok2+swBiKLJMOz2ylFk/48Ia03eH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="361696825" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="361696825" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jun 2023 06:19:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10740"; a="744680355" X-IronPort-AV: E=Sophos;i="6.00,239,1681196400"; d="scan'208";a="744680355" Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by orsmga001.jf.intel.com with ESMTP; 13 Jun 2023 06:19:55 -0700 From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [PATCH v2 3/3] i386/cpuid: Move leaf 7 to correct group Date: Tue, 13 Jun 2023 09:19:29 -0400 Message-Id: <20230613131929.720453-4-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613131929.720453-1-xiaoyao.li@intel.com> References: <20230613131929.720453-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Received-SPF: pass client-ip=134.134.136.65; envelope-from=xiaoyao.li@intel.com; helo=mga03.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake. SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2) is valid or not by checking the bit 0:3 of corresponding EAX is 1 or not. Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum valid subleaf. Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") Signed-off-by: Xiaoyao Li Reviewed-by:Yang Weijiang --- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d7e235ce35a6..86aab9ca4ba2 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1993,7 +1993,6 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; } break; - case 0x7: case 0x12: for (j = 0; ; j++) { c->function = i; @@ -2013,6 +2012,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; } break; + case 0x7: case 0x14: case 0x1d: case 0x1e: {