From patchwork Wed May 3 07:06:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 678674 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp909833wrs; Wed, 3 May 2023 00:26:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7tNNt0RCBbf5XtLCJQwjWCAjb2ZMr9jI4VpyUBGyWqmwH/ifqxDSg+SE6YarVmzcsT/VJH X-Received: by 2002:a05:6214:27c8:b0:61b:5dbc:9d85 with SMTP id ge8-20020a05621427c800b0061b5dbc9d85mr7437147qvb.20.1683098808878; Wed, 03 May 2023 00:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683098808; cv=none; d=google.com; s=arc-20160816; b=cgIw9Vla+MeW+wNd0fng4wh1EtTIC7W90Fqik9OIvVq9Rx/wl6sKilUzZ7uQMPPzra XSSg4rOUY3gUMg1TDe2Vj7PPti02YL/bfUP4HjuBHaRAtVxMbRdJ2S9Hhu0VOsxYOOqc C+YqNtJefk3wt9GzZZLbqmltV8huiPg/U8F4plNSql6r+eAYgDDrJKelTBV5mE1+8a/L /xsS38uDitXEXC+1IT12hxmOz7dYGirMS/vsOonYo0lZUJ8WhGANWXL1EkWq1lR3FraF ZnXG0PnuleX6o12E4tor5IhC1pffHC9K+tKVYMw7pc8TBMS3zET4q7GADmHxqOI5Vy4+ NZLA== 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:cc:to :from:dkim-signature; bh=lbibCyTnr9kxedetkEeMeR0n/g84TcpVDVIMMTB9mS4=; b=pmx8EMvdMcODOe8ltH/mjMUJgmIbdFBL87BLnDZKmbKby2YvoGQDiTslObuCTiiWY2 2SS5g4iG+bvmYmagPOZeGLJTKmteJzgr4bwfGkkwY/QAuTZ0dSQVfsSTWRca42j9I08r 70LFAUCnGbrff2SwRT4u9T0OuKHnFj8pj312q4nqRREcSBXkRhmyhb7smrU8DdlhaGfU wvtfKMmksKe817e34HC5XZ9f1/d+tkcqMOMuYt+nNYm8yMjnT7mMt+ygc6g2KUERdACt 1Hd1vOAEPqHAB//dflftDCNWpE1sdx/DbB9PND3VsXk+Pu1dto2U8J84zdywUrrGOfND TKlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cujk5uo0; 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 ay35-20020a05620a17a300b0074df4bb07fcsi19069994qkb.531.2023.05.03.00.26.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2023 00:26:48 -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=cujk5uo0; 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 1pu6b6-0000lZ-Pb; Wed, 03 May 2023 03:08:20 -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 1pu6aT-0006pF-Ox for qemu-devel@nongnu.org; Wed, 03 May 2023 03:07:41 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pu6a2-0005jW-OD for qemu-devel@nongnu.org; Wed, 03 May 2023 03:07:41 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f1950f569eso30009015e9.2 for ; Wed, 03 May 2023 00:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683097633; x=1685689633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lbibCyTnr9kxedetkEeMeR0n/g84TcpVDVIMMTB9mS4=; b=cujk5uo0cS3wrev1l1yyS8/Z9ALAiUePLuWendhDGafxK5Pn8UE9fi737stdRe971n ZJ5DxBzfu5pcDmaN7YRdnfOdjtEzBZMgJ/MgfJCf86VE/wab5v30oizEvK7umMWb1y6c wtD93PUD3NI8usE8nZuHa7ygSiEtSQtfLIs3MN9+C5KMEacnoiiv9GZf49LqUML6diG1 E7LImcMVQF85JPkQuGDB5iLOJUVbTYw3h6uPXcueNI7esn7fbf7cPvf9jI49igKIshUF U4vpykI/1T0LMDrhcU/jV6rAcss2TaRPe1SJobtMadXXtWNfYqCOpqIOc0iqE9Tdk3Np 9LfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683097633; x=1685689633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lbibCyTnr9kxedetkEeMeR0n/g84TcpVDVIMMTB9mS4=; b=DweE4s90O3GPi+8o0SwMAqDO3EWdJ+syM2aLMeNcjbLa4PQ/vRG2EjWzR9L8Y1NzfV gfqCMX4ZbyLLRWPaQFJrEPha3evAOin4rPRcbGnhnvD8QtRwYjZCkgTCqzEI9akBD69d sGyB4jGPPaJz/PA1Brh3iZgzpw9lhqN2Lra87dvNAcRGJX9l3gCQNVitQZSjuEnCrOwo 4/JYz6MZ1Tv8kIqxVwDLHFJJt6d872VzjNskatYab6RXTrISyPpeIXHXo6pTpeFa3LjV 40a/gFkZO0ysvsX4Oet2YjQ2y+MWvTrchWn/aS6r+GXY3dwAzLrCJlpq1QNHk5Q1Ud8J x1Dw== X-Gm-Message-State: AC+VfDzzg8uJ8+F5Ub0vNYIoYYDpPPzyBIrBaZXk7Nv5l47wHNEbB0CW CpJQUj8nIN01ItAaLSnmCpYGZIlHgH8LYziBbYdm8g== X-Received: by 2002:a7b:c7d0:0:b0:3f1:75b3:60df with SMTP id z16-20020a7bc7d0000000b003f175b360dfmr13232821wmk.41.1683097633369; Wed, 03 May 2023 00:07:13 -0700 (PDT) Received: from stoup.Home ([2a02:c7c:74db:8d00:c01d:9d74:b630:9087]) by smtp.gmail.com with ESMTPSA id q3-20020a1cf303000000b003f3157988f8sm921184wmq.26.2023.05.03.00.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 00:07:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: git@xen0n.name, gaosong@loongson.cn, philmd@linaro.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v4 21/57] tcg/i386: Use full load/store helpers in user-only mode Date: Wed, 3 May 2023 08:06:20 +0100 Message-Id: <20230503070656.1746170-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503070656.1746170-1-richard.henderson@linaro.org> References: <20230503070656.1746170-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x334.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of using helper_unaligned_{ld,st}, use the full load/store helpers. This will allow the fast path to increase alignment to implement atomicity while not immediately raising an alignment exception. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- tcg/i386/tcg-target.c.inc | 52 +++------------------------------------ 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index f838683fc3..e78d4d4aa7 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -1776,7 +1776,6 @@ typedef struct { int seg; } HostAddress; -#if defined(CONFIG_SOFTMMU) /* * Because i686 has no register parameters and because x86_64 has xchg * to handle addr/data register overlap, we have placed all input arguments @@ -1812,7 +1811,7 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) /* resolve label address */ tcg_patch32(label_ptr[0], s->code_ptr - label_ptr[0] - 4); - if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { + if (label_ptr[1]) { tcg_patch32(label_ptr[1], s->code_ptr - label_ptr[1] - 4); } @@ -1834,7 +1833,7 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) /* resolve label address */ tcg_patch32(label_ptr[0], s->code_ptr - label_ptr[0] - 4); - if (TARGET_LONG_BITS > TCG_TARGET_REG_BITS) { + if (label_ptr[1]) { tcg_patch32(label_ptr[1], s->code_ptr - label_ptr[1] - 4); } @@ -1844,51 +1843,8 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_jmp(s, l->raddr); return true; } -#else -static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) -{ - /* resolve label address */ - tcg_patch32(l->label_ptr[0], s->code_ptr - l->label_ptr[0] - 4); - - if (TCG_TARGET_REG_BITS == 32) { - int ofs = 0; - - tcg_out_st(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, ofs); - ofs += 4; - - tcg_out_st(s, TCG_TYPE_I32, l->addrlo_reg, TCG_REG_ESP, ofs); - ofs += 4; - if (TARGET_LONG_BITS == 64) { - tcg_out_st(s, TCG_TYPE_I32, l->addrhi_reg, TCG_REG_ESP, ofs); - ofs += 4; - } - - tcg_out_pushi(s, (uintptr_t)l->raddr); - } else { - tcg_out_mov(s, TCG_TYPE_TL, tcg_target_call_iarg_regs[1], - l->addrlo_reg); - tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); - - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RAX, (uintptr_t)l->raddr); - tcg_out_push(s, TCG_REG_RAX); - } - - /* "Tail call" to the helper, with the return address back inline. */ - tcg_out_jmp(s, (const void *)(l->is_ld ? helper_unaligned_ld - : helper_unaligned_st)); - return true; -} - -static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) -{ - return tcg_out_fail_alignment(s, l); -} - -static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) -{ - return tcg_out_fail_alignment(s, l); -} +#ifndef CONFIG_SOFTMMU static HostAddress x86_guest_base = { .index = -1 }; @@ -1920,7 +1876,7 @@ static inline int setup_guest_base_seg(void) return 0; } #endif /* setup_guest_base_seg */ -#endif /* SOFTMMU */ +#endif /* !SOFTMMU */ /* * For softmmu, perform the TLB load and compare.