From nobody Fri May 3 11:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1639606940; cv=none; d=zohomail.com; s=zohoarc; b=HhQ8oZ5DWOa+k1tcOL41Jl1QKe9IF5z9nxhKpR1K+oY9MH0G0JKxeZyX9C+49PVhlojatzmAj1ZRmWSBiDug4M+o4wsR8gJhwzyMFJYvgqdHAu2upitkfGpebEqqlarLasxc6fVmts5bp8nrQ7roUdKQS9wxLZUqaysYT6Yjk5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639606940; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vIQwV+hCdTRTYDQ07uXq/m8ZDWaZPGpW0EGkgwI+bI4=; b=KTEZwXn3FVkm2SMPckvzoOx2IvLIy1nKigK3mLXKvYI9flgCmSzc/2Gmx0keDAgv2m7Tl/+f9fl28deSxthJ70wu5qvE2g4tHPBnjL9PjJQ38bymD1iwLZYu/eVD0ZIjMAveFg3yHvRO3yiiax/CyTtWuj5Y9mZxsME3QTEY+Vk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1639606940302608.864225210404; Wed, 15 Dec 2021 14:22:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.247618.427002 (Exim 4.92) (envelope-from ) id 1mxceg-0005qz-BJ; Wed, 15 Dec 2021 22:21:46 +0000 Received: by outflank-mailman (output) from mailman id 247618.427002; Wed, 15 Dec 2021 22:21:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxceg-0005qs-7l; Wed, 15 Dec 2021 22:21:46 +0000 Received: by outflank-mailman (input) for mailman id 247618; Wed, 15 Dec 2021 22:21:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxcee-0005ZJ-SV for xen-devel@lists.xenproject.org; Wed, 15 Dec 2021 22:21:44 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6126f12c-5df5-11ec-9e60-abaf8a552007; Wed, 15 Dec 2021 23:21:43 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6126f12c-5df5-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1639606903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c3nwmG65CWTnQUe9tR5dWZEN9Clal0P82PcG0VxhhM8=; b=XMct5QXU6v3nLwcMmXZEsJ00/YnwGaeLFfDcrTtg6kO+4NEf1H1V+nsB QY1yKu7e7kDyYQxX3RNFDifugS9Wi/7dwTvxRWp0FVp0TU/fX/ZS+ifvE Isb4MsVIVWKzkWjWrK310EVjDsloCGDc727MyXFIy9FLnoH3+ws1hMhKv U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: TG0n8gseO5urC0LOd2LjCDg+z6mA+gozGQQsqlgUe7rePI4OdEoTy4053vuUdDrZxSRmtZtICC I/5otxeUTpK4RVC2ZY7UZ2Wg19KtQpRbYFFfLivoHFoZ0lwhhnlejj5DWIzM9t8Nvkv2pIdjpC V2gtmZ8qgD3empa2k9NiGfU3i5EEOTRqQm9JSp0kNqgs5qRISuOhmYoR8/SSx885PnMgJRDIX7 FZZSuNWO/kGHNId3iDPdETdsjLiTWPIlfjiP2LFuYY1Iz0q8mH6MsBYaaJFGtQ0iCcUR95XkEk RzD8hOSrU/wYEt13xfs9Si6N X-SBRS: 5.1 X-MesageID: 60126719 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:h2QDza1llxiymrqL0vbD5R52kn2cJEfYwER7XKvMYLTBsI5bp2MOy GMZWmnVPPreMWb0co0nO4+0pktX7JLRn9U1QQpupC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCanAZqTNMEn970Es5wrNh2eaEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhof1a8 MtBsLWKUCwRHrCPgNk0bwNXOnQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1Er8IvNsT0eqgYvWlt12rxBvc6W5HTBa7N4Le02R9u3pkUQ6mHN qL1bxJXY0niPDZrOG4ON5QYreKsiUvdTABx/Qf9Sa0fvDGIkV0ZPKLWGMXRUsyHQ4NShEnwj kDs8nn9AxoaHMeC0jfD+XWp7sffkCW+VI8MGbmQ8v9xnEbV1mEVEAcRV1awvb++kEHWZj5EA xVKoGx09/F0rRH1CImmN/GlnJKaliAxcOJOH+gT0him8orJoB6kL1QeQRcUPbTKq/QKbTAt0 1aImfbgCjpurKCZRBqhy1uEkd+hEXNLdDFfPEfoWSNAuoC++99r0nojW/46SPbt5uAZDw0c1 NxjQMIWo7wIxfAG2Kyglbwsq2L9/8OZJuLZC+i+Y45E0u+bTNL1D2BLwQKChRqlEGp/ZgPb1 JTjs5LBhN3i9bnXyESwrBwlRdlFHcqtPjzGmkJIFJI87Tmr8HPLVdkOu2AjdRw2YpteIWSBj KrvVeV5vsU70JyCN/AfXm5MI55ykfiI+SrNCJg4keaikrAuLVTarUmClGab3nz3kVhErE3ME czzTCpYNl5DUf4P5GPvH481iOZ3rghjlDu7bc2qlHyPjOvBDEN5vJ9YaTNimMhit/jayOgUm v4CX/a3J+J3DLejP3KJqNFLdjjn7xETXPjLliCeTcbbSiIOJY3rI6W5LWoJd9M3kqJLuP3P+ 33hCEZUxECm3S/MKBmQa2AlY7TqBM4toXU+NC0qHFCpx3l8Ptr/sPZBL8M6Les96ehu7f9oV P1ZKc+ONetCF2bc8DMHYJij8IE7LEa3hRiDNjaOaSQke8IyXBTA/9LpJ1O99CQHAietm9E5p rmsilHSTZYZHlwwB8fKcvO/iVi2uCFFyu51WkLJJPhVeVntr9c2e3Cg0KdvLphVexvZxzac2 wKHOjsipLHA890v7d3EpaGYtIP1QeFwKVVXQjvA5rGsOCiEomf6md1cUPyFdCz2XX/v/Pnwf v1cyvzxPaFVnFtOtIYgQb9nwbhnuonqrr5eiA9lAG/KfxKgDbY5eiuK2sxGt6tswL5FuFTpB hLTq4cCYbjZatn4FFMxJRY+arXR3P4ZrTDe8PApLRio/yRw5reGDR1fMhTkZPax91ep3FfJG dschfM= IronPort-HdrOrdr: A9a23:U/F/Y62kDMbbDxTYFliKuQqjBEgkLtp133Aq2lEZdPU0SKGlfg 6V/MjztCWE7Ar5PUtLpTnuAsa9qB/nm6KdgrNhWItKPjOW21dARbsKheffKlXbcBEWndQtt5 uIHZIeNDXxZ2IK8PoT4mODYqodKA/sytHWuQ/cpU0dMz2Dc8tbnmBE4p7wKDwMeOFBb6BJcq a01458iBeLX28YVci/DmltZZm4mzWa/KiWGCLvHnQcmXGzsQ8= X-IronPort-AV: E=Sophos;i="5.88,209,1635220800"; d="scan'208";a="60126719" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 1/4] x86/cpuid: Split dom0 handling out of init_domain_cpuid_policy() Date: Wed, 15 Dec 2021 22:21:12 +0000 Message-ID: <20211215222115.6829-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211215222115.6829-1-andrew.cooper3@citrix.com> References: <20211215222115.6829-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1639606941774100006 To implement dom0-cpuid=3D support, the special cases would need extending. However there is already a problem with late hwdom where the special cases override toolstack settings, which is unintended and poor behaviour. Introduce a new init_dom0_cpuid_policy() for the purpose, moving the ITSC a= nd ARCH_CAPS logic. The is_hardware_domain() can be dropped, and for now there is no need to rerun recalculate_cpuid_policy(); this is a relatively expens= ive operation, and will become more-so over time. Rearrange the logic in create_dom0() to make room for a call to init_dom0_cpuid_policy(). The AMX plans for having variable sized XSAVE states require that modifications to the policy happen before vCPUs are created. Additionally, factor out domid into a variable so we can be slightly more correct in the case of a failure, and also print the error from domain_create(). This will at least help distinguish -EINVAL from -ENOMEM. No practical change in behaviour. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * New It is slightly weird now having CPUID split into two helpers, while the MSR side of things remains as a special case. It doesn't actually matter right now, and it is going to have to change anyway in due course, so I've decided to go with the simple option for now. --- xen/arch/x86/cpuid.c | 25 +++++++++++++++---------- xen/arch/x86/include/asm/cpuid.h | 3 +++ xen/arch/x86/setup.c | 15 +++++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 151944f65702..f63f5efc17f5 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -727,23 +727,28 @@ int init_domain_cpuid_policy(struct domain *d) if ( !p ) return -ENOMEM; =20 - /* The hardware domain can't migrate. Give it ITSC if available. */ - if ( is_hardware_domain(d) ) - p->extd.itsc =3D cpu_has_itsc; + d->arch.cpuid =3D p; + + recalculate_cpuid_policy(d); + + return 0; +} + +void __init init_dom0_cpuid_policy(struct domain *d) +{ + struct cpuid_policy *p =3D d->arch.cpuid; + + /* dom0 can't migrate. Give it ITSC if available. */ + if ( cpu_has_itsc ) + p->extd.itsc =3D true; =20 /* * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to do= m0, * so dom0 can turn off workarounds as appropriate. Temporary, until = the * domain policy logic gains a better understanding of MSRs. */ - if ( is_hardware_domain(d) && cpu_has_arch_caps ) + if ( cpu_has_arch_caps ) p->feat.arch_caps =3D true; - - d->arch.cpuid =3D p; - - recalculate_cpuid_policy(d); - - return 0; } =20 void guest_cpuid(const struct vcpu *v, uint32_t leaf, diff --git a/xen/arch/x86/include/asm/cpuid.h b/xen/arch/x86/include/asm/cp= uid.h index 46904061d0ef..9c3637549a10 100644 --- a/xen/arch/x86/include/asm/cpuid.h +++ b/xen/arch/x86/include/asm/cpuid.h @@ -59,6 +59,9 @@ bool recheck_cpu_features(unsigned int cpu); /* Allocate and initialise a CPUID policy suitable for the domain. */ int init_domain_cpuid_policy(struct domain *d); =20 +/* Apply dom0-specific tweaks to the CPUID policy. */ +void init_dom0_cpuid_policy(struct domain *d); + /* Clamp the CPUID policy to reality. */ void recalculate_cpuid_policy(struct domain *d); =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index f40a9fe5d351..e716005145d3 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -772,6 +772,7 @@ static struct domain *__init create_dom0(const module_t= *image, }; struct domain *d; char *cmdline; + domid_t domid; =20 if ( opt_dom0_pvh ) { @@ -786,10 +787,16 @@ static struct domain *__init create_dom0(const module= _t *image, if ( iommu_enabled ) dom0_cfg.flags |=3D XEN_DOMCTL_CDF_iommu; =20 - /* Create initial domain 0. */ - d =3D domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim); - if ( IS_ERR(d) || (alloc_dom0_vcpu0(d) =3D=3D NULL) ) - panic("Error creating domain 0\n"); + /* Create initial domain. Not d0 for pvshim. */ + domid =3D get_initial_domain_id(); + d =3D domain_create(domid, &dom0_cfg, !pv_shim); + if ( IS_ERR(d) ) + panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + + init_dom0_cpuid_policy(d); + + if ( alloc_dom0_vcpu0(d) =3D=3D NULL ) + panic("Error creating d%uv0\n", domid); =20 /* Grab the DOM0 command line. */ cmdline =3D image->string ? __va(image->string) : NULL; --=20 2.11.0 From nobody Fri May 3 11:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1639606940; cv=none; d=zohomail.com; s=zohoarc; b=g0zfNKjs7vspQ0rPJEMXVQz2WhQfFRnW5GSUpXMNmd4tqIOiCqld5z0aYl4bootoUD5V08o2ErisgWud+j95BFJz8d1SQrmpzTtPCY/LGksLVuV2J2Kg1E0GOggnMCAa2ZCsHgCGkKRKFySbVpOYMxqu4Z023YdHDntUqUX9Ciw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639606940; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lct/efNtDFjn2LwVR3W1kW13PfqkR3qYBxTvjyUj8pM=; b=CsrGn0F9NtnV6b+PFXq836pQGr+U7mQSSwJOQLSQ416LpedpH3PHY633XO8+qYK+oS5AUE3jXngAW9G2sYrvOPuJeJnqsBr66m/AA35YKG17hF4GF9vtCeCpZaVsfJUzOVkclM0KNk68sqtxlkehbdKsaYDact/ThI6Pd+o1Rmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1639606940863860.3750191565922; Wed, 15 Dec 2021 14:22:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.247619.427007 (Exim 4.92) (envelope-from ) id 1mxceg-0005ut-Pa; Wed, 15 Dec 2021 22:21:46 +0000 Received: by outflank-mailman (output) from mailman id 247619.427007; Wed, 15 Dec 2021 22:21:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxceg-0005ug-Jk; Wed, 15 Dec 2021 22:21:46 +0000 Received: by outflank-mailman (input) for mailman id 247619; Wed, 15 Dec 2021 22:21:45 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxcef-0005ZJ-Mx for xen-devel@lists.xenproject.org; Wed, 15 Dec 2021 22:21:45 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 620a7ecf-5df5-11ec-9e60-abaf8a552007; Wed, 15 Dec 2021 23:21:43 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 620a7ecf-5df5-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1639606904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x7dgLyygTieu5IPGh9PaNnQdDucWMUK0ck0vN46ZQe0=; b=byCEMiZw4MKNEKkANXCa6N9y3etkM51+1/2PWZ6mi5+0G/A6QIOlHVmY E1qi3qCqUCiM/wDLF0c3wn4p3UD1U+NIp+OQk/E9je0cfn/P7fM9OY5rz m7wClo85gFnXEeVA/pxYGvReUehJgmTAzvPJtBpFQql1y474SbQektdZr A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: B+uNPfy2nMfU3sOoyVOiRequXFFuiYR57zcsfX2zsEcXeV68gNmZpJ8hf+DjDYi84FjSZkA7EN fX9y/MZDBnh91QVIJ4g1gnpdApt7WTW65Aq7kCLPhD8YCKzOQlxF4tkSTA3l7hHRGSwW9mRO91 QczXBawPOQlibfduiGaw2ChaSIigxA2RJd/5qoTyRoFM7Nt0eX9JvhNA8FsKuqDijlOcoeEmcA rRKr17PS16a+RL9fQ8d0DQuch+QAeMzo911F+WJbzt1mo9OA7pPc5J88ggAjFGwUNs843GXe5v pvaYM8ySv+2IoasRIEjZr9GX X-SBRS: 5.1 X-MesageID: 59629092 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:iQAcgKAEp/YpWxVW/+Tkw5YqxClBgxIJ4kV8jS/XYbTApG5z1TAAx mQcUDrVPfiKZzakKY0jPIXi9E5QvpDcnIBnQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WL6s1hxZH1c+EX570E87wIbVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/kinYkvpek 4l2v4GOeTcwHPyUm6MSTEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTY+9gnMk8auLsO5sSoCpIxjDFF/c2B5vERs0m4PcFjWlq15gfR54yY eIcZDxXMlffRCFjPws4JYM8meGCunrWJmgwRFW9+vNsvjm7IBZK+KfpGMrYfJqNX8o9tmSyq 3/C/m/5KgoHL9HZwj2Amlq8i+mKkS7lVYY6ELyj6uUskFCV3nYUChAdSR28u/bRt6Klc4sBc QpOoHNo9PVsshzwJjXgY/GmiGeY7xM2dIEMKOcn1jG904iFuwXeCXdRG1atd+canMMxQDUr0 HqAkNXoGSFjvdWpdJ6NyluHhWjsYHZIdAfucQdBFFJYuIe7/OnfmzqWFo47eJNZmOEZDt0ZL 9qiiCElz4segscQv0lQ1QCW2mn8znQlo+Nc2+k2Yo5Hxl8pDGJGT9bxgbQ+0RqmBNzDJrVml CJb8/VyFMhUUfmweNWlGY3h5o2B6fefKyH7ilVyBZQn/DnF0yf9JtENsWohdBozap1sldrVj Kn741k5CHh7ZiTCUEOKS9jpV5RCIVbIS7wJqcw4nvIRO8MsJWdrDQllZFKK3nCFraTfufpXB HtvSu71VSxyIf0+lFKeHr5BuZd2l3hW7T6CHvjTkkX4uYdykVbIEN/pxnPVNbtnhE5FyS2Im +ti2zyil08CDbagO3aPqub+7zkidBAGOHw/kOQPHsbrH+asMDhJ5yb5zexzdop7sb5Sk+uUr HixVlUBkAj0hGHdKBXMYXdmMeu9UZF6pHM9HCotIVf3hCRzPdfxtP8SJ8ktYL0q1O1/1vooH fMLTNqNX6ZUQTPd9jVDMZSk9N5+dA6mjB6lNja+ZGRtZIZpQgHEo4e2fgbm+CQUIDCwsM8y/ ++p2g/BGMJRTAV+FsfGLvmoygrp73QanetzWWrOI8VSJxqwoNQ7dXSpg6Zucc8WKBjFyj+L7 CqsAE8V9bvXvos40NjVnqTY/Y2nJPRzQxhBFG7B4LfoaSSDpji/wZVNWfqjdCzGUD+m472rY OhYwq2uMPADm1oW4YNwH6wykPA77trr4bRb0h5lDDPAaFHyUuFsJXyP3M9usKxRx+AG5VvqC xzXotQKa6+UPM7FEUIKIFt3Z+uO4vgYhz3O4KlnO079/iJ2oOKKXEg608NgU8CBwG+Z6L8Y/ No= IronPort-HdrOrdr: A9a23:hufbQq9tjKQRhlZMxPJuk+DgI+orL9Y04lQ7vn2YSXRuHPBw8P re5cjztCWE7gr5N0tBpTntAsW9qDbnhPtICOoqTNCftWvdyQiVxehZhOOIqVDd8m/Fh4pgPM 9bAtBD4bbLbGSS4/yU3ODBKadD/OW6 X-IronPort-AV: E=Sophos;i="5.88,209,1635220800"; d="scan'208";a="59629092" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 2/4] x86/cpuid: Factor common parsing out of parse_xen_cpuid() Date: Wed, 15 Dec 2021 22:21:13 +0000 Message-ID: <20211215222115.6829-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211215222115.6829-1-andrew.cooper3@citrix.com> References: <20211215222115.6829-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1639606941711100002 dom0-cpuid=3D is going to want to reuse the common parsing loop, so factor = it out into parse_cpuid(). Irritatingly, despite being static const, the features[] array gets duplica= ted each time parse_cpuid() is inlined. As it is a large (and ever growing with new CPU features) datastructure, move it to being file scope so all inlines use the same single object. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * New We probably want to be wary of fallout from this pattern elsewhere. I only noticed it by chance. --- xen/arch/x86/cpuid.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index f63f5efc17f5..e11f5a3c9a6b 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -26,17 +26,26 @@ static const uint32_t __initconst hvm_hap_def_featurema= sk[] =3D INIT_HVM_HAP_DEF_FEATURES; static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; =20 -static int __init parse_xen_cpuid(const char *s) +static const struct feature_name { + const char *name; + unsigned int bit; +} feature_names[] __initconstrel =3D INIT_FEATURE_NAMES; + +/* + * Parse a list of cpuid feature names -> bool, calling the callback for a= ny + * matches found. + * + * always_inline, because this is init code only and we really don't want a + * function pointer call in the middle of the loop. + */ +static int __init always_inline parse_cpuid( + const char *s, void (*callback)(unsigned int feat, bool val)) { const char *ss; int val, rc =3D 0; =20 do { - static const struct feature { - const char *name; - unsigned int bit; - } features[] __initconstrel =3D INIT_FEATURE_NAMES; - const struct feature *lhs, *rhs, *mid =3D NULL /* GCC... */; + const struct feature_name *lhs, *rhs, *mid =3D NULL /* GCC... */; const char *feat; =20 ss =3D strchr(s, ','); @@ -49,8 +58,8 @@ static int __init parse_xen_cpuid(const char *s) feat +=3D 3; =20 /* (Re)initalise lhs and rhs for binary search. */ - lhs =3D features; - rhs =3D features + ARRAY_SIZE(features); + lhs =3D feature_names; + rhs =3D feature_names + ARRAY_SIZE(feature_names); =20 while ( lhs < rhs ) { @@ -72,11 +81,7 @@ static int __init parse_xen_cpuid(const char *s) =20 if ( (val =3D parse_boolean(mid->name, s, ss)) >=3D 0 ) { - if ( !val ) - setup_clear_cpu_cap(mid->bit); - else if ( mid->bit =3D=3D X86_FEATURE_RDRAND && - (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)= ) ) - setup_force_cpu_cap(X86_FEATURE_RDRAND); + callback(mid->bit, val); mid =3D NULL; } =20 @@ -95,6 +100,20 @@ static int __init parse_xen_cpuid(const char *s) =20 return rc; } + +static void __init _parse_xen_cpuid(unsigned int feat, bool val) +{ + if ( !val ) + setup_clear_cpu_cap(feat); + else if ( feat =3D=3D X86_FEATURE_RDRAND && + (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) ) + setup_force_cpu_cap(X86_FEATURE_RDRAND); +} + +static int __init parse_xen_cpuid(const char *s) +{ + return parse_cpuid(s, _parse_xen_cpuid); +} custom_param("cpuid", parse_xen_cpuid); =20 #define EMPTY_LEAF ((struct cpuid_leaf){}) --=20 2.11.0 From nobody Fri May 3 11:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1639606943; cv=none; d=zohomail.com; s=zohoarc; b=CkSrbGDytTtTGymoz5zfrP5qN8c2l2KGXc0OMQXy6WvY+SFSmItL0ng+f27dpn6a5b++l6DBePp2zdqhBA/enGjTZ3iLHtfU6ZOnMs76toPkcnJS2o+FBAbyn38xFnY5jXTtkd8imIcq2FkJc5epAQ18ecvyrukoWsw4gaWa2LQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639606943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4z6Xf46wo0FqPIWQPBE2Z6JpEVgsajI8LIrGEuaejwU=; b=S7flOFuTnFCVnujgfJFvpSAppUPMCh5ln2sz987K+ffmJWYPmk63mQpIRTbpnsQMtUi7mod4uz7B/T3rs2Y5EI47iQ74jvwdFNNIhazzb6epgsE95bbga7cIgunuaV+R2Zjd45RweEI+37dWOQ8jF+E5ZUJaxVLrVGDE8uD2FaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1639606943444736.8591493534813; Wed, 15 Dec 2021 14:22:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.247620.427022 (Exim 4.92) (envelope-from ) id 1mxcei-0006Mw-4n; Wed, 15 Dec 2021 22:21:48 +0000 Received: by outflank-mailman (output) from mailman id 247620.427022; Wed, 15 Dec 2021 22:21:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxcei-0006MT-1M; Wed, 15 Dec 2021 22:21:48 +0000 Received: by outflank-mailman (input) for mailman id 247620; Wed, 15 Dec 2021 22:21:46 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxceg-0005ZJ-Mu for xen-devel@lists.xenproject.org; Wed, 15 Dec 2021 22:21:46 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 62bea4b9-5df5-11ec-9e60-abaf8a552007; Wed, 15 Dec 2021 23:21:45 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 62bea4b9-5df5-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1639606904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1sJTP2vFe7TUxYv8fxcjX4sbJWFBPyrCwJr81dmHE5A=; b=QZlKSctVc7MTYak1OnqQnE1rJ+kPqbYcnj8AIElwLlb1oOERCo4OCu1l VsStOEmPf8xgpYShKkK3f8ycDfgs7/2SufZBtXUAoSI0o93s3WI4Sz1CW diN4uXMYqwseUYdZzdrcpCQW6ORzmgWtNKQeof7dioQ5I5j6+z8+Zp5NN s=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: bfkV+bUSFRfie8G58yskNAm4RdSahQqULovzT5f9dhAknp/T5GNtOf8ZeXBSQKfRdy3v1vVCBq lQK2SsfV1r9xKzD0gbdWMD1TfhIb/Wt9qpEZLfSGLNk+aATyywmS8tpmCzl8ElI6mCPdoXxPe+ vuFMuj6LGgeodUm6Lw6ZCCVqS2kQEMxy+r970Wzlq01hhdeuJ05wS0Q0KJSJ9q+1Qhd4HdIgC+ Syt+Kx6eWE3oUW5ox8NazXPJqyPbZLHWRAUvE2I0JW1Xf/ZJArYF4nxOJdso9Q72ECeVqvqvVd kQSH6MxtmU0pvDCYpg3fpFzv X-SBRS: 5.1 X-MesageID: 60126720 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:2F+FPqMM72hx4RrvrR1okMFynXyQoLVcMsEvi/4bfWQNrUp01TEFz TccWWyCPf6LYWDwL48latvgo0MH7JLSn9FmQQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6UUsxNbVU8En5400s+w7VRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYowuktOhvx NBkj4WbcSc0fbXxsdgHXDANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YsBqit4uM4/AO4QHt2s75TrYEewnUdbIRKCiCdpwgm9p3J4RR662i 8wxSjVORx38PjB1BFYcLpYgt9imgHf9WmgNwL6SjfVuuDWCpOBr65DyNPLFd9rMQt9a9m66j G/b+2XyAjkBKceSjzGC9xqEluLJ2C/2Ro8WPLm57eJxxk2ewHQJDx8bXkf9puO24nNSQPoGd RZSoHB36/Fvqgr7FbERQiFUvla6kzUkRdZVOtcjwzmt1+nM3i+lHGctG2sphMMdiOc6Qjkj1 1msltzvBCByvLD9dU9x5ot4vhvpZ3FLcDZqiTssCFJcvoK9+N1bYgfnF447SMaIYsvJ9SYcK txghAw3nP0tgMECzM1XFniX0mv39vAlouPYjzg7v15JDCslNOZJhKTysDA3CMqsyq7DFDFtW 1BexKCjABgmV83lqcB0aLxl8EuVz/iEKibAplVkAoMs8T+gk1b6I9sBvWAlexc0aJ5fEdMMX KM1kVkLjHO0FCH1BZKbnqrrU5h6pUQePYqNug/ogipmPcEqKV7vENBGbk+MxWH9+HXAYolkU ap3hf2EVC5AYYw+lWLeb75EjdcDm3FmrUuOFMuT50n2jtKjiIu9FO5t3K2mNbtisstpYWz9r r5iCid940kFDbClPHCIqdV7wJJjBSFTOK0aYvd/LoarSjeK0kl7YxMI6b9+KYFjgYpPkeLEo iO0VkNCkQKtjnzbMwSaLHtkbeq3D5p4qHs6Ow0qPEqphCd/Mdr+sv9HestlZ6Qj+cxi0eVwE 6sPdfKfD6kdUT/A4TkcM8Xw9dQwaBSxiAuSFCO5ezxjLYV4TgnE94a8LAvi/SUDFAStss46r +Hy3w/XW8NbFQ9jENzXeLSkyFbo5SoRn+d7Xk3pJNhPeRqzrNg2enKp1vJuepMCMxTOwDeex j26OxZAqLmfuZIx/fnImbuA89WjHdxhExcIBGLc97u3a3XXpzLx3Y9aXe+UVjnBT2eoqr66b OBYwvygYv0KmFFG79h1H7pxlP9s4tLuo/lRzxh+HWWNZFOuU+syLn6D1MhJl6tM2r4G5lfmB hPRooFXaeeTJcfoMF8NPw50PO2M2MYdliTW8flocl7x4zV6/ebfXEhfV/VWZPex8Feh3FsZ/ Noc IronPort-HdrOrdr: A9a23:EaD/Nqp0yV2NSod8zw6W+rcaV5rReYIsimQD101hICG9Evb0qy lhppQmPH7P+VIssRQb8+xoV5PufZqxz/BICOoqTNKftWvdyQiVxehZhOOP/9SJIUbDH4VmpM VdmsZFaeEZDTJB/LvHCAvTKadd/DFQmprY+ts3zB1WPH9Xg7kL1XYfNu4CeHcGPzWvA/ACZf yhz/sCnRWMU1INYP+2A3EUNtKz3eEixPrdEGc77wdM0nj3sQ+V X-IronPort-AV: E=Sophos;i="5.88,209,1635220800"; d="scan'208";a="60126720" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 3/4] x86/cpuid: Introduce dom0-cpuid command line option Date: Wed, 15 Dec 2021 22:21:14 +0000 Message-ID: <20211215222115.6829-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211215222115.6829-1-andrew.cooper3@citrix.com> References: <20211215222115.6829-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1639606944226100001 Specifically, this lets the user opt in to non-default for dom0. Collect all dom0 settings together in dom0_{en,dis}able_feat[], and apply it to dom0's policy when other tweaks are being made. As recalculate_cpuid_policy() is an expensive action, and dom0-cpuid=3D is likely to only be used by the x86 maintainers for development purposes, for= go the recalculation in the general case. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * Rework almost from scratch, on top of broken-out changes. --- docs/misc/xen-command-line.pandoc | 17 +++++++++++++++++ xen/arch/x86/cpuid.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index f7797ea233f9..383a854dec60 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -801,6 +801,23 @@ Controls for how dom0 is constructed on x86 systems. =20 If using this option is necessary to fix an issue, please report a bug. =20 +### dom0-cpuid + =3D List of comma separated booleans + + Applicability: x86 + +This option allows for fine tuning of the facilities dom0 will use, after +accounting for hardware capabilities and Xen settings as enumerated via CP= UID. + +Options are accepted in positive and negative form, to enable or disable +specific features, but specify both forms of the same option is undefined. +All selections via this mechanism are subject to normal CPU Policy safety = and +dependency logic. + +This option is intended for developers to opt dom0 into non-default featur= es, +and is not intended for use in production circumstances. If using this op= tion +is necessary to fix an issue, please report a bug. + ### dom0-iommu =3D List of [ passthrough=3D, strict=3D, map-inclusive=3D<= bool>, map-reserved=3D, none ] diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index e11f5a3c9a6b..83a80ba6de70 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -116,6 +116,23 @@ static int __init parse_xen_cpuid(const char *s) } custom_param("cpuid", parse_xen_cpuid); =20 +static bool __initdata dom0_cpuid_cmdline; +static uint32_t __initdata dom0_enable_feat[FSCAPINTS]; +static uint32_t __initdata dom0_disable_feat[FSCAPINTS]; + +static void __init _parse_dom0_cpuid(unsigned int feat, bool val) +{ + __set_bit(feat, val ? dom0_enable_feat : dom0_disable_feat); +} + +static int __init parse_dom0_cpuid(const char *s) +{ + dom0_cpuid_cmdline =3D true; + + return parse_cpuid(s, _parse_dom0_cpuid); +} +custom_param("dom0-cpuid", parse_dom0_cpuid); + #define EMPTY_LEAF ((struct cpuid_leaf){}) static void zero_leaves(struct cpuid_leaf *l, unsigned int first, unsigned int last) @@ -768,6 +785,25 @@ void __init init_dom0_cpuid_policy(struct domain *d) */ if ( cpu_has_arch_caps ) p->feat.arch_caps =3D true; + + /* Apply dom0-cpuid=3D command line settings, if provided. */ + if ( dom0_cpuid_cmdline ) + { + uint32_t fs[FSCAPINTS]; + unsigned int i; + + cpuid_policy_to_featureset(p, fs); + + for ( i =3D 0; i < ARRAY_SIZE(fs); ++i ) + { + fs[i] |=3D dom0_enable_feat[i]; + fs[i] &=3D ~dom0_disable_feat[i]; + } + + cpuid_featureset_to_policy(fs, p); + + recalculate_cpuid_policy(d); + } } =20 void guest_cpuid(const struct vcpu *v, uint32_t leaf, --=20 2.11.0 From nobody Fri May 3 11:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1639606940; cv=none; d=zohomail.com; s=zohoarc; b=Ohtm4e5L7grdzp9sdDIZQ3leJMFhtGZ+RQVxoz3YM7+Eoek3WJLeCLiUTKjpD/YzzS8bOlgy/XarkM3WrGTWPrysOOpt8+Lv7OmHETzK+4FaCLSW1GUE5gzew3d1jtOmS0H5724HAIvBBiScSdlDCLJrhVE46zaBSFNkzZFu7u0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639606940; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZdEkdewY43s+bvP87mqowIVSruuEZNVklaFQwBZEDcI=; b=TivlK92fdelBT+piFYopXOzqotNMAVO33uING1WQ/f04bK1SVYZ0S4PSgVE+YkT+9TsEoBpLDfk8Gq0RcTYOKaxFH10hO7fsst+vG4ocnLtvk2j9SDBE02tSeP/RCt28FHahDPXbE7gPFp3NZsXexU71r/TTQCHrbExR9KbKVRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1639606940338509.8407866832762; Wed, 15 Dec 2021 14:22:20 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.247616.426980 (Exim 4.92) (envelope-from ) id 1mxcea-0005J8-MI; Wed, 15 Dec 2021 22:21:40 +0000 Received: by outflank-mailman (output) from mailman id 247616.426980; Wed, 15 Dec 2021 22:21:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxcea-0005J1-JK; Wed, 15 Dec 2021 22:21:40 +0000 Received: by outflank-mailman (input) for mailman id 247616; Wed, 15 Dec 2021 22:21:39 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxceZ-0005Iv-6h for xen-devel@lists.xenproject.org; Wed, 15 Dec 2021 22:21:39 +0000 Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5d6815eb-5df5-11ec-85d3-df6b77346a89; Wed, 15 Dec 2021 23:21:37 +0100 (CET) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5d6815eb-5df5-11ec-85d3-df6b77346a89 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1639606897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WS7TqjZJbtgUipE6pePfwgLxq9oaFQsVTAwBm5aBAdY=; b=caaZPpe9V1lnqVaAsPV2Gl4ObbMZ0hn8h5unxxQW4eVM9Geq9yeqr4Ug mTUbIOLldFwnUXUBB9VjwRRVFC73BR/b0cxDle3kvcZdRNYzE6LJfw1v/ 6CPj8mp04ei6EktKxzrOLCivE8Pa7VAZO7N/oWfYxATXV0ba8ZKG5kqCq M=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: CIghVhnnSCByUBP/iUbUGkqFldz5Ml1iaGVjnjha/bNdwNGXWiiJlyBagz3YpSZpFB01MIwTgr o10nqib/3NdcT7Swd8M1J5Fw0rEb9udkY6uGsmJEjIhNQ0HWZOJWL7ZoY0FXA4VChDob47zJkd akwCBa2I/iUbWUe6gcQtGzahT6XYPrFXELIiyWFPi87fKOFIGRdJ1Jppg+Asol4E71n8ytvV8w nUk8nOuxawuYYkqnMPrgymcLB1hdqyXIsOuIEAwfC2Us2fWN76tmEl0++1a5DOY06YM39zIMUv IZqHcUR2u4SmPB7eMnsrV++g X-SBRS: 5.1 X-MesageID: 62205277 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:+RoyF6+3nB6vw2SGn8ppDrUDTXmTJUtcMsCJ2f8bNWPcYEJGY0x3m zMcD2mEPKqIN2ume91ybNuw8BlUvcTQy95iGwFqqik8E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2ybuOU5NXsZ2YhFWeIdA970Ug6wrRg39Yz6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPgr9 s1MhcSaWTx4EfOQucBFajoASnhHaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguwKKsXxMZxZkXZn1TzDVt4tQIzZQrWM7thdtNs1rp4UR66DP ZVGAdZpRD/DRyRpAVAdM4N9ke2Eu3DbYTFg73vA8MLb5ECMlVcsgdABKuH9ZdiiVchT2EGCq Qru3U70HxUbP9y30iee/zSngeqntTP2XsceGaO18tZugUaP3SoDBRsOT1y5rPKlzEmkVLpix 1c8o3R06/JorQryE4e7D0bQTGO4UgA0AeRIEt1iwhG2m4WKvye9XlEnFmcYUYlz3CMpfgAC2 liMltLvIDVgtryJVH6QnoupQSOO1Ts9djFbO3JdJecRy5y6+dxo0EqTJjp2OPft1oWdJN3m/ 9ydQMHSbZ03hNVD6ai09Euvb9mE9smQFV5dCuk6swuYAuJFiGyNO9zABbvzt68owGOlor+p5 iJsdy+2tr9mMH11vHbRKNjh5Znwjxp/DBXSgER0A74q/Cm39niocOh4uW8ldRo4aZlUJGWxO yc/XD+9ArcJZhNGioctPOqM5zkCl/C8RbwJqNiKBjaxXnSBXFDep3w/DaJh92vsjFItgckC1 WSzKq6R4YIhIf0/llKeHr5FuZdyn3xW7T6CHfjTkkX8uZLDNSH9dFvwGAbXBgzPxPjf+1u9H hc2H5bi9iizp8WiOHSKqtBKcghRRZX5bLivw/Fqmie4ClIOMAkc5zX5mNvNoqRpwPZYkPnm5 Ha4VhMKwVbznySfew6LdmpiePXkWpMm9SA3OiklPFCJ3Xk/YNnwsPdDJsVvJbR3pvZ+yfNUT uUef5nSCPp4VTmaqS8WaoPwrdI+eU3z1x6OJSesfBM2Y4VkG17S4tbhcwa2rHsOAyO7uNEQu bql0g+HE5MPSx47VJTdae61zkP3tn8YwbogU0zNK9hVWUPt7Ik1dHCh0q5pe5kBcEyRyCGb2 gCaBQYjidPM+4JlosPUga2krpuyF7csFERtAGSGv629MjPX/zT/zNYYAvqIZz3USEj95L6mO bdO1/j5PfAKwARKvo57H+o5xK4y/YKy9bpTzwAiF3TXdVW7TLhnJyDej8VIs6RMwJ5fuBe3B R3TqoULZ+3RNZO3CkMVKSokcv+HhKMdlTTl5PgoJFn3uX1s972dXEQOZxSBhUSx9leu3F/JF Qv5hPMr1g== IronPort-HdrOrdr: A9a23:p9s7Ya0Zlyq/sjgJC8wRuAqjBIgkLtp133Aq2lEZdPRUGvb4qy nIpoVi6faUskdpZJhOo6HiBEDtexzhHNtOkO0s1NSZLW/bUQmTXeNfBOLZqlWKcUCTygce79 YGT0EXMqyKMbEQt6bHCWeDferIuOP3lZyVuQ== X-IronPort-AV: E=Sophos;i="5.88,209,1635220800"; d="scan'208";a="62205277" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 4/4] x86/cpuid: Advertise SERIALIZE by default to guests Date: Wed, 15 Dec 2021 22:21:15 +0000 Message-ID: <20211215222115.6829-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211215222115.6829-1-andrew.cooper3@citrix.com> References: <20211215222115.6829-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1639606941678100001 I've played with SERIALIZE, TSXLDTRK, MOVDIRI and MOVDIR64 on real hardware, and they all seem fine, including emulation support. SERIALIZE exists specifically to have a userspace usable serialising operat= ion without other side effects. (The only other two choices are CPUID which is= a VMExit under virt and clobbers 4 registers, and IRET-to-self which very slow and consumes content from the stack.) TSXLDTRK is a niche TSX feature, and TSX itself is niche outside of demos of speculative sidechannels. Leave the feature opt-in until a usecase is foun= d, in an effort to preempt the multiple person years of effort it has taken to mop up TSX issues impacting every processor line. MOVDIRI and MOVDIR64 are harder to judge. They're architectural building blocks towards ENQCMD{,S} without obvious usecases on their own. They're of no use to domains without PCI devices, so leave them opt-in for now. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * New --- xen/include/public/arch-x86/cpufeatureset.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/publ= ic/arch-x86/cpufeatureset.h index 647ee9e5e277..0b399375566f 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -278,7 +278,7 @@ XEN_CPUFEATURE(SRBDS_CTRL, 9*32+ 9) /* MSR_MCU_OPT= _CTRL and RNGDS_MITG_DIS. XEN_CPUFEATURE(MD_CLEAR, 9*32+10) /*A VERW clears microarchitectural= buffers */ XEN_CPUFEATURE(RTM_ALWAYS_ABORT, 9*32+11) /*! June 2021 TSX defeaturing in= microcode. */ XEN_CPUFEATURE(TSX_FORCE_ABORT, 9*32+13) /* MSR_TSX_FORCE_ABORT.RTM_ABORT = */ -XEN_CPUFEATURE(SERIALIZE, 9*32+14) /*a SERIALIZE insn */ +XEN_CPUFEATURE(SERIALIZE, 9*32+14) /*A SERIALIZE insn */ XEN_CPUFEATURE(TSXLDTRK, 9*32+16) /*a TSX load tracking suspend/resu= me insns */ XEN_CPUFEATURE(CET_IBT, 9*32+20) /* CET - Indirect Branch Tracking= */ XEN_CPUFEATURE(IBRSB, 9*32+26) /*A IBRS and IBPB support (used by= Intel) */ --=20 2.11.0