From nobody Sun Jul 26 11:03:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1782996488; cv=none; d=zohomail.com; s=zohoarc; b=Rq+cLNm8+SqrKRz7snRgZkuoTeRaDPTPiUJgTKwoAwzEXLgV/S+8pDeTOSMzQ4IiQuLtcEOwagWDy3f1p5cV5NMbF3TsmVBhfRHWa9SS64WYrLb+SEtwTe9xegdCvLAjzmiFCfCCgT8CdYxk6Naa9agBaDk+iG2xcau0U57mnuw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782996488; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0kddJLDEX4DjKhg9Fx4xTOZSnvmi575AEC5qk6HMGsQ=; b=mttW7vpoCPYbSDWW0GMvi3Nj7FFhql+FfosLDhCH6GpMYSWkrFsR4g+DRgU+PWtb4Myd8sqeRPiMQSQQ8FvcOYhtJQTN/FU5Bb70oSomcXRDMt279WsoFc4N/+LvJ0IVkPcASeiHWgO5s2UnVMxXW5ps86rkkMqa6vIpnWZ+/s4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782996488390304.5653253497592; Thu, 2 Jul 2026 05:48:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfGph-00014F-9n; Thu, 02 Jul 2026 08:47:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wfGpf-00013w-QM for qemu-devel@nongnu.org; Thu, 02 Jul 2026 08:47:55 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wfGpd-000594-RR for qemu-devel@nongnu.org; Thu, 02 Jul 2026 08:47:55 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.73]) by linux.microsoft.com (Postfix) with ESMTPSA id 80E3220B7167; Thu, 2 Jul 2026 05:47:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 80E3220B7167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1782996470; bh=0kddJLDEX4DjKhg9Fx4xTOZSnvmi575AEC5qk6HMGsQ=; h=From:To:Cc:Subject:Date:From; b=UfsXAk02L8E5d4IJ8hfQ3tvsXTf5aks3iOcrDZrVTy9JNP06ILr/zsqdWt0IIBSBZ jzJ8MxLDvTrWJMC+UH5mnpfKzspWrdVGltOIJHA4oJYUsuXkQjZTpfA69eb21fgaRi N9N9JRdktUhpnGG6OZoCwKlV/SsmAgj3ZLqsbp1I= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Zhao Liu , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Paolo Bonzini , Wei Liu , Wei Liu , Mohamed Mediouni Subject: [PATCH] target/i386: Skip supervisor in xsave decompaction Date: Thu, 2 Jul 2026 14:47:46 +0200 Message-Id: <20260702124746.450228-1-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linux.microsoft.com) X-ZM-MESSAGEID: 1782996489534158500 Content-Type: text/plain; charset="utf-8" Supervisor state should be skipped b/c there is no slot in standard format XSAVE buffer for it. CET State is being migrated via MSRs and other supervisor state isn't currently migrated. Fixes: 8612deb3f4 Signed-off-by: Magnus Kulke Reviewed-by: Doru Bl=C3=A2nzeanu --- target/i386/cpu.h | 2 ++ target/i386/xsave_helper.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e6a197602d..fff701c6c4 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -655,9 +655,11 @@ typedef enum X86Seg { =20 #define XSTATE_DYNAMIC_MASK (XSTATE_XTILE_DATA_MASK) =20 +#define ESA_FEATURE_XSS_BIT 0 #define ESA_FEATURE_ALIGN64_BIT 1 #define ESA_FEATURE_XFD_BIT 2 =20 +#define ESA_FEATURE_XSS_MASK (1U << ESA_FEATURE_XSS_BIT) #define ESA_FEATURE_ALIGN64_MASK (1U << ESA_FEATURE_ALIGN64_BIT) #define ESA_FEATURE_XFD_MASK (1U << ESA_FEATURE_XFD_BIT) =20 diff --git a/target/i386/xsave_helper.c b/target/i386/xsave_helper.c index 625bae103a..1fa3133b1a 100644 --- a/target/i386/xsave_helper.c +++ b/target/i386/xsave_helper.c @@ -332,7 +332,7 @@ int decompact_xsave_area(const void *buf, size_t buflen= , CPUX86State *env) size_t i; uint32_t eax, ebx, ecx, edx; uint32_t size, dst_off; - bool align64; + bool align64, supervisor; uint64_t guest_xcr0, *xstate_bv; =20 compacted_xstate_bv =3D *(uint64_t *)(buf + XSAVE_XSTATE_BV_OFFSET); @@ -383,6 +383,7 @@ int decompact_xsave_area(const void *buf, size_t buflen= , CPUX86State *env) size =3D eax; dst_off =3D ebx; align64 =3D (ecx & (1u << 1)) !=3D 0; + supervisor =3D (ecx & ESA_FEATURE_XSS_MASK) !=3D 0; =20 /* Component is in the layout but unknown to the guest CPUID model= */ if (size =3D=3D 0) { @@ -433,8 +434,14 @@ int decompact_xsave_area(const void *buf, size_t bufle= n, CPUX86State *env) return -E2BIG; } =20 - /* Copy components marked present in XSTATE_BV to guest model */ - if (((compacted_xstate_bv >> i) & 1) !=3D 0) { + /* + * Copy components marked present in XSTATE_BV to guest model. + * + * NB: Supervisor state is skipped b/c there is no slot in the + * standard format XSAVE buffer (CET state is migrated via MSRs, + * others supervisor state isn't migrated). + */ + if (((compacted_xstate_bv >> i) & 1) !=3D 0 && !supervisor) { memcpy(env->xsave_buf + dst_off, buf + xsave_offset, size); } =20 --=20 2.34.1