From nobody Sun Nov 24 13:54:46 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=1730817275; cv=none; d=zohomail.com; s=zohoarc; b=CwmHwXhYMPaXtaQiOjwKIX5Bje/ntYyVTh9KhsLn+0HTdlIjxsyWqK6cY9qo2FU9J8kMiwXayIjQvQAR61q5p3fxZ2hHymt04m4ce6I7sqI47XI+pf9R2P/SDTOAOExP149lRqD72+25aEIaE0LCGoULT4Xys7/XOnaTJ3VLykk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730817275; 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=AHukccBbBpbC+k7kZ0/gZzzWfRKQINdoK6h9gGQzyg4=; b=aHm0r1mHy/JvqAKgmsgyxm0knRwPw27dDnuvK9bVKFVxZ1SIqUUpQEFSzY9cGcOcBZPrEwRGxQ2q2WTSBu4wMumawPGUZLENFrTvRVGfAhmImwZXI38Au1fcXLrkVnf5Pe4Hhfhu4iMhm31IJIM8ETH0gL/QPj0rFbh3nblEZGA= 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 1730817275553324.6251617484013; Tue, 5 Nov 2024 06:34:35 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.830266.1245291 (Exim 4.92) (envelope-from ) id 1t8KdB-0004oi-OO; Tue, 05 Nov 2024 14:34:05 +0000 Received: by outflank-mailman (output) from mailman id 830266.1245291; Tue, 05 Nov 2024 14:34:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t8KdB-0004mD-8q; Tue, 05 Nov 2024 14:34:05 +0000 Received: by outflank-mailman (input) for mailman id 830266; Tue, 05 Nov 2024 14:34:03 +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 1t8Kd9-0002K5-HU for xen-devel@lists.xenproject.org; Tue, 05 Nov 2024 14:34:03 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ffcd476c-9b82-11ef-a0c5-8be0dac302b0; Tue, 05 Nov 2024 15:34:01 +0100 (CET) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5ceb75f9631so5709387a12.0 for ; Tue, 05 Nov 2024 06:34:01 -0800 (PST) Received: from localhost.localdomain ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cee6a99ff2sm1395047a12.4.2024.11.05.06.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 06:33:59 -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: ffcd476c-9b82-11ef-a0c5-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo1MmYiLCJoZWxvIjoibWFpbC1lZDEteDUyZi5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImZmY2Q0NzZjLTliODItMTFlZi1hMGM1LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwODE3MjQxLjMwOTk5MSwic2VuZGVyIjoiYWxlamFuZHJvLnZhbGxlam9AY2xvdWQuY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1730817240; x=1731422040; 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=AHukccBbBpbC+k7kZ0/gZzzWfRKQINdoK6h9gGQzyg4=; b=fT8CMbkKkoEionf+10rr2ldMJYNDhX+QDFRZilivZDvqtnn8htUu1tNxDov0z0ulV0 kY1kqbe7x8SGosEnflPyAUsyB9diZAQBFvnXAgVYSWMUf9+xVqBw7/JiApz3jTlnRpmh fDS0bAvmBmRS/euKUR3Y6D4F45d5GiMAO6K5E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730817240; x=1731422040; 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=AHukccBbBpbC+k7kZ0/gZzzWfRKQINdoK6h9gGQzyg4=; b=bNmiJftDzQrFvhFURlcL+gnu00nCOTGvhZWnCgYWE7eon4OEvg8EWnEUVSdDCYN5xQ zYS2+qnXLcbXVdV53+cMbBAdo0LSROdeFk23sQlgTnIBct9nFxJlKSjPlJWsy0p5JSiq Z0+wtQYBcdzOX1w0C2cB9+5P1TzHepXDntxuENLXUOirtuIPgvUfpCn2gRdH1t5ecPXR q3us5FEMYkjuTEDC1mKvkDeItqP7GXem6h49/2g3jrO6X9U7M6SC+DI8+UU9/aOKw+pm ASs8cfHD8M5xDsMjgqTTaCsw92odujX3c6jZxwzHUaC3xeqSJ8c4me/mhsmHN2kE6hZK Xsww== X-Gm-Message-State: AOJu0Yw8zLd18fdX1+TbFG9+geylQgYbz2tQrSw47YNIcvJJHwIAVZjy kVKobDZn5G/R73xHxHIkXgx/MDLdc/D/PUmEHo6+agSriiTg9wnxYz00VDHZPR95ppzNdpdyRrk Q X-Google-Smtp-Source: AGHT+IHa/ojeelBSzZGbiAyj+Hr1UbyyUgXITX9+Pi112rloiy17KwqQt0YRmn5B4ntqXT9Ez72fbg== X-Received: by 2002:a05:6402:278e:b0:5ce:de14:63ed with SMTP id 4fb4d7f45d1cf-5cede146458mr4200250a12.36.1730817240423; Tue, 05 Nov 2024 06:34:00 -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 10/13] x86/mpx: Map/unmap xsave area in in read_bndcfgu() Date: Tue, 5 Nov 2024 14:33:07 +0000 Message-ID: <20241105143310.28301-11-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: 1730817276094116600 Content-Type: text/plain; charset="utf-8" No functional change. Signed-off-by: Alejandro Vallejo --- v2: * s/ret/bndcfgu --- xen/arch/x86/xstate.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 6db7ec2ea6a9..9ecbef760277 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -1022,9 +1022,10 @@ int handle_xsetbv(u32 index, u64 new_bv) =20 uint64_t read_bndcfgu(void) { + uint64_t bndcfgu =3D 0; unsigned long cr0 =3D read_cr0(); - struct xsave_struct *xstate - =3D idle_vcpu[smp_processor_id()]->arch.xsave_area; + struct vcpu *v =3D idle_vcpu[smp_processor_id()]; + struct xsave_struct *xstate =3D VCPU_MAP_XSAVE_AREA(v); const struct xstate_bndcsr *bndcsr; =20 ASSERT(cpu_has_mpx); @@ -1050,7 +1051,12 @@ uint64_t read_bndcfgu(void) if ( cr0 & X86_CR0_TS ) write_cr0(cr0); =20 - return xstate->xsave_hdr.xstate_bv & X86_XCR0_BNDCSR ? bndcsr->bndcfgu= : 0; + if ( xstate->xsave_hdr.xstate_bv & X86_XCR0_BNDCSR ) + bndcfgu =3D bndcsr->bndcfgu; + + VCPU_UNMAP_XSAVE_AREA(v, xstate); + + return bndcfgu; } =20 void xstate_set_init(uint64_t mask) --=20 2.47.0