From nobody Sun Nov 24 10:40:50 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=1723622649; cv=none; d=zohomail.com; s=zohoarc; b=GY9Dyx7B617p3C8VDk8FXEhjLUAZL1b474TBvvZB7eTY8XhVlJfvJFTaId1MGl8lNESpOKzvAmnXgX0RixygUKWrQM86++Ndqf2S5XE0ULLySZcj0Me0pLvU95SkNZ3cQhQHQS/Ng7IxHU6aT5DOWxdKLL6DyiCg6ayRVK3guPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723622649; 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=RdskTWB/2cPhbo5K1pGmzV7Y13jiXhq7IXOigUmZosQ=; b=S6MrwDK3MywIb2QHpdQoh54LebAj9TqD2rXisVpgGlAEbBVW8mMykLbi537XkZQ1JAba81cz+QRxcqOuBiSgvxmPDVxkps75lp07yHplxetvxN4pNvDmD522rkEUF4xKxQdmHea6ZATWTv742xntpFyrzjhYeXsozjG35y1Tt+8= 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 1723622649980190.33805954060756; Wed, 14 Aug 2024 01:04:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1se8yh-0003IY-Bj; Wed, 14 Aug 2024 04:03:31 -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 1se8yT-0002tJ-1N for qemu-devel@nongnu.org; Wed, 14 Aug 2024 04:03:23 -0400 Received: from mgamail.intel.com ([198.175.65.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1se8yL-0007rt-9N for qemu-devel@nongnu.org; Wed, 14 Aug 2024 04:03:15 -0400 Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Aug 2024 01:02:43 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.52]) by fmviesa010.fm.intel.com with ESMTP; 14 Aug 2024 01:02:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723622589; x=1755158589; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+1CShJKpDmVBjOQNUIrC3GWrHShE0+pF4rvqTJMJim8=; b=B1OVSrxgfqxn6/VYAbhQpQd/vRDDXI2iB5P+7PnDzydv/2RLfNkYJd7z WAgHVIIImGfg4c8UflJxf6wLO1Zw7udzh4ZRevg7NZQxBK+txyGQhC6dZ sIxxkTQJ8Tdm+WgfpNVKuyx8bP1TWsq1qQb8yMOj5DJuVXq2qmdTP+nMg 0qt515Sy6mwADjF/9gOx2F21rbd02BpS5JrRHA/guwN509a22wLyL0h3O xWStRds2h7U1PvC5n4FOxpSU5XS2DYB2RQMGS79+4Be5cbwwc2hs8RJck wlRClMxcvuePTsyWUva82qZ+DaaA43N/ZBu7bBtTIkpyrBLaCfBbvl/8h w==; X-CSE-ConnectionGUID: ph3zYcS0RiymqV8OAZl5Lw== X-CSE-MsgGUID: tQJf5YMTSUmHh1LLbBTr8w== X-IronPort-AV: E=McAfee;i="6700,10204,11163"; a="25584500" X-IronPort-AV: E=Sophos;i="6.09,288,1716274800"; d="scan'208";a="25584500" X-CSE-ConnectionGUID: KEfZ5W48QYaoJauvCfm6gQ== X-CSE-MsgGUID: 0Haszx6eSjqibH/f847CBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,288,1716274800"; d="scan'208";a="59048963" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, xiaoyao.li@intel.com Subject: [PATCH 7/9] i386/cpu: Suppress CPUID values not defined by Intel Date: Wed, 14 Aug 2024 03:54:29 -0400 Message-Id: <20240814075431.339209-8-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240814075431.339209-1-xiaoyao.li@intel.com> References: <20240814075431.339209-1-xiaoyao.li@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=198.175.65.15; envelope-from=xiaoyao.li@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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1723622652106116600 Content-Type: text/plain; charset="utf-8" Some CPUID leaves are defined by AMD while it also gets exposed to Intel VMs by QEMU. It causes no issue with current VMs however it will not work with Intel TDX because these CPUID leaves are enforced by TDX module as reserved. Stop to advertise them to Intel VMs when vendor_cpuid_only is true. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7a4835289760..fed805e04aeb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6863,12 +6863,16 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, break; case 0x80000000: *eax =3D env->cpuid_xlevel; - *ebx =3D env->cpuid_vendor1; - *edx =3D env->cpuid_vendor2; - *ecx =3D env->cpuid_vendor3; + if (cpu->vendor_cpuid_only && IS_INTEL_CPU(env)) { + *ebx =3D *ecx =3D *edx =3D 0; + } else { + *ebx =3D env->cpuid_vendor1; + *edx =3D env->cpuid_vendor2; + *ecx =3D env->cpuid_vendor3; + } break; case 0x80000001: - *eax =3D env->cpuid_version; + *eax =3D (cpu->vendor_cpuid_only && IS_INTEL_CPU(env)) ? 0 : env->= cpuid_version; *ebx =3D 0; *ecx =3D env->features[FEAT_8000_0001_ECX]; *edx =3D env->features[FEAT_8000_0001_EDX]; --=20 2.34.1