From nobody Sun Nov 24 02:48:06 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=1730130626; cv=none; d=zohomail.com; s=zohoarc; b=BK0s6sry1nXih/tqaXUNoKnBDaYmSufWpbqHEwqmm3V2JnoDW+iEB35VifDG1QEEGSJ6qunUsBarCfwmXLl/6fQQ63GrN7Ih4nxEjAEncPryOTsT+V5XDCr4+QFBscrsjUHP+tdW+HZdrElH85ZbzRvehnRUL29AJc9UQlhkAw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730130626; 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=k5/TXen51hB68I6BFGT+jmFtlRjBnBfjDOpUJmu9hDE=; b=gx+m9MJgc7G/gCaAb3tivUEenNZEAXnfFvXEjgeipG0H1o800SIzFBB7XZd/u2QSoc2yHs5Thxhfr6WHeaVXQMDMX/W3LLSbS2IYohzu8cCXiEzoRyq7yCOjzSZk4k6MrjZ3dZ1OJURIIc7pb1dcD1PHEzscnBLXGnk6jMXMfU4= 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 1730130626696627.3325252790013; Mon, 28 Oct 2024 08:50:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.826687.1241070 (Exim 4.92) (envelope-from ) id 1t5S0N-0001A0-Jk; Mon, 28 Oct 2024 15:50:07 +0000 Received: by outflank-mailman (output) from mailman id 826687.1241070; Mon, 28 Oct 2024 15:50:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5S0N-00019a-Bb; Mon, 28 Oct 2024 15:50:07 +0000 Received: by outflank-mailman (input) for mailman id 826687; Mon, 28 Oct 2024 15:50:05 +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 1t5S0L-000874-BW for xen-devel@lists.xenproject.org; Mon, 28 Oct 2024 15:50:05 +0000 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [2a00:1450:4864:20::629]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4ca4ce99-9544-11ef-a0c2-8be0dac302b0; Mon, 28 Oct 2024 16:50:04 +0100 (CET) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-a9a68480164so620241766b.3 for ; Mon, 28 Oct 2024 08:50:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 08:50:03 -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: 4ca4ce99-9544-11ef-a0c2-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1730130604; x=1730735404; 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=k5/TXen51hB68I6BFGT+jmFtlRjBnBfjDOpUJmu9hDE=; b=TY/fIWVJd9hNosxSg3y3L6TwxGcyw7Z3XrbpVDP6KAO8hoYT8IWuoWN7fhgQSh5JGG +bBsdgJR4MDfiAdoYrWFTpEMiT1TOo7spC056dsdxpo+U0KpKG/fhZU79WPIiYqJ99bY ViUYA3oq4eJvH4rpmRy6UPRfPG6XgaiLJSg+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730130604; x=1730735404; 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=k5/TXen51hB68I6BFGT+jmFtlRjBnBfjDOpUJmu9hDE=; b=RNZV0/86H4+vsjKM0IYys36ILFAR9wTFeMPYBecQYl3eO8tljREINku+2EVhzV6dl6 fO2XhsxpHP9Pap1KENTjjcpzrZohtZlSkkR6xTjRNR3RVTStK6orPJcvNjYjqZFgVIkp hfVhha+VXhw43FknpHKCOOXBxDsmLRajY8GjZzcel0iJFsAznIfJtiltF7yHB7VKKU5a 4tEBBLEFukgvYVQo/atFGN2hu0W8nXZax18exmHaT26sz2xfJECjnFT26gHqTCscTMGi WS93vG7fzaNYdU/tL9KZxVfeb5xhiaJHZXZOmDR3AIqCPGpLiXPPgvIUh1x5VN2GkJuZ zRig== X-Gm-Message-State: AOJu0Yxprcl01SzgNs+btBwc1R8S25lC6HwdnhEuwZj0vjwd/5jz/WwO ztY4WCGg845vZx/vtnjhtCiO1xgUxsAzXvuJ4sTt2KeYxYtMQpvl9Bho7Wygh0BcXK5LIT/vNfI G X-Google-Smtp-Source: AGHT+IEuqJAcG2GYWLVnnngxRLpaSRDV3BwBCu+v1OexXNCj5m10aMlavT0wiEaUKGuKYvkiTGsvTg== X-Received: by 2002:a17:906:6a1d:b0:a9a:18ee:5106 with SMTP id a640c23a62f3a-a9de61e95a5mr760804266b.65.1730130604050; Mon, 28 Oct 2024 08:50:04 -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 05/14] x86/xstate: Map/unmap xsave area in xstate_set_init() and handle_setbv() Date: Mon, 28 Oct 2024 15:49:23 +0000 Message-ID: <20241028154932.6797-6-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: 1730130627234116600 Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: Alejandro Vallejo --- xen/arch/x86/xstate.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index af9e345a7ace..60e752a245ca 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -993,7 +993,12 @@ int handle_xsetbv(u32 index, u64 new_bv) =20 clts(); if ( curr->fpu_dirtied ) - asm ( "stmxcsr %0" : "=3Dm" (curr->arch.xsave_area->fpu_sse.mx= csr) ); + { + struct xsave_struct *xsave_area =3D vcpu_map_xsave_area(curr); + + asm ( "stmxcsr %0" : "=3Dm" (xsave_area->fpu_sse.mxcsr) ); + vcpu_unmap_xsave_area(curr, xsave_area); + } else if ( xstate_all(curr) ) { /* See the comment in i387.c:vcpu_restore_fpu_eager(). */ @@ -1048,7 +1053,7 @@ void xstate_set_init(uint64_t mask) unsigned long cr0 =3D read_cr0(); unsigned long xcr0 =3D this_cpu(xcr0); struct vcpu *v =3D idle_vcpu[smp_processor_id()]; - struct xsave_struct *xstate =3D v->arch.xsave_area; + struct xsave_struct *xstate; =20 if ( ~xfeature_mask & mask ) { @@ -1061,8 +1066,10 @@ void xstate_set_init(uint64_t mask) =20 clts(); =20 + xstate =3D vcpu_map_xsave_area(v); memset(&xstate->xsave_hdr, 0, sizeof(xstate->xsave_hdr)); xrstor(v, mask); + vcpu_unmap_xsave_area(v, xstate); =20 if ( cr0 & X86_CR0_TS ) write_cr0(cr0); --=20 2.47.0