From patchwork Tue May 16 19:40:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 682385 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp18025wrt; Tue, 16 May 2023 12:48:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pNvpUTYRuOWDbDUCni3amMV1RizQ9OfFuC8hoYq3MGQGfl+uHJVlDkYC1lxEaxkILb7pI X-Received: by 2002:ac8:5b92:0:b0:3f3:9b12:3a80 with SMTP id a18-20020ac85b92000000b003f39b123a80mr46309037qta.54.1684266533207; Tue, 16 May 2023 12:48:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684266533; cv=none; d=google.com; s=arc-20160816; b=hAk6LLzEbP2HvxH/n9Isi3jMbJQdp8aUwY7qCH5ffKmMcm4NV/FO7ojagduvcz7vk1 l5Mie4q/RfVaSMZwX29IoRiB9ZiT+dSbcQAUMmcnJF3m9Q8odz7gH0G2mBnZi1lwbpsy zQdTLPfZFk08Kq6s6iFYPW0pxtgXPwewSd6O/07KfGO+vpQ1Rxq2VMq5Wv+IE+XKjcby Ftp+j998FfxjjkXTpSM4xsDXWzN9NKihzmc9TlSu/mRebBcj01chsxFFggNRauDI9I3D yRSrGTb+tk+12jEsVOHYakK469B5NPMbKwIUpSBNI/yJKoQ+7nEwD7HQ2IkqrrIDXj2u 0tZA== 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=0BFtx9KYq0Th2HWZb/BY+/P+rVcQ7G1nOi7Bio8e4oI=; b=IdGYvffVDD+YAwG7qNI2F/4EZctQHR6aZhjUvCo5MwQjQqK9/XVVM6JnTfXw9PZ0U1 J9JTwjZJ1tDJiWpoI2cM+0j3yixaTnZ5Ut+XgVwAZVGY0+n3PHMQkO9Zz/eEcS20NXQP Ai6H1ueoNuvOAQ8At/SmmZ7EQhUQjRnnbACNIB3rM3VMaDjSMbuuAbKNTf6MvKU0M/PS FHHxUOuijPm9YH390vRtm6S+N0ojKYGU3H18elDNFFIe3jswtrTeq3JCRZlyDdw1yK9j ZSsSgBHoA8qhrTZsOrkaDW5f1aFuv38+oZzaELUZd2ckSVz8cqIfQDEog0nlBHDa16Tc Yc0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EslWbfjB; 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 j17-20020ae9c211000000b00759383cdccasi213563qkg.425.2023.05.16.12.48.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 May 2023 12:48:53 -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=EslWbfjB; 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 1pz0Yd-0006eW-HC; Tue, 16 May 2023 15:42:03 -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 1pz0Yc-0006dr-8I for qemu-devel@nongnu.org; Tue, 16 May 2023 15:42:02 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pz0Ya-0002na-Id for qemu-devel@nongnu.org; Tue, 16 May 2023 15:42:01 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5304913530fso8068792a12.0 for ; Tue, 16 May 2023 12:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684266119; x=1686858119; 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=0BFtx9KYq0Th2HWZb/BY+/P+rVcQ7G1nOi7Bio8e4oI=; b=EslWbfjB90BUadvpR2qxu4N6UhJY1ngA1MjB399KaCev/ocB8t23VOXlOwUWWc+rPc y4zWiBARwVSWSAFP2wT5Fk+gIoTIkkkxCZT5srFu8cyNS1j0O9hTAooz/TLuqFg3Yixw WAa4RMGwbVrFK/vcVqd1rzG5uTUfQOlORhiguOErt2lCYsjRHDoFCuncr6+I+26bxWmb yRRvE2BYIAFYDNNWW1p2CUUtvWGvU55tppSFT4HrwUBAMw7vixkn6obuHrPjOBFRZrzp v73rjlTOvfTKgZbyUH4pJcUwr0Angjmh/EVW7SN2pZcFcCpfGNxMGezXcbPA9RIh1kPf RsLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684266119; x=1686858119; 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=0BFtx9KYq0Th2HWZb/BY+/P+rVcQ7G1nOi7Bio8e4oI=; b=OdsuqniOEynJj+a3k0FWg4he/GVTHCg9QJD5H1ndjW/+qwnFpKjR+snjJP/1rhLFe0 +kzbhePM41UZTOKL39Lz+K4ux07Cwgk+3ZzSIFeDL7mwCb/8/v8tysBOtpItrTWY2xKL NtS6jKmiG1P0W7HDq0eOhAZAQWYgipLNjjF75iDLyrfW+X0jg2UnlMZyUU+bnWtrS9yh cmxYH0f8SYtRKTLDoYIcce4qECYX8g64orYWG3Z3Rm/BcLzbqTDm0EZTdJaDIc0P0Ip3 iZXorlJ4SCJmJqDcxLXcKm1spiReikWe8QuDXEaOwclMseRxifqSHl2KSstOM0tespKF dVYw== X-Gm-Message-State: AC+VfDxuzp12oKJ4G2gy/H4dGl820C33ksMHFQ+4mEWrNEKHQLC1jBoQ L6W9fcGAw3sjOE/cEuum5hsDGRliIAvg2lHHeKA= X-Received: by 2002:a05:6a20:394d:b0:104:8824:74eb with SMTP id r13-20020a056a20394d00b00104882474ebmr19735544pzg.51.1684266119092; Tue, 16 May 2023 12:41:59 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:ec81:440e:33a4:40b9]) by smtp.gmail.com with ESMTPSA id z21-20020aa791d5000000b006260526cf0csm13771165pfa.116.2023.05.16.12.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 12:41:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell Subject: [PULL 13/80] tcg/i386: Use full load/store helpers in user-only mode Date: Tue, 16 May 2023 12:40:38 -0700 Message-Id: <20230516194145.1749305-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230516194145.1749305-1-richard.henderson@linaro.org> References: <20230516194145.1749305-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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 911123cfa8..21553f3c39 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.