From nobody Sun Nov 24 16:19:18 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=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1730130639; cv=none; d=zohomail.com; s=zohoarc; b=GI7K0ErHPKrZJyUNP5X7Nu0Ky9aDJ7mcECmKObZLAQ4VwLV9iDsbKHv4O6km3AMyf370vtz9WN3EeTaJhmvB96DO98vcSyte1wBxFCclTBkEM/3K/XujieCQKF3qCgoPLL2g0yfw6OrkyLfGcqQEAXGNTyuJRXURX3K4stL2Nxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730130639; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HwNJgVlmgOrKpINGfBXiXo/pOeaz7GckymMD2iqzF3A=; b=hZDAUw12K32ho5jxI9faZ3mL8jmh17ze7OsFjO2FEgV555hbTitfv7BrNfPosj3k8so0ERrKtGGDD3QFUQywq+3CdYDMVqCuFkwdr2FE69Xu4yN6j3r7086czfGJ1oBtF29394V1k3ihemxyj/5ySyX+Z+NRiqEvbvu2EdrMBoI= 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 1730130639824366.8562377941986; Mon, 28 Oct 2024 08:50:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.826696.1241154 (Exim 4.92) (envelope-from ) id 1t5S0X-0003j4-Dj; Mon, 28 Oct 2024 15:50:17 +0000 Received: by outflank-mailman (output) from mailman id 826696.1241154; Mon, 28 Oct 2024 15:50:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5S0X-0003hF-0R; Mon, 28 Oct 2024 15:50:17 +0000 Received: by outflank-mailman (input) for mailman id 826696; Mon, 28 Oct 2024 15:50:15 +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 1t5S0V-0008FV-44 for xen-devel@lists.xenproject.org; Mon, 28 Oct 2024 15:50:15 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5144c1cb-9544-11ef-99a3-01e77a169b0f; Mon, 28 Oct 2024 16:50:12 +0100 (CET) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a9a2cdc6f0cso603068166b.2 for ; Mon, 28 Oct 2024 08:50:12 -0700 (PDT) Received: from localhost.localdomain ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b3a0834a6sm387674066b.191.2024.10.28.08.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:50:11 -0700 (PDT) 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: 5144c1cb-9544-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1730130612; x=1730735412; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HwNJgVlmgOrKpINGfBXiXo/pOeaz7GckymMD2iqzF3A=; b=Duuih0KxloKm6sWNfEyA3X8M8+QqdQBFfStVqYKNepZMoDGZ4GgrU/L3nbIDlpkcIR Myv9lnFxGJi9oPLOGO9zcTQPANVGlnKp0GyPFPDqIgQlRmmf9twubJSexKwhr7pkb6Lh nJFfBKpdDvM8xntw5V1pnJgPDVORJsZHx7X/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730130612; x=1730735412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HwNJgVlmgOrKpINGfBXiXo/pOeaz7GckymMD2iqzF3A=; b=kVluQsc3kD8D/uZAppkHV2Mi/L2VntPoBw/b3jT9Fc8LdPM4PoQHenK65uCq07PG3F gsRKRBubQDAqrc/TwbodAFb76kpaDqHUVkmW6zFJkQz2KTpM43+N8fLJUPXS1Lo0d07Y a6RKFCXNUVBJ2vuQd5jbzl11v+O6WOtc+HAWfqzrgYwHL5Uza5aRQrEBqr+LazgfS3B0 Ri+djPBzavRK0SwMbdqtZcEDvHITXGUqSfqbbAsRB0KFHMBWAVY9ovAn9uPaGbzeNCS0 cFHgCY5tcK/j0dwgG3962U0QegvwdUll2ENbkCJfVeIOhKGOnMC8ofZhPxambsEbfmhW bVug== X-Gm-Message-State: AOJu0Yx3BjKFw4X6/WGQZjLabr0QIimiUYkTow3VXtpYXBnqZWV+zgTb PEQyIV3weq75Yv2u4VK4d/1IotKKuSys/6eMD1norR9pDIlTo8Krh5HuQ5ehXoTH61qdTWnwrHV E X-Google-Smtp-Source: AGHT+IHEY1nVRqaVDFBcRPDXXekAHbeOYazAPOBV9yuB9+xZ37aBGYXnmRkAxgllujT4PRIvJffbng== X-Received: by 2002:a17:906:c14a:b0:a9a:80bd:2920 with SMTP id a640c23a62f3a-a9de61990b1mr811601166b.53.1730130611929; Mon, 28 Oct 2024 08:50:11 -0700 (PDT) From: Alejandro Vallejo To: xen-devel@lists.xenproject.org Cc: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 14/14] x86/xstate: Make xstate_all() and vcpu_xsave_mask() take explicit xstate Date: Mon, 28 Oct 2024 15:49:32 +0000 Message-ID: <20241028154932.6797-15-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028154932.6797-1-alejandro.vallejo@cloud.com> References: <20241028154932.6797-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1730130641446116600 Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/i387.c | 9 +++++---- xen/arch/x86/include/asm/xstate.h | 5 +++-- xen/arch/x86/xstate.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c index 7e1fb8ad8779..87b44dc11b55 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -108,7 +108,8 @@ static inline void fpu_fxrstor(struct vcpu *v, const fp= usse_t *fpu_ctxt) /* FPU Save Functions */ /*******************************/ =20 -static inline uint64_t vcpu_xsave_mask(const struct vcpu *v) +static inline uint64_t vcpu_xsave_mask(const struct vcpu *v, + const struct xsave_struct *xsave_ar= ea) { if ( v->fpu_dirtied ) return v->arch.nonlazy_xstate_used ? XSTATE_ALL : XSTATE_LAZY; @@ -125,14 +126,14 @@ static inline uint64_t vcpu_xsave_mask(const struct v= cpu *v) * XSTATE_FP_SSE), vcpu_xsave_mask will return XSTATE_ALL. Otherwise * return XSTATE_NONLAZY. */ - return xstate_all(v) ? XSTATE_ALL : XSTATE_NONLAZY; + return xstate_all(v, xsave_area) ? XSTATE_ALL : XSTATE_NONLAZY; } =20 /* Save x87 extended state */ static inline void fpu_xsave(struct vcpu *v, struct xsave_struct *xsave_ar= ea) { bool ok; - uint64_t mask =3D vcpu_xsave_mask(v); + uint64_t mask =3D vcpu_xsave_mask(v, xsave_area); =20 ASSERT(mask); ASSERT(cpu_has_xsave); @@ -213,7 +214,7 @@ void vcpu_restore_fpu_nonlazy(struct vcpu *v, bool need= _stts) * saving state belonging to another vCPU. */ xsave_area =3D vcpu_map_xsave_area(v); - if ( v->arch.fully_eager_fpu || xstate_all(v) ) + if ( v->arch.fully_eager_fpu || xstate_all(v, xsave_area) ) { if ( cpu_has_xsave ) fpu_xrstor(v, xsave_area, XSTATE_ALL); diff --git a/xen/arch/x86/include/asm/xstate.h b/xen/arch/x86/include/asm/x= state.h index 43f7731c2b17..81350d0105bb 100644 --- a/xen/arch/x86/include/asm/xstate.h +++ b/xen/arch/x86/include/asm/xstate.h @@ -132,14 +132,15 @@ xsave_area_compressed(const struct xsave_struct *xsav= e_area) return xsave_area->xsave_hdr.xcomp_bv & XSTATE_COMPACTION_ENABLED; } =20 -static inline bool xstate_all(const struct vcpu *v) +static inline bool xstate_all(const struct vcpu *v, + const struct xsave_struct *xsave_area) { /* * XSTATE_FP_SSE may be excluded, because the offsets of XSTATE_FP_SSE * (in the legacy region of xsave area) are fixed, so saving * XSTATE_FP_SSE will not cause overwriting problem with XSAVES/XSAVEC. */ - return xsave_area_compressed(v->arch.xsave_area) && + return xsave_area_compressed(xsave_area) && (v->arch.xcr0_accum & XSTATE_LAZY & ~XSTATE_FP_SSE); } =20 diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index aa5c062f7e51..cbe56eba89eb 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -1002,7 +1002,7 @@ int handle_xsetbv(u32 index, u64 new_bv) asm ( "stmxcsr %0" : "=3Dm" (xsave_area->fpu_sse.mxcsr) ); vcpu_unmap_xsave_area(curr, xsave_area); } - else if ( xstate_all(curr) ) + else if ( xstate_all(curr, xsave_area) ) { /* See the comment in i387.c:vcpu_restore_fpu_eager(). */ mask |=3D XSTATE_LAZY; --=20 2.47.0