From nobody Mon Nov 25 02:16:34 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=1730817276; cv=none; d=zohomail.com; s=zohoarc; b=XkiS5WXXS8+m6/26c4zIZWjOf4tUQ0hJ8XUHySFl97EHNkRYBwdS4n+/kfwRDvFqLh2DcMGsv7FiHp6BLc7JNwC4IpWKNVGZgPzOWa15k8RGznBzhiiMpIvi3KEJhYQxyqzY/A/sRKNM/wIphJYYd2Y1cKqxd/v4vqd+rVTI5HE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730817276; 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=6B5omt1SedDQO6IJZRH4ErAkBbwq92KD+awlMKQ0bxI=; b=TvITfKSJPc0/5Az7TzhmfYTLvvueMopAD9VxreKI1uchkpENaqfzhQG5prnNN3eQdkCosTt8mklD1NlcQ1lpEsyEvqKNaJCgeyZ1eshHn7fzbPYAPFP4Vq1Medqaf804Irzssi9yS1LfH47/7Jty8Tg6PAFL31kRFtrPfAEnmn8= 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 1730817276300405.51303890148677; Tue, 5 Nov 2024 06:34:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.830268.1245313 (Exim 4.92) (envelope-from ) id 1t8KdF-0005lT-LA; Tue, 05 Nov 2024 14:34:09 +0000 Received: by outflank-mailman (output) from mailman id 830268.1245313; Tue, 05 Nov 2024 14:34:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t8KdF-0005kb-Bk; Tue, 05 Nov 2024 14:34:09 +0000 Received: by outflank-mailman (input) for mailman id 830268; Tue, 05 Nov 2024 14:34:07 +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 1t8KdD-0002K5-OX for xen-devel@lists.xenproject.org; Tue, 05 Nov 2024 14:34:07 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0275fcd4-9b83-11ef-a0c5-8be0dac302b0; Tue, 05 Nov 2024 15:34:05 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5ceccffadfdso3553120a12.2 for ; Tue, 05 Nov 2024 06:34:05 -0800 (PST) Received: from localhost.localdomain ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cee6a99ff2sm1395047a12.4.2024.11.05.06.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 06:34:04 -0800 (PST) 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: 0275fcd4-9b83-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo1MmMiLCJoZWxvIjoibWFpbC1lZDEteDUyYy5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6IjAyNzVmY2Q0LTliODMtMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwODE3MjQ1Ljc1ODA5NCwic2VuZGVyIjoiYWxlamFuZHJvLnZhbGxlam9AY2xvdWQuY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1730817245; x=1731422045; 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=6B5omt1SedDQO6IJZRH4ErAkBbwq92KD+awlMKQ0bxI=; b=i4FMGxGpZc1jBhlMRVOTT5mcac4CED05EJi3mHEGYHY1m3+b+bfXSYHRBR6rMxlNgr 5ePLpd9NCU9CjN8mweZjiTfx3y2/FGXbO2F7pjp7fTlOuL9d8hBCpsWd7bff1rlHVp1p GfSJHcX4eV9iX3ou/oo6fZLCkVJxVcKu/c0zU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730817245; x=1731422045; 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=6B5omt1SedDQO6IJZRH4ErAkBbwq92KD+awlMKQ0bxI=; b=CYr+D4hHVMLbp61AJXknGHtfqWLPkKEtesLpHxC6PNyzYVTpNayGFQJGFyISHfyHga 6NJUUem+b/XqX55tOK9XoPWrVSB4FmLbqOi/tnyZG1Edgnns4eIclcxFCgXTQ6LWRFaO 0sOCFGl9qvrfDdnhiqSNX6KPQ9Lyg+ml4vL9vaT+TDlE8EcskjV7QVd1dKMRF7gEgs5B Kq2mkOBhNUViqEi/p/3tOHlusJKpw9B0Q7DWB8/4zNhXUeIVDtDT+DdU+E1keb+wiSZn 8zQa0X0T49Nxkq+4sM1G3zO30smcz9CFwC1O9+bjxEPdgzwZUt5MsqbT2cFH8hWIhycD QoCw== X-Gm-Message-State: AOJu0Yxo9ZMybraO0V0ti8z+nurZp3HKm3+2BangoeLXUwyUQM03XH85 3lHViGmRASmIp78iMeQ4VwQWMm7GqmCXV2ee/Wh7RXUa1Zbq2p2x61KTr/nLcmppVOB97Rxh/mp D X-Google-Smtp-Source: AGHT+IFJA6M0XBv7FRFRoMs3JuKuoqXi/nf+aCqDEMKXEkJJ1sPRGW37quCEyuWC30mb250kMwCXmw== X-Received: by 2002:a05:6402:210d:b0:5c9:74e3:acbb with SMTP id 4fb4d7f45d1cf-5cea9678020mr15569290a12.10.1730817244742; Tue, 05 Nov 2024 06:34:04 -0800 (PST) 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 v2 13/13] x86/xstate: Make xstate_all() and vcpu_xsave_mask() take explicit xstate Date: Tue, 5 Nov 2024 14:33:10 +0000 Message-ID: <20241105143310.28301-14-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241105143310.28301-1-alejandro.vallejo@cloud.com> References: <20241105143310.28301-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1730817278152116600 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 c794367a3cc7..36a6c8918162 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -107,7 +107,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; @@ -124,14 +125,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(const struct vcpu *v, struct xsave_struct *xs= ave_area) { bool ok; - uint64_t mask =3D vcpu_xsave_mask(v); + uint64_t mask =3D vcpu_xsave_mask(v, xsave_area); =20 ASSERT(mask); /* @@ -211,7 +212,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 d2ef4c0b25f0..e3e9c18239ed 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 b5e8d90ef600..26e460adfd79 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -1003,7 +1003,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