From nobody Fri Apr 26 11:29:47 2024 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=1656841616; cv=none; d=zohomail.com; s=zohoarc; b=Zkfg9uD1FVqnBnThpc/qsEnDUqWLgJsikhvxuh7Y/8uHZg3TdVo43tPeRxvCVuwJHG1TtsgDavKMbElinb4WroK1CjGjMYk9Ieosg5PwlXzm03EwKfWGaSkYH2lZbbHLDrGv+2Ys3osBrpu7mc0HqoMhHOblcBP2biwI5NXbRMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841616; 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=jfQQ/MNFWhWhCmZ0fDK6Z3yWGSF3sEm5B4lXRoyup6I=; b=TD4FyiiI/sIG1FgbyDG4sd/iTKI37xI+72q9PWMrRhtyW45qB07BkdFZGcs7TIj4jnUPpLWawicCYyqhmWheS9ADmvGuAxSQEpXyCtjhIn5ll8MeG+BTzet3/YAl1H7F0/QBN00rA0rxcfxX6nOE3upnFTk5bpQxe+lVRKjXNn4= 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 1656841616299952.3899246157184; Sun, 3 Jul 2022 02:46:56 -0700 (PDT) Received: from localhost ([::1]:57168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7wBr-00077C-AE for importer@patchew.org; Sun, 03 Jul 2022 05:46:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vRt-0003pj-TG for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:25 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:44906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vRs-00048q-7H for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:25 -0400 Received: by mail-pl1-x632.google.com with SMTP id l6so6034787plg.11 for ; Sun, 03 Jul 2022 01:59:23 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:22 -0700 (PDT) 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=jfQQ/MNFWhWhCmZ0fDK6Z3yWGSF3sEm5B4lXRoyup6I=; b=jhTJ6QHzlJbOgiRnm8tq9x5iOzXSRk1XpXMX5J4+n6Tq74iE22xB4QK1VSfOYetk1n FsfEs9wBVY29378mjIJ1fnzEmD+fqOmWq+kA4RHtjPLgif5bLO7erg6TD1ht7ui2KUz+ taDNdo478zUGVnf4skM0EJBNsO0qVNw4Qq0tx8IdIXkKkLYDZo+8oxq5WbzJquqKQd3N v4U8mGOY159i6o8H3mlYk0bnIxn1nJDTDyPmyOwjnutqCPehHiFZ+3K161T6deXszk9y wgK/xJLn1hOPek3t1/5TTG+ooF2cDiOg7i0h2hc0e+fIpftyIbQVjTdr8gzi3xmV+Trs q3tA== 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=jfQQ/MNFWhWhCmZ0fDK6Z3yWGSF3sEm5B4lXRoyup6I=; b=PPzBys1K40ZgtFcwVjk9QRyNQKiqERorgjx83iYe//9/UzfjP02nFzjww0BwKPB8pJ lYFqppAwuEgmH79dr9KsgMs1RX4nrhaWYYdMgySYqyjsQxNreYb3EmRSJQ57vm5Ap6bT CdvVQIm7RuW32g7/Yw5sQEWvQnCObIHz/hflF2A1CoUPFCZTjC9YhRARAAlgyndTVL/U ifdpc6MUfyfG/agJou9/+FUdH4NlMJ6ADGwiUB3FQ9hbI4akdedlQ4TZl9Fh8g1q5Lo5 DEtUh1NN6gw52XhgNjRXxnUtPiLeD46Ogks8f62o/UbqocxMszRm0Qzsv0WJPKZsCTGi NRPg== X-Gm-Message-State: AJIora/8bzIKXdHjJWFxnPI7LUd+j+O/fz6KKD0l7qQRRZloYs1qQ2VD gAdey2Q2qpiJgeZl4ohGvQAOsKTELe5VekK7 X-Google-Smtp-Source: AGRyM1uibHvL3HChN5uSzeIt8f4I1K+W4JCup8P7iv2d7MCf5AjUr2bqI1z0VjK1fJQCL/gDKcg02w== X-Received: by 2002:a17:902:f149:b0:16a:389:1292 with SMTP id d9-20020a170902f14900b0016a03891292mr30492250plb.120.1656838762722; Sun, 03 Jul 2022 01:59:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , WANG Xuerui Subject: [PATCH v21 01/13] linux-user: Add LoongArch generic header files Date: Sun, 3 Jul 2022 14:29:01 +0530 Message-Id: <20220703085913.772936-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841618923100001 From: Song Gao This includes: - sockbits.h - target_errno_defs.h - target_fcntl.h - termbits.h - target_resource.h - target_structs.h Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: WANG Xuerui Message-Id: <20220624031049.1716097-2-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- linux-user/loongarch64/sockbits.h | 11 +++++++++++ linux-user/loongarch64/target_errno_defs.h | 12 ++++++++++++ linux-user/loongarch64/target_fcntl.h | 11 +++++++++++ linux-user/loongarch64/target_prctl.h | 1 + linux-user/loongarch64/target_resource.h | 11 +++++++++++ linux-user/loongarch64/target_structs.h | 11 +++++++++++ linux-user/loongarch64/termbits.h | 11 +++++++++++ 7 files changed, 68 insertions(+) create mode 100644 linux-user/loongarch64/sockbits.h create mode 100644 linux-user/loongarch64/target_errno_defs.h create mode 100644 linux-user/loongarch64/target_fcntl.h create mode 100644 linux-user/loongarch64/target_prctl.h create mode 100644 linux-user/loongarch64/target_resource.h create mode 100644 linux-user/loongarch64/target_structs.h create mode 100644 linux-user/loongarch64/termbits.h diff --git a/linux-user/loongarch64/sockbits.h b/linux-user/loongarch64/soc= kbits.h new file mode 100644 index 0000000000..1cffcae120 --- /dev/null +++ b/linux-user/loongarch64/sockbits.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_SOCKBITS_H +#define LOONGARCH_TARGET_SOCKBITS_H + +#include "../generic/sockbits.h" + +#endif diff --git a/linux-user/loongarch64/target_errno_defs.h b/linux-user/loonga= rch64/target_errno_defs.h new file mode 100644 index 0000000000..c198b8aca9 --- /dev/null +++ b/linux-user/loongarch64/target_errno_defs.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_ERRNO_DEFS_H +#define LOONGARCH_TARGET_ERRNO_DEFS_H + +/* Target uses generic errno */ +#include "../generic/target_errno_defs.h" + +#endif diff --git a/linux-user/loongarch64/target_fcntl.h b/linux-user/loongarch64= /target_fcntl.h new file mode 100644 index 0000000000..99bf586854 --- /dev/null +++ b/linux-user/loongarch64/target_fcntl.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_FCNTL_H +#define LOONGARCH_TARGET_FCNTL_H + +#include "../generic/fcntl.h" + +#endif diff --git a/linux-user/loongarch64/target_prctl.h b/linux-user/loongarch64= /target_prctl.h new file mode 100644 index 0000000000..eb53b31ad5 --- /dev/null +++ b/linux-user/loongarch64/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/loongarch64/target_resource.h b/linux-user/loongarc= h64/target_resource.h new file mode 100644 index 0000000000..0f86bf24ee --- /dev/null +++ b/linux-user/loongarch64/target_resource.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_RESOURCE_H +#define LOONGARCH_TARGET_RESOURCE_H + +#include "../generic/target_resource.h" + +#endif diff --git a/linux-user/loongarch64/target_structs.h b/linux-user/loongarch= 64/target_structs.h new file mode 100644 index 0000000000..6041441e15 --- /dev/null +++ b/linux-user/loongarch64/target_structs.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_STRUCTS_H +#define LOONGARCH_TARGET_STRUCTS_H + +#include "../generic/target_structs.h" + +#endif diff --git a/linux-user/loongarch64/termbits.h b/linux-user/loongarch64/ter= mbits.h new file mode 100644 index 0000000000..d425db8748 --- /dev/null +++ b/linux-user/loongarch64/termbits.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_TERMBITS_H +#define LOONGARCH_TARGET_TERMBITS_H + +#include "../generic/termbits.h" + +#endif --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656840820; cv=none; d=zohomail.com; s=zohoarc; b=HYW9trTBL5bCrxRCGIlS+PEUNyo8QSpxKG69MtsQqpGRIKWAPHZGKyWzYA5O5X3PIJOwz5+yfSYXhHjQOcdGCaRx60882dn6DELvoH1DCl02RVg1B19WhAeAz5XAJoQewE/gQeiXJiCvncukUiHbhUVHchJjENUqTE/jAW33f4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656840820; 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=AUPE1C4HXl6AujPRUCwFngmcCgBSgGym03nofdyDOGU=; b=P7Easida7fq4rOoyWyWDub3EYX30bMA5L7yHYfA5twK2KCRedtyVCogKx4PZCOcUO6AP0KwrJEfiNpDc0pjYgF30KfLK/RWIvAZxZ//RyUR7tEM+5mlNdfL68+NKbNY4eeLDK110uKG62wciMulY3l7Zm4MyUqOOdrFX/cVxkcg= 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 165684082009642.49869028563944; Sun, 3 Jul 2022 02:33:40 -0700 (PDT) Received: from localhost ([::1]:53382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7vz1-0002RB-19 for importer@patchew.org; Sun, 03 Jul 2022 05:33:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vRx-00041i-1q for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:29 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:43962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vRv-000495-0R for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:28 -0400 Received: by mail-pf1-x434.google.com with SMTP id g7so1604110pfb.10 for ; Sun, 03 Jul 2022 01:59:26 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:25 -0700 (PDT) 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=AUPE1C4HXl6AujPRUCwFngmcCgBSgGym03nofdyDOGU=; b=BqbF3qmOl1zQO3+PbeWl26/YsI6D3Rbfl1UO/5akaAbqna2kZ2qfgnuYQ8OCCQfmJL 5bXxxGepBdXEwKOn7w6LtGOb8DDYOHKh9vwEhlc34SkY/N0uYh85ipc86r2FqP1RMMJj IRR9GwJRff4mffBBzL3w+U0uLazxx8Xqamfgky4RdtTLxiypKzwyXQT8usGMLhKF0HPE yJgV07gDufZqOVqvj7Pr3I71q1bGqlH18AQWAmQ6claLutPUKfyFEbAMQDBf1nQaWuKD n0ABsYNl4Ato7IXmHWQM+fcCqfS0Br4JZ45ieMT0Nd/cSXfNll1WFWxVMh014HAdwkbM Aw/g== 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=AUPE1C4HXl6AujPRUCwFngmcCgBSgGym03nofdyDOGU=; b=mm+dr/WsvP4r4BvCAH4bkH8lAInrASQm9x1lSN3LlfcUmEmJWH9KAvvCv9CydiCbgV XH0JzE6PcVlu4r1Q0yr/KVgN9u9z9tssyC50cb3yJTU+Oyyn5g9OqEtb5kiFdmdSeTZw lMDLicyxkM6cTKVeVSvkdSzoJIZYB1AfLLNa9NRC75wPbde/LOtlFr5qqPEBmYU7B6KD id+WIW3bMODKVwBmHTk7tLNFzoyhnEhclwAz6BNaSzAi57nkbSOG9PDwpn5Fmse57WYJ J9tk6iqgtuzur7IxB5gLXW6AS+YcKWqNlhy3Yy2VaiJBFEnknX81Ufeiz+OlIoUprUPf p4gg== X-Gm-Message-State: AJIora/vK+OsIBetventmc4PUvN5cwjrfPJ5D1ObrZUZEJPY0mKDGytS M2l0fvfnJFKNc0k7m0GeashmyOvXD7bIiW62 X-Google-Smtp-Source: AGRyM1sZXHctU+rR8szLC8jjT2DbHn24GnXRgcYh8gjW1qIuM46ywE6T/iWzJXNeib55OyVpIoDkvw== X-Received: by 2002:a63:8f13:0:b0:40c:f042:13a8 with SMTP id n19-20020a638f13000000b0040cf04213a8mr20345676pgd.619.1656838765417; Sun, 03 Jul 2022 01:59:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 02/13] linux-user: Add LoongArch signal support Date: Sun, 3 Jul 2022 14:29:02 +0530 Message-Id: <20220703085913.772936-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656840821511100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Message-Id: <20220624031049.1716097-3-gaosong@loongson.cn> [rth: Rework extctx frame allocation and locking; Properly read/write fcc from signal frame.] Signed-off-by: Richard Henderson --- linux-user/loongarch64/target_signal.h | 13 + linux-user/loongarch64/signal.c | 335 +++++++++++++++++++++++++ 2 files changed, 348 insertions(+) create mode 100644 linux-user/loongarch64/target_signal.h create mode 100644 linux-user/loongarch64/signal.c diff --git a/linux-user/loongarch64/target_signal.h b/linux-user/loongarch6= 4/target_signal.h new file mode 100644 index 0000000000..ad3aaffcb4 --- /dev/null +++ b/linux-user/loongarch64/target_signal.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_SIGNAL_H +#define LOONGARCH_TARGET_SIGNAL_H + +#include "../generic/signal.h" + +#define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 + +#endif /* LOONGARCH_TARGET_SIGNAL_H */ diff --git a/linux-user/loongarch64/signal.c b/linux-user/loongarch64/signa= l.c new file mode 100644 index 0000000000..65fd5f3857 --- /dev/null +++ b/linux-user/loongarch64/signal.c @@ -0,0 +1,335 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * LoongArch emulation of Linux signals + * + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "user-internals.h" +#include "signal-common.h" +#include "linux-user/trace.h" + +#include "target/loongarch/internals.h" + +/* FP context was used */ +#define SC_USED_FP (1 << 0) + +struct target_sigcontext { + uint64_t sc_pc; + uint64_t sc_regs[32]; + uint32_t sc_flags; + uint64_t sc_extcontext[0] QEMU_ALIGNED(16); +}; + + +#define FPU_CTX_MAGIC 0x46505501 +#define FPU_CTX_ALIGN 8 +struct target_fpu_context { + uint64_t regs[32]; + uint64_t fcc; + uint32_t fcsr; +} QEMU_ALIGNED(FPU_CTX_ALIGN); + +#define CONTEXT_INFO_ALIGN 16 +struct target_sctx_info { + uint32_t magic; + uint32_t size; + uint64_t padding; +} QEMU_ALIGNED(CONTEXT_INFO_ALIGN); + +struct target_ucontext { + abi_ulong tuc_flags; + abi_ptr tuc_link; + target_stack_t tuc_stack; + target_sigset_t tuc_sigmask; + uint8_t __unused[1024 / 8 - sizeof(target_sigset_t)]; + struct target_sigcontext tuc_mcontext; +}; + +struct target_rt_sigframe { + struct target_siginfo rs_info; + struct target_ucontext rs_uc; +}; + +/* + * These two structures are not present in guest memory, are private + * to the signal implementation, but are largely copied from the + * kernel's signal implementation. + */ +struct ctx_layout { + void *haddr; + abi_ptr gaddr; + unsigned int size; +}; + +struct extctx_layout { + unsigned int size; + unsigned int flags; + struct ctx_layout fpu; + struct ctx_layout end; +}; + +/* The kernel's sc_save_fcc macro is a sequence of MOVCF2GR+BSTRINS. */ +static uint64_t read_all_fcc(CPULoongArchState *env) +{ + uint64_t ret =3D 0; + + for (int i =3D 0; i < 8; ++i) { + ret |=3D (uint64_t)env->cf[i] << (i * 8); + } + + return ret; +} + +/* The kernel's sc_restore_fcc macro is a sequence of BSTRPICK+MOVGR2CF. */ +static void write_all_fcc(CPULoongArchState *env, uint64_t val) +{ + for (int i =3D 0; i < 8; ++i) { + env->cf[i] =3D (val >> (i * 8)) & 1; + } +} + +static abi_ptr extframe_alloc(struct extctx_layout *extctx, + struct ctx_layout *sctx, unsigned size, + unsigned align, abi_ptr orig_sp) +{ + abi_ptr sp =3D orig_sp; + + sp -=3D sizeof(struct target_sctx_info) + size; + align =3D MAX(align, CONTEXT_INFO_ALIGN); + sp =3D ROUND_DOWN(sp, align); + sctx->gaddr =3D sp; + + size =3D orig_sp - sp; + sctx->size =3D size; + extctx->size +=3D size; + + return sp; +} + +static abi_ptr setup_extcontext(struct extctx_layout *extctx, abi_ptr sp) +{ + memset(extctx, 0, sizeof(struct extctx_layout)); + + /* Grow down, alloc "end" context info first. */ + sp =3D extframe_alloc(extctx, &extctx->end, 0, CONTEXT_INFO_ALIGN, sp); + + /* For qemu, there is no lazy fp context switch, so fp always present.= */ + extctx->flags =3D SC_USED_FP; + sp =3D extframe_alloc(extctx, &extctx->fpu, + sizeof(struct target_rt_sigframe), FPU_CTX_ALIGN, = sp); + + return sp; +} + +static void setup_sigframe(CPULoongArchState *env, + struct target_sigcontext *sc, + struct extctx_layout *extctx) +{ + struct target_sctx_info *info; + struct target_fpu_context *fpu_ctx; + int i; + + __put_user(extctx->flags, &sc->sc_flags); + __put_user(env->pc, &sc->sc_pc); + __put_user(0, &sc->sc_regs[0]); + for (i =3D 1; i < 32; ++i) { + __put_user(env->gpr[i], &sc->sc_regs[i]); + } + + /* + * Set fpu context + */ + info =3D extctx->fpu.haddr; + __put_user(FPU_CTX_MAGIC, &info->magic); + __put_user(extctx->fpu.size, &info->size); + + fpu_ctx =3D (struct target_fpu_context *)(info + 1); + for (i =3D 0; i < 32; ++i) { + __put_user(env->fpr[i], &fpu_ctx->regs[i]); + } + __put_user(read_all_fcc(env), &fpu_ctx->fcc); + __put_user(env->fcsr0, &fpu_ctx->fcsr); + + /* + * Set end context + */ + info =3D extctx->end.haddr; + __put_user(0, &info->magic); + __put_user(extctx->end.size, &info->size); +} + +static bool parse_extcontext(struct extctx_layout *extctx, abi_ptr frame) +{ + memset(extctx, 0, sizeof(*extctx)); + + while (1) { + uint32_t magic, size; + + if (get_user_u32(magic, frame) || get_user_u32(size, frame + 4)) { + return false; + } + + switch (magic) { + case 0: /* END */ + extctx->end.gaddr =3D frame; + extctx->end.size =3D size; + extctx->size +=3D size; + return true; + + case FPU_CTX_MAGIC: + if (size < (sizeof(struct target_sctx_info) + + sizeof(struct target_fpu_context))) { + return false; + } + extctx->fpu.gaddr =3D frame; + extctx->fpu.size =3D size; + extctx->size +=3D size; + break; + default: + return false; + } + + frame +=3D size; + } +} + +static void restore_sigframe(CPULoongArchState *env, + struct target_sigcontext *sc, + struct extctx_layout *extctx) +{ + int i; + + __get_user(env->pc, &sc->sc_pc); + for (i =3D 1; i < 32; ++i) { + __get_user(env->gpr[i], &sc->sc_regs[i]); + } + + if (extctx->fpu.haddr) { + struct target_fpu_context *fpu_ctx =3D + extctx->fpu.haddr + sizeof(struct target_sctx_info); + uint64_t fcc; + + for (i =3D 0; i < 32; ++i) { + __get_user(env->fpr[i], &fpu_ctx->regs[i]); + } + __get_user(fcc, &fpu_ctx->fcc); + write_all_fcc(env, fcc); + __get_user(env->fcsr0, &fpu_ctx->fcsr); + restore_fp_status(env); + } +} + +/* + * Determine which stack to use. + */ +static abi_ptr get_sigframe(struct target_sigaction *ka, + CPULoongArchState *env, + struct extctx_layout *extctx) +{ + abi_ulong sp; + + sp =3D target_sigsp(get_sp_from_cpustate(env), ka); + sp =3D ROUND_DOWN(sp, 16); + sp =3D setup_extcontext(extctx, sp); + sp -=3D sizeof(struct target_rt_sigframe); + + assert(QEMU_IS_ALIGNED(sp, 16)); + + return sp; +} + +void setup_rt_frame(int sig, struct target_sigaction *ka, + target_siginfo_t *info, + target_sigset_t *set, CPULoongArchState *env) +{ + struct target_rt_sigframe *frame; + struct extctx_layout extctx; + abi_ptr frame_addr; + int i; + + frame_addr =3D get_sigframe(ka, env, &extctx); + trace_user_setup_rt_frame(env, frame_addr); + + frame =3D lock_user(VERIFY_WRITE, frame_addr, + sizeof(*frame) + extctx.size, 0); + if (!frame) { + force_sigsegv(sig); + return; + } + extctx.fpu.haddr =3D (void *)frame + (extctx.fpu.gaddr - frame_addr); + extctx.end.haddr =3D (void *)frame + (extctx.end.gaddr - frame_addr); + + tswap_siginfo(&frame->rs_info, info); + + __put_user(0, &frame->rs_uc.tuc_flags); + __put_user(0, &frame->rs_uc.tuc_link); + target_save_altstack(&frame->rs_uc.tuc_stack, env); + + setup_sigframe(env, &frame->rs_uc.tuc_mcontext, &extctx); + + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { + __put_user(set->sig[i], &frame->rs_uc.tuc_sigmask.sig[i]); + } + + env->gpr[4] =3D sig; + env->gpr[5] =3D frame_addr + offsetof(struct target_rt_sigframe, rs_in= fo); + env->gpr[6] =3D frame_addr + offsetof(struct target_rt_sigframe, rs_uc= ); + env->gpr[3] =3D frame_addr; + env->gpr[1] =3D default_rt_sigreturn; + + env->pc =3D ka->_sa_handler; + unlock_user(frame, frame_addr, sizeof(*frame) + extctx.size); +} + +long do_rt_sigreturn(CPULoongArchState *env) +{ + struct target_rt_sigframe *frame; + struct extctx_layout extctx; + abi_ulong frame_addr; + sigset_t blocked; + + frame_addr =3D env->gpr[3]; + trace_user_do_rt_sigreturn(env, frame_addr); + + if (!parse_extcontext(&extctx, frame_addr + sizeof(*frame))) { + goto badframe; + } + + frame =3D lock_user(VERIFY_READ, frame_addr, + sizeof(*frame) + extctx.size, 1); + if (!frame) { + goto badframe; + } + if (extctx.fpu.gaddr) { + extctx.fpu.haddr =3D (void *)frame + (extctx.fpu.gaddr - frame_add= r); + } + + target_to_host_sigset(&blocked, &frame->rs_uc.tuc_sigmask); + set_sigmask(&blocked); + + restore_sigframe(env, &frame->rs_uc.tuc_mcontext, &extctx); + + target_restore_altstack(&frame->rs_uc.tuc_stack, env); + + unlock_user(frame, frame_addr, 0); + return -QEMU_ESIGRETURN; + + badframe: + force_sig(TARGET_SIGSEGV); + return -QEMU_ESIGRETURN; +} + +void setup_sigtramp(abi_ulong sigtramp_page) +{ + uint32_t *tramp =3D lock_user(VERIFY_WRITE, sigtramp_page, 8, 0); + assert(tramp !=3D NULL); + + __put_user(0x03822c0b, tramp + 0); /* ori a7, zero, 0x8b */ + __put_user(0x002b0000, tramp + 1); /* syscall 0 */ + + default_rt_sigreturn =3D sigtramp_page; + unlock_user(tramp, sigtramp_page, 8); +} --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656840956; cv=none; d=zohomail.com; s=zohoarc; b=DHbqwnVNOYX2LpFXRmyq6S3shDrmC/flH1Nca0a7BN5H90Q1+psKc+OI971xHzaucNYoKM/kNtC4PQ8FYfxAd/6k48i9Gm6iubZy+7WNU+3I0QA32zWxV3jbRsfm51nWuH8HxcMxMYfWv44djlT4m5Win3EeH+9vdDcZSdzFbgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656840956; 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=wdR2AdXYQcU9MB9eRdNwupFKlHHJUO4XdfGfsX7z9ZA=; b=KF5QT+tYVufde3CV1aJYjF7RgHxZU8Xpi6Vrmq1jHu6eChq+X8Bej2uXtWViNIJB6QtaAx2QxSCGJpWYfPW9GCZvMkClTlwCZhSd8ZM+Jyv1anwbFmNJO7BhujovmMrbM3on1AysHga2euwNHDxOzUV9yijuc10wE+RegleqRV4= 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 1656840956950389.4657873057457; Sun, 3 Jul 2022 02:35:56 -0700 (PDT) Received: from localhost ([::1]:59840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w1D-0006kd-UF for importer@patchew.org; Sun, 03 Jul 2022 05:35:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vRz-0004DD-NA for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:31 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:53213) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vRy-00049V-2e for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:31 -0400 Received: by mail-pj1-x1030.google.com with SMTP id fz10so475223pjb.2 for ; Sun, 03 Jul 2022 01:59:29 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:28 -0700 (PDT) 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=wdR2AdXYQcU9MB9eRdNwupFKlHHJUO4XdfGfsX7z9ZA=; b=r5s3lkQ/KH/owNvwkx8GX3ARK+tLsS7L8Y3iDkvhKZOpNdAPHnpVGHD8XVqjad6oaD 91dlITPT86XOWg4XNwFBoRprFn+mkHqjf61iLU7ssdVxT7e7HqkbYlY5xT8wp7zSRxfe 7kGohEzRh6XqnTCYeROhh9kc7du36btbJhupgc+2hYtpN3i62lXgddAb/mxbRMV0By6F JaEyOnnfsvYYvuGJK1qfOawM+qnVyjVq8LdgMBOJSA4qcgHMiXiAfRbpnE6/+GMyJmvZ r/uvdgVJ0hzn1LxZtOZjeEfOZ7sc74D7/B+I1P6M8WRyWPeVZCTjv+TkcgWxL3xKjw46 hnZw== 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=wdR2AdXYQcU9MB9eRdNwupFKlHHJUO4XdfGfsX7z9ZA=; b=ayg9OOOQODTiaIlufDRZaPsWaWUgAZnksPibz3MrkJKAubRXbm9rbU5eyQzCdZB4CZ pbzaGLGMm/2/vQpGWfysPCDnSrvG/JrudT64XqjUqpeAdv5u6twhIO7P+5qXV0Ty3582 ZERoebOhK+9ZXtUazdTpCtwMsxG+kToej71feeUfzHKZulaopV4evIoK8nwuC1GKnrpf m+j15Uoc6DngI8ATo9hKVH1K/+X9zLan/uy83YbbGYXNRvqTTttrG8SkAHTbbFhIVp0B /77NNP6tUnFrcUZWeQRHPcHKXnI55u/Xh4k1vfvkuXTfru1p/6K7Eo1QxQkp30xKXF/j jJVw== X-Gm-Message-State: AJIora+68pseEi0+at84dEaVBKfmrbulVxHbDGT4j2FWlGsS4QVWrDAc q/a5CbIul3cdg/8AzRabdWP/w+8p7th9O3Gw X-Google-Smtp-Source: AGRyM1u9+ezK7fHIvZrUnnQ7C4aCPMBPYakcs7g9/3qTSPqSZKvXOC0RN8U7TvLtpuUoogdhvTNTfw== X-Received: by 2002:a17:90b:388c:b0:1ec:d129:704 with SMTP id mu12-20020a17090b388c00b001ecd1290704mr29205904pjb.98.1656838768784; Sun, 03 Jul 2022 01:59:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v21 03/13] linux-user: Add LoongArch elf support Date: Sun, 3 Jul 2022 14:29:03 +0530 Message-Id: <20220703085913.772936-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656840958520100001 From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220624031049.1716097-4-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- linux-user/loongarch64/target_elf.h | 12 ++++ linux-user/elfload.c | 91 +++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 linux-user/loongarch64/target_elf.h diff --git a/linux-user/loongarch64/target_elf.h b/linux-user/loongarch64/t= arget_elf.h new file mode 100644 index 0000000000..95c3f05a46 --- /dev/null +++ b/linux-user/loongarch64/target_elf.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_ELF_H +#define LOONGARCH_TARGET_ELF_H +static inline const char *cpu_get_model(uint32_t eflags) +{ + return "la464"; +} +#endif diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 163fc8a1ee..1de77c7959 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -922,6 +922,97 @@ static void elf_core_copy_regs(target_elf_gregset_t *r= egs, const CPUPPCState *en =20 #endif =20 +#ifdef TARGET_LOONGARCH64 + +#define ELF_START_MMAP 0x80000000 + +#define ELF_CLASS ELFCLASS64 +#define ELF_ARCH EM_LOONGARCH + +#define elf_check_arch(x) ((x) =3D=3D EM_LOONGARCH) + +static inline void init_thread(struct target_pt_regs *regs, + struct image_info *infop) +{ + /*Set crmd PG,DA =3D 1,0 */ + regs->csr.crmd =3D 2 << 3; + regs->csr.era =3D infop->entry; + regs->regs[3] =3D infop->start_stack; +} + +/* See linux kernel: arch/loongarch/include/asm/elf.h */ +#define ELF_NREG 45 +typedef target_elf_greg_t target_elf_gregset_t[ELF_NREG]; + +enum { + TARGET_EF_R0 =3D 0, + TARGET_EF_CSR_ERA =3D TARGET_EF_R0 + 33, + TARGET_EF_CSR_BADV =3D TARGET_EF_R0 + 34, +}; + +static void elf_core_copy_regs(target_elf_gregset_t *regs, + const CPULoongArchState *env) +{ + int i; + + (*regs)[TARGET_EF_R0] =3D 0; + + for (i =3D 1; i < ARRAY_SIZE(env->gpr); i++) { + (*regs)[TARGET_EF_R0 + i] =3D tswapreg(env->gpr[i]); + } + + (*regs)[TARGET_EF_CSR_ERA] =3D tswapreg(env->pc); + (*regs)[TARGET_EF_CSR_BADV] =3D tswapreg(env->CSR_BADV); +} + +#define USE_ELF_CORE_DUMP +#define ELF_EXEC_PAGESIZE 4096 + +#define ELF_HWCAP get_elf_hwcap() + +/* See arch/loongarch/include/uapi/asm/hwcap.h */ +enum { + HWCAP_LOONGARCH_CPUCFG =3D (1 << 0), + HWCAP_LOONGARCH_LAM =3D (1 << 1), + HWCAP_LOONGARCH_UAL =3D (1 << 2), + HWCAP_LOONGARCH_FPU =3D (1 << 3), + HWCAP_LOONGARCH_LSX =3D (1 << 4), + HWCAP_LOONGARCH_LASX =3D (1 << 5), + HWCAP_LOONGARCH_CRC32 =3D (1 << 6), + HWCAP_LOONGARCH_COMPLEX =3D (1 << 7), + HWCAP_LOONGARCH_CRYPTO =3D (1 << 8), + HWCAP_LOONGARCH_LVZ =3D (1 << 9), + HWCAP_LOONGARCH_LBT_X86 =3D (1 << 10), + HWCAP_LOONGARCH_LBT_ARM =3D (1 << 11), + HWCAP_LOONGARCH_LBT_MIPS =3D (1 << 12), +}; + +static uint32_t get_elf_hwcap(void) +{ + LoongArchCPU *cpu =3D LOONGARCH_CPU(thread_cpu); + uint32_t hwcaps =3D 0; + + hwcaps |=3D HWCAP_LOONGARCH_CRC32; + + if (FIELD_EX32(cpu->env.cpucfg[1], CPUCFG1, UAL)) { + hwcaps |=3D HWCAP_LOONGARCH_UAL; + } + + if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, FP)) { + hwcaps |=3D HWCAP_LOONGARCH_FPU; + } + + if (FIELD_EX32(cpu->env.cpucfg[2], CPUCFG2, LAM)) { + hwcaps |=3D HWCAP_LOONGARCH_LAM; + } + + return hwcaps; +} + +#define ELF_PLATFORM "loongarch" + +#endif /* TARGET_LOONGARCH64 */ + #ifdef TARGET_MIPS =20 #define ELF_START_MMAP 0x80000000 --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841080; cv=none; d=zohomail.com; s=zohoarc; b=BFxq2y/wz9p241l5pUOaORTCVio3cdSj9pwIRF0XmS19zy62c/dUVlOIzquYgOLMY/qJhXWkUsf+v7lCet3l5d0//XHnWh/caf8jayogzE4QkHYNgDQQXaT8mXFzYdVms924nXFjQLoMinL1NuH3PrcgshUX7P+8JM8h++tFc/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841080; 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=xN+6s06civR9FB/frcDV6ntpWJlUKq0c4WMTdJ5r+ac=; b=hn7kNaJuvRz/y0CXJT8drmB/lF1oYfdcWKnCS0NKbq3WKs6folIcCHbw3RfRMIZ6d/96Oj9bLXAam+6BHw2F9WZon1qGT+KiESVOnVJ505PY9Cnd/NG2O7x3Ww9PSINZDImaB7dltPi+CVgj4PdaBW5ynJOdhiT1brya0QofeK8= 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 1656841080803706.9141508397489; Sun, 3 Jul 2022 02:38:00 -0700 (PDT) Received: from localhost ([::1]:38550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w3D-00032Y-Hw for importer@patchew.org; Sun, 03 Jul 2022 05:37:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vS4-0004Uq-2f for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:36 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:34596) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vS1-00049p-RJ for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:35 -0400 Received: by mail-pg1-x536.google.com with SMTP id g4so6307226pgc.1 for ; Sun, 03 Jul 2022 01:59:33 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:31 -0700 (PDT) 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=xN+6s06civR9FB/frcDV6ntpWJlUKq0c4WMTdJ5r+ac=; b=HtLe4RhtGrijzVIgMLO5NNR76msNDDFxEcSilA6T7tJhlsx0i+Y1w93aaDpcttRnNJ +JY29GMsEDWOVqlIaX9kO71fKSDh2VVTiNMQExErOJJTJYtVqO+gYuEp3FGvJH5f2GIq /SWMycdeBworGxzOROpU4Tv7OQDbB8DcMGA7/xsp4LGQ19B3xyl/A9tY3MAHl1uzff/E 8cwyUXKk7N236Y6v65xYOsYgqycze5mNV+jNjsImj0UsU6sxghxfxol1Sj7RfgAglnQL TCxrh2QQp8YLCjxqoNamtAGgbNFkx9VXcMDbMHMeBdfXuDgyATx6U5PexPR/tuRldXCw NWNQ== 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=xN+6s06civR9FB/frcDV6ntpWJlUKq0c4WMTdJ5r+ac=; b=I2/R+m0gz1zEVqOyT1aDFmqFuDNYzWJx10nLQ7HnhV0sz0UBGMMKz8+Vd2RdgLDoJa oZMTx4E1PwJzbLEFJ/KU3jYP2bzuUmlQIZbeLIFWVadL8JBE9DYkEUo/BmS2/YbJm45G p20Un+IC3LCK/7wTsVLA2Rb9XbZ/8voGboJOn8ftzyKqJn3HxKW3s0ShzcDWRTs4M0G+ mC8mhX+DLGfi+/lzXcHrMi5dHtLLBRjH6+3A9mqlfdjUDbMn4ryLRP3k4/OMrgRSaFzi BRLRkqKDoY/OhhqwdOrc9Evg0II7rCnljR9EFYL3JUGrFGJepCpmJNMx5qYRPxtlu8Nb sPWQ== X-Gm-Message-State: AJIora/qbBiUUiKbtvs2X7FdFlDYvj5LBrWwSRXCmj7iIg7grb2aE5r9 cHD+YxTsHvPHywSSKkA9bHO+eE4GE0vn+r7i X-Google-Smtp-Source: AGRyM1ucp4Wr9g1uzB5KV2zDbHJmi/LeE9/OpsbYZU9IJYEeExkINmvtdHILf3crLuQqMuUKWEwpQg== X-Received: by 2002:a63:6886:0:b0:40d:c2f9:2dfa with SMTP id d128-20020a636886000000b0040dc2f92dfamr20493949pgc.352.1656838772468; Sun, 03 Jul 2022 01:59:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v21 04/13] linux-user: Add LoongArch syscall support Date: Sun, 3 Jul 2022 14:29:04 +0530 Message-Id: <20220703085913.772936-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841082888100001 From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20220624031049.1716097-5-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- linux-user/loongarch64/syscall_nr.h | 312 ++++++++++++++++++++++++ linux-user/loongarch64/target_syscall.h | 48 ++++ linux-user/syscall_defs.h | 6 +- scripts/gensyscalls.sh | 2 + 4 files changed, 367 insertions(+), 1 deletion(-) create mode 100644 linux-user/loongarch64/syscall_nr.h create mode 100644 linux-user/loongarch64/target_syscall.h diff --git a/linux-user/loongarch64/syscall_nr.h b/linux-user/loongarch64/s= yscall_nr.h new file mode 100644 index 0000000000..be00915adf --- /dev/null +++ b/linux-user/loongarch64/syscall_nr.h @@ -0,0 +1,312 @@ +/* + * This file contains the system call numbers. + * Do not modify. + * This file is generated by scripts/gensyscalls.sh + */ +#ifndef LINUX_USER_LOONGARCH_SYSCALL_NR_H +#define LINUX_USER_LOONGARCH_SYSCALL_NR_H + +#define TARGET_NR_io_setup 0 +#define TARGET_NR_io_destroy 1 +#define TARGET_NR_io_submit 2 +#define TARGET_NR_io_cancel 3 +#define TARGET_NR_io_getevents 4 +#define TARGET_NR_setxattr 5 +#define TARGET_NR_lsetxattr 6 +#define TARGET_NR_fsetxattr 7 +#define TARGET_NR_getxattr 8 +#define TARGET_NR_lgetxattr 9 +#define TARGET_NR_fgetxattr 10 +#define TARGET_NR_listxattr 11 +#define TARGET_NR_llistxattr 12 +#define TARGET_NR_flistxattr 13 +#define TARGET_NR_removexattr 14 +#define TARGET_NR_lremovexattr 15 +#define TARGET_NR_fremovexattr 16 +#define TARGET_NR_getcwd 17 +#define TARGET_NR_lookup_dcookie 18 +#define TARGET_NR_eventfd2 19 +#define TARGET_NR_epoll_create1 20 +#define TARGET_NR_epoll_ctl 21 +#define TARGET_NR_epoll_pwait 22 +#define TARGET_NR_dup 23 +#define TARGET_NR_dup3 24 +#define TARGET_NR_fcntl 25 +#define TARGET_NR_inotify_init1 26 +#define TARGET_NR_inotify_add_watch 27 +#define TARGET_NR_inotify_rm_watch 28 +#define TARGET_NR_ioctl 29 +#define TARGET_NR_ioprio_set 30 +#define TARGET_NR_ioprio_get 31 +#define TARGET_NR_flock 32 +#define TARGET_NR_mknodat 33 +#define TARGET_NR_mkdirat 34 +#define TARGET_NR_unlinkat 35 +#define TARGET_NR_symlinkat 36 +#define TARGET_NR_linkat 37 +#define TARGET_NR_umount2 39 +#define TARGET_NR_mount 40 +#define TARGET_NR_pivot_root 41 +#define TARGET_NR_nfsservctl 42 +#define TARGET_NR_statfs 43 +#define TARGET_NR_fstatfs 44 +#define TARGET_NR_truncate 45 +#define TARGET_NR_ftruncate 46 +#define TARGET_NR_fallocate 47 +#define TARGET_NR_faccessat 48 +#define TARGET_NR_chdir 49 +#define TARGET_NR_fchdir 50 +#define TARGET_NR_chroot 51 +#define TARGET_NR_fchmod 52 +#define TARGET_NR_fchmodat 53 +#define TARGET_NR_fchownat 54 +#define TARGET_NR_fchown 55 +#define TARGET_NR_openat 56 +#define TARGET_NR_close 57 +#define TARGET_NR_vhangup 58 +#define TARGET_NR_pipe2 59 +#define TARGET_NR_quotactl 60 +#define TARGET_NR_getdents64 61 +#define TARGET_NR_lseek 62 +#define TARGET_NR_read 63 +#define TARGET_NR_write 64 +#define TARGET_NR_readv 65 +#define TARGET_NR_writev 66 +#define TARGET_NR_pread64 67 +#define TARGET_NR_pwrite64 68 +#define TARGET_NR_preadv 69 +#define TARGET_NR_pwritev 70 +#define TARGET_NR_sendfile 71 +#define TARGET_NR_pselect6 72 +#define TARGET_NR_ppoll 73 +#define TARGET_NR_signalfd4 74 +#define TARGET_NR_vmsplice 75 +#define TARGET_NR_splice 76 +#define TARGET_NR_tee 77 +#define TARGET_NR_readlinkat 78 +#define TARGET_NR_sync 81 +#define TARGET_NR_fsync 82 +#define TARGET_NR_fdatasync 83 +#define TARGET_NR_sync_file_range 84 +#define TARGET_NR_timerfd_create 85 +#define TARGET_NR_timerfd_settime 86 +#define TARGET_NR_timerfd_gettime 87 +#define TARGET_NR_utimensat 88 +#define TARGET_NR_acct 89 +#define TARGET_NR_capget 90 +#define TARGET_NR_capset 91 +#define TARGET_NR_personality 92 +#define TARGET_NR_exit 93 +#define TARGET_NR_exit_group 94 +#define TARGET_NR_waitid 95 +#define TARGET_NR_set_tid_address 96 +#define TARGET_NR_unshare 97 +#define TARGET_NR_futex 98 +#define TARGET_NR_set_robust_list 99 +#define TARGET_NR_get_robust_list 100 +#define TARGET_NR_nanosleep 101 +#define TARGET_NR_getitimer 102 +#define TARGET_NR_setitimer 103 +#define TARGET_NR_kexec_load 104 +#define TARGET_NR_init_module 105 +#define TARGET_NR_delete_module 106 +#define TARGET_NR_timer_create 107 +#define TARGET_NR_timer_gettime 108 +#define TARGET_NR_timer_getoverrun 109 +#define TARGET_NR_timer_settime 110 +#define TARGET_NR_timer_delete 111 +#define TARGET_NR_clock_settime 112 +#define TARGET_NR_clock_gettime 113 +#define TARGET_NR_clock_getres 114 +#define TARGET_NR_clock_nanosleep 115 +#define TARGET_NR_syslog 116 +#define TARGET_NR_ptrace 117 +#define TARGET_NR_sched_setparam 118 +#define TARGET_NR_sched_setscheduler 119 +#define TARGET_NR_sched_getscheduler 120 +#define TARGET_NR_sched_getparam 121 +#define TARGET_NR_sched_setaffinity 122 +#define TARGET_NR_sched_getaffinity 123 +#define TARGET_NR_sched_yield 124 +#define TARGET_NR_sched_get_priority_max 125 +#define TARGET_NR_sched_get_priority_min 126 +#define TARGET_NR_sched_rr_get_interval 127 +#define TARGET_NR_restart_syscall 128 +#define TARGET_NR_kill 129 +#define TARGET_NR_tkill 130 +#define TARGET_NR_tgkill 131 +#define TARGET_NR_sigaltstack 132 +#define TARGET_NR_rt_sigsuspend 133 +#define TARGET_NR_rt_sigaction 134 +#define TARGET_NR_rt_sigprocmask 135 +#define TARGET_NR_rt_sigpending 136 +#define TARGET_NR_rt_sigtimedwait 137 +#define TARGET_NR_rt_sigqueueinfo 138 +#define TARGET_NR_rt_sigreturn 139 +#define TARGET_NR_setpriority 140 +#define TARGET_NR_getpriority 141 +#define TARGET_NR_reboot 142 +#define TARGET_NR_setregid 143 +#define TARGET_NR_setgid 144 +#define TARGET_NR_setreuid 145 +#define TARGET_NR_setuid 146 +#define TARGET_NR_setresuid 147 +#define TARGET_NR_getresuid 148 +#define TARGET_NR_setresgid 149 +#define TARGET_NR_getresgid 150 +#define TARGET_NR_setfsuid 151 +#define TARGET_NR_setfsgid 152 +#define TARGET_NR_times 153 +#define TARGET_NR_setpgid 154 +#define TARGET_NR_getpgid 155 +#define TARGET_NR_getsid 156 +#define TARGET_NR_setsid 157 +#define TARGET_NR_getgroups 158 +#define TARGET_NR_setgroups 159 +#define TARGET_NR_uname 160 +#define TARGET_NR_sethostname 161 +#define TARGET_NR_setdomainname 162 +#define TARGET_NR_getrusage 165 +#define TARGET_NR_umask 166 +#define TARGET_NR_prctl 167 +#define TARGET_NR_getcpu 168 +#define TARGET_NR_gettimeofday 169 +#define TARGET_NR_settimeofday 170 +#define TARGET_NR_adjtimex 171 +#define TARGET_NR_getpid 172 +#define TARGET_NR_getppid 173 +#define TARGET_NR_getuid 174 +#define TARGET_NR_geteuid 175 +#define TARGET_NR_getgid 176 +#define TARGET_NR_getegid 177 +#define TARGET_NR_gettid 178 +#define TARGET_NR_sysinfo 179 +#define TARGET_NR_mq_open 180 +#define TARGET_NR_mq_unlink 181 +#define TARGET_NR_mq_timedsend 182 +#define TARGET_NR_mq_timedreceive 183 +#define TARGET_NR_mq_notify 184 +#define TARGET_NR_mq_getsetattr 185 +#define TARGET_NR_msgget 186 +#define TARGET_NR_msgctl 187 +#define TARGET_NR_msgrcv 188 +#define TARGET_NR_msgsnd 189 +#define TARGET_NR_semget 190 +#define TARGET_NR_semctl 191 +#define TARGET_NR_semtimedop 192 +#define TARGET_NR_semop 193 +#define TARGET_NR_shmget 194 +#define TARGET_NR_shmctl 195 +#define TARGET_NR_shmat 196 +#define TARGET_NR_shmdt 197 +#define TARGET_NR_socket 198 +#define TARGET_NR_socketpair 199 +#define TARGET_NR_bind 200 +#define TARGET_NR_listen 201 +#define TARGET_NR_accept 202 +#define TARGET_NR_connect 203 +#define TARGET_NR_getsockname 204 +#define TARGET_NR_getpeername 205 +#define TARGET_NR_sendto 206 +#define TARGET_NR_recvfrom 207 +#define TARGET_NR_setsockopt 208 +#define TARGET_NR_getsockopt 209 +#define TARGET_NR_shutdown 210 +#define TARGET_NR_sendmsg 211 +#define TARGET_NR_recvmsg 212 +#define TARGET_NR_readahead 213 +#define TARGET_NR_brk 214 +#define TARGET_NR_munmap 215 +#define TARGET_NR_mremap 216 +#define TARGET_NR_add_key 217 +#define TARGET_NR_request_key 218 +#define TARGET_NR_keyctl 219 +#define TARGET_NR_clone 220 +#define TARGET_NR_execve 221 +#define TARGET_NR_mmap 222 +#define TARGET_NR_fadvise64 223 +#define TARGET_NR_swapon 224 +#define TARGET_NR_swapoff 225 +#define TARGET_NR_mprotect 226 +#define TARGET_NR_msync 227 +#define TARGET_NR_mlock 228 +#define TARGET_NR_munlock 229 +#define TARGET_NR_mlockall 230 +#define TARGET_NR_munlockall 231 +#define TARGET_NR_mincore 232 +#define TARGET_NR_madvise 233 +#define TARGET_NR_remap_file_pages 234 +#define TARGET_NR_mbind 235 +#define TARGET_NR_get_mempolicy 236 +#define TARGET_NR_set_mempolicy 237 +#define TARGET_NR_migrate_pages 238 +#define TARGET_NR_move_pages 239 +#define TARGET_NR_rt_tgsigqueueinfo 240 +#define TARGET_NR_perf_event_open 241 +#define TARGET_NR_accept4 242 +#define TARGET_NR_recvmmsg 243 +#define TARGET_NR_arch_specific_syscall 244 +#define TARGET_NR_wait4 260 +#define TARGET_NR_prlimit64 261 +#define TARGET_NR_fanotify_init 262 +#define TARGET_NR_fanotify_mark 263 +#define TARGET_NR_name_to_handle_at 264 +#define TARGET_NR_open_by_handle_at 265 +#define TARGET_NR_clock_adjtime 266 +#define TARGET_NR_syncfs 267 +#define TARGET_NR_setns 268 +#define TARGET_NR_sendmmsg 269 +#define TARGET_NR_process_vm_readv 270 +#define TARGET_NR_process_vm_writev 271 +#define TARGET_NR_kcmp 272 +#define TARGET_NR_finit_module 273 +#define TARGET_NR_sched_setattr 274 +#define TARGET_NR_sched_getattr 275 +#define TARGET_NR_renameat2 276 +#define TARGET_NR_seccomp 277 +#define TARGET_NR_getrandom 278 +#define TARGET_NR_memfd_create 279 +#define TARGET_NR_bpf 280 +#define TARGET_NR_execveat 281 +#define TARGET_NR_userfaultfd 282 +#define TARGET_NR_membarrier 283 +#define TARGET_NR_mlock2 284 +#define TARGET_NR_copy_file_range 285 +#define TARGET_NR_preadv2 286 +#define TARGET_NR_pwritev2 287 +#define TARGET_NR_pkey_mprotect 288 +#define TARGET_NR_pkey_alloc 289 +#define TARGET_NR_pkey_free 290 +#define TARGET_NR_statx 291 +#define TARGET_NR_io_pgetevents 292 +#define TARGET_NR_rseq 293 +#define TARGET_NR_kexec_file_load 294 +#define TARGET_NR_pidfd_send_signal 424 +#define TARGET_NR_io_uring_setup 425 +#define TARGET_NR_io_uring_enter 426 +#define TARGET_NR_io_uring_register 427 +#define TARGET_NR_open_tree 428 +#define TARGET_NR_move_mount 429 +#define TARGET_NR_fsopen 430 +#define TARGET_NR_fsconfig 431 +#define TARGET_NR_fsmount 432 +#define TARGET_NR_fspick 433 +#define TARGET_NR_pidfd_open 434 +#define TARGET_NR_clone3 435 +#define TARGET_NR_close_range 436 +#define TARGET_NR_openat2 437 +#define TARGET_NR_pidfd_getfd 438 +#define TARGET_NR_faccessat2 439 +#define TARGET_NR_process_madvise 440 +#define TARGET_NR_epoll_pwait2 441 +#define TARGET_NR_mount_setattr 442 +#define TARGET_NR_quotactl_fd 443 +#define TARGET_NR_landlock_create_ruleset 444 +#define TARGET_NR_landlock_add_rule 445 +#define TARGET_NR_landlock_restrict_self 446 +#define TARGET_NR_process_mrelease 448 +#define TARGET_NR_futex_waitv 449 +#define TARGET_NR_set_mempolicy_home_node 450 +#define TARGET_NR_syscalls 451 + +#endif /* LINUX_USER_LOONGARCH_SYSCALL_NR_H */ diff --git a/linux-user/loongarch64/target_syscall.h b/linux-user/loongarch= 64/target_syscall.h new file mode 100644 index 0000000000..8b5de52124 --- /dev/null +++ b/linux-user/loongarch64/target_syscall.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_SYSCALL_H +#define LOONGARCH_TARGET_SYSCALL_H + +#include "qemu/units.h" + +/* + * this struct defines the way the registers are stored on the + * stack during a system call. + */ + +struct target_pt_regs { + /* Saved main processor registers. */ + target_ulong regs[32]; + + /* Saved special registers. */ + struct { + target_ulong era; + target_ulong badv; + target_ulong crmd; + target_ulong prmd; + target_ulong euen; + target_ulong ecfg; + target_ulong estat; + } csr; + target_ulong orig_a0; + target_ulong __last[0]; +}; + +#define UNAME_MACHINE "loongarch64" +#define UNAME_MINIMUM_RELEASE "5.19.0" + +#define TARGET_MCL_CURRENT 1 +#define TARGET_MCL_FUTURE 2 +#define TARGET_MCL_ONFAULT 4 + +#define TARGET_FORCE_SHMLBA + +static inline abi_ulong target_shmlba(CPULoongArchState *env) +{ + return 64 * KiB; +} + +#endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 4587b62ac9..85b0f33e91 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -74,7 +74,7 @@ || defined(TARGET_M68K) || defined(TARGET_CRIS) \ || defined(TARGET_S390X) || defined(TARGET_OPENRISC) \ || defined(TARGET_NIOS2) || defined(TARGET_RISCV) \ - || defined(TARGET_XTENSA) + || defined(TARGET_XTENSA) || defined(TARGET_LOONGARCH64) =20 #define TARGET_IOC_SIZEBITS 14 #define TARGET_IOC_DIRBITS 2 @@ -2196,6 +2196,10 @@ struct target_stat64 { uint64_t st_ino; }; =20 +#elif defined(TARGET_LOONGARCH64) + +/* LoongArch no newfstatat/fstat syscall. */ + #else #error unsupported CPU #endif diff --git a/scripts/gensyscalls.sh b/scripts/gensyscalls.sh index 8fb450e3c9..a2f7664b7b 100755 --- a/scripts/gensyscalls.sh +++ b/scripts/gensyscalls.sh @@ -44,6 +44,7 @@ read_includes() =20 cpp -P -nostdinc -fdirectives-only \ -D_UAPI_ASM_$(upper ${arch})_BITSPERLONG_H \ + -D__ASM_$(upper ${arch})_BITSPERLONG_H \ -D__BITS_PER_LONG=3D${bits} \ -I${linux}/arch/${arch}/include/uapi/ \ -I${linux}/include/uapi \ @@ -99,4 +100,5 @@ generate_syscall_nr openrisc 32 "$output/linux-user/open= risc/syscall_nr.h" generate_syscall_nr riscv 32 "$output/linux-user/riscv/syscall32_nr.h" generate_syscall_nr riscv 64 "$output/linux-user/riscv/syscall64_nr.h" generate_syscall_nr hexagon 32 "$output/linux-user/hexagon/syscall_nr.h" +generate_syscall_nr loongarch 64 "$output/linux-user/loongarch64/syscall_n= r.h" rm -fr "$TMP" --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656839921; cv=none; d=zohomail.com; s=zohoarc; b=EGMY4VqxEiI4/iXHuccdC+LHLgp6khNt5NuPrIuZ+JY4/6cliFQw67jCp6qC1INvZ3Dl/2Sq71ZEdpzqH/BKh2Lwotsu02/DmP2KvwpxjQrk9XVlS17DCqiNKlkmWXxCEZQu1zl8fmW/nzutSJxZynM3umJrbtL/LTOdY+saYxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656839921; 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=gyVKsSKTcz352Hx+z69WvjGNpCZ8RyuObOwnIrxXdDc=; b=Ll/6y9zlj1k89D5+9CX5Z6ToT9O+KDjGHqwHCbd45yww8fqzcdxxVq12gKJmst6KkDybD35LRAR3hBzLdbUYADNAY2D+7IvM744dQ3y9fqtjLR1XB3nXO+cLjIJPYrITvbcC+EHvMmBQ+AVI96FXypIwbzWgy03wpqqeggnwE3o= 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 1656839921130417.17214187635784; Sun, 3 Jul 2022 02:18:41 -0700 (PDT) Received: from localhost ([::1]:47566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7vkW-0003vf-3F for importer@patchew.org; Sun, 03 Jul 2022 05:18:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vS6-0004fv-RE for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:38 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:43525) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vS5-00049z-6o for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:38 -0400 Received: by mail-pg1-x531.google.com with SMTP id 68so6271452pgb.10 for ; Sun, 03 Jul 2022 01:59:36 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:35 -0700 (PDT) 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=gyVKsSKTcz352Hx+z69WvjGNpCZ8RyuObOwnIrxXdDc=; b=j8L9pm/ipgXEuhr5np1WSKHtkDsB/RQ8h2eW1nEFNA5+iJTfOXxe7muKzJqlQaFukF lavf2sP4Xw5fsqSHVcAWy1dQJeGYb3nk0LvqPlbprKy9eru5loRKRLkfUK71p9CoAJF/ R3LLaZ/G3UisIzigshPQ54Qdwlr+jwOXlqfJ+ZY5saayvnO5cChrs08HqrTdvuplA128 E1bStZ2HXwc/pfSSqjiqilJgJOCJ8Ve2HXi66q9YMcXutjBBE0IFSFizC6ABfKyb06i2 AMNjA5/3y0KWqD33xzQQHE+A+TQL5Q1tdYEJkKhl/Mjrpzq+31SiMttYHaIb6WliXqq2 MFrQ== 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=gyVKsSKTcz352Hx+z69WvjGNpCZ8RyuObOwnIrxXdDc=; b=Dk1Z1louV+XRXAH4F6QTxFoEM52PxERtgUrTVxhF1FpJm457ilQ5s0WV/Vg7yIJE7T UEWQwzNmvQAzfiks2RWJVH/9Tv4dBW6SRewL5QyiXUp7dPubD6MV3+tfY0o+ri89J7vl UFZkiq/6IxJcITdxhYAUjRDO4FQLlykC3H//+lCdXvpCmhyN+aGtfmcEGgEe+UUU6Z27 jMwMW/L4nRT8RNaFgrhcgZXoQJ37nyWqQPWkoO7d24ZNC+ofZJNB/vE6qDyz6jLDH8cL 3lG6TUNb7Y+XkRQjSMtFUIdagE6htcTP+BuVWNCdXmlzOZavAXCp7yPlk3w1RpogNmBK CJgw== X-Gm-Message-State: AJIora9AGWuc8T482bAjwljF3olK2plO8jBrvzTrFex9eROke1SduRID IofIeyO0Y1Go+K4mNEpM/iwKesb+1lRNszaq X-Google-Smtp-Source: AGRyM1tJgjeIUmO3ZmoLl+BCMM59dm07rXrXvYkr4VAw4y0xQmom3ORpejhjq92vclMUqaqJus1ZdQ== X-Received: by 2002:a63:2319:0:b0:411:8cff:9a98 with SMTP id j25-20020a632319000000b004118cff9a98mr18077319pgj.422.1656838775872; Sun, 03 Jul 2022 01:59:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 05/13] linux-user: Add LoongArch cpu_loop support Date: Sun, 3 Jul 2022 14:29:05 +0530 Message-Id: <20220703085913.772936-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656839923122100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-6-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- linux-user/loongarch64/target_cpu.h | 34 ++++++++++ linux-user/loongarch64/cpu_loop.c | 96 +++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 linux-user/loongarch64/target_cpu.h create mode 100644 linux-user/loongarch64/cpu_loop.c diff --git a/linux-user/loongarch64/target_cpu.h b/linux-user/loongarch64/t= arget_cpu.h new file mode 100644 index 0000000000..a29af66156 --- /dev/null +++ b/linux-user/loongarch64/target_cpu.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * LoongArch specific CPU ABI and functions for linux-user + * + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#ifndef LOONGARCH_TARGET_CPU_H +#define LOONGARCH_TARGET_CPU_H + +static inline void cpu_clone_regs_child(CPULoongArchState *env, + target_ulong newsp, unsigned flags) +{ + if (newsp) { + env->gpr[3] =3D newsp; + } + env->gpr[4] =3D 0; +} + +static inline void cpu_clone_regs_parent(CPULoongArchState *env, + unsigned flags) +{ +} + +static inline void cpu_set_tls(CPULoongArchState *env, target_ulong newtls) +{ + env->gpr[2] =3D newtls; +} + +static inline abi_ulong get_sp_from_cpustate(CPULoongArchState *state) +{ + return state->gpr[3]; +} +#endif diff --git a/linux-user/loongarch64/cpu_loop.c b/linux-user/loongarch64/cpu= _loop.c new file mode 100644 index 0000000000..894fdd111a --- /dev/null +++ b/linux-user/loongarch64/cpu_loop.c @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * QEMU LoongArch user cpu_loop. + * + * Copyright (c) 2021 Loongson Technology Corporation Limited + */ + +#include "qemu/osdep.h" +#include "qemu.h" +#include "user-internals.h" +#include "cpu_loop-common.h" +#include "signal-common.h" + +void cpu_loop(CPULoongArchState *env) +{ + CPUState *cs =3D env_cpu(env); + int trapnr, si_code; + abi_long ret; + + for (;;) { + cpu_exec_start(cs); + trapnr =3D cpu_exec(cs); + cpu_exec_end(cs); + process_queued_cpu_work(cs); + + switch (trapnr) { + case EXCP_INTERRUPT: + /* just indicate that signals should be handled asap */ + break; + case EXCCODE_SYS: + env->pc +=3D 4; + ret =3D do_syscall(env, env->gpr[11], + env->gpr[4], env->gpr[5], + env->gpr[6], env->gpr[7], + env->gpr[8], env->gpr[9], + -1, -1); + if (ret =3D=3D -QEMU_ERESTARTSYS) { + env->pc -=3D 4; + break; + } + if (ret =3D=3D -QEMU_ESIGRETURN) { + /* + * Returning from a successful sigreturn syscall. + * Avoid clobbering register state. + */ + break; + } + env->gpr[4] =3D ret; + break; + case EXCCODE_INE: + force_sig_fault(TARGET_SIGILL, 0, env->pc); + break; + case EXCCODE_FPE: + si_code =3D TARGET_FPE_FLTUNK; + if (GET_FP_CAUSE(env->fcsr0) & FP_INVALID) { + si_code =3D TARGET_FPE_FLTINV; + } else if (GET_FP_CAUSE(env->fcsr0) & FP_DIV0) { + si_code =3D TARGET_FPE_FLTDIV; + } else if (GET_FP_CAUSE(env->fcsr0) & FP_OVERFLOW) { + si_code =3D TARGET_FPE_FLTOVF; + } else if (GET_FP_CAUSE(env->fcsr0) & FP_UNDERFLOW) { + si_code =3D TARGET_FPE_FLTUND; + } else if (GET_FP_CAUSE(env->fcsr0) & FP_INEXACT) { + si_code =3D TARGET_FPE_FLTRES; + } + force_sig_fault(TARGET_SIGFPE, si_code, env->pc); + break; + case EXCP_DEBUG: + case EXCCODE_BRK: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); + break; + case EXCCODE_BCE: + force_sig_fault(TARGET_SIGSYS, TARGET_SI_KERNEL, env->pc); + break; + case EXCP_ATOMIC: + cpu_exec_step_atomic(cs); + break; + default: + EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\= n", + trapnr); + exit(EXIT_FAILURE); + } + process_pending_signals(env); + } +} + +void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) +{ + int i; + + for (i =3D 0; i < 32; i++) { + env->gpr[i] =3D regs->regs[i]; + } + env->pc =3D regs->csr.era; + +} --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656840899; cv=none; d=zohomail.com; s=zohoarc; b=JhbaRMDzwlAufwGzozniH6vcXthSqksmPNP3LztnZOL5iAps20E7Dzrr37NoH0cZyRQqPP6pfyGmIlKoPvz41WdtF6oTESOS3nGFr9ssSYtDHyCWPhUNac/T1+gHUlBt0HafGn3OBeZiT6payhYyWCWJZ80aq0v+H0SfnHRe90w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656840899; 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=pR1kqzu7xwtxnUko8pBi5w8sHK9mw7vU5UGn6K+yNzI=; b=Y2rlfc7uUUl0TEesMRjlQt5wZzrAUTT/vu76jNVmGet3iAGvywsYq22PBfH/+sGmb/tnaZXHWuof4ZsIwQ9dcY3yszgqGrfC5eU8qZzq4OdAwupr7zoIn5/5J01Td8v8x5Q0xC/b+CO97FCC1mTIlejsxbxdgkJ3BbNF3/Lv2Wo= 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 1656840899751716.3265267065406; Sun, 3 Jul 2022 02:34:59 -0700 (PDT) Received: from localhost ([::1]:57892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w0I-0005S2-K0 for importer@patchew.org; Sun, 03 Jul 2022 05:34:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vS9-0004p8-St for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:41 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:39741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vS8-0004AN-Ap for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:41 -0400 Received: by mail-pl1-x62b.google.com with SMTP id c13so2313105pla.6 for ; Sun, 03 Jul 2022 01:59:39 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:38 -0700 (PDT) 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=pR1kqzu7xwtxnUko8pBi5w8sHK9mw7vU5UGn6K+yNzI=; b=HrjsaLr2QC4GpVt/OAmW1OU3PzhNj5PAkOQryGbxF3dHzuPS+QCpdvC1GRSU5Xh8zS bMDBuPynQtGGy+oCkm4gfZ3z7pDjijpk7i8LlrY9MqyLG0qR5MzfBxymcdDmVAAhyjRI QexAb1tZOpWkvHt7ADu2XwSc4tlGMWREYYRQntCINZ4A2x5NOHzfZfJ4J/1RxCRbVbzW wHqJW/1nKdo7VWP0tHoBJ3Qa9SFrIrdIHS+gSxALWlNQl+5FV76m1Q3MSY0oIp+6CQXg UnwWb/ntunuBHcjOCQcUijDVKQ0hCeBhzW64LOvvDPQUcoyKaCtdw0lPaCIcvFTKBBg+ pN4g== 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=pR1kqzu7xwtxnUko8pBi5w8sHK9mw7vU5UGn6K+yNzI=; b=wxNzK1wxlk95eV/UICstHrNN0ziPlrMAsWQCXq9KYz1JJxk6p39YIjShiWG9Si7TSo vRYW0BXorvhO66reiz6FiRUICgm+yj9N7pLaqUjn4sS7hNdLw2DPl6yw/KFI8X8IUvc3 +X6lYl8dWsH5aw48H3qcs3EZgD+69+44j4JzIXw4KRAjz9gU7qdq2C1GBpdphwOD+Vj6 +8lR0ki+3v3PLa+6aJp2W6ITAGN9eLZInFIzCatSc9DP7pFWFlXOl+utnN4MU428egRm dyy2PvBu8+8ZBkvU/vhUVQu6+b7YCFOUiJYi18oNqsF6jLHNfVBVzkBa+fgGs+p8xydj 5M3g== X-Gm-Message-State: AJIora+K6nFes7aP7/8DT96ojxisPqVzWmBwJHf+2gJmqrvQ8O9yylRh GWIjSKH68usol/ZpkVCefKRd71ov1FXFZdJ5 X-Google-Smtp-Source: AGRyM1tx+ypKI183fH1xKqN5DTuGPIMHH0LVGiboBapcWv+JZS9jae0rnJczJiaZw6jKKtIGHGT6bQ== X-Received: by 2002:a17:903:2345:b0:16a:28ac:1c1b with SMTP id c5-20020a170903234500b0016a28ac1c1bmr31421493plh.106.1656838779045; Sun, 03 Jul 2022 01:59:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 06/13] scripts: add loongarch64 binfmt config Date: Sun, 3 Jul 2022 14:29:06 +0530 Message-Id: <20220703085913.772936-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656840900091100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-7-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- scripts/qemu-binfmt-conf.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 9cb723f443..1f4e2cd19d 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -4,7 +4,7 @@ qemu_target_list=3D"i386 i486 alpha arm armeb sparc sparc32plus sparc64 \ ppc ppc64 ppc64le m68k mips mipsel mipsn32 mipsn32el mips64 mips64el \ sh4 sh4eb s390x aarch64 aarch64_be hppa riscv32 riscv64 xtensa xtensaeb \ -microblaze microblazeel or1k x86_64 hexagon" +microblaze microblazeel or1k x86_64 hexagon loongarch64" =20 i386_magic=3D'\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\= x00\x03\x00' i386_mask=3D'\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\= xff\xfe\xff\xff\xff' @@ -140,6 +140,10 @@ hexagon_magic=3D'\x7fELF\x01\x01\x01\x00\x00\x00\x00\x= 00\x00\x00\x00\x00\x02\x00\x hexagon_mask=3D'\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\x= ff\xff\xfe\xff\xff\xff' hexagon_family=3Dhexagon =20 +loongarch64_magic=3D'\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x= 00\x02\x00\x02\x01' +loongarch64_mask=3D'\xff\xff\xff\xff\xff\xff\xff\xfc\x00\xff\xff\xff\xff\x= ff\xff\xff\xfe\xff\xff\xff' +loongarch64_family=3Dloongarch + qemu_get_family() { cpu=3D${HOST_ARCH:-$(uname -m)} case "$cpu" in --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841758; cv=none; d=zohomail.com; s=zohoarc; b=EKbj4yQiPn3T5YEFrkZEnsVQHGRyen3SK8B77KKmeEDCEJnIT8gBzXwHYNf98SqZER7xzlsq+fWfq1mzDcg0jv4Xo3PBc8Ci9/zYWq0EcbpVEwbUlrIAWDjajQM2aM0ycdgsPLCjiuxfHeE03Ib3PDLRq+xrfq3+8N4Rf2tfozA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841758; 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=21yVEfcVUBo097kH9wR354mUzWjfCDzfOMaCfmjHzQU=; b=ZrrTtXRrIzUVSz+RTLWSvSEX8IzEvvCE75CICBhbaXOl0T5VgihlUKHX3MPAf+FiHbwBAIOigV/pmJ1y4PH6DB0BqaMeLOuxl1kAWJWjD9GdHe7iHAR8sJw33JG2allHM9Fw9kTH/Yj3Byaz/h7ycdjvMqz3ICQBLSdfAAOqcdA= 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 1656841758309107.23144166414647; Sun, 3 Jul 2022 02:49:18 -0700 (PDT) Received: from localhost ([::1]:33344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7wE5-0001lI-Cj for importer@patchew.org; Sun, 03 Jul 2022 05:49:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSE-0004uV-Ug for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:48 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:34648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSB-0004Ag-EM for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:45 -0400 Received: by mail-pl1-x62d.google.com with SMTP id z1so267465plb.1 for ; Sun, 03 Jul 2022 01:59:43 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:41 -0700 (PDT) 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=21yVEfcVUBo097kH9wR354mUzWjfCDzfOMaCfmjHzQU=; b=ralihiRoAOAmdtv4kxXS1x6YAjyz8s+MBaAaRAJ9rXULMSKP9FFx5/jms3mCNnj49h twm+ftTlq5aUv4YQHd5efZgQ8/RqPII3Wo8T0TcMKRdqUzdlefd0uE6PY37abIjIZpZJ hG7UrEkh+KX9ykOxgx8XZEKAK3JRU1Jw/DK5Gn0MnEMSJmaWqygbfUn+XQyIvZOjJtB6 f3Ag0sQErhEuOzYzqzYfZZeDFWGW8FvQCyECESHLJb2WtyXLUlHL6hXUu/cc0QniwcEe RF2WEqtRX1Uv+TAUJG1ah5mtvPxfeKPnxSJthKXBsXayjScgWV6UGWlvBmR0oD5bawjT DpbQ== 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=21yVEfcVUBo097kH9wR354mUzWjfCDzfOMaCfmjHzQU=; b=BOLO+Gsbs2HPqNHDlb+dkea/ax4HAyGsxideuJORbPzXDknk1SeUGLHTfLmvHHCG/O Ie4g+HKi2+n9jwTg1S6N0HehYhym9S+Io/OPKxgA7g/rA+29jH+pamAFk+tTtbkbztqE SDxErGfYv0znBhpvOjCJwsGyivfLGI8R8t7C+JxfePVDkdkzQrnhOlLdjVKtQv2L+rJj SXr2Ep/jgSxaqhDbC4robBX0ZykS7bZhPtUm+u1JEJ8Qwe2yT2YF9BtrcxSYxnjdxFyY 0CwtOC+1Fm2uOtgkGFegfF08V2cnOyV5KlZs7Wfqjewqo2n1nc9hR3uqF3hYMASmxPSt 1zBQ== X-Gm-Message-State: AJIora/PHAYN0YWZ5GbVib06wDtSPGavJ1aa1UO2wlPyBi0hSJG8QsLt HiGRqjfl7Z7xQohJ4c5o8oilbn3xJjGrw9+9 X-Google-Smtp-Source: AGRyM1tDS/o6soM8tzWk7l9P1h5H4rt7YPONQ6wZHNUYVxkndpXlFuLRGHUt/+TiYxg58DS2Hm1JtA== X-Received: by 2002:a17:90b:3148:b0:1ed:75:47b with SMTP id ip8-20020a17090b314800b001ed0075047bmr27783520pjb.9.1656838782161; Sun, 03 Jul 2022 01:59:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 07/13] target/loongarch: remove badaddr from CPULoongArch Date: Sun, 3 Jul 2022 14:29:07 +0530 Message-Id: <20220703085913.772936-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841759083100001 Content-Type: text/plain; charset="utf-8" From: Song Gao We can use CSR_BADV to replace badaddr. Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-8-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.h | 2 -- target/loongarch/gdbstub.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 71a5036c3c..4b4fbcdc71 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -246,8 +246,6 @@ typedef struct CPUArchState { uint64_t lladdr; /* LL virtual address compared against SC */ uint64_t llval; =20 - uint64_t badaddr; - /* LoongArch CSRs */ uint64_t CSR_CRMD; uint64_t CSR_PRMD; diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index 0c48834201..24e126fb2d 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -21,7 +21,7 @@ int loongarch_cpu_gdb_read_register(CPUState *cs, GByteAr= ray *mem_buf, int n) } else if (n =3D=3D 32) { return gdb_get_regl(mem_buf, env->pc); } else if (n =3D=3D 33) { - return gdb_get_regl(mem_buf, env->badaddr); + return gdb_get_regl(mem_buf, env->CSR_BADV); } return 0; } --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841239; cv=none; d=zohomail.com; s=zohoarc; b=aKmSv6UhB5+5x8xLJLvWClI6aEI2yTAzZVeu6lznEvE/tIrMhkujL1dUgtC5R314Ij3ktt6QHKy4DXh0JzjKE6ZtU00AMjVitxQwHwSaK/UlNlg4WUKIk1ackpo3/956wO4MEpHodvPfCzkOSIn7SR3DHMZAGRu68xw9aE9f378= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841239; 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=KtmNbu9yExeJxvfDUNJQ5c1VHDhvr7IbviTyJY19R0g=; b=Glu8NgC40aQ3l/SZMJxSqBPxomt4NPCga5JEBMQpd/WgMZDGqYA1f+F+HuHK/ysbdtZj6LUNPfxcYMV43cj9FbVUU08MzCW6PUT8Rxn9wP9rKHhXwDgumfFgu052SmVk650fDgeKocfFJWy7oh0spyLL+xywGrrMrxuwJTU3YEk= 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 165684123997284.18878535889951; Sun, 3 Jul 2022 02:40:39 -0700 (PDT) Received: from localhost ([::1]:45020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w5m-0007Jj-AJ for importer@patchew.org; Sun, 03 Jul 2022 05:40:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSG-0004uc-6X for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:48 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:51076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSE-0004BH-Ob for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:47 -0400 Received: by mail-pj1-x102a.google.com with SMTP id go6so6662513pjb.0 for ; Sun, 03 Jul 2022 01:59:46 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:44 -0700 (PDT) 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=KtmNbu9yExeJxvfDUNJQ5c1VHDhvr7IbviTyJY19R0g=; b=GdnBGArj2cGdcl4t5v62Ds5t+DfkYD1SbHtHrlog4Fzk4v/F0ugRwxwUnuSW4EHY5O 1VFALVbUXK1UIM8dtj2ru99FSuDGnSov31SnBhfNEQAQ+xwTAgM2RBmtbJwOmXbY4rjN eA/TFm7HVX43JW4KI+83MLGYJR/X02lLYfwnjaVfaNUM+9Vjv+0IWGU9ZxBoxMao6X15 EF8MqMUIqumZzyfxRUzC3fI5KB9smEx/lwzbw2RRZdVUBGPfd9fUyYZ7ij2nmSCRwysU ZYw/AARz5QpF366AMib03s+LhYUpZShouCdWzPrmaQI+e9jOVDGpDIyPPZmT9q89U6tz b1Mw== 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=KtmNbu9yExeJxvfDUNJQ5c1VHDhvr7IbviTyJY19R0g=; b=hZLewKQA7RcPvuhA3FP99QyRZp75EMhbJt8zo/XViiSR95Qy6r5ZlIZq368rC+4r4c iO964FX7qGeNPJmUQ7hvbW0mznjKTsK4CEY/PDk0K78X9lWuL8xK7xM8NxxdG58d9MtD 5x8MmWQDTbnL9SDjLacWgXiDCn93moKyltK81mg46NfTe2jN+PLbkcgwfqx3AwTg40ps BrvPctyiH7KeQ/qZsonSjrfn3pt7D9l6eYR8gjAffXFYFAlj3+i/P44vYOQIkZrefag7 NT6KFYdWJxjjAYljUN6wtDJADOpGhhOCqPBpi3tpF4q5dnRSqG/8YESUYy7WteTunJna ZJQg== X-Gm-Message-State: AJIora9mk7ib+RL1XQpeh8uPyOolLCL+Mqg0br1tIESNgsdwxiaGmJJp 8Xl9UKZvVCDmAAZ9MhvmXVibLxt2360keSSQ X-Google-Smtp-Source: AGRyM1uOeZ7obv5R18Iz75j1OjQLT8KqrYKj9S+SOlUWvEkgGcpKf/v7ZDiFYlF360BTVJxVa6APww== X-Received: by 2002:a17:90b:4cc8:b0:1ee:d3a3:4e6 with SMTP id nd8-20020a17090b4cc800b001eed3a304e6mr29811244pjb.54.1656838785213; Sun, 03 Jul 2022 01:59:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 08/13] target/loongarch: Fix missing update CSR_BADV Date: Sun, 3 Jul 2022 14:29:08 +0530 Message-Id: <20220703085913.772936-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841241522100001 Content-Type: text/plain; charset="utf-8" From: Song Gao loongarch_cpu_do_interrupt() should update CSR_BADV for some EXCCODE. Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-9-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 4c8f96bc3a..e32d4cc269 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -171,18 +171,20 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) cause =3D cs->exception_index; update_badinstr =3D 0; break; - case EXCCODE_ADEM: case EXCCODE_SYS: case EXCCODE_BRK: + case EXCCODE_INE: + case EXCCODE_IPE: + case EXCCODE_FPE: + env->CSR_BADV =3D env->pc; + QEMU_FALLTHROUGH; + case EXCCODE_ADEM: case EXCCODE_PIL: case EXCCODE_PIS: case EXCCODE_PME: case EXCCODE_PNR: case EXCCODE_PNX: case EXCCODE_PPI: - case EXCCODE_INE: - case EXCCODE_IPE: - case EXCCODE_FPE: cause =3D cs->exception_index; break; default: --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841032; cv=none; d=zohomail.com; s=zohoarc; b=FS7ZmYL3H4vXXNu8r/yxQhi6Q6ciL2jPMDfj7fszNkNZMhW2lzoDpFp0ouXgwC2MgWFA1iaxZEWcwiL7JnmYae9BxA5YUVnXHkUBNwKeQxlkJi4HVL0tMjR8VY9NsxSatVsgABgEtyfIptlXnT2k8+y1LlptGPzPkD80hI6zrWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841032; 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=AQeBQJaJ2cUJJgh8YFxOAc0hMFwb7DTvcTB5KsIPLmU=; b=WhmDe7QbRSm3b+cmtD25D4PEvhIyIIDDwGM1yO+lpjdD+U2awdzYyTRPfWgyzSauceM5GonLCTzW4c1a/4u+1JY79u7b3uTJVP2aCd1nPYnPFNPg9rIKO3Sb5SWvNUab6oFrlpMihQVZ5D8Ui2WqYVQ6s4mO828RGBWnmpM0xv0= 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 1656841032806660.9281449525535; Sun, 3 Jul 2022 02:37:12 -0700 (PDT) Received: from localhost ([::1]:36464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w2R-0001du-HR for importer@patchew.org; Sun, 03 Jul 2022 05:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSI-0004x3-VT for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:52 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:33313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSH-0004BZ-3D for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:50 -0400 Received: by mail-pf1-x42b.google.com with SMTP id n12so6441899pfq.0 for ; Sun, 03 Jul 2022 01:59:48 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:47 -0700 (PDT) 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=AQeBQJaJ2cUJJgh8YFxOAc0hMFwb7DTvcTB5KsIPLmU=; b=AIncmNIgsPxl9MXSNLcvQ30eUNuW2juB8Dlnc4+xt8WBn+Pmw3TmvSNncAb/3yXXE8 lzEmfJud6SW9Nkg1hUK8mO2M9jf3P+qEkxVWBS6PiQHeKW24sGgrddVYqhbONeW+CGdB Ppoz+rBHnl8Hfqfhcbjni8sXUJQ38L0fllc7GEKEgMoiXzX6EtUKW/p+BWWSFEEl2615 NoXkuUi7okCMH8iRxMjpS1zHE5zX9RbDlJYpbYVfoLIfAjsUpjyfUX9DqfKXNEEntzAh 5VV1L02Rd2Gpeyb5DIK0s3NugbJGrHNxBAPgB2wXKG+MIOD719DqPwiw/YgnGH3WrXXs btrA== 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=AQeBQJaJ2cUJJgh8YFxOAc0hMFwb7DTvcTB5KsIPLmU=; b=PKA4FWr+PAb1XbfqBc9zqtB7/uvjSXcrRuSefnlS+avxJgLGjyqG6jmv7lpyu/CkoH 6yqID1t1aiN5Mms1fQbnY9i3jaeMioIMMvHNO8iH9cXBppJH48Y9Wp50NjFS+rq4vw0F pOvViN3w1upDTn2N59TIdHK+7wSJ5NeaX/oREfxH+DBkG95I7FT/coYzE9lys2rkn+HI yMwOECw+e75QXbXUEVUD33raxxW72PojzL66WqYQNUpXPLBU2F+zmfklAQhXyp91OKtV RNQPy3Kw3uGQJgjwDB2A26TITGMjrcqJVuuLYSj33oI1tqCgFFKrwVdajWwuwZ7/CTOR QgFQ== X-Gm-Message-State: AJIora+616sa9uoD8ZdWifaBoVcBv6fEVARkiWVYGhJZwoiYF7C6T0CV zGBijbYWHx30r244E8aRdvc67kiYTYf+P0Op X-Google-Smtp-Source: AGRyM1txNYatGa3tNb4XjLbL3XL8QSOd4DEQJKhWt4J9cmnUS1tyQ0/ixdY6VriFNqUfJHCEPZfjIw== X-Received: by 2002:a63:8ac2:0:b0:411:8061:c10f with SMTP id y185-20020a638ac2000000b004118061c10fmr19074295pgd.262.1656838787789; Sun, 03 Jul 2022 01:59:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 09/13] target/loongarch: Fix helper_asrtle_d/asrtgt_d raise wrong exception Date: Sun, 3 Jul 2022 14:29:09 +0530 Message-Id: <20220703085913.772936-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841034665100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Raise EXCCODE_BCE instead of EXCCODE_ADEM for helper_asrtle_d/asrtgt_d. Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-10-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.c | 2 ++ target/loongarch/op_helper.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index e32d4cc269..0013582a3a 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -51,6 +51,7 @@ static const char * const excp_names[] =3D { [EXCCODE_IPE] =3D "Instruction privilege error", [EXCCODE_FPE] =3D "Floating Point Exception", [EXCCODE_DBP] =3D "Debug breakpoint", + [EXCCODE_BCE] =3D "Bound Check Exception", }; =20 const char *loongarch_exception_name(int32_t exception) @@ -176,6 +177,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) case EXCCODE_INE: case EXCCODE_IPE: case EXCCODE_FPE: + case EXCCODE_BCE: env->CSR_BADV =3D env->pc; QEMU_FALLTHROUGH; case EXCCODE_ADEM: diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c index d87049851f..df049cec59 100644 --- a/target/loongarch/op_helper.c +++ b/target/loongarch/op_helper.c @@ -49,14 +49,14 @@ target_ulong helper_bitswap(target_ulong v) void helper_asrtle_d(CPULoongArchState *env, target_ulong rj, target_ulong= rk) { if (rj > rk) { - do_raise_exception(env, EXCCODE_ADEM, GETPC()); + do_raise_exception(env, EXCCODE_BCE, 0); } } =20 void helper_asrtgt_d(CPULoongArchState *env, target_ulong rj, target_ulong= rk) { if (rj <=3D rk) { - do_raise_exception(env, EXCCODE_ADEM, GETPC()); + do_raise_exception(env, EXCCODE_BCE, 0); } } =20 --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656840084; cv=none; d=zohomail.com; s=zohoarc; b=XW6kgD0EfbVK6CBBAd3nOF9WOkmAtbV1W4UVZ2o4MyuSTfXS8h4Trp/jjc/1Ac4xAmp73G9UHMJLIUPk/wwh4cwI0QwpUAW+0d2oMdlLV4NCyM/VJliYV0uGi7bt6OqucXJIhy+Yc/Yy+Ba363FBgCLhYUM8rvhyFYhQzl78vTc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656840084; 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=7miE1J32cGCfgzDoEjdy1xniOQ1sdRcJ/+h0R/nm0Nc=; b=TvBaXXxZ8Te3USQHukdCYEybdDWj1gei5+B+MdLfQupN63Beii4g2qubW/v7L89q1pgoHx40KSzcTVsMN6vGDTjJWip4Ul3cVeI6xllRZH60PkQhv3vPl/cdmKjwaYFG1e+UhKxbUfCcBInNtcH+zg6cwGH0pztXFQa71f80IKM= 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 1656840084786715.328326382505; Sun, 3 Jul 2022 02:21:24 -0700 (PDT) Received: from localhost ([::1]:56262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7vn7-0001Hy-MZ for importer@patchew.org; Sun, 03 Jul 2022 05:21:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSM-0004y7-0M for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:54 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:39767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSK-0004C3-LK for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:53 -0400 Received: by mail-pg1-x52e.google.com with SMTP id q140so6285132pgq.6 for ; Sun, 03 Jul 2022 01:59:52 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:50 -0700 (PDT) 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=7miE1J32cGCfgzDoEjdy1xniOQ1sdRcJ/+h0R/nm0Nc=; b=OOhcRLEV+AHP3/2mcgUTIouoU7yUbLkrUmYrS71DppONiMsWqmje60LjByI5Bmnw7p BrXxWMEXiPvbruQC1fdOu75LVsoJZG6/WyyNqwE/WaWYQQvlWxhBRrE1V7Qt9q9FRW6b vWmIO/54vtHoOTyYV9WrnEoDhpMIa8ZIvMA5jD7TgzpOZfgoGhMQNhUduNabNnHEp6WR weY43dOgTv84pQbS0wd+7FohEgtNEphriNsBM1CZwLXPOrF++zxAxPItgDw3EO+gY+Zj v3jp0JEbr11auFB/wexliFyeNtjZhFltAb55+s5VeRO0CKfH+SCUvEjHgKp16XbUlCPR POag== 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=7miE1J32cGCfgzDoEjdy1xniOQ1sdRcJ/+h0R/nm0Nc=; b=zzl7ILBO8152qc1Z8oVhGkIfVqtwAeyfdXcAPi1zsMQWekQRgaRSZ217Oz+mLAGQTA 5hscFTrhZrfBO6OIwotboHYcxysqij36gqHR3Le4MmmTtmBiTvXRHmnSnsL97d95JeMi jOJq5nNJ9lig3ABT+4/oeaC4oVtYVuKgQiAHSWjBgASY0oj05o8xvID+llUaJVSo09FJ LY8g+b/OpOUNb0DdOZ+JwXC3bFAZgxFC6uZPpoIuPcyDHH7r/tR2PqKI83M7rFMoj4hk +OOsChHNmMSYhDYkzALkcU/C5o9Iq5hMUmLJpLj0y7tW329soxQBXfPVS6OVmkHltL8X xswQ== X-Gm-Message-State: AJIora8XOlE0DWjD0MoHkv760X5Fob0vkKmeU5l5BsDJBbz+KppEZgdN uumxyyDIQ3Jetg1tcLijDTdF6adockam2e5z X-Google-Smtp-Source: AGRyM1t2viVGieSmyBrhHnB8WacHs5mzCg4Sgc4KHFStwA6hr4zlM84MgGKYrt/AS/zi8TgaO1MhPQ== X-Received: by 2002:a63:7a59:0:b0:40c:8f3f:8a7e with SMTP id j25-20020a637a59000000b0040c8f3f8a7emr19687918pgn.582.1656838791338; Sun, 03 Jul 2022 01:59:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 10/13] target/loongarch: remove unused include hw/loader.h Date: Sun, 3 Jul 2022 14:29:10 +0530 Message-Id: <20220703085913.772936-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656840085849100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-11-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 0013582a3a..bf163a8dce 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -18,7 +18,6 @@ #include "fpu/softfloat-helpers.h" #include "cpu-csr.h" #include "sysemu/reset.h" -#include "hw/loader.h" =20 const char * const regnames[32] =3D { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841887; cv=none; d=zohomail.com; s=zohoarc; b=fBDsgwnHCrjlG+CKsG8BpQ8W8W840Jij8bCqMsh2EZ66ZaklzYH9aWomAGSNN8LPeawVwwy/2w98AmWyx81Aw1HRK3VnGSyNJOcoijKVdGtSR8mqHODQFOwiIXovJGnS6Z8xs1KadewPmUdx3rKScuznOuWHNIdcWOpdwiCR2eA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841887; 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=HHZ8mZXSfbHbPb+0SOnZD/cO7fq4POJ4YzIOL2R+a6o=; b=NzQf4JhBOeCWRKNltgUYe1wgf59R5tE13D2kpncrdV1ozuH1kEb532ciDyNp7ELUCRTrVbyDH1IgAuBhqpK1kRjHpM7GyR4gleHS+onr1FUg4E4PQqrj5fPqpqo2sBgAltSHFTuEmZNWbkcLN7pmj0d8dNX/KZeb9rQcAqnjjjE= 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 1656841887761205.10775804511127; Sun, 3 Jul 2022 02:51:27 -0700 (PDT) Received: from localhost ([::1]:35860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7wGE-0003XZ-N4 for importer@patchew.org; Sun, 03 Jul 2022 05:51:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSP-00050z-5K for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:58 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:43962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSN-000495-8M for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:56 -0400 Received: by mail-pf1-x434.google.com with SMTP id g7so1604609pfb.10 for ; Sun, 03 Jul 2022 01:59:54 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:53 -0700 (PDT) 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=HHZ8mZXSfbHbPb+0SOnZD/cO7fq4POJ4YzIOL2R+a6o=; b=DvSMNIf4gYzGreVFBU2RrwUwBrR3cWxpOE6CSM7+ZfCtq9Wm7HgT1LmyzGl8JCWOtL Nw5b5KDH2liCXWk15uLMUFM3lbgwP8u1TXNrRhnKEE8Bw+uTQWDC5TqED6z/YRXuv3u2 4r8EkOVBl8kADcPposVBTJTAC/BooeoXXHItY1io0SdNFnEMPmq/Q4053PpFc8N6ExjO bEDcv+/UQvzke205T2spshE8GL/jubjxn82y9BpyfvzAGQMBrjk4VlWkTFmMkdpu+MIE Yzzj7X1F2ACsov8XcocbFt/93nwRl/pE+Lq4pZIlU5RUjHGaKCZlgr4caVVX3v0PlCJO PsqQ== 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=HHZ8mZXSfbHbPb+0SOnZD/cO7fq4POJ4YzIOL2R+a6o=; b=4X4NnKGa8H4f0GoCpaXy+jMGEC1N3H9o8umUjIq/GQjOHhBsgcW8cmhEDK6jo+b8Qt Pt8kkZQ+UjkAbrNd1iwMNaLbR+18vyMuVy18WkKG6A2pIwkUUX7o3r7mxqciKBEsANOv NpZX/YaZmIRno+/rxtepev+r00g8KW+YvV0JEgwzI4ItzgBOTi5U4azb97IakGmbcOqC jsUm4+ZfXNK7ldHkqf6EQ3wRCbUtc0+++Ze6mcBO/SmZE3sSUK6v18vYfnoSwUi6vU+L rQtK0JbVKNDJX7i4piB4DAXsRg26Ha0Ra2rMVX7qm9D9N+TrmDcRvAtQqr7pIp0dmH0A GRJA== X-Gm-Message-State: AJIora+VNY/w5xEU3PcdWaAZSlhJfkolnxvZLaWW7rLlP3mUC4Fg4Y8m L0QtnThwyKxlGX8FURHi4HnH+DPAi2Sa7dWq X-Google-Smtp-Source: AGRyM1vEnZ7lJHlCNdSLbQ/Df9LXxC1puf1RKQnd18r4flZDtRFnORBVtwTcOcHMWYI1PvFPKyCUQQ== X-Received: by 2002:a63:5a49:0:b0:40d:e7a0:3cb with SMTP id k9-20020a635a49000000b0040de7a003cbmr19754605pgm.69.1656838794471; Sun, 03 Jul 2022 01:59:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 11/13] target/loongarch: Adjust functions and structure to support user-mode Date: Sun, 3 Jul 2022 14:29:11 +0530 Message-Id: <20220703085913.772936-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841888602100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Some functions and member of the structure are different with softmmu-mode So we need adjust them to support user-mode. Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-12-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/cpu.h | 6 ++++ target/loongarch/helper.h | 2 ++ target/loongarch/internals.h | 2 ++ target/loongarch/cpu.c | 21 ++++++++++- target/loongarch/op_helper.c | 6 ++++ .../insn_trans/trans_privileged.c.inc | 36 +++++++++++++++++++ 6 files changed, 72 insertions(+), 1 deletion(-) diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 4b4fbcdc71..d141ec9b5d 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -301,6 +301,7 @@ typedef struct CPUArchState { uint64_t CSR_DERA; uint64_t CSR_DSAVE; =20 +#ifndef CONFIG_USER_ONLY LoongArchTLB tlb[LOONGARCH_TLB_MAX]; =20 AddressSpace address_space_iocsr; @@ -308,6 +309,7 @@ typedef struct CPUArchState { MemoryRegion iocsr_mem; bool load_elf; uint64_t elf_address; +#endif } CPULoongArchState; =20 /** @@ -358,12 +360,16 @@ struct LoongArchCPUClass { =20 static inline int cpu_mmu_index(CPULoongArchState *env, bool ifetch) { +#ifdef CONFIG_USER_ONLY + return MMU_USER_IDX; +#else uint8_t pg =3D FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PG); =20 if (!pg) { return MMU_DA_IDX; } return FIELD_EX64(env->CSR_CRMD, CSR_CRMD, PLV); +#endif } =20 static inline void cpu_get_tb_cpu_state(CPULoongArchState *env, diff --git a/target/loongarch/helper.h b/target/loongarch/helper.h index 85c11a60d4..cbbe008f32 100644 --- a/target/loongarch/helper.h +++ b/target/loongarch/helper.h @@ -95,6 +95,7 @@ DEF_HELPER_FLAGS_2(set_rounding_mode, TCG_CALL_NO_RWG, vo= id, env, i32) =20 DEF_HELPER_1(rdtime_d, i64, env) =20 +#ifndef CONFIG_USER_ONLY /* CSRs helper */ DEF_HELPER_1(csrrd_pgd, i64, env) DEF_HELPER_1(csrrd_tval, i64, env) @@ -128,3 +129,4 @@ DEF_HELPER_4(lddir, tl, env, tl, tl, i32) DEF_HELPER_4(ldpte, void, env, tl, tl, i32) DEF_HELPER_1(ertn, void, env) DEF_HELPER_1(idle, void, env) +#endif diff --git a/target/loongarch/internals.h b/target/loongarch/internals.h index 9d50fbdd81..ea227362b6 100644 --- a/target/loongarch/internals.h +++ b/target/loongarch/internals.h @@ -33,6 +33,7 @@ const char *loongarch_exception_name(int32_t exception); =20 void restore_fp_status(CPULoongArchState *env); =20 +#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_loongarch_cpu; =20 void loongarch_cpu_set_irq(void *opaque, int irq, int level); @@ -48,6 +49,7 @@ bool loongarch_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, bool probe, uintptr_t retaddr); =20 hwaddr loongarch_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); +#endif /* !CONFIG_USER_ONLY */ =20 int loongarch_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int= n); int loongarch_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n= ); diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index bf163a8dce..47c0bdd1ac 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -82,6 +82,7 @@ static void loongarch_cpu_set_pc(CPUState *cs, vaddr valu= e) env->pc =3D value; } =20 +#ifndef CONFIG_USER_ONLY #include "hw/loongarch/virt.h" =20 void loongarch_cpu_set_irq(void *opaque, int irq, int level) @@ -295,6 +296,7 @@ static bool loongarch_cpu_exec_interrupt(CPUState *cs, = int interrupt_request) } return false; } +#endif =20 #ifdef CONFIG_TCG static void loongarch_cpu_synchronize_from_tb(CPUState *cs, @@ -309,6 +311,9 @@ static void loongarch_cpu_synchronize_from_tb(CPUState = *cs, =20 static bool loongarch_cpu_has_work(CPUState *cs) { +#ifdef CONFIG_USER_ONLY + return true; +#else LoongArchCPU *cpu =3D LOONGARCH_CPU(cs); CPULoongArchState *env =3D &cpu->env; bool has_work =3D false; @@ -319,6 +324,7 @@ static bool loongarch_cpu_has_work(CPUState *cs) } =20 return has_work; +#endif } =20 static void loongarch_la464_initfn(Object *obj) @@ -467,7 +473,9 @@ static void loongarch_cpu_reset(DeviceState *dev) env->CSR_DMW[n] =3D FIELD_DP64(env->CSR_DMW[n], CSR_DMW, PLV3, 0); } =20 +#ifndef CONFIG_USER_ONLY env->pc =3D 0x1c000000; +#endif =20 restore_fp_status(env); cs->exception_index =3D -1; @@ -498,6 +506,7 @@ static void loongarch_cpu_realizefn(DeviceState *dev, E= rror **errp) lacc->parent_realize(dev, errp); } =20 +#ifndef CONFIG_USER_ONLY static void loongarch_qemu_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { @@ -532,13 +541,16 @@ static const MemoryRegionOps loongarch_qemu_ops =3D { .max_access_size =3D 8, }, }; +#endif =20 static void loongarch_cpu_init(Object *obj) { LoongArchCPU *cpu =3D LOONGARCH_CPU(obj); - CPULoongArchState *env =3D &cpu->env; =20 cpu_set_cpustate_pointers(cpu); + +#ifndef CONFIG_USER_ONLY + CPULoongArchState *env =3D &cpu->env; qdev_init_gpio_in(DEVICE(cpu), loongarch_cpu_set_irq, N_IRQS); timer_init_ns(&cpu->timer, QEMU_CLOCK_VIRTUAL, &loongarch_constant_timer_cb, cpu); @@ -548,6 +560,7 @@ static void loongarch_cpu_init(Object *obj) memory_region_init_io(&env->iocsr_mem, OBJECT(cpu), &loongarch_qemu_op= s, NULL, "iocsr_misc", 0x428); memory_region_add_subregion(&env->system_iocsr, 0, &env->iocsr_mem); +#endif } =20 static ObjectClass *loongarch_cpu_class_by_name(const char *cpu_model) @@ -615,18 +628,22 @@ static struct TCGCPUOps loongarch_tcg_ops =3D { .initialize =3D loongarch_translate_init, .synchronize_from_tb =3D loongarch_cpu_synchronize_from_tb, =20 +#ifndef CONFIG_USER_ONLY .tlb_fill =3D loongarch_cpu_tlb_fill, .cpu_exec_interrupt =3D loongarch_cpu_exec_interrupt, .do_interrupt =3D loongarch_cpu_do_interrupt, .do_transaction_failed =3D loongarch_cpu_do_transaction_failed, +#endif }; #endif /* CONFIG_TCG */ =20 +#ifndef CONFIG_USER_ONLY #include "hw/core/sysemu-cpu-ops.h" =20 static const struct SysemuCPUOps loongarch_sysemu_ops =3D { .get_phys_page_debug =3D loongarch_cpu_get_phys_page_debug, }; +#endif =20 static void loongarch_cpu_class_init(ObjectClass *c, void *data) { @@ -642,8 +659,10 @@ static void loongarch_cpu_class_init(ObjectClass *c, v= oid *data) cc->has_work =3D loongarch_cpu_has_work; cc->dump_state =3D loongarch_cpu_dump_state; cc->set_pc =3D loongarch_cpu_set_pc; +#ifndef CONFIG_USER_ONLY dc->vmsd =3D &vmstate_loongarch_cpu; cc->sysemu_ops =3D &loongarch_sysemu_ops; +#endif cc->disas_set_info =3D loongarch_cpu_disas_set_info; cc->gdb_read_register =3D loongarch_cpu_gdb_read_register; cc->gdb_write_register =3D loongarch_cpu_gdb_write_register; diff --git a/target/loongarch/op_helper.c b/target/loongarch/op_helper.c index df049cec59..4b429b6699 100644 --- a/target/loongarch/op_helper.c +++ b/target/loongarch/op_helper.c @@ -86,6 +86,9 @@ target_ulong helper_cpucfg(CPULoongArchState *env, target= _ulong rj) =20 uint64_t helper_rdtime_d(CPULoongArchState *env) { +#ifdef CONFIG_USER_ONLY + return cpu_get_host_ticks(); +#else uint64_t plv; LoongArchCPU *cpu =3D env_archcpu(env); =20 @@ -95,8 +98,10 @@ uint64_t helper_rdtime_d(CPULoongArchState *env) } =20 return cpu_loongarch_get_constant_timer_counter(cpu); +#endif } =20 +#ifndef CONFIG_USER_ONLY void helper_ertn(CPULoongArchState *env) { uint64_t csr_pplv, csr_pie; @@ -131,3 +136,4 @@ void helper_idle(CPULoongArchState *env) cs->halted =3D 1; do_raise_exception(env, EXCP_HLT, 0); } +#endif diff --git a/target/loongarch/insn_trans/trans_privileged.c.inc b/target/lo= ongarch/insn_trans/trans_privileged.c.inc index 53596c4f77..9c4dcbfcfb 100644 --- a/target/loongarch/insn_trans/trans_privileged.c.inc +++ b/target/loongarch/insn_trans/trans_privileged.c.inc @@ -7,6 +7,41 @@ =20 #include "cpu-csr.h" =20 +#ifdef CONFIG_USER_ONLY + +#define GEN_FALSE_TRANS(name) \ +static bool trans_##name(DisasContext *ctx, arg_##name * a) \ +{ \ + return false; \ +} + +GEN_FALSE_TRANS(csrrd) +GEN_FALSE_TRANS(csrwr) +GEN_FALSE_TRANS(csrxchg) +GEN_FALSE_TRANS(iocsrrd_b) +GEN_FALSE_TRANS(iocsrrd_h) +GEN_FALSE_TRANS(iocsrrd_w) +GEN_FALSE_TRANS(iocsrrd_d) +GEN_FALSE_TRANS(iocsrwr_b) +GEN_FALSE_TRANS(iocsrwr_h) +GEN_FALSE_TRANS(iocsrwr_w) +GEN_FALSE_TRANS(iocsrwr_d) +GEN_FALSE_TRANS(tlbsrch) +GEN_FALSE_TRANS(tlbrd) +GEN_FALSE_TRANS(tlbwr) +GEN_FALSE_TRANS(tlbfill) +GEN_FALSE_TRANS(tlbclr) +GEN_FALSE_TRANS(tlbflush) +GEN_FALSE_TRANS(invtlb) +GEN_FALSE_TRANS(cacop) +GEN_FALSE_TRANS(ldpte) +GEN_FALSE_TRANS(lddir) +GEN_FALSE_TRANS(ertn) +GEN_FALSE_TRANS(dbcl) +GEN_FALSE_TRANS(idle) + +#else + typedef void (*GenCSRRead)(TCGv dest, TCGv_ptr env); typedef void (*GenCSRWrite)(TCGv dest, TCGv_ptr env, TCGv src); =20 @@ -464,3 +499,4 @@ static bool trans_idle(DisasContext *ctx, arg_idle *a) ctx->base.is_jmp =3D DISAS_NORETURN; return true; } +#endif --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841207; cv=none; d=zohomail.com; s=zohoarc; b=gCfOWSXrq90a7po44spqpSNKrx9Gd3VhahBgrLVUNdzKNPxzUXY6+dbVHskd6NJVKq1ipZXg5eQInzmGaA/LQECc/lHafTbR2Z1XG58dIqV+Oy+KIPD1GjdTZYPrJVC7MnAiJIarzmLw+prxPRs9Zox2wnlBl71eO3pHjAmUNAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841207; 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=0b/YbMxnm80Cwom01Lw/iY4YJnZmRZ4e/YON8i35GFw=; b=UZZZtIEcaHvewbp70FRErnyRVr/5aF35C718d0mc2Xy5g53Qwwc5qKbSoL9zlihcpbOZoDiCb8GHm52XYahteONZaO+gG1A/3sPCKAEKIrZtsKXaR46xlt4MZ2siby22FKWOE9+ms+DMxgWJ/OaQrAeX//kwZ/eiSyVY25fTY/M= 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 165684120743591.8070191657589; Sun, 3 Jul 2022 02:40:07 -0700 (PDT) Received: from localhost ([::1]:42966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w5G-0005xe-0Q for importer@patchew.org; Sun, 03 Jul 2022 05:40:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSS-00052S-4l for qemu-devel@nongnu.org; Sun, 03 Jul 2022 05:00:00 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:38584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSQ-0004Cm-Nv for qemu-devel@nongnu.org; Sun, 03 Jul 2022 04:59:59 -0400 Received: by mail-pg1-x536.google.com with SMTP id e132so6290165pgc.5 for ; Sun, 03 Jul 2022 01:59:58 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:56 -0700 (PDT) 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=0b/YbMxnm80Cwom01Lw/iY4YJnZmRZ4e/YON8i35GFw=; b=RwXSPHkcFBNj2lGMzkSrvJyTYsmMoHP68SP4L1OVXX+G3vxVJsRkp08MOtYwrLeL9s o/aqHbydcYLGqsGCCsAjPDXCgIhV36uvpzSpNF9J4CIJhmD7VtaOHti5NioQ+3jmsfbi FgTaJR/zcsaELdx7drZbJGBC6S/IbhQ4C1EHCaV24xNGCLhWODejj70oxIRERHfRPicH OIfWmzg3kVUhn0aRlOP+/IMEcf2eoZOeRqmEh3z3U3IZOy+GkAG5bAOwzPomgAxQ1M8M 5mUNTokPgxMiDn4eE2BJDBw+DR3kPrGqyrURnT+O4+tiEv9kvQ0+kc2pVxASEICo2WCh /4fA== 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=0b/YbMxnm80Cwom01Lw/iY4YJnZmRZ4e/YON8i35GFw=; b=INZdl4Y8nZNCDp29Khtj2DALZqZAO3uA/PdJvmbkugCPywm7997UtUmbwyhEEFgosV s40sC8uNn+8vhtVbg1fAhgmaj75e/GvccfaXMa0W/F4be6xGXF8r4k4Gml4FNwvUcvfP ub1t13A0mTeDQiu/cdh70MxDz7gHjHCKLHIG+QF2Pj/86Uphv0bTCqFbsxlT8UC1kogF wllOmvuVusdO7/Nd5c7UOkZZ4a/dj/KDU6FEm4LzQffU3M71/7yzxQgF9RrHSZWbVQzn u/ieqGTbe1hYH5AveB/Syk861BYHTRCU6nWDHUK1n18FA4lTb2oZaHMmhAmwYcWPTOq9 uVNQ== X-Gm-Message-State: AJIora9t60lUL87o8S+9aurAenEW7oW5m7/07Quy9Rro4C6LF79fBdbX xUcIV3Jl1CkNhYdS5P0GfnCDvX+wD1Vi6Pnr X-Google-Smtp-Source: AGRyM1uVi/dxvWUPybquXzlaXxaSrHGhh8VFmfktjW0gzp8JUqXXSl8GNO1qpmNDlWi5r8N3WpLNKQ== X-Received: by 2002:aa7:86c9:0:b0:525:3d39:8d0f with SMTP id h9-20020aa786c9000000b005253d398d0fmr30684758pfo.54.1656838797474; Sun, 03 Jul 2022 01:59:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang , WANG Xuerui Subject: [PATCH v21 12/13] default-configs: Add loongarch linux-user support Date: Sun, 3 Jul 2022 14:29:12 +0530 Message-Id: <20220703085913.772936-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841209409100001 Content-Type: text/plain; charset="utf-8" From: Song Gao This patch adds loongarch64 linux-user default configs file. Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Reviewed-by: WANG Xuerui Message-Id: <20220624031049.1716097-13-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- configs/targets/loongarch64-linux-user.mak | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 configs/targets/loongarch64-linux-user.mak diff --git a/configs/targets/loongarch64-linux-user.mak b/configs/targets/l= oongarch64-linux-user.mak new file mode 100644 index 0000000000..7d1b964020 --- /dev/null +++ b/configs/targets/loongarch64-linux-user.mak @@ -0,0 +1,3 @@ +# Default configuration for loongarch64-linux-user +TARGET_ARCH=3Dloongarch64 +TARGET_BASE_ARCH=3Dloongarch --=20 2.34.1 From nobody Fri Apr 26 11:29:47 2024 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=1656841369; cv=none; d=zohomail.com; s=zohoarc; b=MZFHmpnLLS3YSw4UrubQ2BUJXKmbOszgFgKi0sD1rja2J4iKLyZEXfY22q9Mwonhe4AH+WB7RjiNLEl0UrcWj8Ir6B1IZCtiBmtuNKlVPOn6C8YI2ffxG/BmTaEm135KgEEBZw1apr4hAqrM8p8+9AeS8CSQnAiAcdBk+W+f7HM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656841369; 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=ZpM2xT691aOsaTZd6sDap5X966f+8/CDqP5hDIUEL28=; b=hU685vEk27c0aJD3p6vGsrOefJyOM5L2YiMMMTQArb75oUUNWpC9wuYlNz9U4aYZNtddI+H0gqMAWWTTahHlQ6o9WZhh8ljc0nMFBEIG0260vE+HzXFNDiK6oNh6FJ8Y4hEa1dJEUKUoRtGnvZ4YIt7IMhIZB0QEc/dTx4bziBI= 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 1656841369635612.6738111273639; Sun, 3 Jul 2022 02:42:49 -0700 (PDT) Received: from localhost ([::1]:49278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7w7l-0001po-SX for importer@patchew.org; Sun, 03 Jul 2022 05:42:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7vSg-00059v-L0 for qemu-devel@nongnu.org; Sun, 03 Jul 2022 05:00:17 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7vSU-0004D9-LM for qemu-devel@nongnu.org; Sun, 03 Jul 2022 05:00:04 -0400 Received: by mail-pg1-x534.google.com with SMTP id o18so5104204pgu.9 for ; Sun, 03 Jul 2022 02:00:01 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id cq16-20020a056a00331000b00518764d09cdsm18777593pfb.164.2022.07.03.01.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 01:59:59 -0700 (PDT) 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=ZpM2xT691aOsaTZd6sDap5X966f+8/CDqP5hDIUEL28=; b=OoS95rA5srGalUbqm8NyXlImTqjx5VpxWF3D4I0WeXK/azsNCV9zxm+7CSWFVMvCjU 5fwIp96zM0pwmGRW02OcWXa3CEvo+cnN5ghiU+8FavtQv+diM/eba1iFP1ZWcJdUAQwO GhBWowrJDF6Z2QDemKTQwSSmysxmI+QR5wfyoxVB3n2PLrx1NTczbb7oSGRXH2Ma3ZyP CaiI/+Jj0GD1k2SE9vLN6ZamSWA4TStTHvoge+MDc4E96flwWSoarC4uSzYOjaYknn6v jHrWE6Q0H/tcSPevq9UPwoTlzF+cBvQZpmu6Z7XE0ydINo9h6spfn7eZ+c603SLyg8mX 7AEw== 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=ZpM2xT691aOsaTZd6sDap5X966f+8/CDqP5hDIUEL28=; b=aEqXWEoJnm4CKnGVL3lUQZyNnbYnu22g8Qs+iuRB5bXDHjq7EZxX5hKIVqeNygwkp1 ipitwGqkAuNgFMGgo/UYPpPTfUg6w8Tcne8tHzlsXYUKW43mA8HiHHgV9tcVGrZDe6La Inra5P5Rpy7vGB6un3l2C24xdlRUDy04CjUgNaxhTB1vHzP6rN57Q9iRBkIVBJWdRlR1 qlH7jz6PPM3B4BDjFM6h/EW+RCT2g+Rj/2Kcwapx5iy3wlJWLR7LxhibfPXyCSY/vE3J uufQYP9TYdqZYEMOOIMOnpcGmGZ3mtcdF0/bIykAC/Ini9HiGwTMq6iBv24SHOVTtt3A angQ== X-Gm-Message-State: AJIora9/5QrF7XHrTcq4ttuyOUNJKXwfRu9YqLD0kKULfAtArLT7Casn 4IiFLrF8ef/qxGXZrp7FAvd7VWCo3UIaPI4w X-Google-Smtp-Source: AGRyM1sDXW4fhhw+/Co0lAUCuGQwNRDCNZ0bYzfebRoA30xOAfBED6zhGRQAFMWbR7h4T/TKq7QqPQ== X-Received: by 2002:a63:35c4:0:b0:40c:99f6:8889 with SMTP id c187-20020a6335c4000000b0040c99f68889mr19455689pga.387.1656838800274; Sun, 03 Jul 2022 02:00:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Song Gao , Xiaojuan Yang Subject: [PATCH v21 13/13] target/loongarch: Update README Date: Sun, 3 Jul 2022 14:29:13 +0530 Message-Id: <20220703085913.772936-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220703085913.772936-1-richard.henderson@linaro.org> References: <20220703085913.772936-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1656841372037100001 Content-Type: text/plain; charset="utf-8" From: Song Gao Add linux-user emulation introduction Signed-off-by: Song Gao Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220624031049.1716097-14-gaosong@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/README | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/target/loongarch/README b/target/loongarch/README index 4dcd0f1682..9f5edd10c8 100644 --- a/target/loongarch/README +++ b/target/loongarch/README @@ -24,9 +24,9 @@ =20 Download cross-tools. =20 - wget https://github.com/loongson/build-tools/releases/latest/downloa= d/loongarch64-clfs-20211202-cross-tools.tar.xz + wget https://github.com/loongson/build-tools/releases/download/2022.= 05.29/loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz =20 - tar -vxf loongarch64-clfs-20211202-cross-tools.tar.xz -C /opt + tar -vxf loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz -C /opt =20 Config cross-tools env. =20 @@ -60,5 +60,40 @@ =20 ./build/qemu-system-loongarch64 -machine virt -m 4G -cpu Loongson-3A50= 00 -smp 1 -kernel build/tests/tcg/loongarch64-softmmu/hello -monitor none -= display none -chardev file,path=3Dhello.out,id=3Doutput -serial chardev:out= put =20 +- Linux-user emulation + + We already support Linux user emulation. We can use LoongArch cross-tool= s to build LoongArch executables on X86 machines, + and We can also use qemu-loongarch64 to run LoongArch executables. + + 1. Config cross-tools env. + + see System emulation. + + 2. Test tests/tcg/multiarch. + + ./configure --static --prefix=3D/usr --disable-werror --target-lis= t=3D"loongarch64-linux-user" --enable-debug + + cd build + + make && make check-tcg + + 3. Run LoongArch system basic command with loongarch-clfs-system. + + - Config clfs env. + + wget https://github.com/loongson/build-tools/releases/download/2022= .05.29/loongarch64-clfs-system-5.0.tar.bz2 + + tar -vxf loongarch64-clfs-system-5.0.tar.bz2 -C /opt/clfs + + cp /opt/clfs/lib64/ld-linux-loongarch-lp64d.so.1 /lib64 + + export LD_LIBRARY_PATH=3D"/opt/clfs/lib64" + + - Run LoongArch system basic command. + + ./qemu-loongarch64 /opt/clfs/usr/bin/bash + ./qemu-loongarch64 /opt/clfs/usr/bin/ls + ./qemu-loongarch64 /opt/clfs/usr/bin/pwd + - Note. We can get the latest LoongArch documents or LoongArch tools at https://= github.com/loongson/ --=20 2.34.1