From patchwork Tue Apr 9 05:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787171 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp57308wrs; Mon, 8 Apr 2024 22:05:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDkKT+tPRL0KA3apyCKJyrYTNzcXNATiwJxfedoFJp/P9tqR0AwGJLrtTov0eykn4+Nua4qeCWx8ZQng7jvVJp X-Google-Smtp-Source: AGHT+IGxpO8VArKPoph4qAKivivaSr1680FCbQet1qJr9umRZ+ek5LOeAERX0YgUlarDaY7F1oEl X-Received: by 2002:a05:6214:21ca:b0:69b:246b:4bff with SMTP id d10-20020a05621421ca00b0069b246b4bffmr3478100qvh.33.1712639106853; Mon, 08 Apr 2024 22:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712639106; cv=none; d=google.com; s=arc-20160816; b=nznLAfYITwdcm/RrO/rWEjIv2h+rfi9IOGcxZ01gV+r7OMbTiVkXTsXwHI9f3WKjPJ QpNRPzsP+DoF7cvqydwDg4M3zjrq4eQMXCxam3x7QSsyowv1+ZMYVfVp6jtnlh8DBUv+ OISbhJ20WUySeuOzduMJaannZFmdAPP6c+uOOCx9X627rwB94I6EMcX3tZEXYp2zEBjC Dcrmcs4ifOsNVJe6iAeL1kJxPoKbK/F6OpukEEpMXOjai0sHs3nmwdyPxIbOkqcTCUv0 JgcajnlnQM5iG4T570N2zfjE11RMACKoa4NKqxDnZvpFtLoQKR3yit8VEEZMJXrfGKcW Gmhg== 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=xn1vjagAhAGFyndA/SHEdLBYzd75+zPjvoYCTonqVpQ=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=lNRhG9c6MccedRmj6iYs4Fws/1dE+9/lugxXc/oOptk5Vspa9sYsSpsxN6rzmPRJCX KKP4PKmteLat/rWJoQ/AGBK6MtkYoQs2OOdgDisfQZCHW7Vg940iJ0VNtiDr2Jz6x3oS 54cGCxjrb5n8SmpjQAGzhlHkSkFCL/KjMtpLHPoEt7tgeXQAONObUBNQAzJUZCq3Ui92 WNJKoH3CaBfHak4dqpGv18At3Ni/GwdnAnXCeoz9W45PE62GtyHNX63efUnmrKHlbTRk z8PaQgkpSCrdGd0qLAePFqmiUfDys1Z1MxIrmxDGhk7MCLh8ZB1ScIUzRWY9HG3JEm7+ +lnA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CXZHEw0N; 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 y11-20020ad457cb000000b0069b290fb61dsi792912qvx.83.2024.04.08.22.05.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 22:05:06 -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=CXZHEw0N; 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 1ru3di-00039V-5z; Tue, 09 Apr 2024 01:03:22 -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 1ru3dg-000390-OE for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:20 -0400 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru3df-0005G9-1w for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:20 -0400 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3c3aeef1385so2893280b6e.3 for ; Mon, 08 Apr 2024 22:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712638998; x=1713243798; 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=xn1vjagAhAGFyndA/SHEdLBYzd75+zPjvoYCTonqVpQ=; b=CXZHEw0NlNDWcym+UekgroJbNKZ0YsAXtQ8f2+fF0RyqeHygnhaQ90joTyaH8NlN+o JLxh1LpNMm7iEHihesL6vYfNEhGGfqUhFKqtokusKbw7/xTfFYBi3kpLjcGEa74LDvLe bbTsnsbO54tsWMPlpKTiEbI5tjFzHR/gIl7X6pGXKkuSstotLLpO0t2TkkdQqP84689P Fzvr7F2MzChO3ps2Uqdc+qbX73zLtd3Q/oT2lxghKYMITI1+FgueHLWxfjwLUep461qf x5aJoU4TTn7h6paba4/lWEQjmCJXfLXQxt2eVEeu80LInW83hoh7bwcrs4Hf1VEoajts MaqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712638998; x=1713243798; 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=xn1vjagAhAGFyndA/SHEdLBYzd75+zPjvoYCTonqVpQ=; b=gFGlXC2C8nSePTfKr5LuFRXP5DWIq0LDn0e3U0Zxv5j9ZyLzR4eGV29ljBtvE2gcen hSdu0ZNvHZevNafk4/9QWOEuglFRYLr2WffKM2TIIfxffayzkV+OWXTDYSMkAhRGMepK nYEllYGPeKSmqEz/mWXlSpxUZKryflxIz+oBVVtJk3tkXhMLXA5H3ldgeDKDNe1I8mSC uqDf+s+kNOKiaw7KQSNpGlHLMENNTD2B/eySShEAjVaRWnzqGKj6bn9eHxGoa1qsSPUt QR/XU8c6iSUXINAWe5/82oKiNHsywuMnmbI9a9X4P+3hC2k3Bm3ITyQ/EWp9ZsR8SJ8I ++fg== X-Gm-Message-State: AOJu0Ywv2+95mcll5Qa1xIpbSV4EHMLoox2TdE6TK7slVzHQ57vz0p1q vNPU5y8q+czqPo30lafadgZ7g4F5FAmVR02/Mn2FzS/k2O6/j2oNRlDxRm+XSDtSI6hXdyWezf4 x X-Received: by 2002:a05:6808:190e:b0:3c5:d512:22b5 with SMTP id bf14-20020a056808190e00b003c5d51222b5mr12711153oib.14.1712638997981; Mon, 08 Apr 2024 22:03:17 -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.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 22:03:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/28] target/i386: Convert do_xsave_* to X86Access Date: Mon, 8 Apr 2024 19:02:44 -1000 Message-Id: <20240409050302.1523277-11-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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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 The body of do_xsave is now fully converted. Signed-off-by: Richard Henderson --- target/i386/tcg/fpu_helper.c | 47 ++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index 23e22e4521..82a041f4bf 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -2578,8 +2578,9 @@ static void do_xsave_sse(X86Access *ac, target_ulong ptr) } } -static void do_xsave_ymmh(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_xsave_ymmh(X86Access *ac, target_ulong ptr) { + CPUX86State *env = ac->env; int i, nb_xmm_regs; if (env->hflags & HF_CS64_MASK) { @@ -2589,33 +2590,36 @@ static void do_xsave_ymmh(CPUX86State *env, target_ulong ptr, uintptr_t ra) } for (i = 0; i < nb_xmm_regs; i++, ptr += 16) { - cpu_stq_data_ra(env, ptr, env->xmm_regs[i].ZMM_Q(2), ra); - cpu_stq_data_ra(env, ptr + 8, env->xmm_regs[i].ZMM_Q(3), ra); + access_stq(ac, ptr, env->xmm_regs[i].ZMM_Q(2)); + access_stq(ac, ptr + 8, env->xmm_regs[i].ZMM_Q(3)); } } -static void do_xsave_bndregs(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_xsave_bndregs(X86Access *ac, target_ulong ptr) { + CPUX86State *env = ac->env; target_ulong addr = ptr + offsetof(XSaveBNDREG, bnd_regs); int i; for (i = 0; i < 4; i++, addr += 16) { - cpu_stq_data_ra(env, addr, env->bnd_regs[i].lb, ra); - cpu_stq_data_ra(env, addr + 8, env->bnd_regs[i].ub, ra); + access_stq(ac, addr, env->bnd_regs[i].lb); + access_stq(ac, addr + 8, env->bnd_regs[i].ub); } } -static void do_xsave_bndcsr(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_xsave_bndcsr(X86Access *ac, target_ulong ptr) { - cpu_stq_data_ra(env, ptr + offsetof(XSaveBNDCSR, bndcsr.cfgu), - env->bndcs_regs.cfgu, ra); - cpu_stq_data_ra(env, ptr + offsetof(XSaveBNDCSR, bndcsr.sts), - env->bndcs_regs.sts, ra); + CPUX86State *env = ac->env; + + access_stq(ac, ptr + offsetof(XSaveBNDCSR, bndcsr.cfgu), + env->bndcs_regs.cfgu); + access_stq(ac, ptr + offsetof(XSaveBNDCSR, bndcsr.sts), + env->bndcs_regs.sts); } -static void do_xsave_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_xsave_pkru(X86Access *ac, target_ulong ptr) { - cpu_stq_data_ra(env, ptr, env->pkru, ra); + access_stq(ac, ptr, ac->env->pkru); } static void do_fxsave(X86Access *ac, target_ulong ptr) @@ -2668,6 +2672,7 @@ static void do_xsave(CPUX86State *env, target_ulong ptr, uint64_t rfbm, { uint64_t old_bv, new_bv; X86Access ac; + unsigned size; /* The OS must have enabled XSAVE. */ if (!(env->cr[4] & CR4_OSXSAVE_MASK)) { @@ -2683,8 +2688,8 @@ static void do_xsave(CPUX86State *env, target_ulong ptr, uint64_t rfbm, rfbm &= env->xcr0; opt &= rfbm; - access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea), - MMU_DATA_STORE, ra); + size = xsave_area_size(opt, false); + access_prepare(&ac, env, ptr, size, MMU_DATA_STORE, ra); if (opt & XSTATE_FP_MASK) { do_xsave_fpu(&ac, ptr); @@ -2697,22 +2702,22 @@ static void do_xsave(CPUX86State *env, target_ulong ptr, uint64_t rfbm, do_xsave_sse(&ac, ptr); } if (opt & XSTATE_YMM_MASK) { - do_xsave_ymmh(env, ptr + XO(avx_state), ra); + do_xsave_ymmh(&ac, ptr + XO(avx_state)); } if (opt & XSTATE_BNDREGS_MASK) { - do_xsave_bndregs(env, ptr + XO(bndreg_state), ra); + do_xsave_bndregs(&ac, ptr + XO(bndreg_state)); } if (opt & XSTATE_BNDCSR_MASK) { - do_xsave_bndcsr(env, ptr + XO(bndcsr_state), ra); + do_xsave_bndcsr(&ac, ptr + XO(bndcsr_state)); } if (opt & XSTATE_PKRU_MASK) { - do_xsave_pkru(env, ptr + XO(pkru_state), ra); + do_xsave_pkru(&ac, ptr + XO(pkru_state)); } /* Update the XSTATE_BV field. */ - old_bv = cpu_ldq_data_ra(env, ptr + XO(header.xstate_bv), ra); + old_bv = access_ldq(&ac, ptr + XO(header.xstate_bv)); new_bv = (old_bv & ~rfbm) | (inuse & rfbm); - cpu_stq_data_ra(env, ptr + XO(header.xstate_bv), new_bv, ra); + access_stq(&ac, ptr + XO(header.xstate_bv), new_bv); } void helper_xsave(CPUX86State *env, target_ulong ptr, uint64_t rfbm)