From nobody Sun Nov 24 16:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1722314460; cv=none; d=zohomail.com; s=zohoarc; b=B804Wm0dOeZCaTwGOchtAQaZxYK5tIFxbxmyXLTIbug11xpBVyjX3ihuub93ybIJ0WI4xWDjIOqe8qZz3CcSOfgKUqnuq++3xFwrBrVVgPFGPMdRgp4eO7V3tR1lX7EMLWa6YpOXvRnEPtY5DBZOX/qnujOhe1dGCVPHyulE3cU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722314460; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V3joKReEOLxYm+8ItRdwa7hS1Uv4vdrneWZLbeVXUFI=; b=d0ZmZJfCcvqN0bzIOE1vyjiU/gUM/SqO6IuGaUZz6nAzvs/kI/BPgGe/rSrS9vnBXAkLUJvdzKJ8Y3r6GcndLPfnocyaXn7Fq0IFB5eccI6GpoWp67CYii2FtsbSL6MenBuF9S4Kczvq4MCA2HAbCzB+UhzGW9tCvNEDfha4D/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722314460763655.1516879507452; Mon, 29 Jul 2024 21:41:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYeel-0002S7-8a; Tue, 30 Jul 2024 00:40:15 -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 1sYeek-0002Oe-8h for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:14 -0400 Received: from mgamail.intel.com ([192.198.163.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYeei-0006Bm-ET for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:14 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 21:40:09 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 29 Jul 2024 21:40:07 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722314413; x=1753850413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cO8APYbdqznN8knoscacJL2ZntmQ4Beu6oELSifWUR0=; b=iID1x1SzXT8DHjbkxKQL6qRO37kbd/O+kFQODiW1jeKMB5+AdvpEPf5d MI14kt8+o7Dm8HjD/1pJGRoNdhNcSGI9qmcujaI7STk4fswSVPp0wJz2F 5V21q47WtBWbG23s6OsG3qjx3yWUmJzUl87nV1SdKmFp3hZoRzEvE2QZZ iAcuvRS5hAvBDYKQ/afo08TXwwzvny8GIKC5ig0p482wFyvUAYKsHADFB DczOXKrwwDi2+LbknB3kViwJVWNZ5Asg4r95N6lp4KR6kDM2v5j/oHD1f XJ5w2SO9RUc9XT7QmVgRqsLmSUw2pt8ZD5wE9QXEHy1XASBIPURf5+9bf g==; X-CSE-ConnectionGUID: hdy3z9IMTg27qh62tFKXeg== X-CSE-MsgGUID: /Fmg1SIsQROanHNfAeUA4g== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="20288541" X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="20288541" X-CSE-ConnectionGUID: enGiqNH0QJWTpJQtjwSJ7Q== X-CSE-MsgGUID: a52CgpznQ3uw781Hg12p8w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="77429910" From: Zhao Liu To: Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PATCH 1/4] target/i386/cpu: Remove unnecessary SGX feature words checks Date: Tue, 30 Jul 2024 12:55:41 +0800 Message-Id: <20240730045544.2516284-2-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730045544.2516284-1-zhao1.liu@intel.com> References: <20240730045544.2516284-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.14; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.125, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1722314462397116600 Content-Type: text/plain; charset="utf-8" CPUID.0x7.0.ebx and CPUID.0x7.0.ecx leaves have been expressed as the feature word lists, and the Host capability support has been checked in x86_cpu_filter_features(). Therefore, such checks on SGX feature "words" are redundant, and the follow-up adjustments to those feature "words" will not actually take effect. Remove unnecessary SGX feature words related checks. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4688d140c2d9..2b3642c9b13c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6537,8 +6537,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, case 7: /* Structured Extended Feature Flags Enumeration Leaf */ if (count =3D=3D 0) { - uint32_t eax_0_unused, ebx_0, ecx_0, edx_0_unused; - /* Maximum ECX value for sub-leaves */ *eax =3D env->cpuid_level_func7; *ebx =3D env->features[FEAT_7_0_EBX]; /* Feature flags */ @@ -6548,20 +6546,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, } *edx =3D env->features[FEAT_7_0_EDX]; /* Feature flags */ =20 - /* - * SGX cannot be emulated in software. If hardware does not - * support enabling SGX and/or SGX flexible launch control, - * then we need to update the VM's CPUID values accordingly. - */ - x86_cpu_get_supported_cpuid(0x7, 0, - &eax_0_unused, &ebx_0, - &ecx_0, &edx_0_unused); - if ((*ebx & CPUID_7_0_EBX_SGX) && !(ebx_0 & CPUID_7_0_EBX_SGX)= ) { - *ebx &=3D ~CPUID_7_0_EBX_SGX; - } - if ((*ecx & CPUID_7_0_ECX_SGX_LC) - && (!(*ebx & CPUID_7_0_EBX_SGX) || !(ecx_0 & CPUID_7_0= _ECX_SGX_LC))) { + && (!(*ebx & CPUID_7_0_EBX_SGX))) { *ecx &=3D ~CPUID_7_0_ECX_SGX_LC; } } else if (count =3D=3D 1) { --=20 2.34.1 From nobody Sun Nov 24 16:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1722314478; cv=none; d=zohomail.com; s=zohoarc; b=WO1wqQUu3tVLzKyfhVTqETMk+Mre4IZSmIjF/FTfCmD8nvsJs5Zg0jkh2jvwtedAjqujE/XL60WK9Dcl3B2cn7Xo9p5GgC7X+2iLmNS17uodifxyVzCHIdptvp7G5JnGB9+HVGe3EdktoV97cPyV2n1/7DDcJMfPeUmIqkUQqWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722314478; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7Epy1RHNMHm0r+VIY9AQxmm8MqsPGYJJj0tCoQkCjHQ=; b=EeLeg6iMH6F8LkZukxYmgRsu5xqQ/oEBUDF8rEdPLVguTtbHA4gjiKgkbmPVmn0IY5l883hXzsTL2V30vai5Q+TI+mB0zjhQw6mZAzpIqUOYsZHUXrJUcgyvwzXOOCHYiZGYrXil8CSbndreH9QzTfJZ6Nbc9a0mO60kEw+OfEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722314478073880.8387536745612; Mon, 29 Jul 2024 21:41:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYeem-0002V5-3n; Tue, 30 Jul 2024 00:40:16 -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 1sYeek-0002PO-G4 for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:14 -0400 Received: from mgamail.intel.com ([192.198.163.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYeei-0006BM-V3 for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:14 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 21:40:11 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 29 Jul 2024 21:40:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722314413; x=1753850413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9eRZFeah8dznjRAUrRvArWMs0YEBaH6rJfloDBnonuU=; b=V0sjimOod7w6TwK6FJlv11ZAovxMo4LXuz+ctpqjHwgAXBaX7nCKwoYb gBMo6PSAttwT3fRza+zlo7xvsNGDq47g35u77iqOWFZotLqPFyPFvQKwo d+plqKvWP3xJhSgAxxad96W8KVzjmqAgYvVW1z3hF3y7+ElCHrhBTFSs6 +/Dc1lkDVWBX+XgMLRQLv9kH6lJBnCzQjg5znXMEUiZN47MOeyxOJviI7 8w1/RNmEHOfRjs/W/QQj/iOvhQuOQmY4k+cs0NO6bsZG6mbk3uBc82CaW 5zHXj0SVVUS9OoHu/ch5F/xCH/zD88WgOzMDhY98yZ/me5CimwosDPsg/ g==; X-CSE-ConnectionGUID: i0SpAIGSS9KG6OpKjc9PWg== X-CSE-MsgGUID: BYVtEqEKR3yyIAAGSSOWgw== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="20288547" X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="20288547" X-CSE-ConnectionGUID: VHosnQHPTHi03+9n6dEgCg== X-CSE-MsgGUID: wRZYjRe0QAed3qN+9PQKaw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="77429923" From: Zhao Liu To: Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PATCH 2/4] target/i386/cpu: Explicitly express SGX_LC and SGX feature words dependency Date: Tue, 30 Jul 2024 12:55:42 +0800 Message-Id: <20240730045544.2516284-3-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730045544.2516284-1-zhao1.liu@intel.com> References: <20240730045544.2516284-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.14; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.125, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1722314478465116600 Content-Type: text/plain; charset="utf-8" At present, cpu_x86_cpuid() silently masks off SGX_LC if SGX is absent. This is not proper because the user is not told about the dependency between the two. So explicitly define the dependency between SGX_LC and SGX feature words, so that user could get a warning when SGX_LC is enabled but SGX is absent. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2b3642c9b13c..7a6d0b05ce27 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1730,6 +1730,10 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_1_EAX, CPUID_7_1_EAX_WRMSRNS }, .to =3D { FEAT_7_1_EAX, CPUID_7_1_EAX_FRED }, }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to =3D { FEAT_7_0_ECX, CPUID_7_0_ECX_SGX_LC }, + }, }; =20 typedef struct X86RegisterInfo32 { @@ -6545,11 +6549,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, *ecx |=3D CPUID_7_0_ECX_OSPKE; } *edx =3D env->features[FEAT_7_0_EDX]; /* Feature flags */ - - if ((*ecx & CPUID_7_0_ECX_SGX_LC) - && (!(*ebx & CPUID_7_0_EBX_SGX))) { - *ecx &=3D ~CPUID_7_0_ECX_SGX_LC; - } } else if (count =3D=3D 1) { *eax =3D env->features[FEAT_7_1_EAX]; *edx =3D env->features[FEAT_7_1_EDX]; --=20 2.34.1 From nobody Sun Nov 24 16:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1722314458; cv=none; d=zohomail.com; s=zohoarc; b=bxLrDgx+QspVvv1n0z6lNt7lZKfyJWoZhl+EnO41x/IL2s78heeSCiuVI6zqLfCfV2x+aLKciYkNwnjVJrXYc065vEvydrWPpCAH4knNvA19M7sdk6dZ/e+6Q6XDNUD+nE+JZ1laMNgVn8UCzBFPhQ2tSLPR9RAsamMkCM4hksw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722314458; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BUxRvSROgTfNlANlkcfA0cmoOscGd+PMJH+3IIudOxE=; b=mXEJ8TtS8JN4Ax2x1OXCOsms27Vkt9x2yQmX5X4QqkE9nOA+LAtyIe3//YnagArcsw6qab/es2fqPReBLnznV4/DQLIIRUpXNNhJco47bHZvvsooOHjSpZiP8+B9P6zcj0ztlaUILX3QRxGbn3/wjrGIbsYVfENpMeJ+4rUQuW4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722314458108270.2724729259065; Mon, 29 Jul 2024 21:40:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYeen-0002cb-Oi; Tue, 30 Jul 2024 00:40:17 -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 1sYeem-0002Wh-9v for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:16 -0400 Received: from mgamail.intel.com ([192.198.163.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYeek-0006Bm-Jl for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:16 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 21:40:13 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 29 Jul 2024 21:40:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722314415; x=1753850415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y0+ZveYI45DAfzdpujWTiwJ4SUqNeCrezwMTY5sy5OM=; b=WWhqK24dwIE/nSUR4EXIGhSXzuzTB6Eih0lZwqYDt7Q5NYGj1pYl0pd/ JBd8mJ9CIdODQYbBgYFtcVnDsHd3b0Zw4fDMizjysb/kVubMJmgRYdNPu RaUOv354vMBVxvWCqbNM5P1UZIE9PsDEu5De1Jy1MfyUas/pP8PEvTH6Q xHE+TtK3CyXVm9XISKPOrDSwH92fpH0XCINy2L7NVfu6jeRAgnkjPa97J O+MjJKMJXoJdgf78879XAl85g33L2+kqPWosGpl8OhAT4bVQAJ0YNNCUC kudcwuUBzdkOBgiE2IOufPs5QG9MvLAMmMrv61m5bdQpMfcYOBIrpXOy+ Q==; X-CSE-ConnectionGUID: h2/8yhazRdGEKfOFWDYyww== X-CSE-MsgGUID: /G/UY8gGR22IDHM68ufAqg== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="20288553" X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="20288553" X-CSE-ConnectionGUID: ihovqMzlTq6WKRIyWjTBXg== X-CSE-MsgGUID: o2KKnGPPROeRXJ4eG9oDdA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="77429930" From: Zhao Liu To: Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PATCH 3/4] target/i386/cpu: Add dependencies of CPUID 0x12 leaves Date: Tue, 30 Jul 2024 12:55:43 +0800 Message-Id: <20240730045544.2516284-4-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730045544.2516284-1-zhao1.liu@intel.com> References: <20240730045544.2516284-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.14; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.125, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1722314458350116600 Content-Type: text/plain; charset="utf-8" As SDM stated, CPUID 0x12 leaves depend on CPUID_7_0_EBX_SGX (SGX feature word). Since FEAT_SGX_12_0_EAX, FEAT_SGX_12_0_EBX and FEAT_SGX_12_1_EAX define multiple feature words, add the dependencies of those registers to report the warning to user if SGX is absent. Signed-off-by: Zhao Liu --- target/i386/cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7a6d0b05ce27..7f55e9ba3ed8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1734,6 +1734,18 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, .to =3D { FEAT_7_0_ECX, CPUID_7_0_ECX_SGX_LC }, }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to =3D { FEAT_SGX_12_0_EAX, ~0ull }, + }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to =3D { FEAT_SGX_12_0_EBX, ~0ull }, + }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_SGX }, + .to =3D { FEAT_SGX_12_1_EAX, ~0ull }, + }, }; =20 typedef struct X86RegisterInfo32 { --=20 2.34.1 From nobody Sun Nov 24 16:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1722314467; cv=none; d=zohomail.com; s=zohoarc; b=FK7KdY/O0l7dwYYB5Kb2aPXgOg/XIHv22PfPrjx6tEX/P+KCqR1u1y02gH69vZwubPMugqHe9bfdTp1yJo+0WKf9OwvM7ZJIGOkaEox95zJOGdptMqxwgwIFgpleOFfMqR7LiAYBym+vuovIytMQZkJMUifGBR60wWeHRem85+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722314467; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8pKrDVetmnTl64xfiefRVGJq1gY7x6h1ELlxoM55D9Y=; b=O0SI3aWiag/t/fhSmhzPhJhiKQ5kRP2h4dQ2L2JvupwR67P6o9y4yyUyzcKixHARlrpyYQYWf7/QQf+rpKLufSmW2nx24Wd2OxCCc0PlvaDnBdKC8o7s5VsiqQ7hK1igFTxqxFtiBb4NZCzoAkDV7dCS20Lyd2lsAQRFIMThkJw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722314467417346.93606473899786; Mon, 29 Jul 2024 21:41:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYeeo-0002h3-T5; Tue, 30 Jul 2024 00:40:18 -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 1sYeen-0002Zl-23 for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:17 -0400 Received: from mgamail.intel.com ([192.198.163.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYeel-0006BM-CZ for qemu-devel@nongnu.org; Tue, 30 Jul 2024 00:40:16 -0400 Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 21:40:15 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa002.fm.intel.com with ESMTP; 29 Jul 2024 21:40:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722314415; x=1753850415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cL92rD81kzK7ojUvhsDE3dVX2dFVVXty9ZJ/bZd7F3s=; b=j2T34JyMW3T0q/9fvF/WLIeXlY5oaEl95w8gGYgp8bAMGJm2hDENrUjn jq98uIc8GS4tIU2JzZAxVUL+FBaoP2dSghC9PsYHYbwMYG+T+ydrgg9da iv9K9OnoakD2E+w/C4qfpRSDHDCuTviwUfxCmDTC0XLkibkg6ayz3t0t5 oGzLaQufR/CdIcUllFkh9uPcg38NuPjluhZbdMD5fuxprFz+yYBIgOj8b pVEXqHKkAczLmDKXP/h1ChKwOVZWyIszU2sh7CGEsvPrZkqJZCJimxtJP FxhYi9EpOuxrBgt/mbdo4PsONB8eQUg7PL7Vvhg8PBcrv702MHeuYIT4l Q==; X-CSE-ConnectionGUID: 4kGdcnA/Sja505uYmSosyA== X-CSE-MsgGUID: M+dpMc1dTIWgS2KGCAcvVA== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="20288560" X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="20288560" X-CSE-ConnectionGUID: yfA2DkXRS/GBoAw38B1vsw== X-CSE-MsgGUID: jdQwO3WnT5O5S+UthJ6s9w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,247,1716274800"; d="scan'208";a="77429935" From: Zhao Liu To: Paolo Bonzini , "Michael S . Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , qemu-devel@nongnu.org Cc: Zhao Liu Subject: [PATCH 4/4] target/i386/cpu: Mask off SGX/SGX_LC feature words for non-PC machine Date: Tue, 30 Jul 2024 12:55:44 +0800 Message-Id: <20240730045544.2516284-5-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730045544.2516284-1-zhao1.liu@intel.com> References: <20240730045544.2516284-1-zhao1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.14; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.125, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1722314468526116600 Content-Type: text/plain; charset="utf-8" Only PC machine supports SGX, so mask off SGX related feature words for non-PC machine (microvm). Signed-off-by: Zhao Liu --- hw/i386/sgx-stub.c | 5 +++++ hw/i386/sgx.c | 8 ++++++++ include/hw/i386/sgx-epc.h | 1 + target/i386/cpu.c | 15 +++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c index 16b1dfd90bb5..38ff75e9f377 100644 --- a/hw/i386/sgx-stub.c +++ b/hw/i386/sgx-stub.c @@ -32,6 +32,11 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState)); } =20 +bool check_sgx_support(void) +{ + return false; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { return true; diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c index 849472a12865..4900dd414a1f 100644 --- a/hw/i386/sgx.c +++ b/hw/i386/sgx.c @@ -266,6 +266,14 @@ void hmp_info_sgx(Monitor *mon, const QDict *qdict) size); } =20 +bool check_sgx_support(void) +{ + if (!object_dynamic_cast(qdev_get_machine(), TYPE_PC_MACHINE)) { + return false; + } + return true; +} + bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size) { PCMachineState *pcms =3D diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h index 3e00efd870c9..41d55da47999 100644 --- a/include/hw/i386/sgx-epc.h +++ b/include/hw/i386/sgx-epc.h @@ -58,6 +58,7 @@ typedef struct SGXEPCState { int nr_sections; } SGXEPCState; =20 +bool check_sgx_support(void); bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size); void sgx_epc_build_srat(GArray *table_data); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7f55e9ba3ed8..66f9737a117c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6103,6 +6103,21 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w) } break; =20 + case FEAT_7_0_EBX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail =3D CPUID_7_0_EBX_SGX; + } +#endif + break; + case FEAT_7_0_ECX: +#ifndef CONFIG_USER_ONLY + if (!check_sgx_support()) { + unavail =3D CPUID_7_0_ECX_SGX_LC; + } +#endif + break; + default: break; } --=20 2.34.1