From nobody Sat Nov 30 03:46:17 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=1620056432; cv=none; d=zohomail.com; s=zohoarc; b=k1bsjkjBf+5lcWDgqy6Amh0wXJwkkcV7jbf9/U+Ri3kH3flC/SE0eeYPJt7Vyrgto6oCFz31o6WcKY7m+gi+7U/LcGCViA5DwRVTCrlAbDRAlQgHvQonLGYC+SLTFVTDhmEOdP+GBPS2IfHDuYZjcFqQxzv8OQ/adHNWtIC3ZuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620056432; 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=F10saV9MrvqaJxiBzc+z1Jk3cu//eDFS/mytYs/qxE8=; b=dn9Wfd45JNle4++IOF5aG/u5EH7j0xJz99QcKnUOcDzQi9NgjuoxXtnVWq2y3LzB8w/oQMzvhYpsZ6ZEL3h8RoqnWppb2KabZiK22KluW3MnR0rB40VxpREz+umeSCneTszJXF5d63YDwmoQO2rVz6fzxgx28Hsrs73adiUD5G8= 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) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620056432371341.38688830627495; Mon, 3 May 2021 08:40:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.121708.229574 (Exim 4.92) (envelope-from ) id 1ldagG-00029M-9B; Mon, 03 May 2021 15:40:20 +0000 Received: by outflank-mailman (output) from mailman id 121708.229574; Mon, 03 May 2021 15:40:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ldagG-00029B-3u; Mon, 03 May 2021 15:40:20 +0000 Received: by outflank-mailman (input) for mailman id 121708; Mon, 03 May 2021 15:40:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ldagE-00024k-PX for xen-devel@lists.xenproject.org; Mon, 03 May 2021 15:40:18 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6c9f735a-84bf-45b9-93ac-1f6aa835f82c; Mon, 03 May 2021 15:40:13 +0000 (UTC) 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: 6c9f735a-84bf-45b9-93ac-1f6aa835f82c DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620056413; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jIHwbXNLvjr4f1oZ4tb+qy7o6+MtjNlDvDcd+ysvfTI=; b=BuqCEfw74JtwAkbgUHEaJ4rW7Lvf+g4qEZ2gem1LZsno/9w2T50EiQzC 1hjkaCF43UD5FvAxD5vkXiWC2hhI4BrEEo02kSn6Jqc2E8LSJeV8PSfO5 uAM8B2hUPOXRKdQvySIjKreLPUe89c/837zxvqHj5/ubatgU7Hx2dTBIB s=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: H8alMazpCCJaYOggVvYZDMfYy/DJMgq68K+15edzm5ilvKT9vOwyZAbK4zXMFQsGjpvIl4Ip/0 nwLK/2Zp9/y1udBRVGmlXdRyG4omwm65Jugrc0AMhyjBcJM022qsa80ghR3JcJVnUZILxfJav9 gnpBHL2P//yUwAI+4a8TTlnlUuyxAf04CVtk+J7l2zgXYRXL4S31rkABAslf3MqDY+N23PEZpe /VmAKPrEU9vp2EXqUxVFK4ByskrxZ4Io22/XvN3/gNd9OGtI1/Nx3vQrFO1WMR69GPug7arKUI t2U= X-SBRS: 5.1 X-MesageID: 42942252 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:gYQGjKgbg5jonU+AM8TG8wVStHBQXl0ji2hD6mlwRA09T+Wzva mV/cgz/xnylToXRTUcgtiGIqaNWjfx8pRy7IkXM96ZLXHbkUGvK5xv6pan/i34F0TFh5dg/I ppbqQWMqySMXFUlsD/iTPWL/8Bx529/LmslaPiyR5WPGVXQoVByys8NQqBCE1xQ2B9dPwEPb 6R/NBOqTblWVl/VLXYOlA/U+LOp8LGmfvdCHZsbXNK1CC0gTyl87L8GRSDty1uNA9n+rs+7X PD1zXw+6TLiYDB9jbny2TR455K8eGA9vJ/AqW35PQ9G3HJggasaJ8JYczmgAwI X-IronPort-AV: E=Sophos;i="5.82,270,1613451600"; d="scan'208";a="42942252" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/5] x86/xstate: Rename _xstate_ctxt_size() to hw_uncompressed_size() Date: Mon, 3 May 2021 16:39:35 +0100 Message-ID: <20210503153938.14109-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210503153938.14109-1-andrew.cooper3@citrix.com> References: <20210503153938.14109-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) The latter is a more descriptive name, as it explicitly highlights the query from hardware. Simplify the internal logic using cpuid_count_ebx(), and drop the curr/max assertion as this property is guaranteed by the x86 ISA. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- xen/arch/x86/xstate.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index f82dae8053..e6c225a16b 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -554,19 +554,18 @@ void xstate_free_save_area(struct vcpu *v) v->arch.xsave_area =3D NULL; } =20 -static unsigned int _xstate_ctxt_size(u64 xcr0) +static unsigned int hw_uncompressed_size(uint64_t xcr0) { u64 act_xcr0 =3D get_xcr0(); - u32 eax, ebx =3D 0, ecx, edx; + unsigned int size; bool ok =3D set_xcr0(xcr0); =20 ASSERT(ok); - cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); - ASSERT(ebx <=3D ecx); + size =3D cpuid_count_ebx(XSTATE_CPUID, 0); ok =3D set_xcr0(act_xcr0); ASSERT(ok); =20 - return ebx; + return size; } =20 /* Fastpath for common xstate size requests, avoiding reloads of xcr0. */ @@ -578,7 +577,7 @@ unsigned int xstate_ctxt_size(u64 xcr0) if ( xcr0 =3D=3D 0 ) return 0; =20 - return _xstate_ctxt_size(xcr0); + return hw_uncompressed_size(xcr0); } =20 /* Collect the information of processor's extended state */ @@ -635,14 +634,14 @@ void xstate_init(struct cpuinfo_x86 *c) * xsave_cntxt_size is the max size required by enabled features. * We know FP/SSE and YMM about eax, and nothing about edx at pres= ent. */ - xsave_cntxt_size =3D _xstate_ctxt_size(feature_mask); + xsave_cntxt_size =3D hw_uncompressed_size(feature_mask); printk("xstate: size: %#x and states: %#"PRIx64"\n", xsave_cntxt_size, xfeature_mask); } else { BUG_ON(xfeature_mask !=3D feature_mask); - BUG_ON(xsave_cntxt_size !=3D _xstate_ctxt_size(feature_mask)); + BUG_ON(xsave_cntxt_size !=3D hw_uncompressed_size(feature_mask)); } =20 if ( setup_xstate_features(bsp) && bsp ) --=20 2.11.0