From patchwork Tue Apr 9 05:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787174 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp57404wrs; Mon, 8 Apr 2024 22:05:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXE6W49BPPttUYaOByMo/k2w/eeY3qqjiqPuqAtWc+cd7lgRgihw6I4ptwO9z2Fagi8pkBi4gVKLSCDjQF1R16s X-Google-Smtp-Source: AGHT+IEdus4QyYGvohQ6nR3FN1rLV+Plzz07xEFP0UNbzhcZZLSsMCV2DRFjACtR9wL06Vprg42C X-Received: by 2002:a05:620a:12f8:b0:78d:68d6:c1e9 with SMTP id f24-20020a05620a12f800b0078d68d6c1e9mr3163133qkl.47.1712639127656; Mon, 08 Apr 2024 22:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712639127; cv=none; d=google.com; s=arc-20160816; b=Z7KFIV3uBQS5Ve11r5MKfwpCYisBgBCjlKiT6TJd0DuRChDKUKwKmzUUDVRUED4ljv P/dVORD1ULvC1xJyR6WrdNFnc4ByhnFf1mLu02QNh2dIHUJzSlrS6yZuhDo3ZjgGpEO4 Tzd9EDuvBj/ERUtVxtzc7Ll5GdTWtnh9gZ4Lli/m8SAfrNjM9wF0jG/cEe78uKUVMSK6 hfYhTLkv/LWKi0CqEHioHKeGub16YIbFwYn92UKKlKnnoU+QsNaQ4TshjbK4tmoUjIIH kKtMEvs/PWYn8Q5k6KnCqwBxThghpuwfI1nnE67ZiWet4H0s9/JOTi2Ob+zFV/WKa11T L6Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6eUFt2PWahbI/Q/BaP9MYWhwnfohtu4MmJvBHxZyZEg=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=RcCbmj2n+bppaSgATeyoIpPJ9XV1P0xXhyVAu8kNqPOKkRA8Wid1OaWbBuFv7SJQIn NWBHTt72cFX3+mu3N1Ov2kfZENnaksop6AdjixX+toLjOv/EEq8GdwQ7pO+1UUYZp+AA vErTHieg7nPNBNRXbpUqkxXGsftpkjev8/LrIDnGdhJ2dj7Ra/dTGIsSK80G0HwDW5QU oz50w/xPK3QTmt0HP1UGwda/FJw6z22/93X+27ijKPhs5tfxOCKlnDzIO1YGgi4QeotX X6ZtO48rQems2uH/7yFQ6wINxzPcBs8CFHhD0zr4fc4E6RX+v5E54cUCNqn8HIR+NfzT ss7g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rsZ02lZZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a15-20020a05620a16cf00b0078d666019c2si3525091qkn.555.2024.04.08.22.05.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 22:05:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rsZ02lZZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ru3do-0003BK-1G; Tue, 09 Apr 2024 01:03:28 -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 1ru3dn-0003BA-9y for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:27 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru3dl-0005J1-Nc for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:27 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-6ed20fb620fso1747930b3a.2 for ; Mon, 08 Apr 2024 22:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712639004; x=1713243804; 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=6eUFt2PWahbI/Q/BaP9MYWhwnfohtu4MmJvBHxZyZEg=; b=rsZ02lZZmNmC6hZQ53L05GcpCHmXoK5xrN2CrOPrhqR0DCKdnhUsg0SVGFGrRaxe/m JUF8Kh5PUd6yYZ4WgVRgFFYGocPMevD0Dqc5/m8zlWIdE78OcOVTuZ6QdzSEydE0jTS2 n0sX/cgSVoJjC97k4Cq1BdAoOxCmZ5zGRy5H+GDXuXjlTV8HKW40kYyg/JGNfCik+9Fa wh8mcbpJwLdDbqkTXskuY069t9B77W69zh3RJI6E97rLt0aU6Ez/sfHHVaQgY9LAfAER 3I6RworKQ3zCUyJGVgkqrXnUqivgqVvhD/OmiQ0XMT3u9SCN/tlWNIk38ACS85e6/emP SU3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712639004; x=1713243804; 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=6eUFt2PWahbI/Q/BaP9MYWhwnfohtu4MmJvBHxZyZEg=; b=XsyB7ph31jfMWugUuqTkAWkX+MXjNP2oG+sLDMZgmEgCsksyDVmXZU2wWgB7EdAWD1 Y0yU13sEu/0rTj/1CsHyMpyP493enPNnT63WULC6fVOQQU9c51gQuxTz9yp41IltWIK/ Xe2ko41AYL9BX5rg3nmxfCNQQH8H1OcNY2d29vGOBuS91NKmcZHoiEPn1XgGPDLZKpcW oEVocs7lj+ySP+JDnLgWHuDM4sqh0bp4b30LgJkkXnQI9swIGKzswQgL3La6RI5wOZov klHWdTjm8oLgKDJUOtP2FhPDXmWsiLY2LSAx+xfgD9n1/wuY5TpFoj2pXkUAvo9S34Fk 8dBA== X-Gm-Message-State: AOJu0YxOGzgkxZWYYUyCtUPPXSHvmoOEYdI1SfPmRXZ5uKCMmXwoPrlo TTjq1oX518WY6rmqwU+hoQ/FxSn44uaD4wqq0wLYaFi2rGxaaEHpvQJRkIJ2FkMOhifTFLkLN6G A X-Received: by 2002:a05:6a00:c86:b0:6ea:b9a1:63d7 with SMTP id a6-20020a056a000c8600b006eab9a163d7mr12510999pfv.10.1712639004231; Mon, 08 Apr 2024 22:03:24 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id z26-20020aa785da000000b006e64ddfa71asm7654894pfn.170.2024.04.08.22.03.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 22:03:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/28] linux-user/i386: Drop xfeatures_size from sigcontext arithmetic Date: Mon, 8 Apr 2024 19:02:49 -1000 Message-Id: <20240409050302.1523277-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409050302.1523277-1-richard.henderson@linaro.org> References: <20240409050302.1523277-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is subtracting sizeof(target_fpstate_fxsave) in TARGET_FXSAVE_SIZE, then adding it again via &fxsave->xfeatures. Perform the same computation using xstate_size alone. Signed-off-by: Richard Henderson --- linux-user/i386/signal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/linux-user/i386/signal.c b/linux-user/i386/signal.c index 68659fa1db..547c7cc685 100644 --- a/linux-user/i386/signal.c +++ b/linux-user/i386/signal.c @@ -252,7 +252,6 @@ static void xsave_sigcontext(CPUX86State *env, struct target_fpstate_fxsave *fxs __put_user(0, &fxsave->sw_reserved.magic1); } else { uint32_t xstate_size = xsave_area_size(env->xcr0, false); - uint32_t xfeatures_size = xstate_size - TARGET_FXSAVE_SIZE; /* * extended_size is the offset from fpstate_addr to right after the end @@ -272,7 +271,8 @@ static void xsave_sigcontext(CPUX86State *env, struct target_fpstate_fxsave *fxs __put_user(extended_size, &fxsave->sw_reserved.extended_size); __put_user(env->xcr0, &fxsave->sw_reserved.xfeatures); __put_user(xstate_size, &fxsave->sw_reserved.xstate_size); - __put_user(TARGET_FP_XSTATE_MAGIC2, (uint32_t *) &fxsave->xfeatures[xfeatures_size]); + __put_user(TARGET_FP_XSTATE_MAGIC2, + (uint32_t *)((void *)fxsave + xstate_size)); } } @@ -558,7 +558,6 @@ static int xrstor_sigcontext(CPUX86State *env, struct target_fpstate_fxsave *fxs if (env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE) { uint32_t extended_size = tswapl(fxsave->sw_reserved.extended_size); uint32_t xstate_size = tswapl(fxsave->sw_reserved.xstate_size); - uint32_t xfeatures_size = xstate_size - TARGET_FXSAVE_SIZE; /* Linux checks MAGIC2 using xstate_size, not extended_size. */ if (tswapl(fxsave->sw_reserved.magic1) == TARGET_FP_XSTATE_MAGIC1 && @@ -567,7 +566,7 @@ static int xrstor_sigcontext(CPUX86State *env, struct target_fpstate_fxsave *fxs extended_size - TARGET_FPSTATE_FXSAVE_OFFSET)) { return 1; } - if (tswapl(*(uint32_t *) &fxsave->xfeatures[xfeatures_size]) == TARGET_FP_XSTATE_MAGIC2) { + if (tswapl(*(uint32_t *)((void *)fxsave + xstate_size)) == TARGET_FP_XSTATE_MAGIC2) { cpu_x86_xrstor(env, fxsave_addr, -1); return 0; }