From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543361; cv=none; d=zohomail.com; s=zohoarc; b=CEgOI6qpUnC0DRfqm9sUzWcsLbqyALW86i7n+INsW4Bppaleer14ZMf8Hsxwk0Ejbo4eVZwTQ4tf1TbO8LixemI8FYsELWnuxZs+K/yTY0YFXUz8yaxb+oQyGOGZey8Mko176vRLQ9KaOZ32wCKPxE+Csw8hmkyvNacSqk+SxFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543361; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=QO174fyeKkqZhMLOsdBHFZacANHUsreYjHkaCO9IP9huferQioeN7mWTobGy3arbrw7j9jdsbiXbu8/kson4podDkz5bgr/ZI4eYy/v55R8oFqr8zQWYv/R3wDEdgi1wFGnvsrzpuII8sWGvmhcrhoM9nQqLSj6QPyenxSbI4lg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16445433615853.615632376440658; Thu, 10 Feb 2022 17:36:01 -0800 (PST) Received: from localhost ([::1]:50008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKqt-0006mu-4I for importer@patchew.org; Thu, 10 Feb 2022 20:35:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKmh-0003rb-9l for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:39 -0500 Received: from [2607:f8b0:4864:20::430] (port=33299 helo=mail-pf1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmf-0007Gm-DD for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:38 -0500 Received: by mail-pf1-x430.google.com with SMTP id t36so2649569pfg.0 for ; Thu, 10 Feb 2022 17:31:37 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=wdT5wqOHtCK00lz8qk8V6QiN3qsPta+212aIV78F2/wVMq3GHMnJesZDipXC5KqlAF vlUHhveWbf6k2jf1clTTVp9cW9F/JCAKSzvRGSJEYkweeS1gyIzXAA3nuuiLL67QVN8l nDcrQxZ9XbbcqaoGd2YTpfd6a6+6kZ2xzB7CFT0bO+nz1esH4H7M5HUg2nlUvxShpWrK QGxPs/tjoQxXQ0b/HtBvuKt6o2AYIFORKC/2j8RTmbj/q9RvHMGItgYqEXNxX/fJSbfR GAwAl2VGAnwNbPbkNSUo9A1alMMpbuMvZa/BE02dnwj2iA27tpKpxLG7WaYQ5/0b715H 1Iwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Uh058XUts6HPkXe97baHsy8/Ac7JrSk6cgbCWbIo3VY=; b=UnXSmSiJgapENL9rMWkkoOjhyEX4DyHRTcd2983tRqxLFuGCkCyXsMqSzr0U9P9szt falTs4nt6OVK8U+LzbIn6/w2GZzO4cSW1qnDtKh9laQQk7T4llCLtvr2qWlL6jXukTuU ZgNwLuLOpDGhmXqixdM9xCmX0yx6+GVyeJNHkA7oXDf/nTuGDLDwpKf+1mADJiJk2JGr 0xBdXilSNA1XSKKuelCh2211XqKFXhsDShaxTwtrllLotd5uL+yNQAIMFt8lSlxrfME1 fT6Zg9PPWxI8jqWRkjdUzvGTS2i2QphUA/NhqyAD5rXW+hCPRyaQJIOViSpzwEXmKbCB 2iJg== X-Gm-Message-State: AOAM533WLMCExIeTfBR+ZHN0kcEVYrGbQu6xMNsf9oZICedIFnGETCyx OPUjyZR7scyYWbmdZRXncRQqxwMFSJArd/TO X-Google-Smtp-Source: ABdhPJyx7EI5+r5rW+JBfRTFm//wEK25KEFf80+8Slr0ueGbZXWQEtMZo4raQjSClMF1vYEwisMQsw== X-Received: by 2002:a63:64c:: with SMTP id 73mr4441615pgg.360.1644543096015; Thu, 10 Feb 2022 17:31:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/34] common-user/host/sparc64: Fix safe_syscall_base Date: Fri, 11 Feb 2022 12:30:26 +1100 Message-Id: <20220211013059.17994-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::430 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543363007100001 Content-Type: text/plain; charset="utf-8" Use the "retl" instead of "ret" instruction alias, since we do not allocate a register window in this function. Fix the offset to the first stacked parameter, which lies beyond the register window save area. Fixes: 95c021dac835 ("linux-user/host/sparc64: Add safe-syscall.inc.S") Signed-off-by: Richard Henderson --- common-user/host/sparc64/safe-syscall.inc.S | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host= /sparc64/safe-syscall.inc.S index a2f2b9c967..c7be8f2d25 100644 --- a/common-user/host/sparc64/safe-syscall.inc.S +++ b/common-user/host/sparc64/safe-syscall.inc.S @@ -24,7 +24,8 @@ .type safe_syscall_end, @function =20 #define STACK_BIAS 2047 -#define PARAM(N) STACK_BIAS + N*8 +#define WINDOW_SIZE 16 * 8 +#define PARAM(N) STACK_BIAS + WINDOW_SIZE + N * 8 =20 /* * This is the entry point for making a system call. The calling @@ -74,7 +75,7 @@ safe_syscall_end: /* code path for having successfully executed the syscall */ bcs,pn %xcc, 1f nop - ret + retl nop =20 /* code path when we didn't execute the syscall */ --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543690; cv=none; d=zohomail.com; s=zohoarc; b=eKdmVcr5tg2w0Zx+d8KiYrrE3cZM/kkzXIpiIowkJSbQl2Tytl+cPPgM9ylX2j+UhO+1uak0YBvOLsCJNx4HpeAvnhCV9VwhODC3dAHGfjIR+QiD0BnEbnlzyMn5tXudXuoYVhupHwFWQtxcAhhwYH6Lyl5yISHgmNfNSA7yYgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543690; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MExGM3MYFPcI7+Ux4ttjU7B5pEnYQhssTtf96VqegiE=; b=Vk+yrWFropLqYna2BxE3CxZnfuvM+4/3KI06wvVo1FE4MOCtCSDZ6xXQgq11TOw9pm7D3TVZbsEbVbGYZ0c93Yefe5oysK+HakibQSHAu/gwImtjA4nJGwln7QAiNZd4fJNkvXD7lyCRsG34HYIeISmO9ikHBe2EjGGiwTyXbMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543690718761.752876923192; Thu, 10 Feb 2022 17:41:30 -0800 (PST) Received: from localhost ([::1]:58718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKwD-0004Qg-4x for importer@patchew.org; Thu, 10 Feb 2022 20:41:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKml-0003t4-IY for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:44 -0500 Received: from [2607:f8b0:4864:20::435] (port=35339 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmi-0007Hq-7p for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:42 -0500 Received: by mail-pf1-x435.google.com with SMTP id l19so7678276pfu.2 for ; Thu, 10 Feb 2022 17:31:39 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MExGM3MYFPcI7+Ux4ttjU7B5pEnYQhssTtf96VqegiE=; b=jfhmKXJw+nLERJWyHeRP067AURB6tZOxV41T/QhHeeTaBbxC+ks0FtL8sK+qjjemSS AWYyHA3cMPAkCoaVirGzAop6w/5jnLHkBUmvmIRudv5Lk6JcYHN2ozEgrbgxD1f7+2se j2e/G9vIpYRSykPogUM+baeYoRzACYtlsUX/86jAJU2XTyND819FR43siB/o29czXfl6 RF2OBLagVrGQzqE91j9hsj1LmflfQPTT1SwfTSaM2voDMAihvwZ6WgyciusoiuAx2Dnp EKOZ37P0X+VUypAdua402eVdEr5+E2TQ6O56eefX8feRkdT+XhIBW6pGBq1gvlvoLhvj OAHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MExGM3MYFPcI7+Ux4ttjU7B5pEnYQhssTtf96VqegiE=; b=dgOMiVw30J4/pr+/ouOTrZan/ER+rqYAuteUGGnosrrix3u2vfS6pYAmCMU4ESLUiR g2jm1+Um2PJXcwCAjClqL5voQHe9SzawozDWNGJxpIFKugurwvmRHyndoh18Ruj3bLQR CAHoLSi0irjYDYnI9GlKQmbmfZsj7w/MjUdYOCS1ADnpWFGZVN6tMQIJjiEPn+vgwhOo op8GD57g7RH/soZblcyNmNolxmppWTnj0HHNDkKxOY6+1lPDEelsRW/ji8dxCR5DzE3k OV4IICFhvp5UDA7iSivhapH16FJnE+QvABZtu6jDlTS/hbTIb4MokQDWUaZ3NZWnyC/4 +fqQ== X-Gm-Message-State: AOAM531EA9ssC5hXdi6YUvqegHF3TN4t7GokZqyEfg9cTifi7QYi2Tg2 +08er4thGFx6y9wFru8HQCxX1yWaDiyzJgEU X-Google-Smtp-Source: ABdhPJyP3PGdfeY2dpfVV8BMpyh3QB8WClQ2+oBqFRbQQxRqWYALmrYFom9h5KbUccljbjD5uditwA== X-Received: by 2002:a63:1d26:: with SMTP id d38mr8222904pgd.301.1644543098642; Thu, 10 Feb 2022 17:31:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/34] linux-user: Introduce host_signal_mask Date: Fri, 11 Feb 2022 12:30:27 +1100 Message-Id: <20220211013059.17994-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543692720100001 Do not directly access the uc_sigmask member. This is preparation for a sparc64 fix. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/include/host/aarch64/host-signal.h | 5 +++++ linux-user/include/host/alpha/host-signal.h | 5 +++++ linux-user/include/host/arm/host-signal.h | 5 +++++ linux-user/include/host/i386/host-signal.h | 5 +++++ .../include/host/loongarch64/host-signal.h | 5 +++++ linux-user/include/host/mips/host-signal.h | 5 +++++ linux-user/include/host/ppc/host-signal.h | 5 +++++ linux-user/include/host/riscv/host-signal.h | 5 +++++ linux-user/include/host/s390/host-signal.h | 5 +++++ linux-user/include/host/sparc/host-signal.h | 5 +++++ linux-user/include/host/x86_64/host-signal.h | 5 +++++ linux-user/signal.c | 18 ++++++++---------- 12 files changed, 63 insertions(+), 10 deletions(-) diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/inc= lude/host/aarch64/host-signal.h index 9770b36dc1..76ab078069 100644 --- a/linux-user/include/host/aarch64/host-signal.h +++ b/linux-user/include/host/aarch64/host-signal.h @@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.pc =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { struct _aarch64_ctx *hdr; diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/inclu= de/host/alpha/host-signal.h index f4c942948a..a44d670f2b 100644 --- a/linux-user/include/host/alpha/host-signal.h +++ b/linux-user/include/host/alpha/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.sc_pc =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t *pc =3D (uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include= /host/arm/host-signal.h index 6c095773c0..bbeb4ffefb 100644 --- a/linux-user/include/host/arm/host-signal.h +++ b/linux-user/include/host/arm/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.arm_pc =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/includ= e/host/i386/host-signal.h index abe1ece5c9..fd36f06bda 100644 --- a/linux-user/include/host/i386/host-signal.h +++ b/linux-user/include/host/i386/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.gregs[REG_EIP] =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user= /include/host/loongarch64/host-signal.h index 7effa24251..a9dfe0c688 100644 --- a/linux-user/include/host/loongarch64/host-signal.h +++ b/linux-user/include/host/loongarch64/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.__pc =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { const uint32_t *pinsn =3D (const uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/includ= e/host/mips/host-signal.h index c666ed8c3f..ff840dd491 100644 --- a/linux-user/include/host/mips/host-signal.h +++ b/linux-user/include/host/mips/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.pc =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding" #endif diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include= /host/ppc/host-signal.h index 1d8e658ff7..730a321d98 100644 --- a/linux-user/include/host/ppc/host-signal.h +++ b/linux-user/include/host/ppc/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.regs->nip =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.regs->trap !=3D 0x400 diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/inclu= de/host/riscv/host-signal.h index a4f170efb0..aceae544f2 100644 --- a/linux-user/include/host/riscv/host-signal.h +++ b/linux-user/include/host/riscv/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.__gregs[REG_PC] =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/includ= e/host/s390/host-signal.h index a524f2ab00..e454cea54a 100644 --- a/linux-user/include/host/s390/host-signal.h +++ b/linux-user/include/host/s390/host-signal.h @@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.psw.addr =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint16_t *pinsn =3D (uint16_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/inclu= de/host/sparc/host-signal.h index 7342936071..158918f2ec 100644 --- a/linux-user/include/host/sparc/host-signal.h +++ b/linux-user/include/host/sparc/host-signal.h @@ -29,6 +29,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) #endif } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/incl= ude/host/x86_64/host-signal.h index c71d597eb2..d64d076625 100644 --- a/linux-user/include/host/x86_64/host-signal.h +++ b/linux-user/include/host/x86_64/host-signal.h @@ -20,6 +20,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, ui= ntptr_t pc) uc->uc_mcontext.gregs[REG_RIP] =3D pc; } =20 +static inline void *host_signal_mask(ucontext_t *uc) +{ + return &uc->uc_sigmask; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe diff --git a/linux-user/signal.c b/linux-user/signal.c index 32854bb375..0c61459d4a 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -820,6 +820,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) int guest_sig; uintptr_t pc =3D 0; bool sync_sig =3D false; + void *sigmask =3D host_signal_mask(uc); =20 /* * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special @@ -849,8 +850,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) if (info->si_code =3D=3D SEGV_ACCERR && h2g_valid(host_addr)) { /* If this was a write to a TB protected page, restart. */ if (is_write && - handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask, - pc, guest_addr)) { + handle_sigsegv_accerr_write(cpu, sigmask, pc, guest_ad= dr)) { return; } =20 @@ -865,10 +865,10 @@ static void host_signal_handler(int host_sig, siginfo= _t *info, void *puc) } } =20 - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + sigprocmask(SIG_SETMASK, sigmask, NULL); cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc= ); } else { - sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + sigprocmask(SIG_SETMASK, sigmask, NULL); if (info->si_code =3D=3D BUS_ADRALN) { cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); } @@ -909,17 +909,15 @@ static void host_signal_handler(int host_sig, siginfo= _t *info, void *puc) * now and it getting out to the main loop. Signals will be * unblocked again in process_pending_signals(). * - * WARNING: we cannot use sigfillset() here because the uc_sigmask + * WARNING: we cannot use sigfillset() here because the sigmask * field is a kernel sigset_t, which is much smaller than the * libc sigset_t which sigfillset() operates on. Using sigfillset() * would write 0xff bytes off the end of the structure and trash * data on the struct. - * We can't use sizeof(uc->uc_sigmask) either, because the libc - * headers define the struct field with the wrong (too large) type. */ - memset(&uc->uc_sigmask, 0xff, SIGSET_T_SIZE); - sigdelset(&uc->uc_sigmask, SIGSEGV); - sigdelset(&uc->uc_sigmask, SIGBUS); + memset(sigmask, 0xff, SIGSET_T_SIZE); + sigdelset(sigmask, SIGSEGV); + sigdelset(sigmask, SIGBUS); =20 /* interrupt the virtual CPU as soon as possible */ cpu_exit(thread_cpu); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543748; cv=none; d=zohomail.com; s=zohoarc; b=U/uguF2VNIJ2Wt0UYO2++jRPLQNbApdPxbCpO9Yhu3Mg8UVMUafYMEL8m1qHpSeZX+o8stPMI69x4E95r9CDbPQmrcy5j/sM6Sm1AGVjBZaA+GLPDCMtPQunBY5qjNgONgxpg5TD02r6Y2fPzcqjAAsaEgssTzFYHrv96xml15Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AtGuFC3UKK0Idn4w3teyZ8nMq31tfjbJpMimKivxIv0=; b=g8ahO+3tja3k9qhakexXDwVOV7PZScSxsjy+KDPMfcBV6B43NXCp+mDe1TSzP6xmbQ9anjSiRMWbmypyVKLUfKkMUPcfNsaLeLHYdytGSNXTScdB6JFS/2ZQgWn6Uywk55ROripbCAscmMdI44kff2pYCzIPGvdDtFsxzKA2GrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543748001475.0196086908734; Thu, 10 Feb 2022 17:42:28 -0800 (PST) Received: from localhost ([::1]:33526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKx8-0006Y1-WB for importer@patchew.org; Thu, 10 Feb 2022 20:42:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKmo-0003uj-OS for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:48 -0500 Received: from [2607:f8b0:4864:20::102d] (port=44979 helo=mail-pj1-x102d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKml-0007Jw-CD for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:45 -0500 Received: by mail-pj1-x102d.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so7346873pjh.3 for ; Thu, 10 Feb 2022 17:31:42 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AtGuFC3UKK0Idn4w3teyZ8nMq31tfjbJpMimKivxIv0=; b=F8Q1dUMmfsxxA5W5oCNR1T6uemG52YLV4GONAmncF6M7AV9y+JgA0wdntquRulxIrk YvnbMMt9bzQHpcznFCgYcTn74RXOeF3Psj2m5GEdJgQlRhdfdxMSP86Tv1AjmEvufoSG UdvseZ0p34gXolq2ztBzeYSOY1PI0MA29wOjuskxHv1IG6l4AxXWFDToOfrTRmT7n6PX GOgXcPJAOtd4TJrfz4Z2XTByvBSFhaGjhoZ58FB6luuzwqAlzzixiLeXtHeSrD2rWZKk tcpgKgtw7pWeMFov5o9EwnPwUcba+cAtZbA8KEZLnG/eYkVWcoUK1YCuJouO8dssMytp Ld5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AtGuFC3UKK0Idn4w3teyZ8nMq31tfjbJpMimKivxIv0=; b=D/+CU26aHuLTHeEa0VL4trUsgFTbD+CabOVRtVgGsCLRy0vmPv+kW/Nbf/uJ1qCExS z3w40ZWQZ87nwRWN387oav8e0no2D7sicBnJEl7jtydc9V91nFBL5AIYI2p9dGlBbFUo t34/Zd0c8py5C8s4W6LgO1qV5AnveDvWOzEEImCaFTw9yNI+q4MeEiRt9WccDA4KX5FF 0KxBh70DxL5Y97LGu9UFWZh+kIvkSoDtddnXQnvFD6msGmIgw/QYYpc+NJo7hWc1RZB1 6JekCTVl1/Qi6/sSvo0ysidNzMuu40sKJRoZOm2L8QGaQrKuIHlYFcTPBoe9MiypEnOX lVXg== X-Gm-Message-State: AOAM533PqEDkvnSOdA/yXj20wxHzRJPGN28K01ZX787WroAL6iZnAUAz RQj0m39kS9PCY9Vc60TpbLTMS42t4KDvpggi X-Google-Smtp-Source: ABdhPJzvUXQHvWqZ43D3rqoLsOdRLCD6Zq/ThsCA0kDywjF3x9/x7DWha12vxxJIMRwe4Oj5+CAmkw== X-Received: by 2002:a17:90a:190e:: with SMTP id 14mr210941pjg.210.1644543101436; Thu, 10 Feb 2022 17:31:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/34] linux-user: Introduce host_sigcontext Date: Fri, 11 Feb 2022 12:30:28 +1100 Message-Id: <20220211013059.17994-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543749125100001 Do not directly access ucontext_t as the third signal parameter. This is preparation for a sparc64 fix. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/include/host/aarch64/host-signal.h | 13 ++++++++----- linux-user/include/host/alpha/host-signal.h | 11 +++++++---- linux-user/include/host/arm/host-signal.h | 11 +++++++---- linux-user/include/host/i386/host-signal.h | 11 +++++++---- linux-user/include/host/loongarch64/host-signal.h | 11 +++++++---- linux-user/include/host/mips/host-signal.h | 11 +++++++---- linux-user/include/host/ppc/host-signal.h | 11 +++++++---- linux-user/include/host/riscv/host-signal.h | 11 +++++++---- linux-user/include/host/s390/host-signal.h | 11 +++++++---- linux-user/include/host/sparc/host-signal.h | 11 +++++++---- linux-user/include/host/x86_64/host-signal.h | 11 +++++++---- linux-user/signal.c | 4 ++-- 12 files changed, 80 insertions(+), 47 deletions(-) diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/inc= lude/host/aarch64/host-signal.h index 76ab078069..be079684a2 100644 --- a/linux-user/include/host/aarch64/host-signal.h +++ b/linux-user/include/host/aarch64/host-signal.h @@ -11,6 +11,9 @@ #ifndef AARCH64_HOST_SIGNAL_H #define AARCH64_HOST_SIGNAL_H =20 +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + /* Pre-3.16 kernel headers don't have these, so provide fallback definitio= ns */ #ifndef ESR_MAGIC #define ESR_MAGIC 0x45535201 @@ -20,7 +23,7 @@ struct esr_context { }; #endif =20 -static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc) +static inline struct _aarch64_ctx *first_ctx(host_sigcontext *uc) { return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved; } @@ -30,22 +33,22 @@ static inline struct _aarch64_ctx *next_ctx(struct _aar= ch64_ctx *hdr) return (struct _aarch64_ctx *)((char *)hdr + hdr->size); } =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.pc; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.pc =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { struct _aarch64_ctx *hdr; uint32_t insn; diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/inclu= de/host/alpha/host-signal.h index a44d670f2b..4f9e2abc4b 100644 --- a/linux-user/include/host/alpha/host-signal.h +++ b/linux-user/include/host/alpha/host-signal.h @@ -11,22 +11,25 @@ #ifndef ALPHA_HOST_SIGNAL_H #define ALPHA_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.sc_pc; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.sc_pc =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t *pc =3D (uint32_t *)host_signal_pc(uc); uint32_t insn =3D *pc; diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include= /host/arm/host-signal.h index bbeb4ffefb..faba496d24 100644 --- a/linux-user/include/host/arm/host-signal.h +++ b/linux-user/include/host/arm/host-signal.h @@ -11,22 +11,25 @@ #ifndef ARM_HOST_SIGNAL_H #define ARM_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.arm_pc; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.arm_pc =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { /* * In the FSR, bit 11 is WnR, assuming a v6 or diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/includ= e/host/i386/host-signal.h index fd36f06bda..e2b64f077f 100644 --- a/linux-user/include/host/i386/host-signal.h +++ b/linux-user/include/host/i386/host-signal.h @@ -11,22 +11,25 @@ #ifndef I386_HOST_SIGNAL_H #define I386_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_EIP]; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.gregs[REG_EIP] =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user= /include/host/loongarch64/host-signal.h index a9dfe0c688..d33c3fc03e 100644 --- a/linux-user/include/host/loongarch64/host-signal.h +++ b/linux-user/include/host/loongarch64/host-signal.h @@ -11,22 +11,25 @@ #ifndef LOONGARCH64_HOST_SIGNAL_H #define LOONGARCH64_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.__pc; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.__pc =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { const uint32_t *pinsn =3D (const uint32_t *)host_signal_pc(uc); uint32_t insn =3D pinsn[0]; diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/includ= e/host/mips/host-signal.h index ff840dd491..0dbc5cecfd 100644 --- a/linux-user/include/host/mips/host-signal.h +++ b/linux-user/include/host/mips/host-signal.h @@ -11,17 +11,20 @@ #ifndef MIPS_HOST_SIGNAL_H #define MIPS_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.pc; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.pc =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } @@ -30,7 +33,7 @@ static inline void *host_signal_mask(ucontext_t *uc) #error "Unsupported encoding" #endif =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); =20 diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include= /host/ppc/host-signal.h index 730a321d98..b80384d135 100644 --- a/linux-user/include/host/ppc/host-signal.h +++ b/linux-user/include/host/ppc/host-signal.h @@ -11,22 +11,25 @@ #ifndef PPC_HOST_SIGNAL_H #define PPC_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.regs->nip; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.regs->nip =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.regs->trap !=3D 0x400 && (uc->uc_mcontext.regs->dsisr & 0x02000000); diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/inclu= de/host/riscv/host-signal.h index aceae544f2..decacb2325 100644 --- a/linux-user/include/host/riscv/host-signal.h +++ b/linux-user/include/host/riscv/host-signal.h @@ -11,22 +11,25 @@ #ifndef RISCV_HOST_SIGNAL_H #define RISCV_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.__gregs[REG_PC]; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.__gregs[REG_PC] =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { /* * Detect store by reading the instruction at the program counter. diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/includ= e/host/s390/host-signal.h index e454cea54a..6f191e64d7 100644 --- a/linux-user/include/host/s390/host-signal.h +++ b/linux-user/include/host/s390/host-signal.h @@ -11,22 +11,25 @@ #ifndef S390_HOST_SIGNAL_H #define S390_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.psw.addr; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.psw.addr =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint16_t *pinsn =3D (uint16_t *)host_signal_pc(uc); =20 diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/inclu= de/host/sparc/host-signal.h index 158918f2ec..871b6bb269 100644 --- a/linux-user/include/host/sparc/host-signal.h +++ b/linux-user/include/host/sparc/host-signal.h @@ -11,7 +11,10 @@ #ifndef SPARC_HOST_SIGNAL_H #define SPARC_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. = */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { #ifdef __arch64__ return uc->uc_mcontext.mc_gregs[MC_PC]; @@ -20,7 +23,7 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) #endif } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { #ifdef __arch64__ uc->uc_mcontext.mc_gregs[MC_PC] =3D pc; @@ -29,12 +32,12 @@ static inline void host_signal_set_pc(ucontext_t *uc, u= intptr_t pc) #endif } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); =20 diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/incl= ude/host/x86_64/host-signal.h index d64d076625..5a7627fedc 100644 --- a/linux-user/include/host/x86_64/host-signal.h +++ b/linux-user/include/host/x86_64/host-signal.h @@ -10,22 +10,25 @@ #ifndef X86_64_HOST_SIGNAL_H #define X86_64_HOST_SIGNAL_H =20 -static inline uintptr_t host_signal_pc(ucontext_t *uc) +/* The third argument to a SA_SIGINFO handler is ucontext_t. */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_RIP]; } =20 -static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) { uc->uc_mcontext.gregs[REG_RIP] =3D pc; } =20 -static inline void *host_signal_mask(ucontext_t *uc) +static inline void *host_signal_mask(host_sigcontext *uc) { return &uc->uc_sigmask; } =20 -static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe && (uc->uc_mcontext.gregs[REG_ERR] & 0x2); diff --git a/linux-user/signal.c b/linux-user/signal.c index 0c61459d4a..27a0ff30e9 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -800,7 +800,7 @@ void queue_signal(CPUArchState *env, int sig, int si_ty= pe, /* Adjust the signal context to rewind out of safe-syscall if we're in it = */ static inline void rewind_if_in_safe_syscall(void *puc) { - ucontext_t *uc =3D (ucontext_t *)puc; + host_sigcontext *uc =3D (host_sigcontext *)puc; uintptr_t pcreg =3D host_signal_pc(uc); =20 if (pcreg > (uintptr_t)safe_syscall_start @@ -815,7 +815,7 @@ static void host_signal_handler(int host_sig, siginfo_t= *info, void *puc) CPUState *cpu =3D env_cpu(env); TaskState *ts =3D cpu->opaque; target_siginfo_t tinfo; - ucontext_t *uc =3D puc; + host_sigcontext *uc =3D puc; struct emulated_sigtable *k; int guest_sig; uintptr_t pc =3D 0; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543385; cv=none; d=zohomail.com; s=zohoarc; b=lYLcvbxJrqDgFyQvHTnrZMbqGTZhfyTI79UHnSJk7g4Whbyhrf5LnpOUhao3IfvlIPYbaf+tS0duzFtfv4wtuc+dN9QcMO7s4msxzemBU3frPsjnHOW5cCQsCaDnCwYskSpqee5hZH3T3piR7hMc2RJ3zqC9yr6WxpSnnoMVQ80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543385; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rCCF97dQuOIe5HKSPiGIFkUfFA+q0msW14SF5LYunf0=; b=Uakkd1O4R3RZKngQGt8Mrmid4MmqxutrEGw3w3wyzvczB8YIz86MKAItPAIQKz0SX0HLw2M4Ec43LuYr381aPkWWEJ+KT6+aOc1fM6A7T4SYzr2lvgRG6AkZM1UsSN6+OcESK7gY9twtUllEelkHqcFiIlTeX6m06ctwOsH5CzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164454338531756.907952612833924; Thu, 10 Feb 2022 17:36:25 -0800 (PST) Received: from localhost ([::1]:50460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKrJ-00076A-3f for importer@patchew.org; Thu, 10 Feb 2022 20:36:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKmu-0003wz-6i for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:52 -0500 Received: from [2607:f8b0:4864:20::42f] (port=45017 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmo-0007KP-7G for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:48 -0500 Received: by mail-pf1-x42f.google.com with SMTP id y8so10759158pfa.11 for ; Thu, 10 Feb 2022 17:31:45 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rCCF97dQuOIe5HKSPiGIFkUfFA+q0msW14SF5LYunf0=; b=BWN3dboWX3ij5q0jDCjU+3qQoppr8h3W2OWuDxVevzqwGEz3axhF61iFi2Lxbng/VR wDZDNbQyef8TXzu4sSIoqMmmNRtyoVk3tA7zjEUFOZA+9z7Br6P+NjR1aoCjfxvAz6Iy 14P4o6jU3Tfp56SurjGus0Tf/xUJX1M01pOUeR+4b3fIzVFsrT94TSX0kCtAoqrUGlV+ 7NNkERiCqkPqNmn9pjomAS71vxkpWxl3iOc11LAAV8RBplRzvcbFDWrGJwLZwgQRLWcQ ffTLEAyl7mAw37aYfYMc2AiGYU6MvZZESxYkZZ+tSW5lvKN6ozuy3qSN40En47CncKtH 01Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rCCF97dQuOIe5HKSPiGIFkUfFA+q0msW14SF5LYunf0=; b=gNK7KomJg8zBT6pUME5Lc3sA3OXBc9Dp7ks171W4P2AM8Qu/dPnDS4WHH2zWKFUbTm Veqw97KmB7hVq2/BGB/4BFdHLQ7fUDRcPC4SNrVEFtCq5UHJjry4kK9a2nuNACcDzIXh TPF016cAyoBaJxd0U8pzg3zUeESJpDUurEMicOrNp8fQ/vzsuR1MwRhUpRudSU/TGF2G RFx3kHgsOP87j9HJSKkZcd+9BVWx1oc28KIW5Lm+YNHJyH9negSAPr6EMR8DHIOVVPTv haZOgvuyzqRGpYHLFwF0f0KB2KJ/1lhY0T5Mawfo4KXgZeAjhXBrn/+t39CpFkgorJXc 2sLA== X-Gm-Message-State: AOAM533UorzBKrW7WI4IjyodCkEotJpjNZBgH6gRJQXfGoJN1ljcUHJ1 BteyW7M1TXpGm3Zl3Hl45zKICtWwPCHcwVjF X-Google-Smtp-Source: ABdhPJwo3ANOEmJtTdZOiBCDJqHedbaM/TAkERO/3wLqd6oWfKDnB4UhDyOMgGLooLUvvA6tqjeTAw== X-Received: by 2002:a63:ea54:: with SMTP id l20mr4158736pgk.148.1644543104597; Thu, 10 Feb 2022 17:31:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/34] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Date: Fri, 11 Feb 2022 12:30:29 +1100 Message-Id: <20220211013059.17994-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543386977100001 We do not support sparc32 as a host, so there's no point in sparc64 redirecting to sparc. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/include/host/sparc/host-signal.h | 71 ------------------- linux-user/include/host/sparc64/host-signal.h | 64 ++++++++++++++++- 2 files changed, 63 insertions(+), 72 deletions(-) delete mode 100644 linux-user/include/host/sparc/host-signal.h diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/inclu= de/host/sparc/host-signal.h deleted file mode 100644 index 871b6bb269..0000000000 --- a/linux-user/include/host/sparc/host-signal.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * host-signal.h: signal info dependent on the host architecture - * - * Copyright (c) 2003-2005 Fabrice Bellard - * Copyright (c) 2021 Linaro Limited - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING file in the top-level directory. - */ - -#ifndef SPARC_HOST_SIGNAL_H -#define SPARC_HOST_SIGNAL_H - -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. = */ -typedef ucontext_t host_sigcontext; - -static inline uintptr_t host_signal_pc(host_sigcontext *uc) -{ -#ifdef __arch64__ - return uc->uc_mcontext.mc_gregs[MC_PC]; -#else - return uc->uc_mcontext.gregs[REG_PC]; -#endif -} - -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) -{ -#ifdef __arch64__ - uc->uc_mcontext.mc_gregs[MC_PC] =3D pc; -#else - uc->uc_mcontext.gregs[REG_PC] =3D pc; -#endif -} - -static inline void *host_signal_mask(host_sigcontext *uc) -{ - return &uc->uc_sigmask; -} - -static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) -{ - uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); - - if ((insn >> 30) =3D=3D 3) { - switch ((insn >> 19) & 0x3f) { - case 0x05: /* stb */ - case 0x15: /* stba */ - case 0x06: /* sth */ - case 0x16: /* stha */ - case 0x04: /* st */ - case 0x14: /* sta */ - case 0x07: /* std */ - case 0x17: /* stda */ - case 0x0e: /* stx */ - case 0x1e: /* stxa */ - case 0x24: /* stf */ - case 0x34: /* stfa */ - case 0x27: /* stdf */ - case 0x37: /* stdfa */ - case 0x26: /* stqf */ - case 0x36: /* stqfa */ - case 0x25: /* stfsr */ - case 0x3c: /* casa */ - case 0x3e: /* casxa */ - return true; - } - } - return false; -} - -#endif diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/inc= lude/host/sparc64/host-signal.h index 1191fe2d40..f8a8a4908d 100644 --- a/linux-user/include/host/sparc64/host-signal.h +++ b/linux-user/include/host/sparc64/host-signal.h @@ -1 +1,63 @@ -#include "../sparc/host-signal.h" +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2021 Linaro Limited + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING file in the top-level directory. + */ + +#ifndef SPARC64_HOST_SIGNAL_H +#define SPARC64_HOST_SIGNAL_H + +/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. = */ +typedef ucontext_t host_sigcontext; + +static inline uintptr_t host_signal_pc(host_sigcontext *uc) +{ + return uc->uc_mcontext.mc_gregs[MC_PC]; +} + +static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) +{ + uc->uc_mcontext.mc_gregs[MC_PC] =3D pc; +} + +static inline void *host_signal_mask(host_sigcontext *uc) +{ + return &uc->uc_sigmask; +} + +static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) +{ + uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); + + if ((insn >> 30) =3D=3D 3) { + switch ((insn >> 19) & 0x3f) { + case 0x05: /* stb */ + case 0x15: /* stba */ + case 0x06: /* sth */ + case 0x16: /* stha */ + case 0x04: /* st */ + case 0x14: /* sta */ + case 0x07: /* std */ + case 0x17: /* stda */ + case 0x0e: /* stx */ + case 0x1e: /* stxa */ + case 0x24: /* stf */ + case 0x34: /* stfa */ + case 0x27: /* stdf */ + case 0x37: /* stdfa */ + case 0x26: /* stqf */ + case 0x36: /* stqfa */ + case 0x25: /* stfsr */ + case 0x3c: /* casa */ + case 0x3e: /* casxa */ + return true; + } + } + return false; +} + +#endif --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544020; cv=none; d=zohomail.com; s=zohoarc; b=Qcx5wSC6s9AmHjI41E5Q+2QTXZD1vXgIX44NgUEhII7ZRc7vDsAZmvI2j0o1xz+yUwj/hToucW5u3Za2DrugJq43w1w9O3nvuAJj3CkbvyxoK6K05PBbDNt0O2GKCl8HOe5SQitPTCqsFGMF12E/QFkDCjCKCNPx/YrrV5AvYD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544020; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/OhssSczJVbMJGYs6E9M45NQ4kpIeIUWJ7tzrr8g1OM=; b=ng1QrctJBmez4wQPwU4BFAwET2sbrgcZ0lVKruCh+BZ32Pm3wBUMvMPPrhjMjfEI+asGqbHeaYsNZ9PE53LUxCbZugZyeS89zUPM7EqETRF49GWOd974wW0BXvyANJUbZ5gfZ9gRhAGI4cfcol0ATcUDpYt74zIyMTXwAb3m80o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544020565698.515828473884; Thu, 10 Feb 2022 17:47:00 -0800 (PST) Received: from localhost ([::1]:42246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL1X-0004Nr-8N for importer@patchew.org; Thu, 10 Feb 2022 20:46:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKmu-0003xJ-B7 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:52 -0500 Received: from [2607:f8b0:4864:20::42f] (port=40598 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmr-0007Kv-V5 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:51 -0500 Received: by mail-pf1-x42f.google.com with SMTP id a39so12642501pfx.7 for ; Thu, 10 Feb 2022 17:31:48 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OhssSczJVbMJGYs6E9M45NQ4kpIeIUWJ7tzrr8g1OM=; b=j6htwAEQ9oIw3SBZXNz4nmczvxT0rlu+FL6bCx5i7XwDsfShRWAxDqMWymkJjcezPj DYMdjzEA1qc+ttQ7zZyFauQZv4vwlWfWImmko1WyRlX/3ZyerimnfGDi/hVaYBUZJldh WJS/AGqdj8QQ9etBmv1ICDjghCu5U0+rYIuo+XP4aYI3cyWhZq1rgvzSyJlTA7JBv+3j YKBlqEKrfIJ1Qgcf+gQbbdYCR1zashYHIvMfvrCGwxrN48hHNXgpPy6QDN6yWpp0RbR6 Gzx7LqLqu0TrUgwqotqSiuPvegCVqD+e6axKeZ48dmKOtUK8bK4JwTXoYzzOmqLt2vUe 2UQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/OhssSczJVbMJGYs6E9M45NQ4kpIeIUWJ7tzrr8g1OM=; b=idy3U6KuvusvkTyJ+uFv+MKi1KUXvtYAUHgUQ+LN3+TFX1o9i9Xb4/sTaBDNMMX4n2 gLweUq8AgNS5Sp4QIqfyL6KktPX6RABPcIus2F3zIP8HOJ/f0I92G1pdjocGLvfMRHaS Q47j9CQaa6SP7GWqucJzEpUBVxwaHGuNcrY4nGcJ2vK47hzkZxNo3RmkBu9vsZwX7whT UvTn1XBUsO7BzqrdpZeWSXzv1GI8NH6O44Z0CzHc/OqaanuZ0nFrdJgG1HXYg7dHPp9t ghYhHQT8EhB0kZEdP8A+8J3h+kpywS9kJF5vvQoU9hnLyZQv2TND0yvmgRG5J9oCsxZE dOjQ== X-Gm-Message-State: AOAM533XvzVhv52OWdwIQYdaF5mHaP3luwZ6WxVPuK1D2Dv1EdtEI5VX ZJIPB/au3oBkcTzUJWET9KZMltVcOWHm6kI6 X-Google-Smtp-Source: ABdhPJzcfB1rWLMgwXAOEDfnYyhwMcNdNad7ozG0Ud4Oy+pfp67VetJ/shGdV00tk9KFQBtYwln+Vw== X-Received: by 2002:a62:784a:: with SMTP id t71mr10215347pfc.56.1644543107252; Thu, 10 Feb 2022 17:31:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/34] linux-user/include/host/sparc64: Fix host_sigcontext Date: Fri, 11 Feb 2022 12:30:30 +1100 Message-Id: <20220211013059.17994-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544022167100001 Content-Type: text/plain; charset="utf-8" Sparc64 is unique on linux in *not* passing ucontext_t as the third argument to a SA_SIGINFO handler. It passes the old struct sigcontext instead. Set both pc and npc in host_signal_set_pc. Fixes: 8b5bd461935b ("linux-user/host/sparc: Populate host_signal.h") Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/include/host/sparc64/host-signal.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/inc= lude/host/sparc64/host-signal.h index f8a8a4908d..64957c2bca 100644 --- a/linux-user/include/host/sparc64/host-signal.h +++ b/linux-user/include/host/sparc64/host-signal.h @@ -11,22 +11,23 @@ #ifndef SPARC64_HOST_SIGNAL_H #define SPARC64_HOST_SIGNAL_H =20 -/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. = */ -typedef ucontext_t host_sigcontext; +/* The third argument to a SA_SIGINFO handler is struct sigcontext. */ +typedef struct sigcontext host_sigcontext; =20 -static inline uintptr_t host_signal_pc(host_sigcontext *uc) +static inline uintptr_t host_signal_pc(host_sigcontext *sc) { - return uc->uc_mcontext.mc_gregs[MC_PC]; + return sc->sigc_regs.tpc; } =20 -static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc) +static inline void host_signal_set_pc(host_sigcontext *sc, uintptr_t pc) { - uc->uc_mcontext.mc_gregs[MC_PC] =3D pc; + sc->sigc_regs.tpc =3D pc; + sc->sigc_regs.tnpc =3D pc + 4; } =20 -static inline void *host_signal_mask(host_sigcontext *uc) +static inline void *host_signal_mask(host_sigcontext *sc) { - return &uc->uc_sigmask; + return &sc->sigc_mask; } =20 static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc) --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543693; cv=none; d=zohomail.com; s=zohoarc; b=EE+v9/KbaXeddaE56T7nf9hoPsmCdC8o6XUrtMY43gsG0F+l4iJXph4NK8/hbU11DzrgcHtF46UboZKPJT4OUOWUMdU1ZoAR5WYj3yEym/qb7ZtupDJIERV/+8gUMF7jyDX6/4qzLhJyIB0pBEk7wXwYsrwAeMdi6BkxD6a0oEs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HCvTS/+Prs4N88DmcHEGIADFyIfzc+5Gdyad6hpKQy8=; b=JJrrWgFlCQIWC6lt96lN8hqIpGc2q3pVufAu7W9Vdtfxj3HOyHkWu6ui6reO/hlsopXTmoO+emugxEtDeU62IkcvR/ztl9+1PfOYqFBV1vuy1s1F9LG+ozALK7hxJhCND7eo0Wc7wSPq7EOLllbKck8NRnlKfc5uz96i7WiVXNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543693181654.5308831482398; Thu, 10 Feb 2022 17:41:33 -0800 (PST) Received: from localhost ([::1]:59048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKwG-0004di-PO for importer@patchew.org; Thu, 10 Feb 2022 20:41:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKn3-00044E-Hm for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:05 -0500 Received: from [2607:f8b0:4864:20::42a] (port=34732 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmu-0007LE-0U for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:00 -0500 Received: by mail-pf1-x42a.google.com with SMTP id n23so13528822pfo.1 for ; Thu, 10 Feb 2022 17:31:50 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HCvTS/+Prs4N88DmcHEGIADFyIfzc+5Gdyad6hpKQy8=; b=pWMVzgsrOJKr74IepZfcfPEqYfdMlW2y4JeFd/7v2zYL5C5lo1C9RYr3s6mI4R1XFJ AgBDa3D/ALn5L5DyWJn9X6OQ+odl2zZM1MzCYwi8XB0JfPndLxQILXlROzhYZgaAi20W kyMIX48DZ+Dzue9Wz4m7sZmd1asw+5waAf++8znJNUOQFIAGSE0BU3eq5GOQnBwHbqGP gFXFnm3ce4yNMSCkd5WhhUgNmeZCfMkemoVc9oE+q/N43xIEC+5RRG1DVRPukQYTUGH2 rKg4Y2M77opnJ444zBKaNHBqFLqJqrvIB9BvASototsJfNFYC2HbLNE7IoeLLppp2AoS stwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HCvTS/+Prs4N88DmcHEGIADFyIfzc+5Gdyad6hpKQy8=; b=lm9j4P8Z1sNVMVlrNeeY+HecpL+WPHieUMQzoDXCkQc7n5pbUJMX8wRBM7gq7YPYWn mEgSKfYp9uOODMsRCuMKw0SzAPyeHwbztFJncUDBAJmBEODRCTher/Irn4K33R9+swTT FOZtVOvjf6Vwak/QxoEFQFdTaBYvbyGh0fL55WGgG2ec7WlL35wbjlGrcMUgy/slH3DU bwqcpx3UBKkhoJc83crYCiieSO8z2Zh5ki11D12BmoMciIAEsqN2wNQu6yKZM9th47fh uK+ZCzuPQzsuGX0S+CUrY3oo0F1arlFx8NCWAS5wy7HMWWOuxl3KK/uiXUaxbiHd0QiB xiMw== X-Gm-Message-State: AOAM530GSJhZv/8+2szuqZ7k/fdVriqO0owYtERUAFZfpsHU6T0P0UB5 wJam5viB3cCqBIMPWYhJhzigxkSkroxufXKC X-Google-Smtp-Source: ABdhPJw7nHvSehaFvCrY2POrA/eTL3pko1NzhixrmImCNvVOyNZBMk9IF730k3JzLgIBVOC1ptGpIg== X-Received: by 2002:a63:1b0d:: with SMTP id b13mr5268517pgb.50.1644543109887; Thu, 10 Feb 2022 17:31:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/34] accel/tcg: Optimize jump cache flush during tlb range flush Date: Fri, 11 Feb 2022 12:30:31 +1100 Message-Id: <20220211013059.17994-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, Idan Horowitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543694728100003 Content-Type: text/plain; charset="utf-8" From: Idan Horowitz When the length of the range is large enough, clearing the whole cache is faster than iterating over the (possibly extremely large) set of pages contained in the range. This mimics the pre-existing similar optimization done on the flush of the tlb itself. Signed-off-by: Idan Horowitz Message-Id: <20220110164754.1066025-1-idan.horowitz@gmail.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 5e0d0eebc3..926d9a9192 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -783,6 +783,15 @@ static void tlb_flush_range_by_mmuidx_async_0(CPUState= *cpu, } qemu_spin_unlock(&env_tlb(env)->c.lock); =20 + /* + * If the length is larger than the jump cache size, then it will take + * longer to clear each entry individually than it will to clear it al= l. + */ + if (d.len >=3D (TARGET_PAGE_SIZE * TB_JMP_CACHE_SIZE)) { + cpu_tb_jmp_cache_clear(cpu); + return; + } + for (target_ulong i =3D 0; i < d.len; i +=3D TARGET_PAGE_SIZE) { tb_flush_jmp_cache(cpu, d.addr + i); } --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544279; cv=none; d=zohomail.com; s=zohoarc; b=iNN5aiMSII8IU8xv8c/Q1Iaa3nj7RiGHJ82e9ynj1mhSVKvZucMipaNo1ytkvoZrdfo9SDmUcSM3dFplNJMQ9GZwn4f3WregxuPdOU/tFAv2X1Uqtm/Osc8M47Ie+/7Je/yDYW4JqT+Yv3HezqnthRxwdFVal+Dovs0A0iNde7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544279; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xC7suoa36jFUtiePZKS+9H0vArd6rlJO37NOOnD8sis=; b=NKh5MJPMBsHTXuFiz23f+IO+LavJhnAf8BLqJkSV3ND5rD+Q6/ixvrGDuGA2tJYsuSsbQmAPwym1EwiWHAjllSBKKbcGf4qXSmCHXHfy/Q9WZtgjl9NRCTfqZ/TXne182bEisXMHpTuiCkv8J7vbU9X9zOhX4k6wZHz2ng4B+uI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544279476536.2814072709874; Thu, 10 Feb 2022 17:51:19 -0800 (PST) Received: from localhost ([::1]:50896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL5j-0001uX-9f for importer@patchew.org; Thu, 10 Feb 2022 20:51:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKmy-00042x-NW for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:58 -0500 Received: from [2607:f8b0:4864:20::102f] (port=45928 helo=mail-pj1-x102f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmv-0007Lm-SS for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:56 -0500 Received: by mail-pj1-x102f.google.com with SMTP id q11-20020a17090a304b00b001b94d25eaecso2841894pjl.4 for ; Thu, 10 Feb 2022 17:31:53 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xC7suoa36jFUtiePZKS+9H0vArd6rlJO37NOOnD8sis=; b=xYU8pXjzTNLQLkVtwpVD0yClayBGR/HKi694bjz4Mg3X1cyp/J5ENO5niSnq0t4WKF 5teB9nlY4emK1xG1jzRNJpYtgNCtpxBkM/Rgn78rdZBwxsii22AaGDdE6E2u8bqQ+z93 uuR1USrGCziMJMMRQl5UaR5j/xg9ViOUGkzeJMYO0lDpOyNYI495EpFuBZpwRT+aedIF hxF3pz/MvK4uGVCyKkooTWPL0D2DtTzx/mbiwJwuTjO3YqSeJJpSxTGhR2MGjZBXMjfb OmXH9rFRnf+zMYj5mnhhXxSme4qPKFHJZneciJx8OgCgFu2jO38zUODM4I/AVPWPkq+A Oqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xC7suoa36jFUtiePZKS+9H0vArd6rlJO37NOOnD8sis=; b=UMmzUFvJCxYe9EySVqbCeh3ZoSToA4HqOdfsyGFSePTOJVZoFm3+VGfoZg72TJerCU SJbV2LaKbsYqW2HyVXCzSlQzE51NgrabhQOXqGvcXNaVkUP2ArjqNII60+b2/SRxsBDz haXBdgD8WIGb/5qdG0S69Agoi08UI0FV87OwFNnvAQLsYTcsV8hf6U37FET+p+BS4Ujy bQ4QekCF5nbox8Fjm5T7IavbhqIL6QIliilvE+PzTbwYtY+vYTrdXiMfkATCviriadLG Jz8bbIUw2qCilTU2iYYnjOmd9RJoDM84fk7u3nrDv5rWkcInwR3gA9uw9mDNYDeKb8Gk hCHQ== X-Gm-Message-State: AOAM53202FwBAMtXOR1vVXasI+XCKUQuN/GDIyoeGi4y1sDq43hM3GFR qyz25uWdjBri9iS/edsMyGlvLJhWqu/z8jfr X-Google-Smtp-Source: ABdhPJz+k+1NFwITEbuV+A6RZsTpWTxTGzMBQEXO71SM7x6GdbGO9/k0hZHdWl+eOxfo7liLGEFL9A== X-Received: by 2002:a17:902:7595:: with SMTP id j21mr10007349pll.79.1644543112629; Thu, 10 Feb 2022 17:31:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/34] softmmu/cpus: Check if the cpu work list is empty atomically Date: Fri, 11 Feb 2022 12:30:32 +1100 Message-Id: <20220211013059.17994-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, Idan Horowitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544281992100001 Content-Type: text/plain; charset="utf-8" From: Idan Horowitz Instead of taking the lock of the cpu work list in order to check if it's empty, we can just read the head pointer atomically. This decreases cpu_work_list_empty's share from 5% to 1.3% in a profile of icount-enabled aarch64-softmmu. Signed-off-by: Idan Horowitz Message-Id: <20220114004358.299534-1-idan.horowitz@gmail.com> Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- softmmu/cpus.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 23bca46b07..035395ae13 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -73,12 +73,7 @@ bool cpu_is_stopped(CPUState *cpu) =20 bool cpu_work_list_empty(CPUState *cpu) { - bool ret; - - qemu_mutex_lock(&cpu->work_mutex); - ret =3D QSIMPLEQ_EMPTY(&cpu->work_list); - qemu_mutex_unlock(&cpu->work_mutex); - return ret; + return QSIMPLEQ_EMPTY_ATOMIC(&cpu->work_list); } =20 bool cpu_thread_is_idle(CPUState *cpu) --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543385713246.19672278340897; Thu, 10 Feb 2022 17:36:25 -0800 (PST) Received: from localhost ([::1]:50512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKrF-00078H-J0 for importer@patchew.org; Thu, 10 Feb 2022 20:36:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKn0-00043w-II for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:01 -0500 Received: from [2607:f8b0:4864:20::42f] (port=41763 helo=mail-pf1-x42f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKmy-0007Ly-Ml for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:31:58 -0500 Received: by mail-pf1-x42f.google.com with SMTP id i30so13464304pfk.8 for ; Thu, 10 Feb 2022 17:31:56 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p/kq1VLDBUuq/DLan4O/EIkXf7LdPRXYo9qN4abpVU4=; b=fAvGcWmq1qJoeLvI9LiX/8ZXJOX8SDK9mtlbXZxLSkAA/17ESYGc0F2n6fa+scn5y9 dXizSTnPRGl9GXYC0bH0Nv0adJiyRfPfU+rknaAWSdg9W1vvRrtfHFwoy8oFnA/oz2Rm f9O19Fai4pia96t1ydozfkNn2M+Q3yJhJ0o/ltqQmRd7Y/yiB2xYAJk7s2A/5wDu4poQ WeI7kaaagwp+i26ZTIcHrxTVSoyu8hREi0VsQd650vV2/BNEAhn/l75O9NJei3IhlTbq WgGskqBmhexm4oQGsDDYYmwJgpU3g6Fy4AcEmG8JArZcybbvaq6Nc+3cWrhSoCfPCy63 6J9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p/kq1VLDBUuq/DLan4O/EIkXf7LdPRXYo9qN4abpVU4=; b=D+atSaIyfJx4LAjPHKuZcX7I+YuWq88dUYnarrSpw3xfzwZ1947KR/2ixO9qLygB6h /WWD3PgYFIjeCRBbH0Xuu9smCnf1+ihm/p1en2Wf4+vc6ojfmu5goZoF5XmcfAdeC81E 2vOES/JBBf0CX/oxn/12qR+hMrm6LhlDVbCYpw54foKbZv2zqZYWYs9h6Rx3jtgpAyDi 55V/gPqbo6Hkvw5WqsXytWM2rCBzYcYhTmomcvKzAAWtO2uSoJb7g/mU9JaL/jnl58uD MBI2+wtLuNBMolz+GacFjnO1WcJvuS7p7rudJ7I90p2AI1Sw8xVWO4moP5N2KFXUGY9m gzjA== X-Gm-Message-State: AOAM532+tnWaBM7zUDoHH93ioM6qL2MpBD2Na0191jB91NaLUw5bbmgD FHwln6I5K3QN+ZEklX/ggRLZVOsxnNcchK7V X-Google-Smtp-Source: ABdhPJw+xWfhChOjxvr03alMLM0T4GCKpAq9xWyYo95bDgUO+ogX7hVW5ogtLoocHkZ26dmb+4cyvA== X-Received: by 2002:a63:6842:: with SMTP id d63mr8133234pgc.213.1644543115553; Thu, 10 Feb 2022 17:31:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/34] replay: use CF_NOIRQ for special exception-replaying TB Date: Fri, 11 Feb 2022 12:30:33 +1100 Message-Id: <20220211013059.17994-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644543387333100003 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk Commit aff0e204cb1f1c036a496c94c15f5dfafcd9b4b4 introduced CF_NOIRQ usage, but one case was forgotten. Record/replay uses one special TB which is not really executed, but used to cause a correct exception in replay mode. This patch adds CF_NOIRQ flag for such block. Signed-off-by: Pavel Dovgalyuk Reviewed-by: Richard Henderson Message-Id: <164362834054.1754532.7678416881159817273.stgit@pasha-ThinkPad-= X280> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8b4cd6c59d..8da6a55593 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -648,7 +648,8 @@ static inline bool cpu_handle_exception(CPUState *cpu, = int *ret) if (replay_has_exception() && cpu_neg(cpu)->icount_decr.u16.low + cpu->icount_extra =3D= =3D 0) { /* Execute just one insn to trigger exception pending in the l= og */ - cpu->cflags_next_tb =3D (curr_cflags(cpu) & ~CF_USE_ICOUNT) | = 1; + cpu->cflags_next_tb =3D (curr_cflags(cpu) & ~CF_USE_ICOUNT) + | CF_NOIRQ | 1; } #endif return false; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164454392656573.334763586539; Thu, 10 Feb 2022 17:45:26 -0800 (PST) Received: from localhost ([::1]:39438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL01-0002Oj-H7 for importer@patchew.org; Thu, 10 Feb 2022 20:45:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKn4-00044K-7c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:05 -0500 Received: from [2607:f8b0:4864:20::1035] (port=39746 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKn1-0007MS-Nu for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:01 -0500 Received: by mail-pj1-x1035.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso10401249pjt.4 for ; Thu, 10 Feb 2022 17:31:59 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KMWZPJpRr/1EU+0WBrOLUzmhcggx5S8kf5YnkmrzW7A=; b=TqQVr9vg1LXue62Z6jBLWtLiiZPMJYBEca3IWfWl1ZMENKYLtwVN/6orgbvDY+TX6n 9w+YVYFLEbjPH0Pbo/qoQWx/qgBFJKH+4UwX8lnRcmvc8Y/iUN5IKXxZIvoDE9PVBOlk DZro3ivJxz7975Ix9BdkAIgPdMhjM8EQ6Y0lMQY1eFcyK9CY+ZqwxtsF4IC4Pa12bNRi Pk8Gp/6HD8QJsXVQsYcKZXf7JdESFLS44FdJzCTDRquyPrtFGqVjEKWv42KIExd1jivu 0Ep+3q2nhSEDtZ/qGZdImuLXWK4yoZWBQcyq3TvABF+vCv/tAReUJErMvgB7btg9YTLn cAcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KMWZPJpRr/1EU+0WBrOLUzmhcggx5S8kf5YnkmrzW7A=; b=15urWhri9G/6Ql1NiyPKqp5SqgKOCEOcNLnmAFB6Z/WIXF2Kz/O55Wy5nqEk4qXuEJ 1Z+3Mdo5CoBk3Lc/RqsqDmb0C9QU02Ge5FJenWtwyVA5Lr3/+H92aVkewlN/2VKdq5Kf A6HMof2lGlimluJ5xpF8+66OHwmIFf7wOIwOI1LQKJ4vgsI4tnzY3cm1OvDB4HDqddc7 Q1alhOUJ9DJYiQcDwxoZDKp4rlqnW8mTWOeKgVcY63AgebVkIk152YcgA6BVHstLX384 lhVqUwqrVNfAK7FUyVo/apnEJgdkjC3b4eUebXRPIR5oDKg9+pv9h2QezHDEQM1vG7wL vtMQ== X-Gm-Message-State: AOAM532tw3KxFQZsQBgjYHarNUXewBLfFit/J2JEJlYjmwGUJDvmOhoz TFhyy2o/FB3F7w7qVaWa60uHv2g1H9RsRpW8 X-Google-Smtp-Source: ABdhPJwMEoWmt0fqhIVrwlkUqQlMVW2S9WTfRLONNDNFx5cnZdwzfcWD4BKlcrRaRLaDKrs0kfoA6g== X-Received: by 2002:a17:902:e5cd:: with SMTP id u13mr5044745plf.40.1644543118322; Thu, 10 Feb 2022 17:31:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/34] tcg/loongarch64: Fix fallout from recent MO_Q renaming Date: Fri, 11 Feb 2022 12:30:34 +1100 Message-Id: <20220211013059.17994-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: WANG Xuerui , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644543927181100001 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui Apparently we were left behind; just renaming MO_Q to MO_UQ is enough. Fixes: fc313c64345453c7 ("exec/memop: Adding signedness to quad definitions= ") Signed-off-by: WANG Xuerui Message-Id: <20220206162106.1092364-1-i.qemu@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index 9cd46c9be3..d31a0e5991 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -871,7 +871,7 @@ static void tcg_out_qemu_ld_indexed(TCGContext *s, TCGR= eg rd, TCGReg rj, case MO_SL: tcg_out_opc_ldx_w(s, rd, rj, rk); break; - case MO_Q: + case MO_UQ: tcg_out_opc_ldx_d(s, rd, rj, rk); break; default: --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544464; cv=none; d=zohomail.com; s=zohoarc; b=ABaNiS6JvS9XBIPCxTRBOTk1T8hdeZC6IGB7xAZRin6RBWsPKHxfSPR7x46eSgxaOAYViDUzh6GigH6RAy8RJXvLD2P67I2gFrOtRENXZCf9jyh3wKX01wT0FQYkIiKvBWMAFwDMjXeoYBtBJCev9vWbFTNEPiosYxLkrHQna2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544464; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HVufiE0vyQLswkYAsBYJ6cSo8sjE6jK0Xc+XAd3WqGM=; b=RyFChe5UsKy9PypctVwNWIFHis1WCKpsWCBX2OLfsAtF2CDWA/2G+MFY/GlmlYmRZ6MSWaOkDAQ1m0b2/cyq6wHdou4pb2nOSVJvAVF92j+9irH0mYCrT0V7ZYWppn4+mPqFyPBrN0EmUt1a4jsTy6wQ7jnylyOUTHGWH+F1bXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544464578846.142877689796; Thu, 10 Feb 2022 17:54:24 -0800 (PST) Received: from localhost ([::1]:59490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL8h-0007ns-Am for importer@patchew.org; Thu, 10 Feb 2022 20:54:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKn6-00044T-DU for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:06 -0500 Received: from [2607:f8b0:4864:20::42a] (port=40596 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKn3-0007Ms-U1 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:04 -0500 Received: by mail-pf1-x42a.google.com with SMTP id a39so12643212pfx.7 for ; Thu, 10 Feb 2022 17:32:01 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HVufiE0vyQLswkYAsBYJ6cSo8sjE6jK0Xc+XAd3WqGM=; b=ei6z05ZJigIZJpryKfvzJKNzAcWpxvt4QBh1A3x3JphlQetx/R1qRDHgbkjmWkC+qD gfYyCHRMUELWpwPN92EYJOjYKXqklvN3WyycZ7wyH8Nw6mH8ZOWkesn2rZ4wM0XlrefC ZDP2a9P46riaZRwDZwYu/1c68FQBJNN01Vv0pD3P8l8mxM3m+/t92jL7PMACsSrIvQFx 9sVMaEMe5WRUoISRB/Ofiq8Ng/DoKCngvI/UHosIfYesnMLXyagjNkcvi/2kvHGZlzbf 5D+PZ0chhlt1vyBg5cUP7skXdGluuzYWu7A3KWRwHPyMDcM4KrEmPwZOB/LdnqXilCwX 27Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HVufiE0vyQLswkYAsBYJ6cSo8sjE6jK0Xc+XAd3WqGM=; b=5en+Vd5QkpTQIvhZ/Q/ExEUqF/CiaQGdxxvDlZw/beySa9+1ZrrqI6EHds97Xc2ukG 5S1eVZonqYsW699ozwMZAY47b/jD1nuDumsM1lGj+RvJBWY5x8fcKNCZBgZBDuUNWI5l RGPHVsZKYTuS0Oq+QYPKeAbEqMD2m9AGHmY+EYlu04UYgHdUluqCkwgiGh71EiQINoqU /Gh/e3vB/ffwNEvl8e1nj703+Sc7JnflQHOlPPp+oNQvy1U5Ta3EbUSA6+ASowW3eng5 DXKEVuiBmaoDhJOLyi47JIZtLp0i5Tjd2/W6co5aGfZCtj+N28SjnaylmAxloKoVUxKi 79BA== X-Gm-Message-State: AOAM533H8LCONgXS8IuOmsbFlf7l5q7aMpbADzqEkZN+jwT1RkHa3l/W DX+pIuwphnVIBWVaYRz3AUrxtAwbw8eMjSl1 X-Google-Smtp-Source: ABdhPJy+Dm2t4YS+jvuoHxZswGGCVtxi+qh4n3SbEPKuoisq+Ob5mjW3LYm3NreSRvmKUScnrsBaXQ== X-Received: by 2002:a63:5641:: with SMTP id g1mr8285634pgm.579.1644543120621; Thu, 10 Feb 2022 17:32:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/34] tcg/i386: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:35 +1100 Message-Id: <20220211013059.17994-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544465823100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.h | 2 - tcg/i386/tcg-target.c.inc | 103 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 7 deletions(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index b00a6da293..3b2c9437a0 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -232,9 +232,7 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, =20 #define TCG_TARGET_HAS_MEMORY_BSWAP have_movbe =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 4dab09f265..faa15eecab 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -22,6 +22,7 @@ * THE SOFTWARE. */ =20 +#include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" =20 #ifdef CONFIG_DEBUG_TCG @@ -421,8 +422,9 @@ static bool tcg_target_const_match(int64_t val, TCGType= type, int ct) #define OPC_VZEROUPPER (0x77 | P_EXT) #define OPC_XCHG_ax_r32 (0x90) =20 -#define OPC_GRP3_Ev (0xf7) -#define OPC_GRP5 (0xff) +#define OPC_GRP3_Eb (0xf6) +#define OPC_GRP3_Ev (0xf7) +#define OPC_GRP5 (0xff) #define OPC_GRP14 (0x73 | P_EXT | P_DATA16) =20 /* Group 1 opcode extensions for 0x80-0x83. @@ -444,6 +446,7 @@ static bool tcg_target_const_match(int64_t val, TCGType= type, int ct) #define SHIFT_SAR 7 =20 /* Group 3 opcode extensions for 0xf6, 0xf7. To be used with OPC_GRP3. */ +#define EXT3_TESTi 0 #define EXT3_NOT 2 #define EXT3_NEG 3 #define EXT3_MUL 4 @@ -1606,8 +1609,6 @@ static void tcg_out_nopn(TCGContext *s, int n) } =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ @@ -1916,7 +1917,84 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) tcg_out_jmp(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SIZE)]); return true; } -#elif TCG_TARGET_REG_BITS =3D=3D 32 +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrl= o, + TCGReg addrhi, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *label; + + /* + * We are expecting a_bits to max out at 7, so we can usually use test= b. + * For i686, we have to use testl for %esi/%edi. + */ + if (a_mask <=3D 0xff && (TCG_TARGET_REG_BITS =3D=3D 64 || addrlo < 4))= { + tcg_out_modrm(s, OPC_GRP3_Eb | P_REXB_RM, EXT3_TESTi, addrlo); + tcg_out8(s, a_mask); + } else { + tcg_out_modrm(s, OPC_GRP3_Ev, EXT3_TESTi, addrlo); + tcg_out32(s, a_mask); + } + + /* jne slow_path */ + tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); + + label =3D new_ldst_label(s); + label->is_ld =3D is_ld; + label->addrlo_reg =3D addrlo; + label->addrhi_reg =3D addrhi; + label->raddr =3D tcg_splitwx_to_rx(s->code_ptr + 4); + label->label_ptr[0] =3D s->code_ptr; + + s->code_ptr +=3D 4; +} + +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 =3D=3D 32) { + int ofs =3D 0; + + tcg_out_st(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, ofs); + ofs +=3D 4; + + tcg_out_st(s, TCG_TYPE_I32, l->addrlo_reg, TCG_REG_ESP, ofs); + ofs +=3D 4; + if (TARGET_LONG_BITS =3D=3D 64) { + tcg_out_st(s, TCG_TYPE_I32, l->addrhi_reg, TCG_REG_ESP, ofs); + ofs +=3D 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_ARE= G0); + + 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); +} + +#if TCG_TARGET_REG_BITS =3D=3D 32 # define x86_guest_base_seg 0 # define x86_guest_base_index -1 # define x86_guest_base_offset guest_base @@ -1950,6 +2028,7 @@ static inline int setup_guest_base_seg(void) return 0; } # endif +#endif #endif /* SOFTMMU */ =20 static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg datalo, TCGReg da= tahi, @@ -2059,6 +2138,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is64) #if defined(CONFIG_SOFTMMU) int mem_index; tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -2081,6 +2162,11 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is64) add_qemu_ldst_label(s, true, is64, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); + } + tcg_out_qemu_ld_direct(s, datalo, datahi, addrlo, x86_guest_base_index, x86_guest_base_offset, x86_guest_base_seg, is64, opc); @@ -2148,6 +2234,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) #if defined(CONFIG_SOFTMMU) int mem_index; tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -2170,6 +2258,11 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is64) add_qemu_ldst_label(s, false, is64, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); + } + tcg_out_qemu_st_direct(s, datalo, datahi, addrlo, x86_guest_base_index, x86_guest_base_offset, x86_guest_base_seg, opc); #endif --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544717; cv=none; d=zohomail.com; s=zohoarc; b=JZT//GqmJbqd3NAuI68BX065IiGeZAWTTC9NEtl6exFMGQ7wxi5jLPextfUHDefemGFfMgEwslov/PyvUf1QPxXjf0X8eKTqazLVqBziQFxlfgkAxM4/HR4t8ZAQCi9mKakZ1GevDkAGyLcrSVEAi8umPWSDXRCuovxvS0E/LNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544717; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lmQoyzjNb3ryE3LXWs5KKXgdEeGyLNnU6w6uvn+LPxw=; b=GP4XU1NR7a94yS5objCih+DJ1ymPvqZPTPHPFp4qt4fpjOcFcXAZpYUevmlWBojHRwN/5ZH8tj4OcyA1BP9H64NFA5ZaHspCEEczJmT19v0A19Q9HAyPXB+UbOU+mGEQoW6q4IeFal80TUbILTo25qB/6stU7Mxk3LpGTzNU+cY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544717594213.54274251508843; Thu, 10 Feb 2022 17:58:37 -0800 (PST) Received: from localhost ([::1]:39926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILCm-0005O8-Hx for importer@patchew.org; Thu, 10 Feb 2022 20:58:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKn9-00045V-SZ for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:09 -0500 Received: from [2607:f8b0:4864:20::102a] (port=38630 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKn6-0007OM-4L for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:06 -0500 Received: by mail-pj1-x102a.google.com with SMTP id h14-20020a17090a130e00b001b88991a305so10415569pja.3 for ; Thu, 10 Feb 2022 17:32:03 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lmQoyzjNb3ryE3LXWs5KKXgdEeGyLNnU6w6uvn+LPxw=; b=XPymg5ucUOUFnLnWlWZoYtMDFtBAx3t5SCpx1nZjdBZyVZM4A+ga3D8IqIi3ZXmYrg 7ikhZbLSemQTc+eU097cKnOaGtnJ4Zp5kYrjemM+Oo8wTYtmyPabmE2jQhTnK6CFHlyV Kuo05aOCS4qF3UdwvMWs2dM9XQ3tCJ2Sk9peb2s4Sa8wen8o/BSqLI5bOTxY5FwEZ33O aAz9eLncrXOCVsUiBpdlVZwb7i2y94l5G5R3sCrFbcqoDkDi4yMndyQnETYSmcEV7xjE 2Y7GcwHZrIJFQeFAW204EZtfzBaXhn73SHpNTeiQQc64IwlE3z0cgc+mTjiyXRAiMjVp clyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lmQoyzjNb3ryE3LXWs5KKXgdEeGyLNnU6w6uvn+LPxw=; b=01qF78N7E7j/e4C3TE3/tFwkKj8lvZ9kllLpP/AwPJYY4Ejof8iRj2A66r4DBkuB7R Dao9zo2MD+QFlIiORA71SAmvseXTvh4f9kiP/e/DJn/sn+2nusT3jFRFDLOSaOXno5WJ gzMVEw2oW2DCfiCCBUEUFxIZd+LRdfV8qUXjKXvaDSly/D+DvQLfGWADQ3eguFlGwfOG GwkhvxpYYLBJZ4s8KW+UyZMhE55Of7KiESVvXc/BIO7CtyUKRfBZAQGM9rVLHFZ0ZQbZ gB829zKpAXfBf2qly1vLvkhcw5bgm+8FI+85orho7GlnncNxcBmnFPZJej9lBQHBON7N UACg== X-Gm-Message-State: AOAM533lH+6IhV5+Kv2afYj150PJ1CNFUweKxDl9o+kEST5qe7CZb9Fc en2fCbWB4sS/eDRvLE1NpJXvbogfSjhRcz35 X-Google-Smtp-Source: ABdhPJzKVdq0qcqtzI4flqxIxPsWRavP6ZRBkLsuLII473wehlKqXC6KIhYg4iH7HlYAi2XRVmbjOA== X-Received: by 2002:a17:90a:5b07:: with SMTP id o7mr212454pji.246.1644543122821; Thu, 10 Feb 2022 17:32:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/34] tcg/aarch64: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:36 +1100 Message-Id: <20220211013059.17994-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544718362100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.h | 2 - tcg/aarch64/tcg-target.c.inc | 91 +++++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 7a93ac8023..876af589ce 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -151,9 +151,7 @@ typedef enum { =20 void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #endif /* AARCH64_TCG_TARGET_H */ diff --git a/tcg/aarch64/tcg-target.c.inc b/tcg/aarch64/tcg-target.c.inc index a8db553287..077fc51401 100644 --- a/tcg/aarch64/tcg-target.c.inc +++ b/tcg/aarch64/tcg-target.c.inc @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory for details. */ =20 +#include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" #include "qemu/bitops.h" =20 @@ -443,6 +444,7 @@ typedef enum { I3404_ANDI =3D 0x12000000, I3404_ORRI =3D 0x32000000, I3404_EORI =3D 0x52000000, + I3404_ANDSI =3D 0x72000000, =20 /* Move wide immediate instructions. */ I3405_MOVN =3D 0x12800000, @@ -1328,8 +1330,9 @@ static void tcg_out_goto_long(TCGContext *s, const tc= g_insn_unit *target) if (offset =3D=3D sextract64(offset, 0, 26)) { tcg_out_insn(s, 3206, B, offset); } else { - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, (intptr_t)target); - tcg_out_insn(s, 3207, BR, TCG_REG_TMP); + /* Choose X9 as a call-clobbered non-LR temporary. */ + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_X9, (intptr_t)target); + tcg_out_insn(s, 3207, BR, TCG_REG_X9); } } =20 @@ -1541,9 +1544,14 @@ static void tcg_out_cltz(TCGContext *s, TCGType ext,= TCGReg d, } } =20 -#ifdef CONFIG_SOFTMMU -#include "../tcg-ldst.c.inc" +static void tcg_out_adr(TCGContext *s, TCGReg rd, const void *target) +{ + ptrdiff_t offset =3D tcg_pcrel_diff(s, target); + tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 21)); + tcg_out_insn(s, 3406, ADR, rd, offset); +} =20 +#ifdef CONFIG_SOFTMMU /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * MemOpIdx oi, uintptr_t ra) */ @@ -1577,13 +1585,6 @@ static void * const qemu_st_helpers[MO_SIZE + 1] =3D= { #endif }; =20 -static inline void tcg_out_adr(TCGContext *s, TCGReg rd, const void *targe= t) -{ - ptrdiff_t offset =3D tcg_pcrel_diff(s, target); - tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 21)); - tcg_out_insn(s, 3406, ADR, rd, offset); -} - static bool tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) { MemOpIdx oi =3D lb->oi; @@ -1714,15 +1715,58 @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg = addr_reg, MemOp opc, tcg_out_insn(s, 3202, B_C, TCG_COND_NE, 0); } =20 +#else +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_= reg, + unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *label =3D new_ldst_label(s); + + label->is_ld =3D is_ld; + label->addrlo_reg =3D addr_reg; + + /* tst addr, #mask */ + tcg_out_logicali(s, I3404_ANDSI, 0, TCG_REG_XZR, addr_reg, a_mask); + + label->label_ptr[0] =3D s->code_ptr; + + /* b.ne slow_path */ + tcg_out_insn(s, 3202, B_C, TCG_COND_NE, 0); + + label->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + if (!reloc_pc19(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_X1, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); + + /* "Tail call" to the helper, with the return address back inline. */ + tcg_out_adr(s, TCG_REG_LR, l->raddr); + tcg_out_goto_long(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); +} #endif /* CONFIG_SOFTMMU */ =20 static void tcg_out_qemu_ld_direct(TCGContext *s, MemOp memop, TCGType ext, TCGReg data_r, TCGReg addr_r, TCGType otype, TCGReg off_r) { - /* Byte swapping is left to middle-end expansion. */ - tcg_debug_assert((memop & MO_BSWAP) =3D=3D 0); - switch (memop & MO_SSIZE) { case MO_UB: tcg_out_ldst_r(s, I3312_LDRB, data_r, addr_r, otype, off_r); @@ -1756,9 +1800,6 @@ static void tcg_out_qemu_st_direct(TCGContext *s, Mem= Op memop, TCGReg data_r, TCGReg addr_r, TCGType otype, TCGReg off_r) { - /* Byte swapping is left to middle-end expansion. */ - tcg_debug_assert((memop & MO_BSWAP) =3D=3D 0); - switch (memop & MO_SIZE) { case MO_8: tcg_out_ldst_r(s, I3312_STRB, data_r, addr_r, otype, off_r); @@ -1782,6 +1823,10 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg da= ta_reg, TCGReg addr_reg, { MemOp memop =3D get_memop(oi); const TCGType otype =3D TARGET_LONG_BITS =3D=3D 64 ? TCG_TYPE_I64 : TC= G_TYPE_I32; + + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((memop & MO_BSWAP) =3D=3D 0); + #ifdef CONFIG_SOFTMMU unsigned mem_index =3D get_mmuidx(oi); tcg_insn_unit *label_ptr; @@ -1792,6 +1837,10 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg da= ta_reg, TCGReg addr_reg, add_qemu_ldst_label(s, true, oi, ext, data_reg, addr_reg, s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ + unsigned a_bits =3D get_alignment_bits(memop); + if (a_bits) { + tcg_out_test_alignment(s, true, addr_reg, a_bits); + } if (USE_GUEST_BASE) { tcg_out_qemu_ld_direct(s, memop, ext, data_reg, TCG_REG_GUEST_BASE, otype, addr_reg); @@ -1807,6 +1856,10 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg da= ta_reg, TCGReg addr_reg, { MemOp memop =3D get_memop(oi); const TCGType otype =3D TARGET_LONG_BITS =3D=3D 64 ? TCG_TYPE_I64 : TC= G_TYPE_I32; + + /* Byte swapping is left to middle-end expansion. */ + tcg_debug_assert((memop & MO_BSWAP) =3D=3D 0); + #ifdef CONFIG_SOFTMMU unsigned mem_index =3D get_mmuidx(oi); tcg_insn_unit *label_ptr; @@ -1817,6 +1870,10 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg da= ta_reg, TCGReg addr_reg, add_qemu_ldst_label(s, false, oi, (memop & MO_SIZE)=3D=3D MO_64, data_reg, addr_reg, s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ + unsigned a_bits =3D get_alignment_bits(memop); + if (a_bits) { + tcg_out_test_alignment(s, false, addr_reg, a_bits); + } if (USE_GUEST_BASE) { tcg_out_qemu_st_direct(s, memop, data_reg, TCG_REG_GUEST_BASE, otype, addr_reg); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543693; cv=none; d=zohomail.com; s=zohoarc; b=iwyKWZQc1RSp1lQVynhqlhsKmAbjJdVMkp7cl8ZSpP7ly97E2O6N90wwXQY3inVjWMzR+ic033XFyLU78gNFHXq9pjEKtfljie/IdpU5RcT9ADHfvoLERjBPhE89ljmrkxEIXvUN2ODMFD8rnz+Tpdk6pqVpadCz15l9p8CzW00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bbrgztFqJasWUZ/hN5sPKuXUBrKA7jkix0iaPfPUsNY=; b=j4+MJrl8lMgO5MOYbz0WgpaoeJqM05Ldv0Mvyf5LggEfqBsDQ/XyJJVpFs5TJPi1cyEH8R9TAzwpriKNWxlmH5GglYOG0ChONEUbps+Ahb9hZrs8tCIxminyb1NC13lg2ni3FMHRhdnUXb9vtnkxtBnORB8ya9wOgMq0GdfcIJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543693298381.68953635782157; Thu, 10 Feb 2022 17:41:33 -0800 (PST) Received: from localhost ([::1]:59164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKwF-0004hs-Us for importer@patchew.org; Thu, 10 Feb 2022 20:41:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnC-00046Z-4e for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:10 -0500 Received: from [2607:f8b0:4864:20::434] (port=37745 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKn9-0007Om-J2 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:09 -0500 Received: by mail-pf1-x434.google.com with SMTP id y5so13489424pfe.4 for ; Thu, 10 Feb 2022 17:32:06 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bbrgztFqJasWUZ/hN5sPKuXUBrKA7jkix0iaPfPUsNY=; b=LGb2z4gpu5Rs7XltpKbnzu4ELMkm7/xCfs4jnjMWklds+Nx6JdeqD9HQ7mHByOFpgF 3ohVUndDwv+vyxnbYnJEGwCitXUTPz9G2iaMtlnU+nopdkECtfLq5FTx+kjGQAWSzy+R ki/yCKgdsJou3unnbzTLljn1e1j9jd4p5w5pow5CzfdN3pZ9GWW+jf4xLJm1VR+Mx4y4 75+4DRO/k+ozOUYXfxeuoI0Z4xqq2dFro3myNTxa8G/GwXVJv+G9DJgX9wv3NHxT4oPu 65Y7JyKoCgUJukajMQDF8KQr4b10n8AUhCcKQ33ZXhHgzKWWYxpMIBVZmm/9uk9tCvST flbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bbrgztFqJasWUZ/hN5sPKuXUBrKA7jkix0iaPfPUsNY=; b=AKKpEuNJlkoV8iF8z/SaKV4eAEJSDNyv5UP37jbHhtzOLX8ixfx8rO2LjLdvjilHgS 3vU5ctCCQAz8RfW/SrcEhn4fFhMMvtmFuoCkEEm+ji5xuJjA/uM245wq/F5aRHjM0Kvw Av5yDP5SHpujstssk7wVfPn23Yw+yVCnoJx90OMgFd/y+AW9x48442tLxh5ERzpdhv3D sCl3XMapsrs/4FPUClWufWU9tZ4D84SQoD6KWKc7lA2XW2rKDq8mQpoo/fpLnRidvHLD AnEzg2SmLq7/IWFvjDWBNIUjVg1+GRoubRVd0GwE3vTKS/REzV21Hl609Ozn86IV5uYm nwYw== X-Gm-Message-State: AOAM531xAixlfua5pzGbhcAnSMPCALXiFV4c5fDNa16hiehcXlrAuC/Q Jq3OJ2LwVgO66ZdZX3pgUx6vCjtOMKoctdaH X-Google-Smtp-Source: ABdhPJxKGaLriomo7W0HaLf4EDUHCVoo3eyZycS7+zf+7r9SqUuDRztegKzBWFmpJT6gb6aUdFPXGQ== X-Received: by 2002:a63:84c3:: with SMTP id k186mr245354pgd.575.1644543125243; Thu, 10 Feb 2022 17:32:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/34] tcg/ppc: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:37 +1100 Message-Id: <20220211013059.17994-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543694890100005 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/ppc/tcg-target.h | 2 - tcg/ppc/tcg-target.c.inc | 98 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 90 insertions(+), 10 deletions(-) diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index 0943192cde..c775c97b61 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -182,9 +182,7 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); #define TCG_TARGET_DEFAULT_MO (0) #define TCG_TARGET_HAS_MEMORY_BSWAP 1 =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/ppc/tcg-target.c.inc b/tcg/ppc/tcg-target.c.inc index 9e79a7edee..dea24f23c4 100644 --- a/tcg/ppc/tcg-target.c.inc +++ b/tcg/ppc/tcg-target.c.inc @@ -24,6 +24,7 @@ =20 #include "elf.h" #include "../tcg-pool.c.inc" +#include "../tcg-ldst.c.inc" =20 /* * Standardize on the _CALL_FOO symbols used by GCC: @@ -1881,7 +1882,8 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintp= tr_t jmp_rx, } } =20 -static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +static void tcg_out_call_int(TCGContext *s, int lk, + const tcg_insn_unit *target) { #ifdef _CALL_AIX /* Look through the descriptor. If the branch is in range, and we @@ -1892,7 +1894,7 @@ static void tcg_out_call(TCGContext *s, const tcg_ins= n_unit *target) =20 if (in_range_b(diff) && toc =3D=3D (uint32_t)toc) { tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP1, toc); - tcg_out_b(s, LK, tgt); + tcg_out_b(s, lk, tgt); } else { /* Fold the low bits of the constant into the addresses below. */ intptr_t arg =3D (intptr_t)target; @@ -1907,7 +1909,7 @@ static void tcg_out_call(TCGContext *s, const tcg_ins= n_unit *target) tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_REG_TMP1, ofs); tcg_out32(s, MTSPR | RA(TCG_REG_R0) | CTR); tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_REG_TMP1, ofs + SZP); - tcg_out32(s, BCCTR | BO_ALWAYS | LK); + tcg_out32(s, BCCTR | BO_ALWAYS | lk); } #elif defined(_CALL_ELF) && _CALL_ELF =3D=3D 2 intptr_t diff; @@ -1921,16 +1923,21 @@ static void tcg_out_call(TCGContext *s, const tcg_i= nsn_unit *target) =20 diff =3D tcg_pcrel_diff(s, target); if (in_range_b(diff)) { - tcg_out_b(s, LK, target); + tcg_out_b(s, lk, target); } else { tcg_out32(s, MTSPR | RS(TCG_REG_R12) | CTR); - tcg_out32(s, BCCTR | BO_ALWAYS | LK); + tcg_out32(s, BCCTR | BO_ALWAYS | lk); } #else - tcg_out_b(s, LK, target); + tcg_out_b(s, lk, target); #endif } =20 +static void tcg_out_call(TCGContext *s, const tcg_insn_unit *target) +{ + tcg_out_call_int(s, LK, target); +} + static const uint32_t qemu_ldx_opc[(MO_SSIZE + MO_BSWAP) + 1] =3D { [MO_UB] =3D LBZX, [MO_UW] =3D LHZX, @@ -1960,8 +1967,6 @@ static const uint32_t qemu_exts_opc[4] =3D { }; =20 #if defined (CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ @@ -2227,6 +2232,71 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *lb) tcg_out_b(s, 0, lb->raddr); return true; } +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrl= o, + TCGReg addrhi, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *label =3D new_ldst_label(s); + + label->is_ld =3D is_ld; + label->addrlo_reg =3D addrlo; + label->addrhi_reg =3D addrhi; + + /* We are expecting a_bits to max out at 7, much lower than ANDI. */ + tcg_debug_assert(a_bits < 16); + tcg_out32(s, ANDI | SAI(addrlo, TCG_REG_R0, a_mask)); + + label->label_ptr[0] =3D s->code_ptr; + tcg_out32(s, BC | BI(0, CR_EQ) | BO_COND_FALSE | LK); + + label->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + if (!reloc_pc14(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + TCGReg arg =3D TCG_REG_R4; +#ifdef TCG_TARGET_CALL_ALIGN_ARGS + arg |=3D 1; +#endif + if (l->addrlo_reg !=3D arg) { + tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); + } else if (l->addrhi_reg !=3D arg + 1) { + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_I32, arg, l->addrhi_reg); + } else { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R0, arg); + tcg_out_mov(s, TCG_TYPE_I32, arg, arg + 1); + tcg_out_mov(s, TCG_TYPE_I32, arg + 1, TCG_REG_R0); + } + } else { + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R4, l->addrlo_reg); + } + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R3, TCG_AREG0); + + /* "Tail call" to the helper, with the return address back inline. */ + tcg_out_call_int(s, 0, (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); +} + #endif /* SOFTMMU */ =20 static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) @@ -2238,6 +2308,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) #ifdef CONFIG_SOFTMMU int mem_index; tcg_insn_unit *label_ptr; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -2258,6 +2330,10 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) =20 rbase =3D TCG_REG_R3; #else /* !CONFIG_SOFTMMU */ + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); + } rbase =3D guest_base ? TCG_GUEST_BASE_REG : 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { tcg_out_ext32u(s, TCG_REG_TMP1, addrlo); @@ -2313,6 +2389,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) #ifdef CONFIG_SOFTMMU int mem_index; tcg_insn_unit *label_ptr; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -2333,6 +2411,10 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) =20 rbase =3D TCG_REG_R3; #else /* !CONFIG_SOFTMMU */ + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); + } rbase =3D guest_base ? TCG_GUEST_BASE_REG : 0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { tcg_out_ext32u(s, TCG_REG_TMP1, addrlo); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545019; cv=none; d=zohomail.com; s=zohoarc; b=XdEmtEbmPbRqwhUcd+HXVLXlngPrnIqWNHbq6QCWyfAozdNptiHcmf0F1F3ZSBWx27Clp9J84NWIybSXt0+3k6BjyoAWGBGZZGc/vWc0SgCzBNaQuiEAir0sUJpIDQD1o5/+RevTBHGmPEUb3afKAZdGIgIuZvM4IdqKJ8zM1zU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545019; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=96ZQ9FH/trR76vUcFULrouOCXCAN4cLpPF78F0tg0D8=; b=WrnSbAZY5tjnU0ObzQzKxApUj9yWEL2/kykCr/7oPlbEVA4veZUkvoDxPHoIx1lbpDpmhOAgrtyciQ2g+tXx1fgf2BvHF2CY+HjiLTWrw4gTBvLMtT/wd0xW49qDqk9Dvr2ZIWuaugiDhoDHv8fETEbGaAtZAAC4Cm0OLKMFSLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545019678360.11169140770915; Thu, 10 Feb 2022 18:03:39 -0800 (PST) Received: from localhost ([::1]:49898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILHe-0003sD-Hs for importer@patchew.org; Thu, 10 Feb 2022 21:03:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnG-00049K-MD for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:17 -0500 Received: from [2607:f8b0:4864:20::432] (port=42839 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnA-0007P9-UD for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:14 -0500 Received: by mail-pf1-x432.google.com with SMTP id i6so11579911pfc.9 for ; Thu, 10 Feb 2022 17:32:08 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=96ZQ9FH/trR76vUcFULrouOCXCAN4cLpPF78F0tg0D8=; b=UDLOk0sapj47p09GnP7Snnpw0tSeBS/lkGNqtxfTZPHfznYEaqSak8yDI5NON1wJxF Tw/k0MNSkGce6tBsaNbOSb+afCuEAG5n8lp2t3NcVJzSM8x/TzvBlexOFYYwBho8mT0S yscABvWgJvv3YVwNcZyfzAx6HhtuCLxRCM04xFcqdV4WwN4y6qYQlRrraEp49XnavmZ6 CU0na6La4P9/nAoTLiBwV/gptDQUgNkjGUO0WdjQSVxnCnsyjPJ5vq0BRch+IRQIXwle MhIr88p5+ahMYQFrEXTC+SwSNLIhNxKglDmNUNF7BcEoEX0J2iFg3IvuVkqxT33ADTLQ DLhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=96ZQ9FH/trR76vUcFULrouOCXCAN4cLpPF78F0tg0D8=; b=aH+YAQxZa1CSmifNtrx4C120pnfhroRgQGFMMhx75W46nCQM2HDRtwvOlymUUhKl2v sM6CwGhr3m9nPtZ0LlzxIdSX5ZktjwKXga/rsxfUPfO8Aukftesvg/OG4AFCc05jfLA6 AyuAS9w2982vkTXi9NTc/cXGCRDjAdgHWtqLxDqGxhWe6twDwznTWgayGBZVjVpZB/hG CNTRaRr2WE7R5mXnjkwPXEt3jUAHyzMYBIgO+wqtQ6JvqgQwXepP2njOUTmzrQS7Ef6A 9ufKm0tqSnY6vpEziPvtDP4ARlLyIZVA8pwN2xHkMe5/Z/NQmD4V4QVaFxzWmwI+4IYs OaqA== X-Gm-Message-State: AOAM533eSwrEL2HadB5d3HiTATJVVbyvIWQQ1cFLaJi1z+e1ZnpuBz9c n1G7OrUv/7mccJqWurKLz6CgISYPSV9TTRGx X-Google-Smtp-Source: ABdhPJxSgobU6151OyNMacQlB84KP1E25S86KcQWb11aZhGVbOsMyKfTUvUNjVe3AoS41N/Ik0JuYQ== X-Received: by 2002:a63:ff44:: with SMTP id s4mr1275561pgk.559.1644543127649; Thu, 10 Feb 2022 17:32:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/34] tcg/riscv: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:38 +1100 Message-Id: <20220211013059.17994-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545021800100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.h | 2 -- tcg/riscv/tcg-target.c.inc | 63 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h index ef78b99e98..11c9b3e4f4 100644 --- a/tcg/riscv/tcg-target.h +++ b/tcg/riscv/tcg-target.h @@ -165,9 +165,7 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); =20 #define TCG_TARGET_DEFAULT_MO (0) =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 0 diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index e9488f7093..6409d9c3d5 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -27,6 +27,7 @@ * THE SOFTWARE. */ =20 +#include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" =20 #ifdef CONFIG_DEBUG_TCG @@ -847,8 +848,6 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) */ =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * MemOpIdx oi, uintptr_t ra) */ @@ -1053,6 +1052,54 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) tcg_out_goto(s, l->raddr); return true; } +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_= reg, + unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *l =3D new_ldst_label(s); + + l->is_ld =3D is_ld; + l->addrlo_reg =3D addr_reg; + + /* We are expecting a_bits to max out at 7, so we can always use andi.= */ + tcg_debug_assert(a_bits < 12); + tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_TMP1, addr_reg, a_mask); + + l->label_ptr[0] =3D s->code_ptr; + tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP1, TCG_REG_ZERO, 0); + + l->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + /* resolve label address */ + if (!reloc_sbimm12(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + + /* tail call, with the return address back inline. */ + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RA, (uintptr_t)l->raddr); + tcg_out_call_int(s, (const void *)(l->is_ld ? helper_unaligned_ld + : helper_unaligned_st), true); + 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); +} + #endif /* CONFIG_SOFTMMU */ =20 static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, @@ -1108,6 +1155,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1]; +#else + unsigned a_bits; #endif TCGReg base =3D TCG_REG_TMP0; =20 @@ -1130,6 +1179,10 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) tcg_out_ext32u(s, base, addr_regl); addr_regl =3D base; } + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, a_bits); + } if (guest_base !=3D 0) { tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); } @@ -1174,6 +1227,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1]; +#else + unsigned a_bits; #endif TCGReg base =3D TCG_REG_TMP0; =20 @@ -1196,6 +1251,10 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) tcg_out_ext32u(s, base, addr_regl); addr_regl =3D base; } + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, false, addr_regl, a_bits); + } if (guest_base !=3D 0) { tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); } --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544866; cv=none; d=zohomail.com; s=zohoarc; b=ID/18xSqBh8hEy6Z2QeQydJ57ULS7B3NQEtYZu3t6zsY+OSPQGZzA5eY48kh/xVAfmGjSXGoxHOUacoae57e1HgfVq6v1RpasxVS1RitETtQxPSCrH+nCg/ffy3u56+tezgyc8HgApzL2w27CMIDfCiUQ4gPROObhDun4pR6pyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544866; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zEuruAU4Gg9D5uqZ9fSiUk5LmbWCZEEQTTVVGzrpyrE=; b=FoLZF2E+v8mHSgvvekZri3Cb2xvxltKUE9uqGpjufYj8IvXB5HCFTzljYt+gtRt1v3c+cF8Zv7Umr+Fb4aMukYnpBMAMb7cXFCXiCvtvQte5IqLj+qv9k9qpbmBM9aM2Z9/8ZWV4JELJejXZ4/NooiPIvpQ0+g8qz/I4uRZYVy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164454486605814.93576140184473; Thu, 10 Feb 2022 18:01:06 -0800 (PST) Received: from localhost ([::1]:45484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILF8-0000kS-SI for importer@patchew.org; Thu, 10 Feb 2022 21:01:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnG-00049C-1P for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:16 -0500 Received: from [2607:f8b0:4864:20::430] (port=41767 helo=mail-pf1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnD-0007PJ-Cs for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:13 -0500 Received: by mail-pf1-x430.google.com with SMTP id i30so13465187pfk.8 for ; Thu, 10 Feb 2022 17:32:11 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zEuruAU4Gg9D5uqZ9fSiUk5LmbWCZEEQTTVVGzrpyrE=; b=zf8dA+3TH7Bf63/llFN9CUdTvOKqXkxdCILf0zpmsLTn4IlLNoxb6rxCbj36TZXrpa s+qoBGUzy9GixnJ5lMKsT3x0VuPA0HX36VGZ1VcGHEsXo9+aKCvkwBs06zYQU39LvhP2 /7MgFbvoLToLUUx8A7oHF3tXTU5KipZWKdfWeV8OM/5rdu9EUOvWgDBpNVNstvGX/ZgM 4AcRKp6eyY/MT6Qsvyu+BKwi8YVpmMaTBtC7d9o+ocqLCnknX6fcCVN0dmsIgD8h1pDW o7JV0XAihay6hWVhN5UM1Qcy2OV4kz+uR41PMW7gBu8Qv8mB9woikH6y05sIBQ3/O9MP nyxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zEuruAU4Gg9D5uqZ9fSiUk5LmbWCZEEQTTVVGzrpyrE=; b=Q7hGCK6SkhiLbQMmnL7xyLgMq3sarrVkN25cQOPAO+qlIq6tSaiVrFhRPnM7ZoH3D6 pshkPv66SDY63t8DLlFRRcl+MNSA51lECSX4TXWye1ixrguWOHRoJVVV0NE+xaCzvSO9 XFEft7iFotQgZqpf3SdwVjrjtiEAmfS7kZxnB5tEjPIivCt5ekEPePv02LE7bnInewX2 j0T/rMRm4ex8e+zjMHl3fRkBStTpJMcUq8DYkELvBe8ZMOp4K1n5dRyxM90el9ulsdmn Hr1gIXo05+boWuCIrnOuXIXNyigHbhDuxjMvP3+ZE0/4jaK5X/Y6wJ/RkOk814Yylx9m Ad5g== X-Gm-Message-State: AOAM531foPp0ZQkJ/qHsHOnd4rkhX1EiP6G8OLEXxIRzv95rGiyxjqaq ShgJiDn2sa+gZ6qIJUSZNlXaDjwRhyFYIYxF X-Google-Smtp-Source: ABdhPJyqn7tbYJPbXLowmZgtz7AIcBfnJQlBpez6xaq8+kj1rMabX/HSrIItKt5wAlPe3MS8hmnkWw== X-Received: by 2002:a65:6947:: with SMTP id w7mr1040139pgq.435.1644543130160; Thu, 10 Feb 2022 17:32:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/34] tcg/s390x: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:39 +1100 Message-Id: <20220211013059.17994-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::430 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544870021100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/s390x/tcg-target.h | 2 -- tcg/s390x/tcg-target.c.inc | 59 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tcg/s390x/tcg-target.h b/tcg/s390x/tcg-target.h index 527ada0f63..69217d995b 100644 --- a/tcg/s390x/tcg-target.h +++ b/tcg/s390x/tcg-target.h @@ -178,9 +178,7 @@ static inline void tb_target_set_jmp_target(uintptr_t t= c_ptr, uintptr_t jmp_rx, /* no need to flush icache explicitly */ } =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/s390x/tcg-target.c.inc b/tcg/s390x/tcg-target.c.inc index b12fbfda63..d56c1e51e4 100644 --- a/tcg/s390x/tcg-target.c.inc +++ b/tcg/s390x/tcg-target.c.inc @@ -29,6 +29,7 @@ #error "unsupported code generation mode" #endif =20 +#include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" #include "elf.h" =20 @@ -136,6 +137,7 @@ typedef enum S390Opcode { RI_OIHL =3D 0xa509, RI_OILH =3D 0xa50a, RI_OILL =3D 0xa50b, + RI_TMLL =3D 0xa701, =20 RIE_CGIJ =3D 0xec7c, RIE_CGRJ =3D 0xec64, @@ -1804,8 +1806,6 @@ static void tcg_out_qemu_st_direct(TCGContext *s, Mem= Op opc, TCGReg data, } =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - /* We're expecting to use a 20-bit negative offset on the tlb memory ops. = */ QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) > 0); QEMU_BUILD_BUG_ON(TLB_MASK_TABLE_OFS(0) < -(1 << 19)); @@ -1942,6 +1942,53 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *lb) return true; } #else +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, + TCGReg addrlo, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *l =3D new_ldst_label(s); + + l->is_ld =3D is_ld; + l->addrlo_reg =3D addrlo; + + /* We are expecting a_bits to max out at 7, much lower than TMLL. */ + tcg_debug_assert(a_bits < 16); + tcg_out_insn(s, RI, TMLL, addrlo, a_mask); + + tcg_out16(s, RI_BRC | (7 << 4)); /* CC in {1,2,3} */ + l->label_ptr[0] =3D s->code_ptr; + s->code_ptr +=3D 1; + + l->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + if (!patch_reloc(l->label_ptr[0], R_390_PC16DBL, + (intptr_t)tcg_splitwx_to_rx(s->code_ptr), 2)) { + return false; + } + + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_R3, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); + + /* "Tail call" to the helper, with the return address back inline. */ + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_R14, (uintptr_t)l->raddr); + tgen_gotoi(s, S390_CC_ALWAYS, (const void *)(l->is_ld ? helper_unalign= ed_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); +} + static void tcg_prepare_user_ldst(TCGContext *s, TCGReg *addr_reg, TCGReg *index_reg, tcg_target_long *disp) { @@ -1980,7 +2027,11 @@ static void tcg_out_qemu_ld(TCGContext* s, TCGReg da= ta_reg, TCGReg addr_reg, #else TCGReg index_reg; tcg_target_long disp; + unsigned a_bits =3D get_alignment_bits(opc); =20 + if (a_bits) { + tcg_out_test_alignment(s, true, addr_reg, a_bits); + } tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp); tcg_out_qemu_ld_direct(s, opc, data_reg, addr_reg, index_reg, disp); #endif @@ -2007,7 +2058,11 @@ static void tcg_out_qemu_st(TCGContext* s, TCGReg da= ta_reg, TCGReg addr_reg, #else TCGReg index_reg; tcg_target_long disp; + unsigned a_bits =3D get_alignment_bits(opc); =20 + if (a_bits) { + tcg_out_test_alignment(s, false, addr_reg, a_bits); + } tcg_prepare_user_ldst(s, &addr_reg, &index_reg, &disp); tcg_out_qemu_st_direct(s, opc, data_reg, addr_reg, index_reg, disp); #endif --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544172; cv=none; d=zohomail.com; s=zohoarc; b=X9HKS0jdiPi1CpYRj/ILwQ30aZOPczSk207ZGlktZZMX6jg0Ktpv0z4vel1yN4Hu9bZavwAlaU+ArS2FqiZWD0QNRFGqti4lelpV2RMaLu9G+ey8ywZd34bJaCkBw/j4phVXA/2SYpH6QkaBDVps5rSz1u8H0mrogmc1BHo1ICQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=R3xqjTdKiJkmJv6WGPeyRjVcl4w/T06J0OPgPuyDfvR46iNPktw9DA3tKMDEhdaU7lg47g8LQcJNCr9a5Fg3atbfta2mw8Js2ryQZ7zYzflXjlJYGxIAid7MF72Xoo8apvuuTY7Z5nfXIdzgHKqlq96J4m/CICjMB9Eft24NE4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16445441726351004.339395497111; Thu, 10 Feb 2022 17:49:32 -0800 (PST) Received: from localhost ([::1]:47866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL3z-0008HX-EG for importer@patchew.org; Thu, 10 Feb 2022 20:49:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnK-00049t-8c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:18 -0500 Received: from [2607:f8b0:4864:20::631] (port=45601 helo=mail-pl1-x631.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnG-0007PQ-0c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:15 -0500 Received: by mail-pl1-x631.google.com with SMTP id w20so3391846plq.12 for ; Thu, 10 Feb 2022 17:32:13 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=oCjlMNx4fPvaMHkeF8P5Dbv7pEihIBintUIYvJYwXoSddqFaEut8YlWwKjki7CxnAT iNm9hnzxFwPgEOtDmJ5hDjL1tZXwSNvzBkD4NYd3awxmbXzjf7/I5mM4e6BFX5uHs0oT aIkr+Mx5n2vqSPQfUay1T9C9SDO6xp1l8alxCWPi/DzQ3WWDL6t4VQGvLJFa953D8ejx YWOkVX/r3L/L5Lt5cCTu+shVSKUWxxul219QKphmWnzkItjT8XLB5SOYo246UdMyVzHn 88w6BR2KHgnXohBgYSUETUOa6iliB0PahEaGunQII5uDk+1fob8Qwmge3DEA0nEG2npL LRXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eqQZpXDeCV1SzzmmGSe5uysSf0Qll8u+UkCjmQOI+nE=; b=Ypwj/s0LeZpvoSt4RbCOd2xlV/ouM9mKqGT4ABdfu9lOzKusvkfjBLKm8q1eG6ysPd W9FNsb4G4GheXv71lAsTDGKc8eO8Za4woscOASfxA1CVFeQH9SG4y4FKXJeCu9WX/a6c 8E4Oq/EdvyFLc86ZRAyhBaZgT9Qi2Xr40srr8HV14ofxjzRiPQRQ6IIuRiWMH2Vpma75 SXolzAdE7VsocGPsSQv5sgnjMFmGK+Blc+EW25vsd0b+ww4pb9lP+tpBWMPGl77b3IhB EubTchwwcE+QxjYfcvu/d/y8BSd6iIg8Z34OM5+mt54lm85q3xbYRI2o10zkM4rfcDWb tKVA== X-Gm-Message-State: AOAM5332qzIgDlQx1Ag/g2MsxAE6GIyFiw9ccOs4Lx79Kha4HAwFHZv+ wGu7VEQXjurGIvXEvVoGwyI9Y+drm6Ith/8P X-Google-Smtp-Source: ABdhPJxgKgmkQOhCbAecwVQvyTdC2JHYB9LA8GbmuCxQM4udtAt5zbrjOEsIB/QOa2wFJMMddLvd0A== X-Received: by 2002:a17:90b:707:: with SMTP id s7mr198320pjz.99.1644543132735; Thu, 10 Feb 2022 17:32:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/34] tcg/tci: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:40 +1100 Message-Id: <20220211013059.17994-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::631 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544174053100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/tci.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tcg/tci.c b/tcg/tci.c index 336af5945a..fe92b5d084 100644 --- a/tcg/tci.c +++ b/tcg/tci.c @@ -292,11 +292,11 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, T= CGCond condition) static uint64_t tci_qemu_ld(CPUArchState *env, target_ulong taddr, MemOpIdx oi, const void *tb_ptr) { - MemOp mop =3D get_memop(oi) & (MO_BSWAP | MO_SSIZE); + MemOp mop =3D get_memop(oi); uintptr_t ra =3D (uintptr_t)tb_ptr; =20 #ifdef CONFIG_SOFTMMU - switch (mop) { + switch (mop & (MO_BSWAP | MO_SSIZE)) { case MO_UB: return helper_ret_ldub_mmu(env, taddr, oi, ra); case MO_SB: @@ -326,10 +326,14 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target= _ulong taddr, } #else void *haddr =3D g2h(env_cpu(env), taddr); + unsigned a_mask =3D (1u << get_alignment_bits(mop)) - 1; uint64_t ret; =20 set_helper_retaddr(ra); - switch (mop) { + if (taddr & a_mask) { + helper_unaligned_ld(env, taddr); + } + switch (mop & (MO_BSWAP | MO_SSIZE)) { case MO_UB: ret =3D ldub_p(haddr); break; @@ -377,11 +381,11 @@ static uint64_t tci_qemu_ld(CPUArchState *env, target= _ulong taddr, static void tci_qemu_st(CPUArchState *env, target_ulong taddr, uint64_t va= l, MemOpIdx oi, const void *tb_ptr) { - MemOp mop =3D get_memop(oi) & (MO_BSWAP | MO_SSIZE); + MemOp mop =3D get_memop(oi); uintptr_t ra =3D (uintptr_t)tb_ptr; =20 #ifdef CONFIG_SOFTMMU - switch (mop) { + switch (mop & (MO_BSWAP | MO_SIZE)) { case MO_UB: helper_ret_stb_mmu(env, taddr, val, oi, ra); break; @@ -408,9 +412,13 @@ static void tci_qemu_st(CPUArchState *env, target_ulon= g taddr, uint64_t val, } #else void *haddr =3D g2h(env_cpu(env), taddr); + unsigned a_mask =3D (1u << get_alignment_bits(mop)) - 1; =20 set_helper_retaddr(ra); - switch (mop) { + if (taddr & a_mask) { + helper_unaligned_st(env, taddr); + } + switch (mop & (MO_BSWAP | MO_SIZE)) { case MO_UB: stb_p(haddr, val); break; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164454392458317.86998714746869; Thu, 10 Feb 2022 17:45:24 -0800 (PST) Received: from localhost ([::1]:39228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIKzz-0002Gy-HC for importer@patchew.org; Thu, 10 Feb 2022 20:45:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnM-0004HQ-TR for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:20 -0500 Received: from [2607:f8b0:4864:20::62a] (port=40831 helo=mail-pl1-x62a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnK-0007Pu-2E for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:20 -0500 Received: by mail-pl1-x62a.google.com with SMTP id y17so3402287plg.7 for ; Thu, 10 Feb 2022 17:32:16 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=StWraBvQ7+cOtM3wTdtfXS094/SeTqLb1TCB0a+TFak=; b=HdDNKC0S0g6EgC0H9UP1DqrojDh8tUDggkTb2eSK51VDTyXhjzboKSxQAxKu4boJea yiaFsqB97sMn2QK3qiLmaSF2e3IIu4h+BeGm55SfDXH9S5jxIPpavCwbYZy2FORq5XaF Z0nAyb4kTWLZicxsomrbNCp4W95P0aaaJhH/SS1YJ5qTJkrxGM3mkWAEDkXJmvywRdoj UCT/ywqkJqvcn8wfI7yP76NWq1An3RhUWPdpmb8Bs49Y5DQhaOV+Jk7SqTUudh5iWdWt KtaycLprwh28oNnbX/TaeNyPdpQlE+dgnrYaEAFStyhVkvdt/aTaBaXYatdOhlae7GtC huhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=StWraBvQ7+cOtM3wTdtfXS094/SeTqLb1TCB0a+TFak=; b=dZIIYyPkx5D8z8vnjBPXSjOn6bixh1sa7/nbybFUqgd2yK8GHRAOAo7+JPryKRC8zr r61+CnhdG9Ap+g9Skrlv3NCRyizuEa17Rg003BS8uJRqy+TXIYOOkANujw3Ip+sGe41U Sg7J86y59zSM5E819y31YV56QVDsUj3qP2MGw0CXVZUGOqkprYdgZ3UHSlkg09hv4wC5 ZWplCOiSyI+eLGtTtSJy3zPnbdj76+8cAi15xI49Lk8SGK7UCrk5UbfNFrqUSvr6g/LP yypNqf4kkBw5xu1atNXInuoDkSoD/dysKKpDDwX6FwNMUXs9b+LdK/KS/5iu+rkXaMwk KW6g== X-Gm-Message-State: AOAM53194rR1q0EHTPsMFTWwMFunvCoJDLBlSpwTkOU+QAjSOjArtGLg 8/tqJyxkgzrkvsK4JLYmbbRTBi4AVwI9Gq/l X-Google-Smtp-Source: ABdhPJxpecpkubSTuOianivZWEJIPucwmdZf0UngR1qQb1Jbc9gfQA+/mK3IVlrsU/28eEPzXAvdJQ== X-Received: by 2002:a17:903:244a:: with SMTP id l10mr10117845pls.32.1644543135545; Thu, 10 Feb 2022 17:32:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/34] tcg/loongarch64: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:41 +1100 Message-Id: <20220211013059.17994-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: WANG Xuerui , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644543927200100002 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui Signed-off-by: WANG Xuerui Reviewed-by: Richard Henderson Message-Id: <20220106134238.3936163-1-git@xen0n.name> Signed-off-by: Richard Henderson --- tcg/loongarch64/tcg-target.h | 2 - tcg/loongarch64/tcg-target.c.inc | 71 +++++++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 4 deletions(-) diff --git a/tcg/loongarch64/tcg-target.h b/tcg/loongarch64/tcg-target.h index 05010805e7..d58a6162f2 100644 --- a/tcg/loongarch64/tcg-target.h +++ b/tcg/loongarch64/tcg-target.h @@ -171,9 +171,7 @@ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uin= tptr_t, uintptr_t); =20 #define TCG_TARGET_DEFAULT_MO (0) =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif =20 #define TCG_TARGET_HAS_MEMORY_BSWAP 0 =20 diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.= c.inc index d31a0e5991..a3debf6da7 100644 --- a/tcg/loongarch64/tcg-target.c.inc +++ b/tcg/loongarch64/tcg-target.c.inc @@ -29,6 +29,8 @@ * THE SOFTWARE. */ =20 +#include "../tcg-ldst.c.inc" + #ifdef CONFIG_DEBUG_TCG static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] =3D { "zero", @@ -642,8 +644,6 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TC= GArg val, */ =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - /* * helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * MemOpIdx oi, uintptr_t ra) @@ -825,6 +825,61 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, T= CGLabelQemuLdst *l) =20 return tcg_out_goto(s, l->raddr); } +#else + +/* + * Alignment helpers for user-mode emulation + */ + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addr_= reg, + unsigned a_bits) +{ + TCGLabelQemuLdst *l =3D new_ldst_label(s); + + l->is_ld =3D is_ld; + l->addrlo_reg =3D addr_reg; + + /* + * Without micro-architecture details, we don't know which of bstrpick= or + * andi is faster, so use bstrpick as it's not constrained by imm field + * width. (Not to say alignments >=3D 2^12 are going to happen any time + * soon, though) + */ + tcg_out_opc_bstrpick_d(s, TCG_REG_TMP1, addr_reg, 0, a_bits - 1); + + l->label_ptr[0] =3D s->code_ptr; + tcg_out_opc_bne(s, TCG_REG_TMP1, TCG_REG_ZERO, 0); + + l->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + /* resolve label address */ + if (!reloc_br_sk16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + + /* tail call, with the return address back inline. */ + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RA, (uintptr_t)l->raddr); + tcg_out_call_int(s, (const void *)(l->is_ld ? helper_unaligned_ld + : helper_unaligned_st), true); + 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); +} + #endif /* CONFIG_SOFTMMU */ =20 /* @@ -887,6 +942,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg= *args, TCGType type) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1]; +#else + unsigned a_bits; #endif TCGReg base; =20 @@ -903,6 +960,10 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGAr= g *args, TCGType type) data_regl, addr_regl, s->code_ptr, label_ptr); #else + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, a_bits); + } base =3D tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); TCGReg guest_base_reg =3D USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_RE= G_ZERO; tcg_out_qemu_ld_indexed(s, data_regl, base, guest_base_reg, opc, type); @@ -941,6 +1002,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGAr= g *args) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[1]; +#else + unsigned a_bits; #endif TCGReg base; =20 @@ -958,6 +1021,10 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args) data_regl, addr_regl, s->code_ptr, label_ptr); #else + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, false, addr_regl, a_bits); + } base =3D tcg_out_zext_addr_if_32_bit(s, addr_regl, TCG_REG_TMP0); TCGReg guest_base_reg =3D USE_GUEST_BASE ? TCG_GUEST_BASE_REG : TCG_RE= G_ZERO; tcg_out_qemu_st_indexed(s, data_regl, base, guest_base_reg, opc); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545208; cv=none; d=zohomail.com; s=zohoarc; b=XA7YDG8GIpabPw011w/eqpdvwen1yFQgHxxJ4nAIU32jNxK/F1d48rL12Lxj9AJxCfkYRIiBXzWECUirv1Kn69H0r3POflnkCQeLM5L5X16fMsKmT9mpZf5WadnCXW56rE31O3f0dGrI1MOicK6FjsSzH+yy3pnRC9poLvg1vPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545208; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gtQTuzYRH3IYlPuAlfK2e9bXFz+7xqKrXCWRmmR5YQg=; b=I3ZJwjFg6qS4U7IdLe4u7PVY1sd7PaIbdiNiB6/We3fuCWCpbBGXmE1MnhreaxgQ69rRxG3dIz8kUaBdpN2sJvBIwyGYLX6XBtRK1qgUH8gbVCaaerKTTzCQ9V42BBltoGs7jyozSWy7cekj1OgddMxnvcr+cx96uvobeMUf5i0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164454520865139.26841898763337; Thu, 10 Feb 2022 18:06:48 -0800 (PST) Received: from localhost ([::1]:55238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILKh-0007dW-33 for importer@patchew.org; Thu, 10 Feb 2022 21:06:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnN-0004J1-ID for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:21 -0500 Received: from [2607:f8b0:4864:20::42a] (port=40599 helo=mail-pf1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnL-0007QD-Ki for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:21 -0500 Received: by mail-pf1-x42a.google.com with SMTP id a39so12644585pfx.7 for ; Thu, 10 Feb 2022 17:32:19 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gtQTuzYRH3IYlPuAlfK2e9bXFz+7xqKrXCWRmmR5YQg=; b=RosGj4MBi2IpXThl9LAkqjZHBJF0/yybULfjgDVEkh/xvVpz+gWbCdOObtOCfAmrIm u9jpbDgN79uA2QD8KnZgVUEybSK0wOXkbIrKdGCjSgIURjNR3SY70ca5Sjvjlu9b9Gex Wog7+NQbvIS/OnlByB0Lm2Y2VEmFJZG2HQ23dt3tG/9HxmBZPh/cGxDvLJwYjDB+rJxe T6gWkscKLzoeh5qbcI98SvDebbIC7IBOHUNgZYeOlb+M1edm8S4b1XuWZPu0F3DQNg7b lzhdC2P/eGpnJ8NF0/yKWtqa5jbMu25y+wWzD1ByVScBJ4ylza3q8ycYdhK0cK944sxD Rr2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gtQTuzYRH3IYlPuAlfK2e9bXFz+7xqKrXCWRmmR5YQg=; b=QmjefTk0M79lxsITjLrEiu1tnmLm5IkSutvOTwQTEz72LbaIHnM9kGXzEtPKM8R7oA bjckz0wkfSskTFtd9R/9yTDWA001vgzX0CvYY+PatnewEGMDoTELnHWXTddbIljnq7Fy LkHY6MmpCyQzZYG4n2Es+HrH2H0cPgVte2SN2fgu6KIn/lZobkHsbNUqZfA+3MAhogV+ riTyJFTxBioIbTpWKqRy7wN4t7aRHAMJdqFUNpFpKA8VmDHQ+X/+X58wP1Kk8u95sNl9 q8JQEeqjDM1opAiUurd+JQJnGiIPLDFM7M06pWME0lYrtt1ODgYpw2oy3SBBinefM6Ef BgIw== X-Gm-Message-State: AOAM533nMQFuEjbpliV5oB/tciJ57xUFpClTqm+6ym+LMJpWkUYrcdGp AAjrtBqkCylZ959Gl4VGiCVxH1C9DRSnCfSK X-Google-Smtp-Source: ABdhPJy7NWb/cYvtsW68qDuadwAi6/hY7wip2DtYjDQJ+We3Kug2TGWss9Y44I5/C18o7ELLk6E6qQ== X-Received: by 2002:a05:6a00:1345:: with SMTP id k5mr10328307pfu.29.1644543138428; Thu, 10 Feb 2022 17:32:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 17/34] tcg/arm: Drop support for armv4 and armv5 hosts Date: Fri, 11 Feb 2022 12:30:42 +1100 Message-Id: <20220211013059.17994-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545210680100001 Content-Type: text/plain; charset="utf-8" Support for unaligned accesses is difficult for pre-v6 hosts. While debian still builds for armv4, we cannot use a compile time test, so test the architecture at runtime and error out. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 5345c4e39c..29d63e98a8 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -2474,6 +2474,11 @@ static void tcg_target_init(TCGContext *s) if (pl !=3D NULL && pl[0] =3D=3D 'v' && pl[1] >=3D '4' && pl[1] <= =3D '9') { arm_arch =3D pl[1] - '0'; } + + if (arm_arch < 6) { + error_report("TCG: ARMv%d is unsupported; exiting", arm_arch); + exit(EXIT_FAILURE); + } } =20 tcg_target_available_regs[TCG_TYPE_I32] =3D ALL_GENERAL_REGS; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544462; cv=none; d=zohomail.com; s=zohoarc; b=H2hwZmZ6SxxBjBzOeHFz40Ep+QINB3Edf7PP5R6PyauDLAwfg0WN3gPCoDe580z54tVJwlm4DZI30JqBaFD0DbnaVItjSkYyEOvQ3/sJhtITn6me5qZZgBMTr+dt9IzcqxyT1T78BpOxtOliS4v8jnptbWfnyPpWmOl281MeKRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544462; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=or+WCmpdAjyGxZzhXn9TNsfY/xdJlpnnP3pV6mAQxRc=; b=PvKNP5cbD7pDGrspOrd5GBAqfZKPdMh1X0ftP0wB9ZNM6TbP2UFO0xOJMpbx1cQY/5et3a7wS0a2woOydhHbG3VmcWIC8cVLeiT3xcZwl/Y4/PaA+EL9jfIA4VnMdqPc+sLh9VJDoRKgKDYfw3OZhb5lX51HcvcTsDyYGKlBRhs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544462292235.63096659293421; Thu, 10 Feb 2022 17:54:22 -0800 (PST) Received: from localhost ([::1]:59340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL8f-0007hw-75 for importer@patchew.org; Thu, 10 Feb 2022 20:54:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnR-0004T8-1r for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:25 -0500 Received: from [2607:f8b0:4864:20::42b] (port=38655 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnO-0007Qa-07 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:24 -0500 Received: by mail-pf1-x42b.google.com with SMTP id x15so11079668pfr.5 for ; Thu, 10 Feb 2022 17:32:21 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=or+WCmpdAjyGxZzhXn9TNsfY/xdJlpnnP3pV6mAQxRc=; b=NBGiYXvgS5WMXg8yWBlMJTFN6ylXxcGpHzDuSMTaU/JET0rCsIiAqA8zz2d7Ht+AaI LQC04j6zrcL564qIh2dpi4w3L7gwhhzzzA0nwrI5uzuZeiRxrWYThuDih4edCcd46tcI BGb3faZbikXx4eqBn1FcY1WpE3GguM5tmyQzn5EDYttwldAbjhtlXFSpoGUYQXcsn06/ QejotS+1XHI++NGoj2ob7bH8kIw8oK55K1Na16iEsoAPyFpoTDsZVCzQTw3OxB7e9AEi SmdA3ScZozkyRrZceBWNwJc8kLlAZtmZv9YlK9rP8RzBK5Jh0CgHiViVWyKa6AnoJdFv 890Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=or+WCmpdAjyGxZzhXn9TNsfY/xdJlpnnP3pV6mAQxRc=; b=h96BuSlG3QGKt7UZ6C1Pl+0vP6op5mqEQBzTaIZeKtBip2vyKSkLFwUtm9YTuXw8Gj +AZy+HOTFOejZDo8unSBx1LAZdrVScBhGHI/8UHkAVX4Q7l+/BrQgf1vEq8OZQ+avHBa fuTa2pWTQ8jnbo/ACG4qCcfXkZriafxgJGctv9MdC3OQMs9ujW9I6supaRI0C2RwkL/g 3zOUAExBBwyo7nKr8VvNoHJ3BNpq8WXQAQ4DfWd4Vxpp0L9WnB7oy1xhKLAyraSk5tb8 IN2k9EkEe/HWezVq2nnWnSHZAqaheSYI/rnS3jn2O++j4k/48B+Xz/zEKFfC+v8t4A7l xP/Q== X-Gm-Message-State: AOAM533OTFbvS++eveE5Ql9YpfnzyK35wLqdxLFVfySjAQeq+HbPT1FW UeKTPRIBkYKwmhadbrZK8bIt18soZ1DTY/5c X-Google-Smtp-Source: ABdhPJyYI7P+r9eBzA/T0wZ2XfJHAUF/5AwNFdWIOWoYhYy02uPFVAFakRzQEIFLWiNt9nsZG4lEtw== X-Received: by 2002:a05:6a00:174d:: with SMTP id j13mr10211151pfc.58.1644543140702; Thu, 10 Feb 2022 17:32:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/34] tcg/arm: Remove use_armv5t_instructions Date: Fri, 11 Feb 2022 12:30:43 +1100 Message-Id: <20220211013059.17994-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544463567100001 Content-Type: text/plain; charset="utf-8" This is now always true, since we require armv6. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 3 +-- tcg/arm/tcg-target.c.inc | 35 ++++++----------------------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index f41b809554..5c9ba5feea 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -28,7 +28,6 @@ =20 extern int arm_arch; =20 -#define use_armv5t_instructions (__ARM_ARCH >=3D 5 || arm_arch >=3D 5) #define use_armv6_instructions (__ARM_ARCH >=3D 6 || arm_arch >=3D 6) #define use_armv7_instructions (__ARM_ARCH >=3D 7 || arm_arch >=3D 7) =20 @@ -109,7 +108,7 @@ extern bool use_neon_instructions; #define TCG_TARGET_HAS_eqv_i32 0 #define TCG_TARGET_HAS_nand_i32 0 #define TCG_TARGET_HAS_nor_i32 0 -#define TCG_TARGET_HAS_clz_i32 use_armv5t_instructions +#define TCG_TARGET_HAS_clz_i32 1 #define TCG_TARGET_HAS_ctz_i32 use_armv7_instructions #define TCG_TARGET_HAS_ctpop_i32 0 #define TCG_TARGET_HAS_deposit_i32 use_armv7_instructions diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 29d63e98a8..f3b635063f 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -596,11 +596,7 @@ static void tcg_out_b_reg(TCGContext *s, ARMCond cond,= TCGReg rn) * Unless the C portion of QEMU is compiled as thumb, we don't need * true BX semantics; merely a branch to an address held in a register. */ - if (use_armv5t_instructions) { - tcg_out_bx_reg(s, cond, rn); - } else { - tcg_out_mov_reg(s, cond, TCG_REG_PC, rn); - } + tcg_out_bx_reg(s, cond, rn); } =20 static void tcg_out_dat_imm(TCGContext *s, ARMCond cond, ARMInsn opc, @@ -1247,14 +1243,7 @@ static void tcg_out_goto(TCGContext *s, ARMCond cond= , const tcg_insn_unit *addr) } =20 /* LDR is interworking from v5t. */ - if (arm_mode || use_armv5t_instructions) { - tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); - return; - } - - /* else v4t */ - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); - tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); + tcg_out_movi_pool(s, cond, TCG_REG_PC, addri); } =20 /* @@ -1270,26 +1259,14 @@ static void tcg_out_call(TCGContext *s, const tcg_i= nsn_unit *addr) if (disp - 8 < 0x02000000 && disp - 8 >=3D -0x02000000) { if (arm_mode) { tcg_out_bl_imm(s, COND_AL, disp); - return; - } - if (use_armv5t_instructions) { + } else { tcg_out_blx_imm(s, disp); - return; } + return; } =20 - if (use_armv5t_instructions) { - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); - tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); - } else if (arm_mode) { - /* ??? Know that movi_pool emits exactly 1 insn. */ - tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); - tcg_out_movi_pool(s, COND_AL, TCG_REG_PC, addri); - } else { - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); - tcg_out_mov_reg(s, COND_AL, TCG_REG_R14, TCG_REG_PC); - tcg_out_bx_reg(s, COND_AL, TCG_REG_TMP); - } + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, addri); + tcg_out_blx_reg(s, COND_AL, TCG_REG_TMP); } =20 static void tcg_out_goto_label(TCGContext *s, ARMCond cond, TCGLabel *l) --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644543929; cv=none; d=zohomail.com; s=zohoarc; b=aONbF3DjRI2zEIcCnBYR39E0DXDQncxr22OU2t7GOEGVpnugwPLkawOLddUO9haLJ4cDcxSRCTVPGrSIPjw++1oo9kqUZ06hZ8nwYR7zvj+gucywgf9Zt8cHApGGucTJFCkkx2HdxUhhojnzqNVnTS7eRFb8u4RyoJZ++a5dUoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644543929; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1eIr+o74KNNgcXDiiw/QxB0XZ933sRJAUNisk+EGA/Y=; b=eln1ylRmrw7yDf925DPz3zBGcOFcN9WMMHQ44k6mND9rBahgeNrR0MYef4ks9/b6jUpAW4CdC7Bkk2mvirTXxBjZCk9hKKtHJZlWLHFwIulAav7Pudr60+TLxOM1hUKkaBcCopOVI5MYkv8fKbkuVRwqoLKVVEKvpnrBFnp3XLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644543929843481.2869418889485; Thu, 10 Feb 2022 17:45:29 -0800 (PST) Received: from localhost ([::1]:39506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL04-0002RO-HH for importer@patchew.org; Thu, 10 Feb 2022 20:45:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnT-0004by-GR for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:27 -0500 Received: from [2607:f8b0:4864:20::62b] (port=33523 helo=mail-pl1-x62b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnQ-0007Qq-K6 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:27 -0500 Received: by mail-pl1-x62b.google.com with SMTP id l9so1804348plg.0 for ; Thu, 10 Feb 2022 17:32:24 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1eIr+o74KNNgcXDiiw/QxB0XZ933sRJAUNisk+EGA/Y=; b=jyv1DnmR2VvRWV2JObvZjs0/751S3pmZMv68KeMMHIhs9He7jxBg7iR0y5noHUR0r7 N4AUzjnJAxfZCwIBHRe+idUnzxQwTurgMNo5IPzxPOX9TEYkLbCTCVT2OWc5OrJ0pGgo FAuXWOjKAv1nmtQ0jrc1U9Xhke4AJK5m39x3oYS2yshVRPn2QPEQ1Bm56sMjfE8jWwXy XXS/br8mfSr5u7bGVCs/mrQf06NcONps3uPfL4r9RnTnWJHzh/96MpjcVCCv9HIBB8k+ ARoUxfcvUmpN57upQzfNCwu6n844TVqZbTMe3/agXNWdVTGT4aCspybHYemMTLeTjezB fBUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1eIr+o74KNNgcXDiiw/QxB0XZ933sRJAUNisk+EGA/Y=; b=BkCmQR+A80Fh+foOwuqtDQ4hzE0/vvURc3l5pHW1f0kEEtygEgXRIJTvDAxmwAcdwg 6kAJcj3JV2WR0fBWZsT396A8IRg7J8iuawbDNk5+kSw7RxwbrsjJXze8w0Rg/f54GFCn R6RW6Pyru7PdNspCoR6FXSlQaOQNJTscSW2vKhu4/kJHxBzcRNeImGg8J3eAxgO5f9BP jA4zYD84skAXmgydCy2wNYiFCi+jHvWsxevPbPt3QDwD57D+SLUlKDuc7dLE11wiAN4T ReavSleRS823gmBKxjaQInBKlcylviqmzcVLyjJrTtsl6QEuoI/c8yhhPA2aPXN6dE6u sIHw== X-Gm-Message-State: AOAM532RQ/D7HU701hkz2hsMwvUfNMov+6V1raS2Hq9tds4jk81yTG8V a1gDZZUEvPD5piP8MMCawiwDh+PodPr0N6xm X-Google-Smtp-Source: ABdhPJzmz5Si6kqlgGkC5x+fJe3YaKOAMEH58Nj6tz0tYWqoo0tmSxpluwdN8f9oD8mbtKWtee92bQ== X-Received: by 2002:a17:902:da91:: with SMTP id j17mr10106792plx.89.1644543142931; Thu, 10 Feb 2022 17:32:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/34] tcg/arm: Remove use_armv6_instructions Date: Fri, 11 Feb 2022 12:30:44 +1100 Message-Id: <20220211013059.17994-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644543931497100001 Content-Type: text/plain; charset="utf-8" This is now always true, since we require armv6. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 1 - tcg/arm/tcg-target.c.inc | 192 ++++++--------------------------------- 2 files changed, 27 insertions(+), 166 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 5c9ba5feea..1dd4cd5377 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -28,7 +28,6 @@ =20 extern int arm_arch; =20 -#define use_armv6_instructions (__ARM_ARCH >=3D 6 || arm_arch >=3D 6) #define use_armv7_instructions (__ARM_ARCH >=3D 7 || arm_arch >=3D 7) =20 #undef TCG_TARGET_STACK_GROWSUP diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index f3b635063f..9eb43407ea 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -923,17 +923,6 @@ static void tcg_out_dat_rIN(TCGContext *s, ARMCond con= d, ARMInsn opc, static void tcg_out_mul32(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn, TCGReg rm) { - /* if ArchVersion() < 6 && d =3D=3D n then UNPREDICTABLE; */ - if (!use_armv6_instructions && rd =3D=3D rn) { - if (rd =3D=3D rm) { - /* rd =3D=3D rn =3D=3D rm; copy an input to tmp first. */ - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); - rm =3D rn =3D TCG_REG_TMP; - } else { - rn =3D rm; - rm =3D rd; - } - } /* mul */ tcg_out32(s, (cond << 28) | 0x90 | (rd << 16) | (rm << 8) | rn); } @@ -941,17 +930,6 @@ static void tcg_out_mul32(TCGContext *s, ARMCond cond,= TCGReg rd, static void tcg_out_umull32(TCGContext *s, ARMCond cond, TCGReg rd0, TCGReg rd1, TCGReg rn, TCGReg rm) { - /* if ArchVersion() < 6 && (dHi =3D=3D n || dLo =3D=3D n) then UNPREDI= CTABLE; */ - if (!use_armv6_instructions && (rd0 =3D=3D rn || rd1 =3D=3D rn)) { - if (rd0 =3D=3D rm || rd1 =3D=3D rm) { - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); - rn =3D TCG_REG_TMP; - } else { - TCGReg t =3D rn; - rn =3D rm; - rm =3D t; - } - } /* umull */ tcg_out32(s, (cond << 28) | 0x00800090 | (rd1 << 16) | (rd0 << 12) | (rm << 8) | rn); @@ -960,17 +938,6 @@ static void tcg_out_umull32(TCGContext *s, ARMCond con= d, TCGReg rd0, static void tcg_out_smull32(TCGContext *s, ARMCond cond, TCGReg rd0, TCGReg rd1, TCGReg rn, TCGReg rm) { - /* if ArchVersion() < 6 && (dHi =3D=3D n || dLo =3D=3D n) then UNPREDI= CTABLE; */ - if (!use_armv6_instructions && (rd0 =3D=3D rn || rd1 =3D=3D rn)) { - if (rd0 =3D=3D rm || rd1 =3D=3D rm) { - tcg_out_mov_reg(s, cond, TCG_REG_TMP, rn); - rn =3D TCG_REG_TMP; - } else { - TCGReg t =3D rn; - rn =3D rm; - rm =3D t; - } - } /* smull */ tcg_out32(s, (cond << 28) | 0x00c00090 | (rd1 << 16) | (rd0 << 12) | (rm << 8) | rn); @@ -990,15 +957,8 @@ static void tcg_out_udiv(TCGContext *s, ARMCond cond, =20 static void tcg_out_ext8s(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg r= n) { - if (use_armv6_instructions) { - /* sxtb */ - tcg_out32(s, 0x06af0070 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rn, SHIFT_IMM_LSL(24)); - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rd, SHIFT_IMM_ASR(24)); - } + /* sxtb */ + tcg_out32(s, 0x06af0070 | (cond << 28) | (rd << 12) | rn); } =20 static void __attribute__((unused)) @@ -1009,113 +969,37 @@ tcg_out_ext8u(TCGContext *s, ARMCond cond, TCGReg r= d, TCGReg rn) =20 static void tcg_out_ext16s(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg = rn) { - if (use_armv6_instructions) { - /* sxth */ - tcg_out32(s, 0x06bf0070 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rn, SHIFT_IMM_LSL(16)); - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rd, SHIFT_IMM_ASR(16)); - } + /* sxth */ + tcg_out32(s, 0x06bf0070 | (cond << 28) | (rd << 12) | rn); } =20 static void tcg_out_ext16u(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg = rn) { - if (use_armv6_instructions) { - /* uxth */ - tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rn, SHIFT_IMM_LSL(16)); - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rd, SHIFT_IMM_LSR(16)); - } + /* uxth */ + tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rn); } =20 static void tcg_out_bswap16(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg rn, int flags) { - if (use_armv6_instructions) { - if (flags & TCG_BSWAP_OS) { - /* revsh */ - tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); - return; - } - - /* rev16 */ - tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); - if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) =3D=3D TCG_BSWAP_OZ) { - /* uxth */ - tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd); - } + if (flags & TCG_BSWAP_OS) { + /* revsh */ + tcg_out32(s, 0x06ff0fb0 | (cond << 28) | (rd << 12) | rn); return; } =20 - if (flags =3D=3D 0) { - /* - * For stores, no input or output extension: - * rn =3D xxAB - * lsr tmp, rn, #8 tmp =3D 0xxA - * and tmp, tmp, #0xff tmp =3D 000A - * orr rd, tmp, rn, lsl #8 rd =3D xABA - */ - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, rn, SHIFT_IMM_LSR(8)); - tcg_out_dat_imm(s, cond, ARITH_AND, TCG_REG_TMP, TCG_REG_TMP, 0xff= ); - tcg_out_dat_reg(s, cond, ARITH_ORR, - rd, TCG_REG_TMP, rn, SHIFT_IMM_LSL(8)); - return; + /* rev16 */ + tcg_out32(s, 0x06bf0fb0 | (cond << 28) | (rd << 12) | rn); + if ((flags & (TCG_BSWAP_IZ | TCG_BSWAP_OZ)) =3D=3D TCG_BSWAP_OZ) { + /* uxth */ + tcg_out32(s, 0x06ff0070 | (cond << 28) | (rd << 12) | rd); } - - /* - * Byte swap, leaving the result at the top of the register. - * We will then shift down, zero or sign-extending. - */ - if (flags & TCG_BSWAP_IZ) { - /* - * rn =3D 00AB - * ror tmp, rn, #8 tmp =3D B00A - * orr tmp, tmp, tmp, lsl #16 tmp =3D BA00 - */ - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, rn, SHIFT_IMM_ROR(8)); - tcg_out_dat_reg(s, cond, ARITH_ORR, - TCG_REG_TMP, TCG_REG_TMP, TCG_REG_TMP, - SHIFT_IMM_LSL(16)); - } else { - /* - * rn =3D xxAB - * and tmp, rn, #0xff00 tmp =3D 00A0 - * lsl tmp, tmp, #8 tmp =3D 0A00 - * orr tmp, tmp, rn, lsl #24 tmp =3D BA00 - */ - tcg_out_dat_rI(s, cond, ARITH_AND, TCG_REG_TMP, rn, 0xff00, 1); - tcg_out_dat_reg(s, cond, ARITH_MOV, - TCG_REG_TMP, 0, TCG_REG_TMP, SHIFT_IMM_LSL(8)); - tcg_out_dat_reg(s, cond, ARITH_ORR, - TCG_REG_TMP, TCG_REG_TMP, rn, SHIFT_IMM_LSL(24)); - } - tcg_out_dat_reg(s, cond, ARITH_MOV, rd, 0, TCG_REG_TMP, - (flags & TCG_BSWAP_OS - ? SHIFT_IMM_ASR(8) : SHIFT_IMM_LSR(8))); } =20 static void tcg_out_bswap32(TCGContext *s, ARMCond cond, TCGReg rd, TCGReg= rn) { - if (use_armv6_instructions) { - /* rev */ - tcg_out32(s, 0x06bf0f30 | (cond << 28) | (rd << 12) | rn); - } else { - tcg_out_dat_reg(s, cond, ARITH_EOR, - TCG_REG_TMP, rn, rn, SHIFT_IMM_ROR(16)); - tcg_out_dat_imm(s, cond, ARITH_BIC, - TCG_REG_TMP, TCG_REG_TMP, 0xff | 0x800); - tcg_out_dat_reg(s, cond, ARITH_MOV, - rd, 0, rn, SHIFT_IMM_ROR(8)); - tcg_out_dat_reg(s, cond, ARITH_EOR, - rd, rd, TCG_REG_TMP, SHIFT_IMM_LSR(8)); - } + /* rev */ + tcg_out32(s, 0x06bf0f30 | (cond << 28) | (rd << 12) | rn); } =20 static void tcg_out_deposit(TCGContext *s, ARMCond cond, TCGReg rd, @@ -1283,7 +1167,7 @@ static void tcg_out_mb(TCGContext *s, TCGArg a0) { if (use_armv7_instructions) { tcg_out32(s, INSN_DMB_ISH); - } else if (use_armv6_instructions) { + } else { tcg_out32(s, INSN_DMB_MCR); } } @@ -1489,8 +1373,7 @@ static TCGReg tcg_out_arg_reg64(TCGContext *s, TCGReg= argreg, if (argreg & 1) { argreg++; } - if (use_armv6_instructions && argreg >=3D 4 - && (arglo & 1) =3D=3D 0 && arghi =3D=3D arglo + 1) { + if (argreg >=3D 4 && (arglo & 1) =3D=3D 0 && arghi =3D=3D arglo + 1) { tcg_out_strd_8(s, COND_AL, arglo, TCG_REG_CALL_STACK, (argreg - 4) * 4); return argreg + 2; @@ -1520,8 +1403,6 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg = addrlo, TCGReg addrhi, int cmp_off =3D (is_load ? offsetof(CPUTLBEntry, addr_read) : offsetof(CPUTLBEntry, addr_write)); int fast_off =3D TLB_MASK_TABLE_OFS(mem_index); - int mask_off =3D fast_off + offsetof(CPUTLBDescFast, mask); - int table_off =3D fast_off + offsetof(CPUTLBDescFast, table); unsigned s_bits =3D opc & MO_SIZE; unsigned a_bits =3D get_alignment_bits(opc); =20 @@ -1534,12 +1415,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg= addrlo, TCGReg addrhi, } =20 /* Load env_tlb(env)->f[mmu_idx].{mask,table} into {r0,r1}. */ - if (use_armv6_instructions) { - tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); - } else { - tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_R0, TCG_AREG0, mask_off); - tcg_out_ld(s, TCG_TYPE_I32, TCG_REG_R1, TCG_AREG0, table_off); - } + tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); =20 /* Extract the tlb index from the address into R0. */ tcg_out_dat_reg(s, COND_AL, ARITH_AND, TCG_REG_R0, TCG_REG_R0, addrlo, @@ -1550,7 +1426,7 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg = addrlo, TCGReg addrhi, * Load the tlb comparator into R2/R3 and the fast path addend into R1. */ if (cmp_off =3D=3D 0) { - if (use_armv6_instructions && TARGET_LONG_BITS =3D=3D 64) { + if (TARGET_LONG_BITS =3D=3D 64) { tcg_out_ldrd_rwb(s, COND_AL, TCG_REG_R2, TCG_REG_R1, TCG_REG_R= 0); } else { tcg_out_ld32_rwb(s, COND_AL, TCG_REG_R2, TCG_REG_R1, TCG_REG_R= 0); @@ -1558,15 +1434,12 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGRe= g addrlo, TCGReg addrhi, } else { tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R1, TCG_REG_R1, TCG_REG_R0, 0); - if (use_armv6_instructions && TARGET_LONG_BITS =3D=3D 64) { + if (TARGET_LONG_BITS =3D=3D 64) { tcg_out_ldrd_8(s, COND_AL, TCG_REG_R2, TCG_REG_R1, cmp_off); } else { tcg_out_ld32_12(s, COND_AL, TCG_REG_R2, TCG_REG_R1, cmp_off); } } - if (!use_armv6_instructions && TARGET_LONG_BITS =3D=3D 64) { - tcg_out_ld32_12(s, COND_AL, TCG_REG_R3, TCG_REG_R1, cmp_off + 4); - } =20 /* Load the tlb addend. */ tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R1, @@ -1631,7 +1504,6 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGReg argreg, datalo, datahi; MemOpIdx oi =3D lb->oi; MemOp opc =3D get_memop(oi); - void *func; =20 if (!reloc_pc24(lb->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { return false; @@ -1646,18 +1518,8 @@ static bool tcg_out_qemu_ld_slow_path(TCGContext *s,= TCGLabelQemuLdst *lb) argreg =3D tcg_out_arg_imm32(s, argreg, oi); argreg =3D tcg_out_arg_reg32(s, argreg, TCG_REG_R14); =20 - /* For armv6 we can use the canonical unsigned helpers and minimize - icache usage. For pre-armv6, use the signed helpers since we do - not have a single insn sign-extend. */ - if (use_armv6_instructions) { - func =3D qemu_ld_helpers[opc & MO_SIZE]; - } else { - func =3D qemu_ld_helpers[opc & MO_SSIZE]; - if (opc & MO_SIGN) { - opc =3D MO_UL; - } - } - tcg_out_call(s, func); + /* Use the canonical unsigned helpers and minimize icache usage. */ + tcg_out_call(s, qemu_ld_helpers[opc & MO_SIZE]); =20 datalo =3D lb->datalo_reg; datahi =3D lb->datahi_reg; @@ -1760,7 +1622,7 @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemO= p opc, break; case MO_UQ: /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions + if (USING_SOFTMMU && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); } else if (datalo !=3D addend) { @@ -1803,7 +1665,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, Mem= Op opc, TCGReg datalo, break; case MO_UQ: /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions + if (USING_SOFTMMU && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); } else if (datalo =3D=3D addrlo) { @@ -1880,7 +1742,7 @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMC= ond cond, MemOp opc, break; case MO_64: /* Avoid strd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions + if (USING_SOFTMMU && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); } else { @@ -1912,7 +1774,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, Mem= Op opc, TCGReg datalo, break; case MO_64: /* Avoid strd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU && use_armv6_instructions + if (USING_SOFTMMU && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); } else { --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544411; cv=none; d=zohomail.com; s=zohoarc; b=PjUMkEAL3N3SjaHVuu7ElJq5qXv6hHqjw1jqfKHmuQgCBSMq8dTLaKwBmc5lxzBckCOo2LKCg96REwcYtqNL971AlZVFjEzjJF750+QepNvGMEZzBqa8g+pbOHQJUAlPrwDrO67YTeCymKPrPmGaleDi/od6NJ2euDxZzEHS2ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544411; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dGf6H379BZy6DeZ68czss+3cTWHfMO8pxL4mOJcpMBU=; b=E4EAkDPEdyw/Mmm+FH/orOX3CvkFpv1AOOidJ+igj9eLqkpcu196EOn/67J3zF1uonmFbnTxeVEHQK75fUv7ioGqMInL3Zraitp2nFRGvdjZexneiu2CA3GfbRN0AMYzkYJBQSKm0EEaHQQD498KKrAfXEHHkxDtyaCk1GX53K0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544411963562.5667043726406; Thu, 10 Feb 2022 17:53:31 -0800 (PST) Received: from localhost ([::1]:56786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL7q-0005xz-JF for importer@patchew.org; Thu, 10 Feb 2022 20:53:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnY-0004qh-Pv for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:32 -0500 Received: from [2607:f8b0:4864:20::1033] (port=34343 helo=mail-pj1-x1033.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnS-0007RB-Q7 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:32 -0500 Received: by mail-pj1-x1033.google.com with SMTP id ki18-20020a17090ae91200b001b8be87e9abso3064062pjb.1 for ; Thu, 10 Feb 2022 17:32:26 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dGf6H379BZy6DeZ68czss+3cTWHfMO8pxL4mOJcpMBU=; b=TkaflsB18rfoW+jzTeM4vskmjopROlEpt4ExDn3FobscgH3UiuJlMLl25ZIzGSehBd s3opCbPNek54+9gSozyza8y7Y/e/MgQJA6n/6ekI4g3g8u9UNfr/sGP3PE4GfZ6GO+9X zwuiSWn/Z04BacqzuIWBKtctmTyTdVAoIbKUuyVE0k7VaNyVYaYQYtj8zx0S0JzcdNYO p8qAHEhgYwIOOJ1/st7SF/OlUGXgtvVK4Q0uSXqh8igDf6LWSuTTZ5FY+AO/QSakOWSh NHyNHbluq22aJq6gPl55OfqYTV9LsiHQX+OM9RD7cHTpWJg85KxHWnpyt3r5sKpdSpb8 t4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dGf6H379BZy6DeZ68czss+3cTWHfMO8pxL4mOJcpMBU=; b=mH+Wo8DlvabYwu/Sx/bXirbiroNiXxzEIZcFv0JTPBi8ePx3Y6tnlHrz1Sspejd73X rl+HoBl7mpBC031iIvBXWDjupHMD8N+P/ezXNzMh7BMP34Yx3VoAN7dyoy8MT8lLnhtP 6mP5ZbBmzJ6sDIKWjoXaDiAXguHDKniSEjM2zpGbNJ0fOxG8Scwofs74YfG3yso0jCTF tR9/KRrlhw7GYQdMtVhcWPlMFd6ke6ZUaImqdE3xXKYuvBH3KZEqGHtYFK8uV4O52O0O Ownyk3GMEgNHc9+mwVmznBG/1Ewyv9rhIzLoucL+wh5Jjv8pXN6+LlwvD4ZHg4awE6I+ a4DA== X-Gm-Message-State: AOAM531bEvK/6khPCqeyXH7urfqicaSTEwjyLcvB3gTMXsXC5+Tn1LEV HrIneaejmp0FxWUVbFLPPRJSWEgaXrPkchkM X-Google-Smtp-Source: ABdhPJzMte4nnmQyz5U5BBwlrponfdHYEG7M9s50boEGeZiHblYIfJ70tWM6kBv5dnmGssmsbUH7cg== X-Received: by 2002:a17:903:11d0:: with SMTP id q16mr10000412plh.134.1644543145426; Thu, 10 Feb 2022 17:32:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/34] tcg/arm: Check alignment for ldrd and strd Date: Fri, 11 Feb 2022 12:30:45 +1100 Message-Id: <20220211013059.17994-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1033 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544414078100001 Content-Type: text/plain; charset="utf-8" We will shortly allow the use of unaligned memory accesses, and these require proper alignment. Use get_alignment_bits to verify and remove USING_SOFTMMU. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 9eb43407ea..4b0b4f4c2f 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -34,13 +34,6 @@ bool use_idiv_instructions; bool use_neon_instructions; #endif =20 -/* ??? Ought to think about changing CONFIG_SOFTMMU to always defined. */ -#ifdef CONFIG_SOFTMMU -# define USING_SOFTMMU 1 -#else -# define USING_SOFTMMU 0 -#endif - #ifdef CONFIG_DEBUG_TCG static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] =3D { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", @@ -1621,8 +1614,8 @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemO= p opc, tcg_out_ld32_r(s, COND_AL, datalo, addrlo, addend); break; case MO_UQ: - /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU + /* LDRD requires alignment; double-check that. */ + if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); } else if (datalo !=3D addend) { @@ -1664,8 +1657,8 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, Mem= Op opc, TCGReg datalo, tcg_out_ld32_12(s, COND_AL, datalo, addrlo, 0); break; case MO_UQ: - /* Avoid ldrd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU + /* LDRD requires alignment; double-check that. */ + if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_ldrd_8(s, COND_AL, datalo, addrlo, 0); } else if (datalo =3D=3D addrlo) { @@ -1741,8 +1734,8 @@ static void tcg_out_qemu_st_index(TCGContext *s, ARMC= ond cond, MemOp opc, tcg_out_st32_r(s, cond, datalo, addrlo, addend); break; case MO_64: - /* Avoid strd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU + /* STRD requires alignment; double-check that. */ + if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); } else { @@ -1773,8 +1766,8 @@ static void tcg_out_qemu_st_direct(TCGContext *s, Mem= Op opc, TCGReg datalo, tcg_out_st32_12(s, COND_AL, datalo, addrlo, 0); break; case MO_64: - /* Avoid strd for user-only emulation, to handle unaligned. */ - if (USING_SOFTMMU + /* STRD requires alignment; double-check that. */ + if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_strd_8(s, COND_AL, datalo, addrlo, 0); } else { --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544198; cv=none; d=zohomail.com; s=zohoarc; b=O0qTtKlCFThJLpD+TrrIAbt3miyYUesPxk4rwZa7FZX+EPI9CFXk+/WuhFSM0zdajjuvcuy4jLMmUHe0BeYTC+kryYerDUK45EOzBseT6NO86relTe94O1tvWQ+6B7gxAn24hcYkEPJKaFT85PkHttG/KStfSQkolznplUjqCME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544198; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ketepLsla6Fb9Bi8BESWHNr++JeX+OGmr7bPr/0gl9Q=; b=WYLwmh7508IZuVcrKoQICmqEvDWPwaURvZCsU7A+xeDzbHAWcJ8KTLMh3DaWJs93hB/MHhUnqQxwK7ekQyaYZz9cPNowbccq2GuCrXroox191oTGPG8aIayaBerK2frxENg1Mq8aVhvao3WtenBW0YJR6gA662lCI6jcaNgdOlM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544198434344.0332754321644; Thu, 10 Feb 2022 17:49:58 -0800 (PST) Received: from localhost ([::1]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL4P-00006r-EW for importer@patchew.org; Thu, 10 Feb 2022 20:49:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnX-0004l7-9k for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:31 -0500 Received: from [2607:f8b0:4864:20::632] (port=38861 helo=mail-pl1-x632.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnV-0007RR-9A for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:31 -0500 Received: by mail-pl1-x632.google.com with SMTP id c3so3414893pls.5 for ; Thu, 10 Feb 2022 17:32:28 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ketepLsla6Fb9Bi8BESWHNr++JeX+OGmr7bPr/0gl9Q=; b=sDy9WM39MjTlY9fYGPwHjWuv9WsKJ0Grr8ukp8YsPm7tp9Nr+JY/ZfBP9kmvyLvquN F1+D2zqpm91/aisap8Ntsck8EWSvo0hp8OVHH80gktsHn5Oam3gB2i2n97e1WK4PwsRn Jn4LO9O56B31y6iEv3YHDLcJfkhFrVGaBh3CyGoBqjMbhxuu/QAlAlytk1NmQhK3+LUa V0JWFRV8AXNZ6GE6aPEitI5Z7Hhz97XpD0f458c5DaK7u5gfAmsrLPt9iQVhWF0VKjLm 4o1Q5YYkdQwfYodHAxg64iui9yxHv0OkFo7LkzS8J37SGJaDmq0FoGSiO9aSNjU3Myyz c4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ketepLsla6Fb9Bi8BESWHNr++JeX+OGmr7bPr/0gl9Q=; b=L/80glWuFRhXAApts6BACWIuY2mZgw0IrXC8pZ3STQkrBU9ubWjRUB709sbg0dw25F nHH0IaxWlPAAVyeK2XUjIqbTRQiFReiw+/R3FazpWPVdocvJ1llMyOGg37AB0jC/n9bF rWlC2dLHWEfmnQxZZH6DZWfhEmlKb1QP842trXC3eXHjP32ahk4BmSavO4y1OFP01XHs ujG8kRdCA27Q+0YIIz1XLJ0kGP69/GfIsvNTplqn6JkFtiEqlewSBjyYGz3XVJjJRlkl qZ5OpaycDGj+2g3r3KpDMbXrtysQblXoSWr2aN5gswFxOpk5Dy135KmcDE1rkM0ZuVLX U/wA== X-Gm-Message-State: AOAM532voUekC98aobIbSIoXxAA6xVhSgB8YvKbYQbbb0H5b/sMsB+VX XZr/YQV1eEYp8bL+XD93JZAwJMTjTkkeXEIn X-Google-Smtp-Source: ABdhPJynLeuB263Tatj7eyStzWt3OnvdTud5iaACsRfJDiAsPV4duUQY6nVDhqMRhjINNmUfiv+yLw== X-Received: by 2002:a17:902:7595:: with SMTP id j21mr10009335pll.79.1644543147672; Thu, 10 Feb 2022 17:32:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 21/34] tcg/arm: Support unaligned access for softmmu Date: Fri, 11 Feb 2022 12:30:46 +1100 Message-Id: <20220211013059.17994-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::632 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544200221100001 Content-Type: text/plain; charset="utf-8" From armv6, the architecture supports unaligned accesses. All we need to do is perform the correct alignment check in tcg_out_tlb_read. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 41 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 4b0b4f4c2f..d290b4556c 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -1396,16 +1396,9 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGReg= addrlo, TCGReg addrhi, int cmp_off =3D (is_load ? offsetof(CPUTLBEntry, addr_read) : offsetof(CPUTLBEntry, addr_write)); int fast_off =3D TLB_MASK_TABLE_OFS(mem_index); - unsigned s_bits =3D opc & MO_SIZE; - unsigned a_bits =3D get_alignment_bits(opc); - - /* - * We don't support inline unaligned acceses, but we can easily - * support overalignment checks. - */ - if (a_bits < s_bits) { - a_bits =3D s_bits; - } + unsigned s_mask =3D (1 << (opc & MO_SIZE)) - 1; + unsigned a_mask =3D (1 << get_alignment_bits(opc)) - 1; + TCGReg t_addr; =20 /* Load env_tlb(env)->f[mmu_idx].{mask,table} into {r0,r1}. */ tcg_out_ldrd_8(s, COND_AL, TCG_REG_R0, TCG_AREG0, fast_off); @@ -1440,27 +1433,35 @@ static TCGReg tcg_out_tlb_read(TCGContext *s, TCGRe= g addrlo, TCGReg addrhi, =20 /* * Check alignment, check comparators. - * Do this in no more than 3 insns. Use MOVW for v7, if possible, + * Do this in 2-4 insns. Use MOVW for v7, if possible, * to reduce the number of sequential conditional instructions. * Almost all guests have at least 4k pages, which means that we need * to clear at least 9 bits even for an 8-byte memory, which means it * isn't worth checking for an immediate operand for BIC. + * + * For unaligned accesses, test the page of the last unit of alignment. + * This leaves the least significant alignment bits unchanged, and of + * course must be zero. */ + t_addr =3D addrlo; + if (a_mask < s_mask) { + t_addr =3D TCG_REG_R0; + tcg_out_dat_imm(s, COND_AL, ARITH_ADD, t_addr, + addrlo, s_mask - a_mask); + } if (use_armv7_instructions && TARGET_PAGE_BITS <=3D 16) { - tcg_target_ulong mask =3D ~(TARGET_PAGE_MASK | ((1 << a_bits) - 1)= ); - - tcg_out_movi32(s, COND_AL, TCG_REG_TMP, mask); + tcg_out_movi32(s, COND_AL, TCG_REG_TMP, ~(TARGET_PAGE_MASK | a_mas= k)); tcg_out_dat_reg(s, COND_AL, ARITH_BIC, TCG_REG_TMP, - addrlo, TCG_REG_TMP, 0); + t_addr, TCG_REG_TMP, 0); tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R2, TCG_REG_TMP,= 0); } else { - if (a_bits) { - tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, - (1 << a_bits) - 1); + if (a_mask) { + tcg_debug_assert(a_mask <=3D 0xff); + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, a_mask); } - tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, addrlo, + tcg_out_dat_reg(s, COND_AL, ARITH_MOV, TCG_REG_TMP, 0, t_addr, SHIFT_IMM_LSR(TARGET_PAGE_BITS)); - tcg_out_dat_reg(s, (a_bits ? COND_EQ : COND_AL), ARITH_CMP, + tcg_out_dat_reg(s, (a_mask ? COND_EQ : COND_AL), ARITH_CMP, 0, TCG_REG_R2, TCG_REG_TMP, SHIFT_IMM_LSL(TARGET_PAGE_BITS)); } --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544714; cv=none; d=zohomail.com; s=zohoarc; b=P6Gc56aPftLNXfMCsEpcFdLEodQd28C1DHUIbVlf2PjvKD5tCshZ6uofPn2hXTv08eQzPcSvA4n3zMT8C5szEADAd3JTxboepXOG/hZvl7ymJWbyGOJ5nUqUBwDWqcYAC31/5wVDQv6KrTBztjxb4rgHy4+WP80UUZS/1hmz9qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544714; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pHwGtxTPnKymye/vw/7yD1dXIO9OSaibyYfhujQ3zXk=; b=YUeB+U8GpDUB9TsHhaSAOPzF0qlY+GhTROxqoL2uITCPaxuLJC25VWld1T3FLoQS84F5GRCoVLn6DwtOhZ3LeIEls3ZZoGMW8ekGHcElQ6KgFelCvtE3gyQgSb3kXppJJduwfQiwn/9Q3LZk4qAMYH9Vv8VPModjcgsGQMhrOZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544714211370.5328066012662; Thu, 10 Feb 2022 17:58:34 -0800 (PST) Received: from localhost ([::1]:39624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILCj-0005CO-2E for importer@patchew.org; Thu, 10 Feb 2022 20:58:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnZ-0004s7-Jp for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:34 -0500 Received: from [2607:f8b0:4864:20::1035] (port=40562 helo=mail-pj1-x1035.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnX-0007S1-3w for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:33 -0500 Received: by mail-pj1-x1035.google.com with SMTP id c8-20020a17090a674800b001b91184b732so7978036pjm.5 for ; Thu, 10 Feb 2022 17:32:30 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pHwGtxTPnKymye/vw/7yD1dXIO9OSaibyYfhujQ3zXk=; b=abYgKwCtySDPROOH18RqPEe1kKpXg75l4jk2gelP7aiSJA1rLOUoz3R0YPYy49+zak OqR/RoT3b5JpxOsONf+0v+LYiBshi8L0IBNxgnwvh04wkwbECrWE/t09uyBrhtXTRMDa T5Y0+Jt97j+5NPNltIwrdMzeZlcur3dd7vGw4rFEvYwKC71SgPL10ltRadM6a/uJ9wY8 9MxYcUpTcShLWP3CjV0yXuXhlfOyMDL6snjvHH9OQ5LgE2l4nVvQCLA74CEfohAYc9hM VGoa401f3277mVKITYZGOY7FDfeLljYvHKj2gql0sMPIwvv9golsUa7yHlY6v5g3RYoU erxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pHwGtxTPnKymye/vw/7yD1dXIO9OSaibyYfhujQ3zXk=; b=Yv/w0NGcRJjvDkNC+RtF3FjTwIOT5Pyn0SwTelo3fsvA0rjeSElazYZcCDhZK+6Q1l qvKmzmyy6b1Z4dnJNEiBglDZxjNcvJTsIyYDkwoFeXu1chW0LK9vGLdzkpFrS+iPb3LR dan2rOqEdbrRKRwPBLNmv3hm7g+jUnYTEjhbST7GSJaZERXuv9tQarlR5uukM3V4Zbzg VmcyL6k7cJEWe/epg693R+hhuI1Jw4PDOI/IkozJ60Rxxiwk8ZmkDp5s91+7ab3kcXI7 8oAmi21dgO9Si040RvpB6YxxGkdN1jBiJELgTVTx7QPADZrKgeruJnjABKZttocG419J SqAg== X-Gm-Message-State: AOAM533yVET2S1i7vMyXLowV4fFXkkER2ExNgIYcrvouQsGNAxattUzj RsDlKltPpaLCjTDPIHrn8fpstKd1/Zxq2TcX X-Google-Smtp-Source: ABdhPJyVJoga69sMANR3Y5bcF25BcFcrCuzz3fEQyxN2ZO4EA4u8iepSbJMUvizifZHNidkOqnnBuw== X-Received: by 2002:a17:902:a512:: with SMTP id s18mr9813555plq.51.1644543149917; Thu, 10 Feb 2022 17:32:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/34] tcg/arm: Reserve a register for guest_base Date: Fri, 11 Feb 2022 12:30:47 +1100 Message-Id: <20220211013059.17994-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1035 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544716189100001 Content-Type: text/plain; charset="utf-8" Reserve a register for the guest_base using aarch64 for reference. By doing so, we do not have to recompute it for every memory load. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c.inc | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index d290b4556c..7eebbfaf02 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -84,6 +84,9 @@ static const int tcg_target_call_oarg_regs[2] =3D { =20 #define TCG_REG_TMP TCG_REG_R12 #define TCG_VEC_TMP TCG_REG_Q15 +#ifndef CONFIG_SOFTMMU +#define TCG_REG_GUEST_BASE TCG_REG_R11 +#endif =20 typedef enum { COND_EQ =3D 0x0, @@ -1593,7 +1596,8 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) =20 static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, TCGReg datalo, TCGReg datahi, - TCGReg addrlo, TCGReg addend) + TCGReg addrlo, TCGReg addend, + bool scratch_addend) { /* Byte swapping is left to middle-end expansion. */ tcg_debug_assert((opc & MO_BSWAP) =3D=3D 0); @@ -1619,7 +1623,7 @@ static void tcg_out_qemu_ld_index(TCGContext *s, MemO= p opc, if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_ldrd_r(s, COND_AL, datalo, addrlo, addend); - } else if (datalo !=3D addend) { + } else if (scratch_addend) { tcg_out_ld32_rwb(s, COND_AL, datalo, addend, addrlo); tcg_out_ld32_12(s, COND_AL, datahi, addend, 4); } else { @@ -1703,14 +1707,14 @@ static void tcg_out_qemu_ld(TCGContext *s, const TC= GArg *args, bool is64) label_ptr =3D s->code_ptr; tcg_out_bl_imm(s, COND_NE, 0); =20 - tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend); + tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, addend, true); =20 add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ if (guest_base) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, guest_base); - tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, TCG_REG_TMP); + tcg_out_qemu_ld_index(s, opc, datalo, datahi, + addrlo, TCG_REG_GUEST_BASE, false); } else { tcg_out_qemu_ld_direct(s, opc, datalo, datahi, addrlo); } @@ -1719,7 +1723,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is64) =20 static void tcg_out_qemu_st_index(TCGContext *s, ARMCond cond, MemOp opc, TCGReg datalo, TCGReg datahi, - TCGReg addrlo, TCGReg addend) + TCGReg addrlo, TCGReg addend, + bool scratch_addend) { /* Byte swapping is left to middle-end expansion. */ tcg_debug_assert((opc & MO_BSWAP) =3D=3D 0); @@ -1739,9 +1744,14 @@ static void tcg_out_qemu_st_index(TCGContext *s, ARM= Cond cond, MemOp opc, if (get_alignment_bits(opc) >=3D MO_64 && (datalo & 1) =3D=3D 0 && datahi =3D=3D datalo + 1) { tcg_out_strd_r(s, cond, datalo, addrlo, addend); - } else { + } else if (scratch_addend) { tcg_out_st32_rwb(s, cond, datalo, addend, addrlo); tcg_out_st32_12(s, cond, datahi, addend, 4); + } else { + tcg_out_dat_reg(s, cond, ARITH_ADD, TCG_REG_TMP, + addend, addrlo, SHIFT_IMM_LSL(0)); + tcg_out_st32_12(s, cond, datalo, TCG_REG_TMP, 0); + tcg_out_st32_12(s, cond, datahi, TCG_REG_TMP, 4); } break; default: @@ -1804,7 +1814,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) mem_index =3D get_mmuidx(oi); addend =3D tcg_out_tlb_read(s, addrlo, addrhi, opc, mem_index, 0); =20 - tcg_out_qemu_st_index(s, COND_EQ, opc, datalo, datahi, addrlo, addend); + tcg_out_qemu_st_index(s, COND_EQ, opc, datalo, datahi, + addrlo, addend, true); =20 /* The conditional call must come last, as we're going to return here.= */ label_ptr =3D s->code_ptr; @@ -1814,9 +1825,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ if (guest_base) { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP, guest_base); - tcg_out_qemu_st_index(s, COND_AL, opc, datalo, - datahi, addrlo, TCG_REG_TMP); + tcg_out_qemu_st_index(s, COND_AL, opc, datalo, datahi, + addrlo, TCG_REG_GUEST_BASE, false); } else { tcg_out_qemu_st_direct(s, opc, datalo, datahi, addrlo); } @@ -2958,6 +2968,13 @@ static void tcg_target_qemu_prologue(TCGContext *s) =20 tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); =20 +#ifndef CONFIG_SOFTMMU + if (guest_base) { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_GUEST_BASE, guest_base); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_GUEST_BASE); + } +#endif + tcg_out_b_reg(s, COND_AL, tcg_target_call_iarg_regs[1]); =20 /* --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544853; cv=none; d=zohomail.com; s=zohoarc; b=MtZkAAUPpypjlqoiU9XwD89Qon3PpJOY9mAP2Yy+9WgYvplvO0B7+PsM874G9X7AEse1E60dsfR5uMvzeczHO/dODXnRjmoc5yYkFlJzUX8uvd+fuz6ODk36FGpG8FhTiGgaUO8etqdwD4M0f37A8fn1YbipgnKm9m/rBU3B5xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544853; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=h3OMhMoGTS9ir2j1MNRjTZSgTM6ppy0sE7+1oijotYw=; b=Rsd49K/6hUrbPu6mfIl/i/FWu0r6kevXDzsjUYqvg8P+NhVKfK9hfCpeBsJsQLdP5J0hjkv1arXqH1YaHlrYGx6QCqKjurcbEvDD965mEUFSMZjoxzJfC4QPnu7pH87ymbHhmtqiIbemS+Y/ik+GzzL386N9ElEWp32sfn1f+JM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544853889469.22387654963575; Thu, 10 Feb 2022 18:00:53 -0800 (PST) Received: from localhost ([::1]:45244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILEy-0000bB-Nx for importer@patchew.org; Thu, 10 Feb 2022 21:00:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnb-0004wY-RJ for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:37 -0500 Received: from [2607:f8b0:4864:20::432] (port=35345 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnZ-0007SL-FW for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:35 -0500 Received: by mail-pf1-x432.google.com with SMTP id l19so7682055pfu.2 for ; Thu, 10 Feb 2022 17:32:33 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h3OMhMoGTS9ir2j1MNRjTZSgTM6ppy0sE7+1oijotYw=; b=QKktmBhFmbrELOKhrH47e4RUl8v2v1cL56u7N5IYxLQ5BBhVlHU8i8G1mjCZKnVs2U PBkiXUutDHPKDbULchwpjy775GkTa1v3qtIdBwv1B2e7TBipAOvi0g2ht17cZcPv89pE wTKTD6L314ZfsO+tDjeCvYs7DyXrV6g2mj+ZjxHNIpPzfMqzGWL7thoDGLH6hDg/J04c osXfv2ZkNIizbTYa8EZZQQ1qn5G+SN++q82Cg4804OJ1RUY1WzdH3uepB5wxFzQOJrIm gnw19ezdqcVqzv2769wjxV/ngWrgqc47cRs4++FYLOAApUglC/8GqpuEU6nDiQmuAaSO sGhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h3OMhMoGTS9ir2j1MNRjTZSgTM6ppy0sE7+1oijotYw=; b=eGvpO5NjP6kWLCNVr0X9/bNtowSYjG/LnTL0PMnentEgXUtV7+FFRXYPp+boUE9+hW wEMCqHL5NQNzRqNABM7pAhP+cf6MMM4LVC7JVASBcCF7mlCzz9/xmhGHCiAr6H3yIJYv cHDWP74gWjDWsQZEy1qJMljJGuAcB+931g9pteuKHhb7Totb6ttl0tgqlytmVnXIXY7+ XNkcbsgWJmEi4+FcCvMivHsDahm/9afPwQ9aoeGlUX4Dye4Onzp+aYyVZthfHWFSsFO0 Z+dYqUeL5VcvExFywxbAST3jh5kN7LdanVU2L4W+bz4OiYTysxzs5/SvAygJAlRogEyq CBMg== X-Gm-Message-State: AOAM530muwvlFYNItwoF9SWfyhBjIJxs6I2E5GO4AsXF8WpD3bQf4UH9 hIiNYpfLiMZxjiJL0ugyfkknNP1MQ97Qd8Sy X-Google-Smtp-Source: ABdhPJyvQuFMVVyhAPS6Lyh8zpG2rbgPex6pdotseteZx9JYf0sFKKY0vQarcPwVcTCY2kb+yN4hAA== X-Received: by 2002:a63:86:: with SMTP id 128mr8265499pga.13.1644543152271; Thu, 10 Feb 2022 17:32:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/34] tcg/arm: Support raising sigbus for user-only Date: Fri, 11 Feb 2022 12:30:48 +1100 Message-Id: <20220211013059.17994-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544855577100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.h | 2 - tcg/arm/tcg-target.c.inc | 83 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 81 insertions(+), 4 deletions(-) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 1dd4cd5377..27c27a1f14 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -151,9 +151,7 @@ extern bool use_neon_instructions; /* not defined -- call should be eliminated at compile time */ void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t); =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif #define TCG_TARGET_NEED_POOL_LABELS =20 #endif diff --git a/tcg/arm/tcg-target.c.inc b/tcg/arm/tcg-target.c.inc index 7eebbfaf02..e1ea69669c 100644 --- a/tcg/arm/tcg-target.c.inc +++ b/tcg/arm/tcg-target.c.inc @@ -23,6 +23,7 @@ */ =20 #include "elf.h" +#include "../tcg-ldst.c.inc" #include "../tcg-pool.c.inc" =20 int arm_arch =3D __ARM_ARCH; @@ -1289,8 +1290,6 @@ static void tcg_out_vldst(TCGContext *s, ARMInsn insn, } =20 #ifdef CONFIG_SOFTMMU -#include "../tcg-ldst.c.inc" - /* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, * int mmu_idx, uintptr_t ra) */ @@ -1592,6 +1591,74 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *lb) tcg_out_goto(s, COND_AL, qemu_st_helpers[opc & MO_SIZE]); return true; } +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrl= o, + TCGReg addrhi, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *label =3D new_ldst_label(s); + + label->is_ld =3D is_ld; + label->addrlo_reg =3D addrlo; + label->addrhi_reg =3D addrhi; + + /* We are expecting a_bits to max out at 7, and can easily support 8. = */ + tcg_debug_assert(a_mask <=3D 0xff); + /* tst addr, #mask */ + tcg_out_dat_imm(s, COND_AL, ARITH_TST, 0, addrlo, a_mask); + + /* blne slow_path */ + label->label_ptr[0] =3D s->code_ptr; + tcg_out_bl_imm(s, COND_NE, 0); + + label->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + if (!reloc_pc24(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + if (TARGET_LONG_BITS =3D=3D 64) { + /* 64-bit target address is aligned into R2:R3. */ + if (l->addrhi_reg !=3D TCG_REG_R2) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, l->addrhi_reg); + } else if (l->addrlo_reg !=3D TCG_REG_R3) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, l->addrhi_reg); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, l->addrlo_reg); + } else { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R1, TCG_REG_R2); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R2, TCG_REG_R3); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R3, TCG_REG_R1); + } + } else { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_R1, l->addrlo_reg); + } + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R0, TCG_AREG0); + + /* + * Tail call to the helper, with the return address back inline, + * just for the clarity of the debugging traceback -- the helper + * cannot return. We have used BLNE to arrive here, so LR is + * already set. + */ + tcg_out_goto(s, COND_AL, (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); +} #endif /* SOFTMMU */ =20 static void tcg_out_qemu_ld_index(TCGContext *s, MemOp opc, @@ -1689,6 +1756,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is64) int mem_index; TCGReg addend; tcg_insn_unit *label_ptr; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -1712,6 +1781,10 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is64) add_qemu_ldst_label(s, true, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, true, addrlo, addrhi, a_bits); + } if (guest_base) { tcg_out_qemu_ld_index(s, opc, datalo, datahi, addrlo, TCG_REG_GUEST_BASE, false); @@ -1801,6 +1874,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) int mem_index; TCGReg addend; tcg_insn_unit *label_ptr; +#else + unsigned a_bits; #endif =20 datalo =3D *args++; @@ -1824,6 +1899,10 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is64) add_qemu_ldst_label(s, false, oi, datalo, datahi, addrlo, addrhi, s->code_ptr, label_ptr); #else /* !CONFIG_SOFTMMU */ + a_bits =3D get_alignment_bits(opc); + if (a_bits) { + tcg_out_test_alignment(s, false, addrlo, addrhi, a_bits); + } if (guest_base) { tcg_out_qemu_st_index(s, COND_AL, opc, datalo, datahi, addrlo, TCG_REG_GUEST_BASE, false); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544190710789.1411826269846; Thu, 10 Feb 2022 17:49:50 -0800 (PST) Received: from localhost ([::1]:48038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL4H-0008O5-EK for importer@patchew.org; Thu, 10 Feb 2022 20:49:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKnf-00052x-3J for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:42 -0500 Received: from [2607:f8b0:4864:20::42b] (port=42838 helo=mail-pf1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnc-0007Si-Dd for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:38 -0500 Received: by mail-pf1-x42b.google.com with SMTP id i6so11582042pfc.9 for ; Thu, 10 Feb 2022 17:32:36 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JKMjMlXFJG6hvG1+zESWbFSMe4fCNR2aaQRlmfkml/s=; b=VTAV11oVtV1f1Ysr2SuomphFG+5J4bLgNbbW6p9hAmF/DJgob/pGpq1yYu8q+nhqWD O4tyK7FNlW1gNonJQGtrAWNfoT2MI2kMexSpNqt+FhJTtgvtSDGrfezuFGvMw4uFXcYL /AFr99K9KqCf6Fv0bvnSNoygYARzNcoYgUXIZUkL7gIzniRGBsxOGb0OUPvAD+yS17po 4X1VmO8o4382DXxFvRGrEUXaciDObZfC8i30QCyOHlVoVBcdgs9l+a6DHkSD58Tgjw9Y vQpCz+35BRhtwHE75YuScQxpfcZgn/5Xq75j3HOp+ifd8b2QIbXa0lJcmnHc5liR56Ue OLmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JKMjMlXFJG6hvG1+zESWbFSMe4fCNR2aaQRlmfkml/s=; b=HzSmXQ1M0q/LWvidQvcwPWzhMJTVzN0x2hyazjy57rBI5Ukj/pTVY81YzqqSIN1q0K 7LH/+NOWJi4vs+DIEVzn8lupOSFC4G/nXc3s19y3L5Kas/L/H3g9JEch9P4+cGyV+s/x vU93kuSlQyE8GL6dVSFDPLi3HgiiXAZi/e9DomW7tobzAqqcfakPcYhI/xj8C2BkVlCQ EngymFJiY6aSvG3O0XYraAaFQnOdlT5eytwLJrXV3BCnk2XmSsz2bGbtZYy5791jMoI+ DHwqQCnc/UO/WFuRp/wvY7++HdiKEOrRFFM2GX22FpdwK6tUXHGsgjTtSaXpo473MLCO Zl3g== X-Gm-Message-State: AOAM530UTc2if06XJkRQBNCE+lMdXlLqeqcHpeeEFFILuu3RZe0v2s3n 4IOqPUQOrafOaq2b5OSy+Quqx+KddN4iHhpg X-Google-Smtp-Source: ABdhPJxgNjq+PsgEz0a91H/1GcKdPE8Nr+hZ58KDmfLAdWq7kUY5JT+lyO6S/5gDU70dQmBJZi4mLw== X-Received: by 2002:a63:4d66:: with SMTP id n38mr8263483pgl.597.1644543155000; Thu, 10 Feb 2022 17:32:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/34] tcg/mips: Support unaligned access for user-only Date: Fri, 11 Feb 2022 12:30:49 +1100 Message-Id: <20220211013059.17994-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644544191729100001 This is kinda sorta the opposite of the other tcg hosts, where we get (normal) alignment checks for free with host SIGBUS and need to add code to support unaligned accesses. Fortunately, the ISA contains pairs of instructions that are used to implement unaligned memory accesses. Use them. Tested-by: Jiaxun Yang Reviewed-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.h | 2 - tcg/mips/tcg-target.c.inc | 334 +++++++++++++++++++++++++++++++++++++- 2 files changed, 328 insertions(+), 8 deletions(-) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index c366fdf74b..7669213175 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -207,8 +207,6 @@ extern bool use_mips32r2_instructions; void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t, uintptr_t) QEMU_ERROR("code path is reachable"); =20 -#ifdef CONFIG_SOFTMMU #define TCG_TARGET_NEED_LDST_LABELS -#endif =20 #endif diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 27b020e66c..2c94ac2ed6 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -24,6 +24,8 @@ * THE SOFTWARE. */ =20 +#include "../tcg-ldst.c.inc" + #ifdef HOST_WORDS_BIGENDIAN # define MIPS_BE 1 #else @@ -230,16 +232,26 @@ typedef enum { OPC_ORI =3D 015 << 26, OPC_XORI =3D 016 << 26, OPC_LUI =3D 017 << 26, + OPC_BNEL =3D 025 << 26, + OPC_BNEZALC_R6 =3D 030 << 26, OPC_DADDIU =3D 031 << 26, + OPC_LDL =3D 032 << 26, + OPC_LDR =3D 033 << 26, OPC_LB =3D 040 << 26, OPC_LH =3D 041 << 26, + OPC_LWL =3D 042 << 26, OPC_LW =3D 043 << 26, OPC_LBU =3D 044 << 26, OPC_LHU =3D 045 << 26, + OPC_LWR =3D 046 << 26, OPC_LWU =3D 047 << 26, OPC_SB =3D 050 << 26, OPC_SH =3D 051 << 26, + OPC_SWL =3D 052 << 26, OPC_SW =3D 053 << 26, + OPC_SDL =3D 054 << 26, + OPC_SDR =3D 055 << 26, + OPC_SWR =3D 056 << 26, OPC_LD =3D 067 << 26, OPC_SD =3D 077 << 26, =20 @@ -1015,8 +1027,6 @@ static void tcg_out_call(TCGContext *s, const tcg_ins= n_unit *arg) } =20 #if defined(CONFIG_SOFTMMU) -#include "../tcg-ldst.c.inc" - static void * const qemu_ld_helpers[(MO_SSIZE | MO_BSWAP) + 1] =3D { [MO_UB] =3D helper_ret_ldub_mmu, [MO_SB] =3D helper_ret_ldsb_mmu, @@ -1324,7 +1334,82 @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s,= TCGLabelQemuLdst *l) tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); return true; } -#endif + +#else + +static void tcg_out_test_alignment(TCGContext *s, bool is_ld, TCGReg addrl= o, + TCGReg addrhi, unsigned a_bits) +{ + unsigned a_mask =3D (1 << a_bits) - 1; + TCGLabelQemuLdst *l =3D new_ldst_label(s); + + l->is_ld =3D is_ld; + l->addrlo_reg =3D addrlo; + l->addrhi_reg =3D addrhi; + + /* We are expecting a_bits to max out at 7, much lower than ANDI. */ + tcg_debug_assert(a_bits < 16); + tcg_out_opc_imm(s, OPC_ANDI, TCG_TMP0, addrlo, a_mask); + + l->label_ptr[0] =3D s->code_ptr; + if (use_mips32r6_instructions) { + tcg_out_opc_br(s, OPC_BNEZALC_R6, TCG_REG_ZERO, TCG_TMP0); + } else { + tcg_out_opc_br(s, OPC_BNEL, TCG_TMP0, TCG_REG_ZERO); + tcg_out_nop(s); + } + + l->raddr =3D tcg_splitwx_to_rx(s->code_ptr); +} + +static bool tcg_out_fail_alignment(TCGContext *s, TCGLabelQemuLdst *l) +{ + void *target; + + if (!reloc_pc16(l->label_ptr[0], tcg_splitwx_to_rx(s->code_ptr))) { + return false; + } + + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + /* A0 is env, A1 is skipped, A2:A3 is the uint64_t address. */ + TCGReg a2 =3D MIPS_BE ? l->addrhi_reg : l->addrlo_reg; + TCGReg a3 =3D MIPS_BE ? l->addrlo_reg : l->addrhi_reg; + + if (a3 !=3D TCG_REG_A2) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); + } else if (a2 !=3D TCG_REG_A3) { + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, a3); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, a2); + } else { + tcg_out_mov(s, TCG_TYPE_I32, TCG_TMP0, TCG_REG_A2); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A2, TCG_REG_A3); + tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_A3, TCG_TMP0); + } + } else { + tcg_out_mov(s, TCG_TYPE_TL, TCG_REG_A1, l->addrlo_reg); + } + tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_A0, TCG_AREG0); + + /* + * Tail call to the helper, with the return address back inline. + * We have arrived here via BNEL, so $31 is already set. + */ + target =3D (l->is_ld ? helper_unaligned_ld : helper_unaligned_st); + tcg_out_call_int(s, target, true); + 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); +} +#endif /* SOFTMMU */ =20 static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, bool is_64) @@ -1430,6 +1515,127 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, T= CGReg lo, TCGReg hi, } } =20 +static void __attribute__((unused)) +tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, MemOp opc, bool is_64) +{ + const MIPSInsn lw1 =3D MIPS_BE ? OPC_LWL : OPC_LWR; + const MIPSInsn lw2 =3D MIPS_BE ? OPC_LWR : OPC_LWL; + const MIPSInsn ld1 =3D MIPS_BE ? OPC_LDL : OPC_LDR; + const MIPSInsn ld2 =3D MIPS_BE ? OPC_LDR : OPC_LDL; + + bool sgn =3D (opc & MO_SIGN); + + switch (opc & (MO_SSIZE | MO_BSWAP)) { + case MO_SW | MO_BE: + case MO_UW | MO_BE: + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, OPC_LBU, lo, base, 1); + if (use_mips32r2_instructions) { + tcg_out_opc_bf(s, OPC_INS, lo, TCG_TMP0, 31, 8); + } else { + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP0, TCG_TMP0, 8); + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); + } + break; + + case MO_SW | MO_LE: + case MO_UW | MO_LE: + if (use_mips32r2_instructions && lo !=3D base) { + tcg_out_opc_imm(s, OPC_LBU, lo, base, 0); + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP0, base, 1); + tcg_out_opc_bf(s, OPC_INS, lo, TCG_TMP0, 31, 8); + } else { + tcg_out_opc_imm(s, OPC_LBU, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, sgn ? OPC_LB : OPC_LBU, TCG_TMP1, base, 1); + tcg_out_opc_sa(s, OPC_SLL, TCG_TMP1, TCG_TMP1, 8); + tcg_out_opc_reg(s, OPC_OR, lo, TCG_TMP0, TCG_TMP1); + } + break; + + case MO_SL: + case MO_UL: + tcg_out_opc_imm(s, lw1, lo, base, 0); + tcg_out_opc_imm(s, lw2, lo, base, 3); + if (TCG_TARGET_REG_BITS =3D=3D 64 && is_64 && !sgn) { + tcg_out_ext32u(s, lo, lo); + } + break; + + case MO_UL | MO_BSWAP: + case MO_SL | MO_BSWAP: + if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, lw1, lo, base, 0); + tcg_out_opc_imm(s, lw2, lo, base, 3); + tcg_out_bswap32(s, lo, lo, + TCG_TARGET_REG_BITS =3D=3D 64 && is_64 + ? (sgn ? TCG_BSWAP_OS : TCG_BSWAP_OZ) : 0); + } else { + const tcg_insn_unit *subr =3D + (TCG_TARGET_REG_BITS =3D=3D 64 && is_64 && !sgn + ? bswap32u_addr : bswap32_addr); + + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0); + tcg_out_bswap_subr(s, subr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 3); + tcg_out_mov(s, is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32, lo, TCG_TM= P3); + } + break; + + case MO_UQ: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_opc_imm(s, ld1, lo, base, 0); + tcg_out_opc_imm(s, ld2, lo, base, 7); + } else { + tcg_out_opc_imm(s, lw1, MIPS_BE ? hi : lo, base, 0 + 0); + tcg_out_opc_imm(s, lw2, MIPS_BE ? hi : lo, base, 0 + 3); + tcg_out_opc_imm(s, lw1, MIPS_BE ? lo : hi, base, 4 + 0); + tcg_out_opc_imm(s, lw2, MIPS_BE ? lo : hi, base, 4 + 3); + } + break; + + case MO_UQ | MO_BSWAP: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, ld1, lo, base, 0); + tcg_out_opc_imm(s, ld2, lo, base, 7); + tcg_out_bswap64(s, lo, lo); + } else { + tcg_out_opc_imm(s, ld1, TCG_TMP0, base, 0); + tcg_out_bswap_subr(s, bswap64_addr); + /* delay slot */ + tcg_out_opc_imm(s, ld2, TCG_TMP0, base, 7); + tcg_out_mov(s, TCG_TYPE_I64, lo, TCG_TMP3); + } + } else if (use_mips32r2_instructions) { + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); + tcg_out_opc_imm(s, lw1, TCG_TMP1, base, 4 + 0); + tcg_out_opc_imm(s, lw2, TCG_TMP1, base, 4 + 3); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, TCG_TMP0); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, TCG_TMP1); + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? lo : hi, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, MIPS_BE ? hi : lo, TCG_TMP1, 16); + } else { + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 0 + 0); + tcg_out_bswap_subr(s, bswap32_addr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 0 + 3); + tcg_out_opc_imm(s, lw1, TCG_TMP0, base, 4 + 0); + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? lo : hi, TCG_TMP3); + tcg_out_bswap_subr(s, bswap32_addr); + /* delay slot */ + tcg_out_opc_imm(s, lw2, TCG_TMP0, base, 4 + 3); + tcg_out_mov(s, TCG_TYPE_I32, MIPS_BE ? hi : lo, TCG_TMP3); + } + break; + + default: + g_assert_not_reached(); + } +} + static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); @@ -1438,6 +1644,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits, s_bits; #endif TCGReg base =3D TCG_REG_A0; =20 @@ -1467,7 +1675,27 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ + if (use_mips32r6_instructions) { + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + } else { + if (a_bits && a_bits !=3D s_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + if (a_bits >=3D s_bits) { + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_= 64); + } else { + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is= _64); + } + } #endif } =20 @@ -1532,6 +1760,79 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TC= GReg lo, TCGReg hi, } } =20 +static void __attribute__((unused)) +tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, MemOp opc) +{ + const MIPSInsn sw1 =3D MIPS_BE ? OPC_SWL : OPC_SWR; + const MIPSInsn sw2 =3D MIPS_BE ? OPC_SWR : OPC_SWL; + const MIPSInsn sd1 =3D MIPS_BE ? OPC_SDL : OPC_SDR; + const MIPSInsn sd2 =3D MIPS_BE ? OPC_SDR : OPC_SDL; + + /* Don't clutter the code below with checks to avoid bswapping ZERO. = */ + if ((lo | hi) =3D=3D 0) { + opc &=3D ~MO_BSWAP; + } + + switch (opc & (MO_SIZE | MO_BSWAP)) { + case MO_16 | MO_BE: + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 0); + tcg_out_opc_imm(s, OPC_SB, lo, base, 1); + break; + + case MO_16 | MO_LE: + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, lo, 8); + tcg_out_opc_imm(s, OPC_SB, lo, base, 0); + tcg_out_opc_imm(s, OPC_SB, TCG_TMP0, base, 1); + break; + + case MO_32 | MO_BSWAP: + tcg_out_bswap32(s, TCG_TMP3, lo, 0); + lo =3D TCG_TMP3; + /* fall through */ + case MO_32: + tcg_out_opc_imm(s, sw1, lo, base, 0); + tcg_out_opc_imm(s, sw2, lo, base, 3); + break; + + case MO_64 | MO_BSWAP: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_bswap64(s, TCG_TMP3, lo); + lo =3D TCG_TMP3; + } else if (use_mips32r2_instructions) { + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP0, 0, MIPS_BE ? hi : lo); + tcg_out_opc_reg(s, OPC_WSBH, TCG_TMP1, 0, MIPS_BE ? lo : hi); + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP0, TCG_TMP0, 16); + tcg_out_opc_sa(s, OPC_ROTR, TCG_TMP1, TCG_TMP1, 16); + hi =3D MIPS_BE ? TCG_TMP0 : TCG_TMP1; + lo =3D MIPS_BE ? TCG_TMP1 : TCG_TMP0; + } else { + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? lo : hi, 0); + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 0 + 0); + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 0 + 3); + tcg_out_bswap32(s, TCG_TMP3, MIPS_BE ? hi : lo, 0); + tcg_out_opc_imm(s, sw1, TCG_TMP3, base, 4 + 0); + tcg_out_opc_imm(s, sw2, TCG_TMP3, base, 4 + 3); + break; + } + /* fall through */ + case MO_64: + if (TCG_TARGET_REG_BITS =3D=3D 64) { + tcg_out_opc_imm(s, sd1, lo, base, 0); + tcg_out_opc_imm(s, sd2, lo, base, 7); + } else { + tcg_out_opc_imm(s, sw1, MIPS_BE ? hi : lo, base, 0 + 0); + tcg_out_opc_imm(s, sw2, MIPS_BE ? hi : lo, base, 0 + 3); + tcg_out_opc_imm(s, sw1, MIPS_BE ? lo : hi, base, 4 + 0); + tcg_out_opc_imm(s, sw2, MIPS_BE ? lo : hi, base, 4 + 3); + } + break; + + default: + tcg_abort(); + } +} static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) { TCGReg addr_regl, addr_regh __attribute__((unused)); @@ -1540,6 +1841,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; +#else + unsigned a_bits, s_bits; #endif TCGReg base =3D TCG_REG_A0; =20 @@ -1558,7 +1861,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - base =3D TCG_REG_A0; if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { tcg_out_ext32u(s, base, addr_regl); addr_regl =3D base; @@ -1570,7 +1872,27 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ + if (use_mips32r6_instructions) { + if (a_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + if (a_bits && a_bits !=3D s_bits) { + tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); + } + if (a_bits >=3D s_bits) { + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); + } + } #endif } =20 --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545017348244.41187087740468; Thu, 10 Feb 2022 18:03:37 -0800 (PST) Received: from localhost ([::1]:49668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILHb-0003i8-VN for importer@patchew.org; Thu, 10 Feb 2022 21:03:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKny-00057K-NH for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:00 -0500 Received: from [2607:f8b0:4864:20::436] (port=38669 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKns-0007So-BV for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:32:55 -0500 Received: by mail-pf1-x436.google.com with SMTP id x15so11081006pfr.5 for ; Thu, 10 Feb 2022 17:32:39 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+XsfJcpBAH8croteMv6Er6rAN5b3b1fxSc8BZAh+/k=; b=AspVQwwfvY0FH9wxbBlWnZzvUSKuy4JiEGpGaI26hpv7iFe5tpvAQUoiGBsz1gslVv k+AiVJAGFZ3SJFcWvLzJeCrwVvewuEE4uXXOtdumcI9l5wC7gnO27D0oihdom+QmNCBX 4PeApzIuHbkPMGs5Vk8Nz1ci1xz1vrbQG4Gjnq0u1OjkkOcLuP/NPJzoIxmQnHzU2HqP 5wGl4dAz17wuFImpA10hVxBbcBXjPNpSH+8DwQzou7OmEItKzjrA2kfJclzVRm2cH/0M 5Ky0jViAz8LrUn8a3Y7zPUxJmxp41VGaU+gZF2E8/WXZMe6RgQ7huDfMm9uAhAIC8LNS 2p3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c+XsfJcpBAH8croteMv6Er6rAN5b3b1fxSc8BZAh+/k=; b=A5Xxz8NtFGl+gtUYd0Qf6tIWUxC71FcFEPfHgGb7Ri2lQ8LI/Uy9efuP0kC3Byi2L8 uLcSinyb1nTF0hHP1Lyswhi8sqQe4fNSGZjSzTDVRLFRbdIhN3DXjwaJG8Jdpd26mqAl O1IsEh1O8ahAAanR8nJ02MfF9rKA4Q+yVSNzK+0upesWEYH8NbNDGtIKYXNsRcDqRY9I wtf5s9j7FihQR6CUZvFCXKTmJYleYnFunM1iBF4ydVIFVDsIJhnPV2H6rtkE1Opbyxus A8Cpzjl9nUVg3hnG9xRZxrcKdkLb4UrDnqd464RqLut04Si1ydeDOOthdGWZc7JDXcxd nwFw== X-Gm-Message-State: AOAM5323Kchs3QBHLfQg+qrR9HDfxWjqB22wiS6cvzG3e+d3m6SKtqUi eEZfTWRnqvjFVBz1t/Ceyblp6PkH2AOnCAcv X-Google-Smtp-Source: ABdhPJw1zcuhha+auddrSKtuUIwlwUKzqkWZb4419Bpmt6zhRt6b98DAQxceaIKVIVE3GIlejAkFFw== X-Received: by 2002:aa7:9634:: with SMTP id r20mr10191154pfg.57.1644543157905; Thu, 10 Feb 2022 17:32:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/34] tcg/mips: Support unaligned access for softmmu Date: Fri, 11 Feb 2022 12:30:50 +1100 Message-Id: <20220211013059.17994-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::436 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644545019678100001 We can use the routines just added for user-only to emit unaligned accesses in softmmu mode too. Tested-by: Jiaxun Yang Reviewed-by: Jiaxun Yang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c.inc | 91 ++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index 2c94ac2ed6..993149d18a 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1134,8 +1134,10 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg b= ase, TCGReg addrl, tcg_insn_unit *label_ptr[2], bool is_load) { MemOp opc =3D get_memop(oi); - unsigned s_bits =3D opc & MO_SIZE; unsigned a_bits =3D get_alignment_bits(opc); + unsigned s_bits =3D opc & MO_SIZE; + unsigned a_mask =3D (1 << a_bits) - 1; + unsigned s_mask =3D (1 << s_bits) - 1; int mem_index =3D get_mmuidx(oi); int fast_off =3D TLB_MASK_TABLE_OFS(mem_index); int mask_off =3D fast_off + offsetof(CPUTLBDescFast, mask); @@ -1143,7 +1145,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg ba= se, TCGReg addrl, int add_off =3D offsetof(CPUTLBEntry, addend); int cmp_off =3D (is_load ? offsetof(CPUTLBEntry, addr_read) : offsetof(CPUTLBEntry, addr_write)); - target_ulong mask; + target_ulong tlb_mask; =20 /* Load tlb_mask[mmu_idx] and tlb_table[mmu_idx]. */ tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP0, TCG_AREG0, mask_off); @@ -1157,27 +1159,13 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg = base, TCGReg addrl, /* Add the tlb_table pointer, creating the CPUTLBEntry address in TMP3= . */ tcg_out_opc_reg(s, ALIAS_PADD, TCG_TMP3, TCG_TMP3, TCG_TMP1); =20 - /* We don't currently support unaligned accesses. - We could do so with mips32r6. */ - if (a_bits < s_bits) { - a_bits =3D s_bits; - } - - /* Mask the page bits, keeping the alignment bits to compare against. = */ - mask =3D (target_ulong)TARGET_PAGE_MASK | ((1 << a_bits) - 1); - /* Load the (low-half) tlb comparator. */ if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); - tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, mask); + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + LO_OFF); } else { tcg_out_ldst(s, (TARGET_LONG_BITS =3D=3D 64 ? OPC_LD : TCG_TARGET_REG_BITS =3D=3D 64 ? OPC_LWU : OPC_L= W), TCG_TMP0, TCG_TMP3, cmp_off); - tcg_out_movi(s, TCG_TYPE_TL, TCG_TMP1, mask); - /* No second compare is required here; - load the tlb addend for the fast path. */ - tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); } =20 /* Zero extend a 32-bit guest address for a 64-bit host. */ @@ -1185,7 +1173,25 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg b= ase, TCGReg addrl, tcg_out_ext32u(s, base, addrl); addrl =3D base; } - tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); + + /* + * Mask the page bits, keeping the alignment bits to compare against. + * For unaligned accesses, compare against the end of the access to + * verify that it does not cross a page boundary. + */ + tlb_mask =3D (target_ulong)TARGET_PAGE_MASK | a_mask; + tcg_out_movi(s, TCG_TYPE_I32, TCG_TMP1, tlb_mask); + if (a_mask >=3D s_mask) { + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, addrl); + } else { + tcg_out_opc_imm(s, ALIAS_PADDI, TCG_TMP2, addrl, s_mask - a_mask); + tcg_out_opc_reg(s, OPC_AND, TCG_TMP1, TCG_TMP1, TCG_TMP2); + } + + if (TCG_TARGET_REG_BITS >=3D TARGET_LONG_BITS) { + /* Load the tlb addend for the fast path. */ + tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); + } =20 label_ptr[0] =3D s->code_ptr; tcg_out_opc_br(s, OPC_BNE, TCG_TMP1, TCG_TMP0); @@ -1193,7 +1199,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg ba= se, TCGReg addrl, /* Load and test the high half tlb comparator. */ if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { /* delay slot */ - tcg_out_ld(s, TCG_TYPE_I32, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); + tcg_out_ldst(s, OPC_LW, TCG_TMP0, TCG_TMP3, cmp_off + HI_OFF); =20 /* Load the tlb addend for the fast path. */ tcg_out_ld(s, TCG_TYPE_PTR, TCG_TMP2, TCG_TMP3, add_off); @@ -1515,8 +1521,7 @@ static void tcg_out_qemu_ld_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, } } =20 -static void __attribute__((unused)) -tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, +static void tcg_out_qemu_ld_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc, bool is_64) { const MIPSInsn lw1 =3D MIPS_BE ? OPC_LWL : OPC_LWR; @@ -1645,8 +1650,8 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; #else - unsigned a_bits, s_bits; #endif + unsigned a_bits, s_bits; TCGReg base =3D TCG_REG_A0; =20 data_regl =3D *args++; @@ -1655,10 +1660,20 @@ static void tcg_out_qemu_ld(TCGContext *s, const TC= GArg *args, bool is_64) addr_regh =3D (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); oi =3D *args++; opc =3D get_memop(oi); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; =20 + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 1); - tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + if (use_mips32r6_instructions || a_bits >=3D s_bits) { + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + } else { + tcg_out_qemu_ld_unalign(s, data_regl, data_regh, base, opc, is_64); + } add_qemu_ldst_label(s, 1, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, @@ -1675,12 +1690,6 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - a_bits =3D get_alignment_bits(opc); - s_bits =3D opc & MO_SIZE; - /* - * R6 removes the left/right instructions but requires the - * system to support misaligned memory accesses. - */ if (use_mips32r6_instructions) { if (a_bits) { tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); @@ -1760,8 +1769,7 @@ static void tcg_out_qemu_st_direct(TCGContext *s, TCG= Reg lo, TCGReg hi, } } =20 -static void __attribute__((unused)) -tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, +static void tcg_out_qemu_st_unalign(TCGContext *s, TCGReg lo, TCGReg hi, TCGReg base, MemOp opc) { const MIPSInsn sw1 =3D MIPS_BE ? OPC_SWL : OPC_SWR; @@ -1841,9 +1849,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) MemOp opc; #if defined(CONFIG_SOFTMMU) tcg_insn_unit *label_ptr[2]; -#else - unsigned a_bits, s_bits; #endif + unsigned a_bits, s_bits; TCGReg base =3D TCG_REG_A0; =20 data_regl =3D *args++; @@ -1852,10 +1859,20 @@ static void tcg_out_qemu_st(TCGContext *s, const TC= GArg *args, bool is_64) addr_regh =3D (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); oi =3D *args++; opc =3D get_memop(oi); + a_bits =3D get_alignment_bits(opc); + s_bits =3D opc & MO_SIZE; =20 + /* + * R6 removes the left/right instructions but requires the + * system to support misaligned memory accesses. + */ #if defined(CONFIG_SOFTMMU) tcg_out_tlb_load(s, base, addr_regl, addr_regh, oi, label_ptr, 0); - tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + if (use_mips32r6_instructions || a_bits >=3D s_bits) { + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + } else { + tcg_out_qemu_st_unalign(s, data_regl, data_regh, base, opc); + } add_qemu_ldst_label(s, 0, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, @@ -1872,12 +1889,6 @@ static void tcg_out_qemu_st(TCGContext *s, const TCG= Arg *args, bool is_64) } else { tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_GUEST_BASE_REG, addr_regl= ); } - a_bits =3D get_alignment_bits(opc); - s_bits =3D opc & MO_SIZE; - /* - * R6 removes the left/right instructions but requires the - * system to support misaligned memory accesses. - */ if (use_mips32r6_instructions) { if (a_bits) { tcg_out_test_alignment(s, true, addr_regl, addr_regh, a_bits); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545504; cv=none; d=zohomail.com; s=zohoarc; b=a59dTHFuP3YCkfd5q1eR7ZmQsKLcpBzDS19MaNrnnGSCyFO99yMxP1dESDn4jMiEMhhl2tGKinuTaixszc/yoAp4XlxtwzL1IfJJC2y+Du/xYZmZAF/+shbLgUnod+eEvPpSON0/RZeYq9phGFXIVHDjPpZ1MhgApSM0SwOPPTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545504; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rj8W15BjEs983VZ+OaZ4835OoWsx8SmAf3ewHrqpkEo=; b=mcg3n/mzWykNXBfXmNwFlO0vjU0qg6LHgCyECLmMWuUxV8SgXKUe/Hq0T1HAyVuFt9USVs7DfFpM1FOhT0CbdtYeKZxRXLX4FR3pkOp+UK+qC76eprJKBpZVsYNF9XC4A1NfCxPzPt22fnxfp1KjlkTGmiaNvKYOHjhMcvZE/EY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545504540609.5972120375737; Thu, 10 Feb 2022 18:11:44 -0800 (PST) Received: from localhost ([::1]:36874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILPT-0006Bd-Gv for importer@patchew.org; Thu, 10 Feb 2022 21:11:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo8-0005eL-Jq for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:08 -0500 Received: from [2607:f8b0:4864:20::434] (port=39462 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007T6-Bg for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:08 -0500 Received: by mail-pf1-x434.google.com with SMTP id r19so13491444pfh.6 for ; Thu, 10 Feb 2022 17:32:41 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rj8W15BjEs983VZ+OaZ4835OoWsx8SmAf3ewHrqpkEo=; b=TYGBkuTpEYJeli4FLcOtfJkSRpNdSPHecF57q5No1deUH2XbzYRNhglHazkJm+0BAZ wSHa1sqOmv/of+zg8/5ZY2Mz/xs29rZ75vOYu8yMpO9SfQE6ENO4e+ZMkAXkwGRKkVrb TksolYlWJOjuRONHh4X0Rx3pWkaL/ad9w0vhb/oK5ug650y1AuQPyxJItmqFY9iAysHS Hypg6jMY22SkhqyXCtRKm6eXe9p9lNKyd8qRkT3hnsFOYCF/0st2Xudi3Rl5SD/O4RQd vaPyfjA+rA33wGN0PgUFgXxmFh5BeubeN602IeDkE4f6LGxcarDsgBfln+G8z+ouf2/z GqXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rj8W15BjEs983VZ+OaZ4835OoWsx8SmAf3ewHrqpkEo=; b=MvHbi8C7BLjNL6zAA3FEVnzfsKGTGC/wvdK+6aChzN72NSwC5n7EEgmpLdolsocc6R /tjLYQ50t7nZsJn4wTBg+3XFcjkNTvQkY6vIUiTeeUAjoETTkxQFAY2YVDIPSI2JStbQ vBhMXrTxcHbxlUKbX4Ipn3nM1x/OL3vvJ/ehwylfBKoVfkASC1dHxMhnbKpfM1ZbJFn8 ESdhxBzrPw9zE2ggerLxYA6vw2YnPXCdktmL1OmyoWsnkp2w3wFC8HAUahdlGn0ck7an UUpD67ZG8/XXJiNEOdMyWbXmS7JfWyz0hcGtlEaAq0FJ1Pl8qlX6IKwzQVetBnIm8+5x OHcA== X-Gm-Message-State: AOAM5325eK7Fuin9XRyUqNrBaCtvFTqCg73Cz+Gh6XBPHLZ8LlKxHmle UlUdbag86ANzG0wRn+zQcZK7qyPB9OHEISJZ X-Google-Smtp-Source: ABdhPJxL3rXi0+ZtDjCfp9Z0hTvJ7jlhiwy4Me0GI2Q8FYqbL76pwzJ3n0bKBZ3tJ5xW07zS0VUGGw== X-Received: by 2002:a05:6a00:130a:: with SMTP id j10mr10176584pfu.32.1644543160704; Thu, 10 Feb 2022 17:32:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/34] tcg/sparc: Use tcg_out_movi_imm13 in tcg_out_addsub2_i64 Date: Fri, 11 Feb 2022 12:30:51 +1100 Message-Id: <20220211013059.17994-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545505926100001 Content-Type: text/plain; charset="utf-8" When BH is constant, it is constrained to 11 bits for use in MOVCC. For the cases in which we must load the constant BH into a register, we do not need the full logic of tcg_out_movi; we can use the simpler function for emitting a 13 bit constant. This eliminates the only case in which TCG_REG_T2 was passed to tcg_out_movi, which will shortly become invalid. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 0c062c60eb..8d5992ef29 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -795,7 +795,7 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg r= l, TCGReg rh, if (use_vis3_instructions && !is_sub) { /* Note that ADDXC doesn't accept immediates. */ if (bhconst && bh !=3D 0) { - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh); + tcg_out_movi_imm13(s, TCG_REG_T2, bh); bh =3D TCG_REG_T2; } tcg_out_arith(s, rh, ah, bh, ARITH_ADDXC); @@ -811,9 +811,13 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg = rl, TCGReg rh, tcg_out_movcc(s, TCG_COND_GEU, MOVCC_XCC, rh, ah, 0); } } else { - /* Otherwise adjust BH as if there is carry into T2 ... */ + /* + * Otherwise adjust BH as if there is carry into T2. + * Note that constant BH is constrained to 11 bits for the MOVCC, + * so the adjustment fits 12 bits. + */ if (bhconst) { - tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_T2, bh + (is_sub ? -1 : = 1)); + tcg_out_movi_imm13(s, TCG_REG_T2, bh + (is_sub ? -1 : 1)); } else { tcg_out_arithi(s, TCG_REG_T2, bh, 1, is_sub ? ARITH_SUB : ARITH_ADD); --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545197; cv=none; d=zohomail.com; s=zohoarc; b=m8Ml1/fqyDkqW+8pqEy3D0EKqJml3mtiZzL9ClNz9Z9HsYTbcIewoylREEHucoUEKSV5/X1XIoRnll66CN+T1oSXl3bH5LXD5g66FxT00wPLdntFw9Qrn094+Mwi0TFZbcXisPk1P9tOujKDdCy4L41aoFPovE8s2w20WB7n4RQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545197; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=ZwW7xYCaHrBoPUCl+b7nlx5uSUVBbI6PslZNuPGpS18br3Ze5+gjrmRa5ftOaUPsZb0tB49OI20CvAVlwpKqyCHiRn2XQmP1/QLkH3/k2h0d+DP2LWnE9YIohO/xNoLOsrlakRKvoygHV3fPxwCOrOnR3YSZ7yIZG1Fre3T8Njk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545197440939.1515955653804; Thu, 10 Feb 2022 18:06:37 -0800 (PST) Received: from localhost ([::1]:54948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILKW-0007Ri-Dg for importer@patchew.org; Thu, 10 Feb 2022 21:06:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo6-0005Uh-Ik for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: from [2607:f8b0:4864:20::102a] (port=50721 helo=mail-pj1-x102a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnz-0007TV-Ca for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: by mail-pj1-x102a.google.com with SMTP id m7so6793928pjk.0 for ; Thu, 10 Feb 2022 17:32:44 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=B9GCi5THLac5y9J1TUd45HvlxD2Tr6LPbXYWHjkP7XcyBp/c5v65PAiTv6TzZkcjki EVoLQKrSUc1kAmdT3l37lHOSmlZs55+UP73wVFaxDCjICLVUy/WEJVF8WAoK1EBMivj6 N28tfiX7ceE1tDeKi3y035mT2YQCNicam1IP+pPU5InUSxoO+h2jMTIRj+yG8ktfYBPc usG8Nxv/11Y3MWkFYB5+MqcUoPeOFRElvfodR7cUX36Rg/slYIyra9A6BT5UVQ30W7Od GjnwZj1pa3ZoYPbuGguqg1kENvG0wADtPq5vqWvTQNKCRZlYxAB9YYTL+KzksbWgmOoG XZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gnA8hzIESQl5O1aIfCztJlw8cTUepzPhnQX56XahBLg=; b=ns8/y3tg9JNEc6mLYonyCoR4fraRvY6UcISTx/HwyNiLbCAGRg+VoZy8Ps8nsg7EOI pu3+xa7TC+GL78Mzo6Q6Vr17WRDkwiRlSTIaPc8/a1Swuw3uYzbVkcm99nbEK0KZMXrf f3wICZBuDw33vCU2eGwaxaPw/nw60Abf48yyNoP26p2vikTbzPacfkmCjOshTZUGS4jy Lz6AJrvd6gDWXBGgMBVbQ6SAYmNzdMp34VZDkVfMbVLi2LnE2AlyOdVbnJfwNTEkW9Jo fdNEnCLh3Lrt04dXj12tDPA9bqYX413misfDO+oETRqWSp9OLB2k8I7zuE0NO1jOPZkX OQ9Q== X-Gm-Message-State: AOAM531pqzyLkLw8r1QzPkC26pnGaMwDzxI9fto47ScdYSHFokLY4lGr wDKNu9L0puKtkNlw74GPaYRLApjFzoy+/w4H X-Google-Smtp-Source: ABdhPJzha7Z7vuKaleBpI/k7GSeDZUdIh+7qr7ugcYHosvsoSD3Ejyqca0aDg63Dj+SAZy6sQAxJbw== X-Received: by 2002:a17:902:8609:: with SMTP id f9mr9949638plo.80.1644543163026; Thu, 10 Feb 2022 17:32:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/34] tcg/sparc: Split out tcg_out_movi_imm32 Date: Fri, 11 Feb 2022 12:30:52 +1100 Message-Id: <20220211013059.17994-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::102a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545198248100003 Content-Type: text/plain; charset="utf-8" Handle 32-bit constants with a separate function, so that tcg_out_movi_int does not need to recurse. This slightly rearranges the order of tests for small constants, but produces the same output. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 8d5992ef29..2f7c8dcb0a 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -413,15 +413,30 @@ static void tcg_out_movi_imm13(TCGContext *s, TCGReg = ret, int32_t arg) tcg_out_arithi(s, ret, TCG_REG_G0, arg, ARITH_OR); } =20 +static void tcg_out_movi_imm32(TCGContext *s, TCGReg ret, int32_t arg) +{ + if (check_fit_i32(arg, 13)) { + /* A 13-bit constant sign-extended to 64-bits. */ + tcg_out_movi_imm13(s, ret, arg); + } else { + /* A 32-bit constant zero-extended to 64 bits. */ + tcg_out_sethi(s, ret, arg); + if (arg & 0x3ff) { + tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); + } + } +} + static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg, bool in_prologue) { tcg_target_long hi, lo =3D (int32_t)arg; tcg_target_long test, lsb; =20 - /* Make sure we test 32-bit constants for imm13 properly. */ - if (type =3D=3D TCG_TYPE_I32) { - arg =3D lo; + /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ + if (type =3D=3D TCG_TYPE_I32 || arg =3D=3D (uint32_t)arg) { + tcg_out_movi_imm32(s, ret, arg); + return; } =20 /* A 13-bit constant sign-extended to 64-bits. */ @@ -439,15 +454,6 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, } } =20 - /* A 32-bit constant, or 32-bit zero-extended to 64-bits. */ - if (type =3D=3D TCG_TYPE_I32 || arg =3D=3D (uint32_t)arg) { - tcg_out_sethi(s, ret, arg); - if (arg & 0x3ff) { - tcg_out_arithi(s, ret, ret, arg & 0x3ff, ARITH_OR); - } - return; - } - /* A 32-bit constant sign-extended to 64-bits. */ if (arg =3D=3D lo) { tcg_out_sethi(s, ret, ~arg); @@ -471,13 +477,13 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, /* A 64-bit constant decomposed into 2 32-bit pieces. */ if (check_fit_i32(lo, 13)) { hi =3D (arg - lo) >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); + tcg_out_movi_imm32(s, ret, hi); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arithi(s, ret, ret, lo, ARITH_ADD); } else { hi =3D arg >> 32; - tcg_out_movi(s, TCG_TYPE_I32, ret, hi); - tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T2, lo); + tcg_out_movi_imm32(s, ret, hi); + tcg_out_movi_imm32(s, TCG_REG_T2, lo); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); } --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545360; cv=none; d=zohomail.com; s=zohoarc; b=PGAi6sQ5s8j/oxSZXjZ32elXNg3Q5U8Bd0zMThYwXYsN/YHlaFL5PtZB2YLTw6ufWcPCK+8ehNODSxup58n+vCSsAgwJmGpgZwTS+rEReXYkPeed8BVLdDFWDKsTMpGeLQxg54oRHALBY9If6fF6hBop3k9+fHoU6ql91pTIm5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545360; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6gT0loTTikTyP62uuClYFZJH9vRBsPpRKE1y+i3/wdg=; b=bEQtlrGGuEYbnV8tPFjOolirK35RGSRg3wap1b3AZrvIauWAVVzwtHMgUEVgCOVdtyo5IV0xpmBGPgVqOfx9NCzZaIBzGackFEVdzdJIy2KIBq6jDJahJxj0aNqfO40Wn9ftTIa+iN5U0Ux4D6oSHudLkoHWjaYrlHbN7bIyY38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545360770399.34257007413305; Thu, 10 Feb 2022 18:09:20 -0800 (PST) Received: from localhost ([::1]:60854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILN9-0003Dd-Hb for importer@patchew.org; Thu, 10 Feb 2022 21:09:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo6-0005Sz-3Y for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: from [2607:f8b0:4864:20::42d] (port=46008 helo=mail-pf1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKnz-0007Tj-CT for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:05 -0500 Received: by mail-pf1-x42d.google.com with SMTP id 9so10601489pfx.12 for ; Thu, 10 Feb 2022 17:32:46 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6gT0loTTikTyP62uuClYFZJH9vRBsPpRKE1y+i3/wdg=; b=BsuUbaQLM8NeBTan1cTZznV/P+3CR+Y6Ymphp4h+sekgf+ttt0utJncGD1VHAiCwju 6ca0xEIXcbzbcRQh7ITHGxCqq+JjyGQerHOT/4cUIdgYNwad/nvWAQ554vLGaG6DiXge U9SGICYgBrLKG4rk8t8/Vv718q6z/Rzl0KnF53OXJfqJY7eYAExsMULekSaGmfBspvyb nWpcZQ/V01VUWkZC1sDzgs22XJwH898rBWUx8w3eflUdtR3I8o4O71yIAWvxu6ESeZvh vhd0ZDp1Avz3Fmy0m93aA4OQ+TECbXBmix8S1TGDA2ucluQSkMZ9y0lVATUK/MB4j59H shew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6gT0loTTikTyP62uuClYFZJH9vRBsPpRKE1y+i3/wdg=; b=DiUXvNNv4wtclngYU+jhskodyKs/lsJ/x5Ju+Vn83ef81KlUbmv8aHOkkQTri5dawU UHXLeC+zNbdWpHqaO4eIsC4pOqDwOMMPsv5OSbw0tvpJNoohoBvPKB/l+NtxdBzKAxBW X9qVIeE09MeofFkZbusuvOpkp0D3NrbsnzfNX/YV510Zpz4UNUoEXkPAVal3GXUgBTBY pJcqhdW5dWHcSURKMplIUqBOrN5RCe6T2N+YzoVdFDBMK8h3RJQMLPQzQGc1NXGm3YBa vCs+M8/a7xF5nFkd5haOKUo13zq0fNv1Yq+tSYChgawi24BoDF3mYDCuXjDmIdy9kHYI 4AUA== X-Gm-Message-State: AOAM532XcSGLJ+SmHQCGRrKhDoNu9XGg2bSctOuOsZIN8qERxKwgkd6M Uz1YsE7MySvJ0LkXIeOXB2LFgnybM60YIVHD X-Google-Smtp-Source: ABdhPJzAW8QLKeQf/2EET0IbcrxMhrByZQWNEe1vNgIKQbjHCvHgHirdC7aA+mgAIUNV0EzF/ltQCQ== X-Received: by 2002:aa7:8c0b:: with SMTP id c11mr10255201pfd.62.1644543165187; Thu, 10 Feb 2022 17:32:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 28/34] tcg/sparc: Add scratch argument to tcg_out_movi_int Date: Fri, 11 Feb 2022 12:30:53 +1100 Message-Id: <20220211013059.17994-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545361774100002 Content-Type: text/plain; charset="utf-8" This will allow us to control exactly what scratch register is used for loading the constant. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 2f7c8dcb0a..7a8f20ee9a 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -428,7 +428,8 @@ static void tcg_out_movi_imm32(TCGContext *s, TCGReg re= t, int32_t arg) } =20 static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret, - tcg_target_long arg, bool in_prologue) + tcg_target_long arg, bool in_prologue, + TCGReg scratch) { tcg_target_long hi, lo =3D (int32_t)arg; tcg_target_long test, lsb; @@ -483,16 +484,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, } else { hi =3D arg >> 32; tcg_out_movi_imm32(s, ret, hi); - tcg_out_movi_imm32(s, TCG_REG_T2, lo); + tcg_out_movi_imm32(s, scratch, lo); tcg_out_arithi(s, ret, ret, 32, SHIFT_SLLX); - tcg_out_arith(s, ret, ret, TCG_REG_T2, ARITH_OR); + tcg_out_arith(s, ret, ret, scratch, ARITH_OR); } } =20 static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg) { - tcg_out_movi_int(s, type, ret, arg, false); + tcg_debug_assert(ret !=3D TCG_REG_T2); + tcg_out_movi_int(s, type, ret, arg, false, TCG_REG_T2); } =20 static void tcg_out_ldst_rr(TCGContext *s, TCGReg data, TCGReg a1, @@ -847,7 +849,7 @@ static void tcg_out_call_nodelay(TCGContext *s, const t= cg_insn_unit *dest, } else { uintptr_t desti =3D (uintptr_t)dest; tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, - desti & ~0xfff, in_prologue); + desti & ~0xfff, in_prologue, TCG_REG_O7); tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); } } @@ -1023,7 +1025,8 @@ static void tcg_target_qemu_prologue(TCGContext *s) =20 #ifndef CONFIG_SOFTMMU if (guest_base !=3D 0) { - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base, = true); + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, + guest_base, true, TCG_REG_T1); tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); } #endif --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544405; cv=none; d=zohomail.com; s=zohoarc; b=nv/zBJlPiayifEMQFWbbtnKsIc7SCodV32EYYeIFVu+EoTXguhCmtpPvhZjBq3slXTAwTB9CVqFFi2gnyvUUs9pGACgvSjnv/rSysz2mqoU8XhcJXC+E0Ttfme0d6gkmoBIbizr7w6pxPpPjdaU2qVnC1iNzu1MZFjS4rI7nJkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544405; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=ggWKC2Yuj8F5a2yo2cuQRJsQtNOoMf2xvFb8ZLCkuuefX67hN+5GEVgBhUURe+4AR9Z6sfvLhYtSaATY2NLp5dH5nGdvz12wav7/Kyx04l8LjXyQETPXYTLVuXH9iCcExSwmKAg4uMnJIoyOWXkheWzdljv21fSPfVGuZPuEW58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544405302129.97231345349917; Thu, 10 Feb 2022 17:53:25 -0800 (PST) Received: from localhost ([::1]:56630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIL7k-0005rb-11 for importer@patchew.org; Thu, 10 Feb 2022 20:53:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo6-0005Uk-Ig for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: from [2607:f8b0:4864:20::434] (port=43562 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007Tx-2h for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: by mail-pf1-x434.google.com with SMTP id d187so13456910pfa.10 for ; Thu, 10 Feb 2022 17:32:48 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=UlIlf16oOuJoFR0t7BqFNOP/xcfHzdiK9LLvSkxBjqbjQkUN4WW2ZkWpgx2HlULufB 35ZEQATtQOUmjGSRvmLgBvSWPi+DboIMj53FAJqk4TRC57V5NxBSajW/vek85vlhA0QJ UOlqpp615uwKCaGJeApPHkIgLJX7WjO+9SQh5nDr6krJC5Pezhuvsb1BRh2ds4Q6cfez FGZwztoNYnZEdI5DVOgbtrsxpmezgOUfU4MQFwK5qu65t12oyM2qUNwlMH1lYc+2YAlB Wa0x9WRdflGMXS1O2VqrRsS4YbiYgvTSlFt98XeUXUSeWBzrTcbhTXf8W27WTLsg90cP ipew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i9IlxASYWdMKhZxsDfqVFvhQfn78zXXAMRB1dUwXGuQ=; b=IhxkulpgfhUsiqws6sMElSoq5bSN88ItMNIiVujT5VWMmtvkZ5dhrhQag8WjCYrNb+ X8HAQP7IXI+02ktdlrxLMRwecywQrBRdNUfeXOgtaXW/jiC9zrDy3s3bxOv6QI0Nzwg0 UnAu1RIjJ0XZvWSkWWUXsn6IkeO+OF5QTrKFSPQvhY1udlgLb0cAPw9HJMPx2XDkMe9Z 9HaRkgr651ZhD1gJGxbQhOprKaeGFU/J7UqHrI1rlvYkdOXCB9S1RIJHI2XRafufmTOz IgVc644Ddxd15BRvLy/YEgzwDpo004p58Hdylx8ndXZIBbJmw5Hg8p/H7lYMbfDHDFkt DiNg== X-Gm-Message-State: AOAM530WyUuLnlruW1BQPZv28e8Aa9choNqCGh9lu9rh2BAOXS4JAofu ZUgcCO48tFMMMPG5aHUc8Q9LXmp09ajG5aja X-Google-Smtp-Source: ABdhPJwYjMsuT6Ny8dNL9xh0xSXI+tetECsG1bPKTaDuFaHhPfMheWaHkJi896uUzUgtYw8ZVLyMJQ== X-Received: by 2002:a62:1ace:: with SMTP id a197mr10230551pfa.63.1644543167626; Thu, 10 Feb 2022 17:32:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/34] tcg/sparc: Improve code gen for shifted 32-bit constants Date: Fri, 11 Feb 2022 12:30:54 +1100 Message-Id: <20220211013059.17994-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544407343100001 We had code for checking for 13 and 21-bit shifted constants, but we can do better and allow 32-bit shifted constants. This is still 2 insns shorter than the full 64-bit sequence. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 7a8f20ee9a..ed2f4ecc40 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -462,17 +462,17 @@ static void tcg_out_movi_int(TCGContext *s, TCGType t= ype, TCGReg ret, return; } =20 - /* A 21-bit constant, shifted. */ + /* A 32-bit constant, shifted. */ lsb =3D ctz64(arg); test =3D (tcg_target_long)arg >> lsb; - if (check_fit_tl(test, 13)) { - tcg_out_movi_imm13(s, ret, test); - tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); - return; - } else if (lsb > 10 && test =3D=3D extract64(test, 0, 21)) { + if (lsb > 10 && test =3D=3D extract64(test, 0, 21)) { tcg_out_sethi(s, ret, test << 10); tcg_out_arithi(s, ret, ret, lsb - 10, SHIFT_SLLX); return; + } else if (test =3D=3D (uint32_t)test || test =3D=3D (int32_t)test) { + tcg_out_movi_int(s, TCG_TYPE_I64, ret, test, in_prologue, scratch); + tcg_out_arithi(s, ret, ret, lsb, SHIFT_SLLX); + return; } =20 /* A 64-bit constant decomposed into 2 32-bit pieces. */ --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545359; cv=none; d=zohomail.com; s=zohoarc; b=TpyxmyrjYYsE25VJBfN+qJtmOHdtyt7AnEgLE5xPeYgO5ad5/kRhv0UIEWXNfDJHPPEL5BX0Sp7sEUr8DBEsI0HkgpGZnQvhF/+Ort4Vj0ach7I5u++kz4jaJV7NGRE3YTTpI5GeV0eCtuNEapzLAD6TJtYxkGFxJ0zmBfzbQsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545359; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3FHMimKJDAjCiqHF0GBMwwzERJvWjLvoPgPfQf5aE2U=; b=bBnWUf59M2531wBOpiUGCwMj5amUu94O+19nZJsLQk8Kk0lW7eIjItTYnK0dsUF2Dohx9fk2fqckyiUte8vm8bfWHXnMOeVzxG9Rimb6Pew9x75LhkTVHlg5ydrJsuqNCVTrCoROqOuGHhCK38DllRDvG2GntrIuxMfQu+8uD7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545359221356.3470355009682; Thu, 10 Feb 2022 18:09:19 -0800 (PST) Received: from localhost ([::1]:60740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILN8-00039P-Qk for importer@patchew.org; Thu, 10 Feb 2022 21:09:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo8-0005bk-3c for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:08 -0500 Received: from [2607:f8b0:4864:20::432] (port=40612 helo=mail-pf1-x432.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007UX-7m for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:07 -0500 Received: by mail-pf1-x432.google.com with SMTP id a39so12647135pfx.7 for ; Thu, 10 Feb 2022 17:32:51 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3FHMimKJDAjCiqHF0GBMwwzERJvWjLvoPgPfQf5aE2U=; b=RiK+VUYBfa5MQUdW/sVybmNEcSNE+5IcPnASLfpYooEY+CKhLOoMUvDZ/d7UBcY8Ck NTD5Bw3VDizz48EgQ7HYeopV8SHYVOz5KJHZTIAWJLm/rWHnvCuOFZpA5AbDe1OzeI6b UQJSxwkmdTuzrZnkojL7TbMPw+p5a0AzAGnTCcT+83U/Jh36YeO1pfsEfUgYEwFA5fIF 2f4BvXAutGXbUGkdICTQLnr1h4c7Qh4P22dO5Paurq4nh3Ts/Fzujhd85TytsSY9wb62 09iNvYytI91BzdE+51mZ/WKW401KHv6ZDvKS3JUfWsHQG5tP2ul5qP0mmErLJebrkEpE KspQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3FHMimKJDAjCiqHF0GBMwwzERJvWjLvoPgPfQf5aE2U=; b=8HyamBUf3cIk3XCCTxszY6X3hOYHPKvH/1nF1TED2Tdkwj5/OoRjAN/exsNswMvGQk vrjwEVgcKDSnsC8QZIgDup6FgKLfuAyQ51OZDOMEfwQEiC2R2C5VKW+ESyDT7Z3twy1W NFM5Vj/UCC7U7ru1zsv7kg7H1cW7eDS3ACwqa/clpo8oE+7ye/GvraCyQdTEp9K88TIi CLjdHBttzMF2+tl2bv/hbSfYVs4/3UgFTKa6pucjuGDsA/ipQ9Z5R/XO/ywcTSafTa46 WQXRlJBwhISuLaLVsT5UdMYnypF7NXZxZcNXnTGfMBczzYEBAu8igI0BGuUB1nvpVfI7 0hQA== X-Gm-Message-State: AOAM532v+QblUD2d6Dy1Bicklb5YU+6bgFgU8I30HrbLt/gQIvBEYs1z LzVVS5QRIKEhLA/ixgimZt1ji0G8j92kBGxO X-Google-Smtp-Source: ABdhPJxWxKjErDO5S7xGrHLCLYzc8QDNYuxdLKx1RDod02Q0L3vaAadFT2MapYU8y38zvznaBzdr2g== X-Received: by 2002:a05:6a00:198f:: with SMTP id d15mr10261245pfl.78.1644543170839; Thu, 10 Feb 2022 17:32:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/34] tcg/sparc: Convert patch_reloc to return bool Date: Fri, 11 Feb 2022 12:30:55 +1100 Message-Id: <20220211013059.17994-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::432 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545361771100001 Since 7ecd02a06f8, if patch_reloc fails we restart translation with a smaller TB. SPARC had its function signature changed, but not the logic. Replace assert with return false. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index ed2f4ecc40..213aba4be6 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -323,12 +323,16 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int ty= pe, =20 switch (type) { case R_SPARC_WDISP16: - assert(check_fit_ptr(pcrel >> 2, 16)); + if (!check_fit_ptr(pcrel >> 2, 16)) { + return false; + } insn &=3D ~INSN_OFF16(-1); insn |=3D INSN_OFF16(pcrel); break; case R_SPARC_WDISP19: - assert(check_fit_ptr(pcrel >> 2, 19)); + if (!check_fit_ptr(pcrel >> 2, 19)) { + return false; + } insn &=3D ~INSN_OFF19(-1); insn |=3D INSN_OFF19(pcrel); break; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544663; cv=none; d=zohomail.com; s=zohoarc; b=T1+73qxjpmM5g9ce+eFEedq24af2IXqJYhjxrN+iG3THSFExbP+2yDELBDKR6K8QDm0tVS+PnoJ4NYOkMZj5NMpBGrwDYnR5DP0O3y1qO07ah1ivUrDEKKqpgXT3pvebdk8HDzsYBPWWYpHF4bY+3DbEpXPSm5lHsIDspTvyTYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544663; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VVgTfM7BfNjQi2pAaP/bo2OPnT/0AIG3Sa126Er0izA=; b=A9rFlBYXR24rWqw1L4sI9gf2y0GPcot5rFFiZsXk9yfwYvF7N9NFwqH0SwzcpbBbYCQfqDSdmgVKgAoAK7RAvKhO7Na+Jbl8fOYcP5KKyz/8sTzVCGJAvUD6Au63ORRbXoXQnTA1PtuS1Qv8Kqm8DeNf8Jp5Q/tb+4FKsPTQTJ8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544663070384.3013942677944; Thu, 10 Feb 2022 17:57:43 -0800 (PST) Received: from localhost ([::1]:36954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILBs-0003Lg-Mp for importer@patchew.org; Thu, 10 Feb 2022 20:57:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo7-0005bF-VT for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:07 -0500 Received: from [2607:f8b0:4864:20::42d] (port=40608 helo=mail-pf1-x42d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007Uv-9S for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:07 -0500 Received: by mail-pf1-x42d.google.com with SMTP id a39so12647303pfx.7 for ; Thu, 10 Feb 2022 17:32:54 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VVgTfM7BfNjQi2pAaP/bo2OPnT/0AIG3Sa126Er0izA=; b=SN9VuGGm31jmL+Sy9XUdGUYAPQ6x2qYmQckKpxwVQLAvcIIVl3fjcq096aiFzfTipq /o05pab5rUkqLNqP5F6ggnxbl8uVLozMdiXDtGe70zmrj09rCddoyRypvDzpJNyuyknQ rYAVlBTzXVOa6SzaOIzgDaswyY+Q/iVsJDQmRvS0FOJg+ZTK/BqNw2L2+bmBU0w64cib 5C3fQjfvu3c7zqyVJJmhf2c8/ISog0DPkGk1z9ar3m4h55180vGDR/JMcKRDyEnAOaJV qV0gk/pYYNyVgnQ1WIN0QPLPDs2qR1I59fddrrYhr7s6iIL8dmnwH7Q9gn5KDTGnbwHe 1XRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VVgTfM7BfNjQi2pAaP/bo2OPnT/0AIG3Sa126Er0izA=; b=NfhG2HucxhvCxoCHKHlnc492A4jaUBcCS0hEQGhC3uaemuV2U/1ndGzjvs6Q1n8ahh Z5OTE5Y6mKMaBDvedDA47wJxgrqbfQ96lqmwlnLEsWgghDrcSdVfMSg231SUrn0zc5AU 37cRLRLLPsN4SY+S2knfm2pKt6o5Hw6L5kh+ysYCr5PQWRfgQmnvymtGaUz/40Gr2o4x SGCKRuiiNt/IGUan/joJ0E6SWCW2vXtiYDe2pD6mLY9FPmWnBv+c2gX780LlR0pFR8nD 7KauNDOZ3mEH3ywOIH5XiHwm0RWPEO+yC+5Vcm2N/+tTKpMETZFZQejhPA8IUgfluUZN U7wg== X-Gm-Message-State: AOAM532jZ9DRBejjT7RTpO7OIyKOyU60+etOPswEPJiQTdhvaM+zD4xB i2emng0B+g1YmXDphXrf6G5hrfB1ANj77IwT X-Google-Smtp-Source: ABdhPJyjjBFft5zZdavkpivRl0pMleQHSDCNOigPSQncUbbE4zle6qMh9QoORbGcML3Ff6RLaq1d0A== X-Received: by 2002:a63:64c:: with SMTP id 73mr4445570pgg.360.1644543173339; Thu, 10 Feb 2022 17:32:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 31/34] tcg/sparc: Use the constant pool for 64-bit constants Date: Fri, 11 Feb 2022 12:30:56 +1100 Message-Id: <20220211013059.17994-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::42d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544664651100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 213aba4be6..e78945d153 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -336,6 +336,13 @@ static bool patch_reloc(tcg_insn_unit *src_rw, int typ= e, insn &=3D ~INSN_OFF19(-1); insn |=3D INSN_OFF19(pcrel); break; + case R_SPARC_13: + if (!check_fit_ptr(value, 13)) { + return false; + } + insn &=3D ~INSN_IMM13(-1); + insn |=3D INSN_IMM13(value); + break; default: g_assert_not_reached(); } @@ -479,6 +486,14 @@ static void tcg_out_movi_int(TCGContext *s, TCGType ty= pe, TCGReg ret, return; } =20 + /* Use the constant pool, if possible. */ + if (!in_prologue && USE_REG_TB) { + new_pool_label(s, arg, R_SPARC_13, s->code_ptr, + tcg_tbrel_diff(s, NULL)); + tcg_out32(s, LDX | INSN_RD(ret) | INSN_RS1(TCG_REG_TB)); + return; + } + /* A 64-bit constant decomposed into 2 32-bit pieces. */ if (check_fit_i32(lo, 13)) { hi =3D (arg - lo) >> 32; --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545550; cv=none; d=zohomail.com; s=zohoarc; b=dbw2fUbTvwb2mAMf6OVoWrAosUTkLXKCpogARJoqKqsfUFN0L/POY9mtQHo9LNuZBCjOvbY/MxU5xpE670ZQtccKssuW+Dy3Vy8dWiaabU06pJ79Kq04rnALx7eH2DytE0rLhbL2ReJCCGY1V/JSwesyuIDH/zg6GRiDEkhonYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545550; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tw347i7UUzkCL2aGKWmeY7B5v0kBuROLRWuELxPT4a8=; b=YuofHtOgNnDtnlVDieaXWIuEbkm34o0v6UyCc9Wp/OcRlK0X3FLwvQK3H05Lx1ODjfaTKOtjoKweoSUhcV3eh9CEW9lA3Tj52ED7cj7+bi+A/WxNEjwwSYyu0mlxflhjiqIfBdOKE88p0Djo0OdQI7K4264D50P4OkwE+KptJ6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545550708353.0057437964098; Thu, 10 Feb 2022 18:12:30 -0800 (PST) Received: from localhost ([::1]:38456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILQD-0007JL-Mm for importer@patchew.org; Thu, 10 Feb 2022 21:12:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo9-0005hA-9e for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:09 -0500 Received: from [2607:f8b0:4864:20::62d] (port=42610 helo=mail-pl1-x62d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007V5-F2 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:08 -0500 Received: by mail-pl1-x62d.google.com with SMTP id z17so3402730plb.9 for ; Thu, 10 Feb 2022 17:32:56 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tw347i7UUzkCL2aGKWmeY7B5v0kBuROLRWuELxPT4a8=; b=cVsgXvF9zkl1aIGHj9csl8mcf3sc6EVEIOdsgdxAYHrYx3gsJxL2SIPHj6svbAOAYR g1/yjOHz4UuvX+AuLTiJK1jS+v9i18X5i4KjCWRuC2MbleE27Ygfcl5CThGXyBPHuid1 5aYoU1jtsNbjJRIYPAYFdXowPODsjaU62wGhIOgPJTi0KV4Ys76bEyJiQ+2ADkKkIwvc SUm3K3AQE+dNWbmErjNytdfVsQ8a45xYW46qYZJMq9+IT2fJppDxtvgvvZG4kggmgQ+9 k5McsFlCR8yAEGloCYSoYG7XlSxueziLW7xDKTqrwX6PoywVC7YECoy8byQOTke1iDWA b+MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tw347i7UUzkCL2aGKWmeY7B5v0kBuROLRWuELxPT4a8=; b=EtkGrlTxeFGa4iMVlPm0Xgh5Oq9AaZXXQOrP1URIr5ve/T0vlTWd05h7oJrreISuv1 7QoD39rSJkSGm5jvtbPVASa/Tgi/DrVk1EnEeADOzuPZbUk8Z5F2PSXsXZE9mNBzbgdB rtTYmJ92jSNzdgnVPkztCcVESNn61NKETq8MxGqU0geL2mxcJjLTaPBjeedk4eVpbyVX 98KpZrNUyiJgEpvfQ0LlEBU2CbylYFEW4UEGbs5QhCiDy3bKE6kv5VqcW6Lz735SohVO Ib6wB3x0OuwEO+eSoX7wc/N4ey4KcDClSNXdWi1Byx3zVrGjwn9ek7garh/50ltDZvE+ zO9g== X-Gm-Message-State: AOAM530GSdfFWxGJ5ZdOfmC7At/Xuow1bg6kYkiC4qFPkx7L4pAhRio8 cp5AGmVhSc9agNl40abZFi+55U1slIonfBms X-Google-Smtp-Source: ABdhPJyjKtJUWudwfylAP85mrMCLh0d4IPKheJkel6YVxOTh6FJ4jZ/Yur9yNCemHB2rmuvtydlWyQ== X-Received: by 2002:a17:902:b90a:: with SMTP id bf10mr10266713plb.36.1644543175639; Thu, 10 Feb 2022 17:32:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 32/34] tcg/sparc: Add tcg_out_jmpl_const for better tail calls Date: Fri, 11 Feb 2022 12:30:57 +1100 Message-Id: <20220211013059.17994-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545551720100001 Content-Type: text/plain; charset="utf-8" Due to mapping changes, we now rarely place the code_gen_buffer near the main executable. Which means that direct calls will now rarely be in range. So, always use indirect calls for tail calls, which allows us to avoid clobbering %o7, and therefore we need not save and restore it. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index e78945d153..646bb462c3 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -858,6 +858,19 @@ static void tcg_out_addsub2_i64(TCGContext *s, TCGReg = rl, TCGReg rh, tcg_out_mov(s, TCG_TYPE_I64, rl, tmp); } =20 +static void tcg_out_jmpl_const(TCGContext *s, const tcg_insn_unit *dest, + bool in_prologue, bool tail_call) +{ + uintptr_t desti =3D (uintptr_t)dest; + + /* Be careful not to clobber %o7 for a tail call. */ + tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, + desti & ~0xfff, in_prologue, + tail_call ? TCG_REG_G2 : TCG_REG_O7); + tcg_out_arithi(s, tail_call ? TCG_REG_G0 : TCG_REG_O7, + TCG_REG_T1, desti & 0xfff, JMPL); +} + static void tcg_out_call_nodelay(TCGContext *s, const tcg_insn_unit *dest, bool in_prologue) { @@ -866,10 +879,7 @@ static void tcg_out_call_nodelay(TCGContext *s, const = tcg_insn_unit *dest, if (disp =3D=3D (int32_t)disp) { tcg_out32(s, CALL | (uint32_t)disp >> 2); } else { - uintptr_t desti =3D (uintptr_t)dest; - tcg_out_movi_int(s, TCG_TYPE_PTR, TCG_REG_T1, - desti & ~0xfff, in_prologue, TCG_REG_O7); - tcg_out_arithi(s, TCG_REG_O7, TCG_REG_T1, desti & 0xfff, JMPL); + tcg_out_jmpl_const(s, dest, in_prologue, false); } } =20 @@ -960,11 +970,10 @@ static void build_trampolines(TCGContext *s) =20 /* Set the retaddr operand. */ tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); - /* Set the env operand. */ - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); /* Tail call. */ - tcg_out_call_nodelay(s, qemu_ld_helpers[i], true); - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); + tcg_out_jmpl_const(s, qemu_ld_helpers[i], true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } =20 for (i =3D 0; i < ARRAY_SIZE(qemu_st_helpers); ++i) { @@ -1006,14 +1015,14 @@ static void build_trampolines(TCGContext *s) if (ra >=3D TCG_REG_O6) { tcg_out_st(s, TCG_TYPE_PTR, TCG_REG_O7, TCG_REG_CALL_STACK, TCG_TARGET_CALL_STACK_OFFSET); - ra =3D TCG_REG_G1; + } else { + tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); } - tcg_out_mov(s, TCG_TYPE_PTR, ra, TCG_REG_O7); - /* Set the env operand. */ - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O0, TCG_AREG0); + /* Tail call. */ - tcg_out_call_nodelay(s, qemu_st_helpers[i], true); - tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_O7, ra); + tcg_out_jmpl_const(s, qemu_st_helpers[i], true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } } #endif --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644544663; cv=none; d=zohomail.com; s=zohoarc; b=IxFZIIUAgtgXmQmfeeUH4wA/aWGRgt8IugLM/KQ9RFC5j4CLqcjT02cZRCog0AgugoG7yqrxLstNjvvG/K3uo4G7d1qrU1tJRzquudjlBnbnCt5yceNj/jWZP3cn9VzQL1itcTFaBdzbCbFvpPqS9bPZaS+VCYywrIjLaDgI63c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644544663; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q9Mw3HOlXqdDBaQPUYlwfi1FpDtHVrlZ6VwZ3zscXTc=; b=IxpKI+dVAQGaGqyo/SgviSWw8SETnVhaBJofmEcKMluzs7CLNsNom3/QEJzs5bTJvHfWPyksskK/Nl8PyURpqGfU/KihHlDL1hJ5bJ/0o/y+LVBUOQZ6pX0SGyEX0yaHDfz1TPloO+epXKRnE/djE9eanoqeSWAUnv9jKkIj6XQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644544663387233.7157683490958; Thu, 10 Feb 2022 17:57:43 -0800 (PST) Received: from localhost ([::1]:37120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILBv-0003Tw-0s for importer@patchew.org; Thu, 10 Feb 2022 20:57:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKo7-0005Y0-4C for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:07 -0500 Received: from [2607:f8b0:4864:20::62e] (port=43593 helo=mail-pl1-x62e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo0-0007VK-7e for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:06 -0500 Received: by mail-pl1-x62e.google.com with SMTP id p6so3215885plf.10 for ; Thu, 10 Feb 2022 17:32:59 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q9Mw3HOlXqdDBaQPUYlwfi1FpDtHVrlZ6VwZ3zscXTc=; b=iLLU7G0xEPERwL617JheJXI97lzvAVda3ge31Ii/cXJ3JO7k40WnKny1fkQ3rGR4Gs rWUCh5QHNDSeLoD1LF6Jhhyxs4Oh6vySIkvqxkmkWzkySiMQTUB0670YYtQNF09ZK6ww p2EtJfEilzUvc4G0okjWJCU/jxs0Qb/IAPqpC/kt6nClM1wfgeehxn/ohJGMk1QSLWb6 yEazQIB0KCq4oCtND34JjvDknvcySndIQRoOgcOAmyfFpp4Kses7qOPtCCf3y/GlGH4V 0d9ZBT+yek0qZcda5QlIFtxLpL+zitWOQizRJ7cTYP+69gVyXaF7vQ7UacUSE1uEPIfx tgyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q9Mw3HOlXqdDBaQPUYlwfi1FpDtHVrlZ6VwZ3zscXTc=; b=4awTGUIRps/aKhrBaIg2knrqTo8CGojFlTOQfh5uAhHd8TPUE5kL41+ItILPQZ4wLW x0Z4NfflsLOiJT5+dojoC02TSm45JpVRW+GwaTG8Cei3CC1JTVZWpINuxLUF/ffSKTfG O2oIemMQaAE964W+mJYvOf/r/WIZj3z7sPyYgP47jxDFl49GZ2fCZP+83CY5a3cFKvgS 77u+ar0pYSUXFvzA37ya/9HxQitnEpgA0/gpHpnYuqVaE3ko2yUzf4s6ahDah01sSmLj 3S6eddDe3ORVb8rLlUPQzhgOAnfCXygTfUK3PauJZaUtCpkABOVLAWa5L/k/sPVZsJRt MLdQ== X-Gm-Message-State: AOAM530Wq5awYVrT5Tf/s74/pA+W0l8DGSMIRmUtrNcSw7EVgcnYCmSl nk/b4dgnCVIruTcNNtPS0TuLfNwXlUcb+pXb X-Google-Smtp-Source: ABdhPJwNVo+MCIDkmsgebmGL73Rnorq1KzLiVnQ2sIKSaVAACYhhDNiqeaeYmify+ZxuVlaYqyeV1w== X-Received: by 2002:a17:90a:5d82:: with SMTP id t2mr207994pji.65.1644543178137; Thu, 10 Feb 2022 17:32:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 33/34] tcg/sparc: Support unaligned access for user-only Date: Fri, 11 Feb 2022 12:30:58 +1100 Message-Id: <20220211013059.17994-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::62e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644544681519100001 Content-Type: text/plain; charset="utf-8" This is kinda sorta the opposite of the other tcg hosts, where we get (normal) alignment checks for free with host SIGBUS and need to add code to support unaligned accesses. This inline code expansion is somewhat large, but it takes quite a few instructions to make a function call to a helper anyway. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/sparc/tcg-target.c.inc | 219 +++++++++++++++++++++++++++++++++++-- 1 file changed, 211 insertions(+), 8 deletions(-) diff --git a/tcg/sparc/tcg-target.c.inc b/tcg/sparc/tcg-target.c.inc index 646bb462c3..72d9552fd0 100644 --- a/tcg/sparc/tcg-target.c.inc +++ b/tcg/sparc/tcg-target.c.inc @@ -211,6 +211,7 @@ static const int tcg_target_call_oarg_regs[] =3D { #define ARITH_ADD (INSN_OP(2) | INSN_OP3(0x00)) #define ARITH_ADDCC (INSN_OP(2) | INSN_OP3(0x10)) #define ARITH_AND (INSN_OP(2) | INSN_OP3(0x01)) +#define ARITH_ANDCC (INSN_OP(2) | INSN_OP3(0x11)) #define ARITH_ANDN (INSN_OP(2) | INSN_OP3(0x05)) #define ARITH_OR (INSN_OP(2) | INSN_OP3(0x02)) #define ARITH_ORCC (INSN_OP(2) | INSN_OP3(0x12)) @@ -1025,6 +1026,38 @@ static void build_trampolines(TCGContext *s) tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); } } +#else +static const tcg_insn_unit *qemu_unalign_ld_trampoline; +static const tcg_insn_unit *qemu_unalign_st_trampoline; + +static void build_trampolines(TCGContext *s) +{ + for (int ld =3D 0; ld < 2; ++ld) { + void *helper; + + while ((uintptr_t)s->code_ptr & 15) { + tcg_out_nop(s); + } + + if (ld) { + helper =3D helper_unaligned_ld; + qemu_unalign_ld_trampoline =3D tcg_splitwx_to_rx(s->code_ptr); + } else { + helper =3D helper_unaligned_st; + qemu_unalign_st_trampoline =3D tcg_splitwx_to_rx(s->code_ptr); + } + + if (!SPARC64 && TARGET_LONG_BITS =3D=3D 64) { + /* Install the high part of the address. */ + tcg_out_arithi(s, TCG_REG_O1, TCG_REG_O2, 32, SHIFT_SRLX); + } + + /* Tail call. */ + tcg_out_jmpl_const(s, helper, true, true); + /* delay slot -- set the env argument */ + tcg_out_mov_delay(s, TCG_REG_O0, TCG_AREG0); + } +} #endif =20 /* Generate global QEMU prologue and epilogue code */ @@ -1075,9 +1108,7 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* delay slot */ tcg_out_movi_imm13(s, TCG_REG_O0, 0); =20 -#ifdef CONFIG_SOFTMMU build_trampolines(s); -#endif } =20 static void tcg_out_nop_fill(tcg_insn_unit *p, int count) @@ -1162,18 +1193,22 @@ static TCGReg tcg_out_tlb_load(TCGContext *s, TCGRe= g addr, int mem_index, static const int qemu_ld_opc[(MO_SSIZE | MO_BSWAP) + 1] =3D { [MO_UB] =3D LDUB, [MO_SB] =3D LDSB, + [MO_UB | MO_LE] =3D LDUB, + [MO_SB | MO_LE] =3D LDSB, =20 [MO_BEUW] =3D LDUH, [MO_BESW] =3D LDSH, [MO_BEUL] =3D LDUW, [MO_BESL] =3D LDSW, [MO_BEUQ] =3D LDX, + [MO_BESQ] =3D LDX, =20 [MO_LEUW] =3D LDUH_LE, [MO_LESW] =3D LDSH_LE, [MO_LEUL] =3D LDUW_LE, [MO_LESL] =3D LDSW_LE, [MO_LEUQ] =3D LDX_LE, + [MO_LESQ] =3D LDX_LE, }; =20 static const int qemu_st_opc[(MO_SIZE | MO_BSWAP) + 1] =3D { @@ -1192,11 +1227,12 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg d= ata, TCGReg addr, MemOpIdx oi, bool is_64) { MemOp memop =3D get_memop(oi); + tcg_insn_unit *label_ptr; + #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; const tcg_insn_unit *func; - tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, offsetof(CPUTLBEntry, addr_read)); @@ -1260,13 +1296,99 @@ static void tcg_out_qemu_ld(TCGContext *s, TCGReg d= ata, TCGReg addr, =20 *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #else + TCGReg index =3D (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); + unsigned a_bits =3D get_alignment_bits(memop); + unsigned s_bits =3D memop & MO_SIZE; + unsigned t_bits; + if (SPARC64 && TARGET_LONG_BITS =3D=3D 32) { tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); addr =3D TCG_REG_T1; } - tcg_out_ldst_rr(s, data, addr, - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), + + /* + * Normal case: alignment equal to access size. + */ + if (a_bits =3D=3D s_bits) { + tcg_out_ldst_rr(s, data, addr, index, + qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); + return; + } + + /* + * Test for at least natural alignment, and assume most accesses + * will be aligned -- perform a straight load in the delay slot. + * This is required to preserve atomicity for aligned accesses. + */ + t_bits =3D MAX(a_bits, s_bits); + tcg_debug_assert(t_bits < 13); + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); + + /* beq,a,pt %icc, label */ + label_ptr =3D s->code_ptr; + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); + /* delay slot */ + tcg_out_ldst_rr(s, data, addr, index, qemu_ld_opc[memop & (MO_BSWAP | MO_SSIZE)]); + + if (a_bits >=3D s_bits) { + /* + * Overalignment: A successful alignment test will perform the mem= ory + * operation in the delay slot, and failure need only invoke the + * handler for SIGBUS. + */ + TCGReg arg_low =3D TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS =3D= =3D 64); + tcg_out_call_nodelay(s, qemu_unalign_ld_trampoline, false); + /* delay slot -- move to low part of argument reg */ + tcg_out_mov_delay(s, arg_low, addr); + } else { + /* Underalignment: load by pieces of minimum alignment. */ + int ld_opc, a_size, s_size, i; + + /* + * Force full address into T1 early; avoids problems with + * overlap between @addr and @data. + */ + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); + + a_size =3D 1 << a_bits; + s_size =3D 1 << s_bits; + if ((memop & MO_BSWAP) =3D=3D MO_BE) { + ld_opc =3D qemu_ld_opc[a_bits | MO_BE | (memop & MO_SIGN)]; + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); + ld_opc =3D qemu_ld_opc[a_bits | MO_BE]; + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); + tcg_out_arithi(s, data, data, a_size, SHIFT_SLLX); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } else if (a_bits =3D=3D 0) { + ld_opc =3D LDUB; + tcg_out_ldst(s, data, TCG_REG_T1, 0, ld_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + if ((memop & MO_SIGN) && i =3D=3D s_size - a_size) { + ld_opc =3D LDSB; + } + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, ld_opc); + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLL= X); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } else { + ld_opc =3D qemu_ld_opc[a_bits | MO_LE]; + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, ld_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_AD= D); + if ((memop & MO_SIGN) && i =3D=3D s_size - a_size) { + ld_opc =3D qemu_ld_opc[a_bits | MO_LE | MO_SIGN]; + } + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, ld_= opc); + tcg_out_arithi(s, TCG_REG_T2, TCG_REG_T2, i * 8, SHIFT_SLL= X); + tcg_out_arith(s, data, data, TCG_REG_T2, ARITH_OR); + } + } + } + + *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #endif /* CONFIG_SOFTMMU */ } =20 @@ -1274,11 +1396,12 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg d= ata, TCGReg addr, MemOpIdx oi) { MemOp memop =3D get_memop(oi); + tcg_insn_unit *label_ptr; + #ifdef CONFIG_SOFTMMU unsigned memi =3D get_mmuidx(oi); TCGReg addrz, param; const tcg_insn_unit *func; - tcg_insn_unit *label_ptr; =20 addrz =3D tcg_out_tlb_load(s, addr, memi, memop, offsetof(CPUTLBEntry, addr_write)); @@ -1315,13 +1438,93 @@ static void tcg_out_qemu_st(TCGContext *s, TCGReg d= ata, TCGReg addr, =20 *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #else + TCGReg index =3D (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0); + unsigned a_bits =3D get_alignment_bits(memop); + unsigned s_bits =3D memop & MO_SIZE; + unsigned t_bits; + if (SPARC64 && TARGET_LONG_BITS =3D=3D 32) { tcg_out_arithi(s, TCG_REG_T1, addr, 0, SHIFT_SRL); addr =3D TCG_REG_T1; } - tcg_out_ldst_rr(s, data, addr, - (guest_base ? TCG_GUEST_BASE_REG : TCG_REG_G0), + + /* + * Normal case: alignment equal to access size. + */ + if (a_bits =3D=3D s_bits) { + tcg_out_ldst_rr(s, data, addr, index, + qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); + return; + } + + /* + * Test for at least natural alignment, and assume most accesses + * will be aligned -- perform a straight store in the delay slot. + * This is required to preserve atomicity for aligned accesses. + */ + t_bits =3D MAX(a_bits, s_bits); + tcg_debug_assert(t_bits < 13); + tcg_out_arithi(s, TCG_REG_G0, addr, (1u << t_bits) - 1, ARITH_ANDCC); + + /* beq,a,pt %icc, label */ + label_ptr =3D s->code_ptr; + tcg_out_bpcc0(s, COND_E, BPCC_A | BPCC_PT | BPCC_ICC, 0); + /* delay slot */ + tcg_out_ldst_rr(s, data, addr, index, qemu_st_opc[memop & (MO_BSWAP | MO_SIZE)]); + + if (a_bits >=3D s_bits) { + /* + * Overalignment: A successful alignment test will perform the mem= ory + * operation in the delay slot, and failure need only invoke the + * handler for SIGBUS. + */ + TCGReg arg_low =3D TCG_REG_O1 + (!SPARC64 && TARGET_LONG_BITS =3D= =3D 64); + tcg_out_call_nodelay(s, qemu_unalign_st_trampoline, false); + /* delay slot -- move to low part of argument reg */ + tcg_out_mov_delay(s, arg_low, addr); + } else { + /* Underalignment: store by pieces of minimum alignment. */ + int st_opc, a_size, s_size, i; + + /* + * Force full address into T1 early; avoids problems with + * overlap between @addr and @data. + */ + tcg_out_arith(s, TCG_REG_T1, addr, index, ARITH_ADD); + + a_size =3D 1 << a_bits; + s_size =3D 1 << s_bits; + if ((memop & MO_BSWAP) =3D=3D MO_BE) { + st_opc =3D qemu_st_opc[a_bits | MO_BE]; + for (i =3D 0; i < s_size; i +=3D a_size) { + TCGReg d =3D data; + int shift =3D (s_size - a_size - i) * 8; + if (shift) { + d =3D TCG_REG_T2; + tcg_out_arithi(s, d, data, shift, SHIFT_SRLX); + } + tcg_out_ldst(s, d, TCG_REG_T1, i, st_opc); + } + } else if (a_bits =3D=3D 0) { + tcg_out_ldst(s, data, TCG_REG_T1, 0, STB); + for (i =3D 1; i < s_size; i++) { + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); + tcg_out_ldst(s, TCG_REG_T2, TCG_REG_T1, i, STB); + } + } else { + /* Note that ST*A with immediate asi must use indexed address.= */ + st_opc =3D qemu_st_opc[a_bits + MO_LE]; + tcg_out_ldst_rr(s, data, TCG_REG_T1, TCG_REG_G0, st_opc); + for (i =3D a_size; i < s_size; i +=3D a_size) { + tcg_out_arithi(s, TCG_REG_T2, data, i * 8, SHIFT_SRLX); + tcg_out_arithi(s, TCG_REG_T1, TCG_REG_T1, a_size, ARITH_AD= D); + tcg_out_ldst_rr(s, TCG_REG_T2, TCG_REG_T1, TCG_REG_G0, st_= opc); + } + } + } + + *label_ptr |=3D INSN_OFF19(tcg_ptr_byte_diff(s->code_ptr, label_ptr)); #endif /* CONFIG_SOFTMMU */ } =20 --=20 2.25.1 From nobody Thu Dec 18 17:48:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1644545787; cv=none; d=zohomail.com; s=zohoarc; b=Cb1mq2JqnQZf9AWXHxiqggvqhjCqXUIRP8nqyMrEMpjZyfjrYMDn2ybVQfyGNeaB80q+8sjcEAzzCB6yhsJx8SPSYThlY/rWSfCRNye6WzM26ZDyEz3BkiF4cdfLhbl0EdmdNo9PH3oe7QMo5rg6hpwkFTtqqd7d5tbEl+qrFXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644545787; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E7JCU1a/pkRMOjn44wnlj8F4Wtu8gz5MK8RJjxKzysE=; b=jmgyRqJLNV9isXNO2Ib1yiRRScARUSwbd6a1ChGpUKDM+FcoMmNAqJEIQ1+x6YGQ6zF4UPqo1aVCoYGgpOC64z2eJIYrQtfIggIDgVhM43nSGbLtd4MTdibzdovXR2bcO1vssgiN/G+EvNuuVeR4d3xtLRlPxLSJjnDUGvytltk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644545787582963.1457637908669; Thu, 10 Feb 2022 18:16:27 -0800 (PST) Received: from localhost ([::1]:41258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nILU1-0000oG-Up for importer@patchew.org; Thu, 10 Feb 2022 21:16:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIKoZ-0005rm-UQ for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:36 -0500 Received: from [2607:f8b0:4864:20::434] (port=43564 helo=mail-pf1-x434.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIKo1-0007VW-Gs for qemu-devel@nongnu.org; Thu, 10 Feb 2022 20:33:11 -0500 Received: by mail-pf1-x434.google.com with SMTP id d187so13457799pfa.10 for ; Thu, 10 Feb 2022 17:33:01 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id h5sm25738788pfi.111.2022.02.10.17.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 17:33:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E7JCU1a/pkRMOjn44wnlj8F4Wtu8gz5MK8RJjxKzysE=; b=fshm3hWQloyhBPjbfQtTna3OYyQUYODkY7XWqgbwLRrZgg9fQuLOK6RV7MSmk2mrJ1 Oy2qg3/iWLu5Tkvw7hwm9mL12aW0buEXSFoUQ1GU6ZGOVQP1rpkThcte8cKI1x4D/fJb JPcufIPRP/telAky94qMvHZpw8DKonpMA9T7FgBERfJKDZwRkqbibT/f0ars1bwxW5Ka VFqgS4mcrn839gO1CKVaWDexOZo1Y5Q7M9XIe9YLBlPY1quMhwqZnX5aOdKpPNPZvqyB R/VCMZBO3q9L6LMfNLXu9kXyvUu/eA1ymW4rtwmgtPCyEJv+bJjk/5YQaFvKXvQLIxtC 0WHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E7JCU1a/pkRMOjn44wnlj8F4Wtu8gz5MK8RJjxKzysE=; b=Ol1rjRwJS5ZB8AAPRSFrUfhBuaNrIZHc9k9n6SPnWSnDmhUQUUlpPfDm+JVzmPk2L9 SE6MvgNACTxC4voRjDMBOVZseTJr1LB/3IGtNEWrMCiSUHfSjkwDcNWroAXnTpq+G9O3 xL6HiSdmNWlWOM3Ohx25tSs3wj2HguTlEhn0PAT1bfPKoGfQgwjG56lr7e5rcmXHZDWT GZkQnR/WXeCzI7HkNnBAhRr8Dv4PDqshqnWdFVF+EX2oGY9t9Sw125xfmNpjmzc+wd1t gdXF/D6bExXP5UpwyOR9LkubucYZu1CqSTWewM0/fXzF0N33TbkVhcD+qLObz9UpBXml jTgQ== X-Gm-Message-State: AOAM532/m2Du6XKEfb1Zq304mPSG207V+5TRFdXZrM901PVGZo3ptryu Di0q6T1l3hwFY2eO/najtF34kvMYxxLTnZAw X-Google-Smtp-Source: ABdhPJwTuqdJha2W43dOMt73Fxi0CaeMrvonGqAigG3h7pD4pVzME9MQ0bc9eU5iWtW7W/KpteEqsA== X-Received: by 2002:a63:5454:: with SMTP id e20mr8312601pgm.621.1644543180392; Thu, 10 Feb 2022 17:33:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 34/34] tests/tcg/multiarch: Add sigbus.c Date: Fri, 11 Feb 2022 12:30:59 +1100 Message-Id: <20220211013059.17994-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220211013059.17994-1-richard.henderson@linaro.org> References: <20220211013059.17994-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::434 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Cc: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1644545789164100001 Content-Type: text/plain; charset="utf-8" A mostly generic test for unaligned access raising SIGBUS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- tests/tcg/multiarch/sigbus.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/tcg/multiarch/sigbus.c diff --git a/tests/tcg/multiarch/sigbus.c b/tests/tcg/multiarch/sigbus.c new file mode 100644 index 0000000000..8134c5fd56 --- /dev/null +++ b/tests/tcg/multiarch/sigbus.c @@ -0,0 +1,68 @@ +#define _GNU_SOURCE 1 + +#include +#include +#include +#include + + +unsigned long long x =3D 0x8877665544332211ull; +void * volatile p =3D (void *)&x + 1; + +void sigbus(int sig, siginfo_t *info, void *uc) +{ + assert(sig =3D=3D SIGBUS); + assert(info->si_signo =3D=3D SIGBUS); +#ifdef BUS_ADRALN + assert(info->si_code =3D=3D BUS_ADRALN); +#endif + assert(info->si_addr =3D=3D p); + exit(EXIT_SUCCESS); +} + +int main() +{ + struct sigaction sa =3D { + .sa_sigaction =3D sigbus, + .sa_flags =3D SA_SIGINFO + }; + int allow_fail =3D 0; + int tmp; + + tmp =3D sigaction(SIGBUS, &sa, NULL); + assert(tmp =3D=3D 0); + + /* + * Select an operation that's likely to enforce alignment. + * On many guests that support unaligned accesses by default, + * this is often an atomic operation. + */ +#if defined(__aarch64__) + asm volatile("ldxr %w0,[%1]" : "=3Dr"(tmp) : "r"(p) : "memory"); +#elif defined(__alpha__) + asm volatile("ldl_l %0,0(%1)" : "=3Dr"(tmp) : "r"(p) : "memory"); +#elif defined(__arm__) + asm volatile("ldrex %0,[%1]" : "=3Dr"(tmp) : "r"(p) : "memory"); +#elif defined(__powerpc__) + asm volatile("lwarx %0,0,%1" : "=3Dr"(tmp) : "r"(p) : "memory"); +#elif defined(__riscv_atomic) + asm volatile("lr.w %0,(%1)" : "=3Dr"(tmp) : "r"(p) : "memory"); +#else + /* No insn known to fault unaligned -- try for a straight load. */ + allow_fail =3D 1; + tmp =3D *(volatile int *)p; +#endif + + assert(allow_fail); + + /* + * We didn't see a signal. + * We might as well validate the unaligned load worked. + */ + if (BYTE_ORDER =3D=3D LITTLE_ENDIAN) { + assert(tmp =3D=3D 0x55443322); + } else { + assert(tmp =3D=3D 0x77665544); + } + return EXIT_SUCCESS; +} --=20 2.25.1