From patchwork Tue Apr 9 05:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787166 Delivered-To: patch@linaro.org Received: by 2002:adf:fdd2:0:b0:346:15ad:a2a with SMTP id i18csp57034wrs; Mon, 8 Apr 2024 22:04:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWAg+6GRLRydPjC+TzuLSV4UBV3pwhpzXsLBWwyAqcxDk7I7P4axPkDuBu5r8RmmZD3UMU53QimBXMAswK9U77H X-Google-Smtp-Source: AGHT+IEvVioajCtKeIitbzNLD3QYXIuXqZNkURc/2bdYQkucRFhzaWApexyUQZ+Mpjqu+9bekd5E X-Received: by 2002:a05:6214:e48:b0:69b:1e64:413d with SMTP id o8-20020a0562140e4800b0069b1e64413dmr4554133qvc.52.1712639044611; Mon, 08 Apr 2024 22:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712639044; cv=none; d=google.com; s=arc-20160816; b=tCGL8GSsKTy+no6ktdeOPTC51mSKlzbEruziMHpRr68wlfV+W1BLiaz0z/BK9QeVVO MPG6G7Zd2jRB+YCU1HdnknT4c8K27UiyWe5/FJ5fCGS0ORynGIknjDrPznObELjepe2a abQT8WnabLyC/9kmKfc/5egrIllevfdfvJujYuR4sHXQLOkeImKk4ngAeRSbMlEtj3J5 P4DIp4EQgYNPCIGwQmOZfgJlzIFufn9+SSMQ68Ke5i1u2ims86MENdzziqXQ7gLsIyi1 lIoV32UVX3nSzs1EICqDDoa126X3OvridOzJzDVeHJRi3BngpO2he6uJ7O+PvjMDH7pD ARQw== 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=Lp1ipweNADN/6K9dE0kz0Ja73YaJ/vSstA3RIvGr8kM=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=F8JAvtm6Po0MyDPOXI7CANuI0SCKOtJw5bcgnPr+0YULOgziAHmHmA450r9HQsU/cd q6hCby8glwrsDY3Z78iW0Zr/iigta1Qg/1MTjCAim9Hkczljk1EKAKPm5keNOjTrPoem lbsNk4F+2wcJIKezTdd/HlQVa+xBAuMafYFjncs4RVifaMiNXYmN3leRdzlOLMfYu0rm RezfbpQuhH6yy64M+lqK2dPw9Da86JTUpAnPxDUI6if9dMPpzO8y+xrC+du5dz1cdtgl S4311YQgi54mc4KFoBHpAnFrNomB6G2ev4Xt7dkl0FiSnOCLTA80jvC52zF+f9xytEBw MOCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGVWqD60; 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 ev2-20020a0562140a8200b006992215faa0si9276556qvb.484.2024.04.08.22.04.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 22:04:04 -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=bGVWqD60; 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 1ru3dh-00039C-4w; Tue, 09 Apr 2024 01:03:21 -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 1ru3df-00038f-OP for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:19 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru3de-0005FX-0v for qemu-devel@nongnu.org; Tue, 09 Apr 2024 01:03:19 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-22fa18566adso121512fac.0 for ; Mon, 08 Apr 2024 22:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712638996; x=1713243796; 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=Lp1ipweNADN/6K9dE0kz0Ja73YaJ/vSstA3RIvGr8kM=; b=bGVWqD60NjJM/0SL2FCs5WeHp9OQhyuHbwyG+WkNwqlu/g3ydJBOx/IMFMgY7vcRYk NNWmyWTqxm7Bp/C4CQmZ5rkhICt+5ukRoH4vNCcjGK69PbjL5sHhU9swEPyQNvhLnZOE xMruL8Xy84zWJxEqsdpP/4CqsnbpiFm+PVLtXxc4qISXvXOXAsdXT2MaF3YXw5+uobuq PxarYji448fn3sMbHKDGzVEjepVD1lGfZKSDEaIR8U/qTII1L7NLyTmOK/uOBS1NZtCB k6vvBx+TqJBBBxgq8yaubnfk+xp9Naet/aCI9dXsd0eyVeDbWVLRynKVNO4q1ROm9pfu 3etg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712638996; x=1713243796; 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=Lp1ipweNADN/6K9dE0kz0Ja73YaJ/vSstA3RIvGr8kM=; b=Y+gLNH1FY64rNZ1VWVj0mtEYwAJIIgRNLPzmtlkEP9V8pfZogZKve+TIHyJOv91tOJ QdXPVMTgsE80jd6gUsTS6yelFkA11/J8aDQBgpkBOGqwSZ8iIZLzxamuWDXWO93nz57k z91JT5rtUGFgAekQlFpJDduV0odnnnYn4xRKfwzswG6aaWMj9KtO4kOMNNUpH9h7+5CJ cvgwx/L/flg2CBBHAoZdVqHhm7G2Vv/PZDHWbbW6dShS+ZRnek+1TdkEPux40ITBQLC8 bpKU/EkSp5tGHLtKN0kJ28sZ97kpHe8UTDZ6cRrk25dmWzW6niHVIE5Z1V6g26RDoBUD 8QAA== X-Gm-Message-State: AOJu0YwDUTFbLO93OSmNjqxg74foIauetUmkJ6+2stfglX21jCpjxybW atTXQnyXVtK/xYixiUUOLXl0heXE3Cs3hzs6OfA/pKaarH9VkP5H8fPSBXhbnKs664MKJgh7Cci e X-Received: by 2002:a05:6870:15c4:b0:22a:107c:4dd6 with SMTP id k4-20020a05687015c400b0022a107c4dd6mr11849811oad.40.1712638996599; Mon, 08 Apr 2024 22:03:16 -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.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 22:03:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/28] tagret/i386: Convert do_fxsave, do_fxrstor to X86Access Date: Mon, 8 Apr 2024 19:02:43 -1000 Message-Id: <20240409050302.1523277-10-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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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 Move the alignment fault from do_* to helper_*, as it need not apply to usage from within user-only signal handling. Signed-off-by: Richard Henderson --- target/i386/tcg/fpu_helper.c | 84 ++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c index 59f73ad075..23e22e4521 100644 --- a/target/i386/tcg/fpu_helper.c +++ b/target/i386/tcg/fpu_helper.c @@ -2618,8 +2618,25 @@ static void do_xsave_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) cpu_stq_data_ra(env, ptr, env->pkru, ra); } -static void do_fxsave(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_fxsave(X86Access *ac, target_ulong ptr) { + CPUX86State *env = ac->env; + + do_xsave_fpu(ac, ptr); + if (env->cr[4] & CR4_OSFXSR_MASK) { + do_xsave_mxcsr(ac, ptr); + /* Fast FXSAVE leaves out the XMM registers */ + if (!(env->efer & MSR_EFER_FFXSR) + || (env->hflags & HF_CPL_MASK) + || !(env->hflags & HF_LMA_MASK)) { + do_xsave_sse(ac, ptr); + } + } +} + +void helper_fxsave(CPUX86State *env, target_ulong ptr) +{ + uintptr_t ra = GETPC(); X86Access ac; /* The operand must be 16 byte aligned */ @@ -2629,22 +2646,7 @@ static void do_fxsave(CPUX86State *env, target_ulong ptr, uintptr_t ra) access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea), MMU_DATA_STORE, ra); - do_xsave_fpu(&ac, ptr); - - if (env->cr[4] & CR4_OSFXSR_MASK) { - do_xsave_mxcsr(&ac, ptr); - /* Fast FXSAVE leaves out the XMM registers */ - if (!(env->efer & MSR_EFER_FFXSR) - || (env->hflags & HF_CPL_MASK) - || !(env->hflags & HF_LMA_MASK)) { - do_xsave_sse(&ac, ptr); - } - } -} - -void helper_fxsave(CPUX86State *env, target_ulong ptr) -{ - do_fxsave(env, ptr, GETPC()); + do_fxsave(&ac, ptr); } static uint64_t get_xinuse(CPUX86State *env) @@ -2849,8 +2851,25 @@ static void do_xrstor_pkru(CPUX86State *env, target_ulong ptr, uintptr_t ra) env->pkru = cpu_ldq_data_ra(env, ptr, ra); } -static void do_fxrstor(CPUX86State *env, target_ulong ptr, uintptr_t ra) +static void do_fxrstor(X86Access *ac, target_ulong ptr) { + CPUX86State *env = ac->env; + + do_xrstor_fpu(ac, ptr); + if (env->cr[4] & CR4_OSFXSR_MASK) { + do_xrstor_mxcsr(ac, ptr); + /* Fast FXRSTOR leaves out the XMM registers */ + if (!(env->efer & MSR_EFER_FFXSR) + || (env->hflags & HF_CPL_MASK) + || !(env->hflags & HF_LMA_MASK)) { + do_xrstor_sse(ac, ptr); + } + } +} + +void helper_fxrstor(CPUX86State *env, target_ulong ptr) +{ + uintptr_t ra = GETPC(); X86Access ac; /* The operand must be 16 byte aligned */ @@ -2860,22 +2879,7 @@ static void do_fxrstor(CPUX86State *env, target_ulong ptr, uintptr_t ra) access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea), MMU_DATA_LOAD, ra); - do_xrstor_fpu(&ac, ptr); - - if (env->cr[4] & CR4_OSFXSR_MASK) { - do_xrstor_mxcsr(&ac, ptr); - /* Fast FXRSTOR leaves out the XMM registers */ - if (!(env->efer & MSR_EFER_FFXSR) - || (env->hflags & HF_CPL_MASK) - || !(env->hflags & HF_LMA_MASK)) { - do_xrstor_sse(&ac, ptr); - } - } -} - -void helper_fxrstor(CPUX86State *env, target_ulong ptr) -{ - do_fxrstor(env, ptr, GETPC()); + do_fxrstor(&ac, ptr); } static void do_xrstor(CPUX86State *env, target_ulong ptr, uint64_t rfbm, uintptr_t ra) @@ -3007,12 +3011,20 @@ void cpu_x86_frstor(CPUX86State *env, target_ulong ptr, int data32) void cpu_x86_fxsave(CPUX86State *env, target_ulong ptr) { - do_fxsave(env, ptr, 0); + X86Access ac; + + access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea), + MMU_DATA_STORE, 0); + do_fxsave(&ac, ptr); } void cpu_x86_fxrstor(CPUX86State *env, target_ulong ptr) { - do_fxrstor(env, ptr, 0); + X86Access ac; + + access_prepare(&ac, env, ptr, sizeof(X86LegacyXSaveArea), + MMU_DATA_LOAD, 0); + do_fxrstor(&ac, ptr); } void cpu_x86_xsave(CPUX86State *env, target_ulong ptr)