From nobody Mon Nov 25 10:40:23 2024 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1716771270; cv=none; d=zohomail.com; s=zohoarc; b=TRG2B9zv5k5VQktPGGINQP7sAIjQ2VT4eeOhwQ0TA4SkRYgGtmYf8GF8jmIlIpAq+N8xbXe1E513RnXXyx/xHKAQ/3dcX7dDu6eWbVZlb4f2TQs5CspqXIf4QPe0eBJLvYDbqc/eyAHYmj0mUsqglfbBjheHkjwmONzeTffrZMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716771270; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=vNGTbU6DTUvMSHt1rxKvf5wFDuC+/EH4FoXciheiqRg=; b=XMKPu5Nkx2nU8SPiE2D1rIBXTJ8PXovbqN9BoqwtxHR1cZBwdHeanbkLdcNrTTzxerIiqDDLvzsLotaIQ2pf1r04CKfdtuCz8lrgW4nRTc5LBW1MVVhsTdqdSO4lgESHnXMPOGlADVLkkRSKZJVR7D4FOKoCMtXE9omFvJPnKrc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716771270728655.2731278441108; Sun, 26 May 2024 17:54:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBOZd-0007YG-9l; Sun, 26 May 2024 20:50:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBOZM-0007HF-Fj for qemu-devel@nongnu.org; Sun, 26 May 2024 20:50:32 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBOZK-0003hP-2d for qemu-devel@nongnu.org; Sun, 26 May 2024 20:50:32 -0400 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6f12171523eso4699425a34.1 for ; Sun, 26 May 2024 17:50:21 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f8fd6d7598sm3942958b3a.220.2024.05.26.17.50.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 17:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716771021; x=1717375821; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vNGTbU6DTUvMSHt1rxKvf5wFDuC+/EH4FoXciheiqRg=; b=IW/YV/g3z8GMM37gpwlYY5QUELIP9mQuH1ZZz/F5lX7DUJvCpXc0UnAixZc9nxo4Pz ItfINgNUPlT8P9ioQ2FT7XBaum9i3l1eVwvjeffmfSlHgjGkXMO4KvmzW9toZlN0dbhC I3M1VncSQLUi0YzYyOPscjKrr5AnnkkAZeacO+NoWW0ReIMHmzcyEqx/NYDlkd4PU/fD tTks55PwhZtlPq4BNeh5PtSLfzORJCtjXna+bDr2ssB7OjURq0Q+uWov7anu7Dc5vvKq TDOypPhPlIJSigjUwzCWca7QCSXaYV4vGv3LvY1O+DcTVcAP9FNFtn/NTrRs3HQgQNfj i4Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716771021; x=1717375821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vNGTbU6DTUvMSHt1rxKvf5wFDuC+/EH4FoXciheiqRg=; b=kqyP+M4Mqs1IycMt+pg/Cs2m1cqgrkjk7zj6TGEwzOXKDctD1ZXlssTrcEtt4MsiCx bMqevEPqNTDsFM1a1+h5dk5tk+tIL0ek7a1D+LfCasj3hT06FZLmW5W30H5N8vbC1gTf W+ahirUX3ehAcXLKGmtC+/0tmv+SSOvdIdBFasDSgrGuZtGEA/wMw4a94SdplE4BugVO TlYkyQEHhiCFMqhL8OtZxKZYEusfPVGpsWmuzga1u8sL+t4Ow8JONV09QC96ILw0cTnf u7dIR0KOTgUG91YRhd9gCOV3CHE7ivLt0dStP/SvcqEwVV0y49lq93/Du3n7/lVtbuFS 9jUQ== X-Gm-Message-State: AOJu0YzYZwMs2vC3ohVPQtVZaZyOAwQOjyR84XG7d8863DtW2IqSUbge FRg6gQrgEJUN5iKXL04gmkHbzP3NsvZqP5HRMPGJEioQFAit18yWzXWIUpVPeptNyqotSvBsXXC 4 X-Google-Smtp-Source: AGHT+IEbQxdYqF0MRFYLAx8XZ75mE79vXrUuxYoO7+cCJ5IEaQtY1Pi5bFpKnba0FQqfPGzlsS/o6A== X-Received: by 2002:a05:6870:828b:b0:24f:eadd:9a30 with SMTP id 586e51a60fabf-24feade53d6mr2861908fac.55.1716771021077; Sun, 26 May 2024 17:50:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/28] linux-user/i386: Honor xfeatures in xrstor_sigcontext Date: Sun, 26 May 2024 17:49:56 -0700 Message-Id: <20240527005001.642825-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240527005001.642825-1-richard.henderson@linaro.org> References: <20240527005001.642825-1-richard.henderson@linaro.org> 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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 @linaro.org) X-ZM-MESSAGEID: 1716771272063100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 47e6c0ff0d..e716ec8989 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -613,6 +613,7 @@ static bool xrstor_sigcontext(CPUX86State *env, FPState= Kind fpkind, struct target_fpx_sw_bytes *sw =3D (void *)&fxstate->sw_reserved; uint32_t magic1, magic2; uint32_t extended_size, xstate_size, min_size, max_size; + uint64_t xfeatures; =20 switch (fpkind) { case FPSTATE_XSAVE: @@ -629,10 +630,25 @@ static bool xrstor_sigcontext(CPUX86State *env, FPSta= teKind fpkind, xstate_size > extended_size) { break; } + + /* + * Restore the features indicated in the frame, masked by + * those currently enabled. Re-check the frame size. + * ??? It is not clear where the kernel does this, but it + * is not in check_xstate_in_sigframe, and so (probably) + * does not fall back to fxrstor. + */ + xfeatures =3D tswap64(sw->xfeatures) & env->xcr0; + min_size =3D xsave_area_size(xfeatures, false); + if (xstate_size < min_size) { + return false; + } + if (!access_ok(env_cpu(env), VERIFY_READ, fxstate_addr, xstate_size + TARGET_FP_XSTATE_MAGIC2_SIZE)) { return false; } + /* * Check for the presence of second magic word at the end of memory * layout. This detects the case where the user just copied the le= gacy @@ -645,7 +661,8 @@ static bool xrstor_sigcontext(CPUX86State *env, FPState= Kind fpkind, if (magic2 !=3D TARGET_FP_XSTATE_MAGIC2) { break; } - cpu_x86_xrstor(env, fxstate_addr, -1); + + cpu_x86_xrstor(env, fxstate_addr, xfeatures); return true; =20 default: --=20 2.34.1