From patchwork Thu Jan 6 10:41:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV31l3V7Yz9sPC for ; Thu, 6 Jan 2022 21:46:34 +1100 (AEDT) Received: from localhost ([::1]:51178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QHu-0001Sz-Pt for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:46:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0007bs-A8 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:42669) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004iH-QE for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:55 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MsI0I-1mG4kL2EqA-00tnYG; Thu, 06 Jan 2022 11:41:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/27] qemu-binfmt-conf.sh: fix -F option Date: Thu, 6 Jan 2022 11:41:11 +0100 Message-Id: <20220106104137.732883-2-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:u/u13qdSs/kU8Vs9v+pdfCeRb9U1GZv5YzYxbvq1T3zShlYgeAo 55d46nATiXQXlggjcSmdKmjjv54hDxTlO8lg8T6DJi5OyLHliCCrhej5g9W0TW1bVl6lMp1 8Da6B+XUI+9L6PoAHmG8AiGSOGMTvaUKgKnrDe+8YZhncDI0L87duczmYuu1QQefJwwIisF ItE+qhbyB7i3XUl+j/Nwg== X-UI-Out-Filterresults: notjunk:1;V03:K0:fmlVKuJeyXM=:3Hp/XK/EX5eI6czik/18w0 g5C9du2lDiVX59fYoafYEQNzoGzo/SOxy3lRpsKAB5LhlDJFDJ571hCJuWjpvxXKxSCUZxGpk jfwBLgJ5RgT3+g5OHz+34ec07eCGk1LUldzGHm8cJTavekhnwlcVlIQE7KyPSEEzPISsYsXDV uv5+VdKZv8GJN5klh+XiseM4l76wByIJn5quPHG+8VmZxuVYrTtkrgUlINk3G9YaBl3ApiTTF +iCh+I8Z8ESi++JTDtZdNNGKrzW/3RykTl2fAkXeeGPsQLReretrM/8U3wBqs51bplSP/vhtc Oep9B//Oc5+yRpuxtigHYmAmf+dCGL3kavsEQadv6tU3BkJ7xnBG2JvbzzB6vxNfG8IWCyFeF U/SPSuTRxhi5lsjsPOibt6qEZulbmptjYa+/QBukjE7MMm0uFZVpDD9rat8YogqXd17uUIUfP 9u5h8II0KCn6S7W0cLl16U+13vXZCCqExPRwFFIYMHidWncE/SbC2nm5ajoVlDnbBkd4RbbZq mkMvM5w7xQDAeoIskvRrjSRpJgLfxStOIXe1l1rigcmXte+XSnTXnumtdzmk6jYHGkWkLG/xl QtjiTonsnnkHLwrvd9DwZjvINW9JK/rCArMMP2Fse80j5gN629gkLEyfdU8KT0zJAi+ZIbTUp 6UMbiLmUf2cedGStJ/ZzdC2VvFGRpJSr41GDPp0IoChufWMs3HuUiCX/+FzgmaIFIJY4= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Wilck , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Martin Wilck qemu-binfmt-conf.sh should use "-F" as short option for "--qemu-suffix". Fix the getopt call to make this work. Fixes: 7155be7cda5c ("qemu-binfmt-conf.sh: allow to provide a suffix to the interpreter name") Signed-off-by: Martin Wilck Reviewed-by: Laurent Vivier Message-Id: <20211129135100.3934-1-mwilck@suse.com> Signed-off-by: Laurent Vivier --- scripts/qemu-binfmt-conf.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 7de996d536ea..e9bfeb94d314 100755 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -340,7 +340,9 @@ PERSISTENT=no PRESERVE_ARG0=no QEMU_SUFFIX="" -options=$(getopt -o ds:Q:S:e:hc:p:g: -l debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,persistent:,preserve-argv0: -- "$@") +_longopts="debian,systemd:,qemu-path:,qemu-suffix:,exportdir:,help,credential:,\ +persistent:,preserve-argv0:" +options=$(getopt -o ds:Q:S:e:hc:p:g:F: -l ${_longopts} -- "$@") eval set -- "$options" while true ; do From patchwork Thu Jan 6 10:41:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV37v5Nc2z9sPC for ; Thu, 6 Jan 2022 21:51:55 +1100 (AEDT) Received: from localhost ([::1]:40546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QN7-0005Ik-Ix for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:51:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDY-0007lh-PI for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:43203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004jn-Pt for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MfHIZ-1mTdQV0KgV-00goy9; Thu, 06 Jan 2022 11:41:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/27] linux-user/hexagon: Use generic target_stat64 structure Date: Thu, 6 Jan 2022 11:41:12 +0100 Message-Id: <20220106104137.732883-3-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:P3yrWGTTx8rZnUXP2Z1XBlZNARuCE+UfgT+nMT7CQ92zhAn/ZbH Sfb81stPeKZwHvTRyc+rsmSpW0vlJ+e08LbXopw5RPLWzQMM/sKYgTvM7myvTNsTsHajLTz OOmxVmqPV33D0/cHqe2YXKIo1TTuKIhJay+kvjiADHmw0kaMHdc3btotYcvbMD4S0bi5VIC 5wwODfY/UJeJhJ4f11CEg== X-UI-Out-Filterresults: notjunk:1;V03:K0:gKN/v6+/gwA=:oqTBn+xf57wX/oMcQcOpUG 6VyL+a2J0p1sDEaQuuuK5vilF9JjUrCsiyfE1BZpSliuzOHGWZLpdZ+iVW4DXjoFoCVKVe40H oSvpP3LJlU7vNXANsXZaQaD9GfSSx/o/iCBXPF5Gtc3AA8aLQFp25arQuPFmxQs4uFcU6/vvq G4OJ08paOG/jQ59u1cmjiiyq4HYBlEseOB07vbsB111igMosSqE27GhRbMcQynu06Nr3VeZPk x/4+yvb6wrLjp9T8YK9pu9Y7EkroS3TbQUULfc8atMa5/sZbBgVSZeJ/2cfl9F8DUHchQEIns k2WWNTHWB5WN90qVz3843u17/Rs/xTBReFUgQkulketTpPsJihj4Pl5O9mOwzq3f2tGqxVUYU pAnCo0599TwDs1pSW4T/SZp9movFUzuy0Rzy0XQ3hHA42Yb2JMnn9HIhAFvU4sVFflK6lD+Fi FkMluOKq2mEiHW83aftBAfZzxf4xMsHtH2o+OWNhGzwlgTIJVDfEkSsRWgNPmCkL5dkmRtSC7 APQbF+TCI1Foac9BeYpYXXdbyoqSjsBKTjRDmi/U33st2hyJE0pCqgirvoLyDmgoJwX3Fx1ax MKo+N80HbioHM9AMz/KzfDt1neYTdbJv2kdzOKx8Q6VJL3bX6B+TMP5ZU5TAH96qIH94YhO/w /NHvGoGkckGoYLMMTBvByF65hJfC/jyJ7xIQMtGbN0FiGCLjEgEeFSrUs2iLWgT62WxI= Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Taylor Simpson , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Linux Hexagon port doesn't define a specific 'struct stat' but uses the generic one (see Linux commit 6103ec56c65c [*] "asm-generic: add generic ABI headers" which predates the introduction of the Hexagon port). Remove the target specific target_stat (which in fact is the target_stat64 structure but uses incorrect target_long and ABI unsafe long long types) and use the generic target_stat64 instead. [*] https://github.com/torvalds/linux/commit/6103ec56c65c3#diff-5f59b07b38273b7d6a74193bc81a8cd18928c688276eae20cb10c569de3253ee Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Reviewed-by: Taylor Simpson Tested-by: Taylor Simpson Message-Id: <20211116210919.2823206-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/syscall_defs.h | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 0b139759377b..585e933140ac 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2133,7 +2133,8 @@ struct target_stat64 { abi_ulong __unused5; }; -#elif defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) || defined(TARGET_RISCV) +#elif defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) \ + || defined(TARGET_RISCV) || defined(TARGET_HEXAGON) /* These are the asm-generic versions of the stat and stat64 structures */ @@ -2244,31 +2245,6 @@ struct target_stat64 { uint64_t st_ino; }; -#elif defined(TARGET_HEXAGON) - -struct target_stat { - unsigned long long st_dev; - unsigned long long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned long long st_rdev; - target_ulong __pad1; - long long st_size; - target_long st_blksize; - int __pad2; - long long st_blocks; - - target_long target_st_atime; - target_long target_st_atime_nsec; - target_long target_st_mtime; - target_long target_st_mtime_nsec; - target_long target_st_ctime; - target_long target_st_ctime_nsec; - int __unused[2]; -}; - #else #error unsupported CPU #endif From patchwork Thu Jan 6 10:41:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV2x95zNpz9sPC for ; Thu, 6 Jan 2022 21:42:37 +1100 (AEDT) Received: from localhost ([::1]:43876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QE6-0007dW-6O for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:42:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0007bm-8l for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:39177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004iY-QE for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:55 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mr9OA-1mYsk70HpO-00oCxw; Thu, 06 Jan 2022 11:41:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/27] linux-user: Mark cpu_loop() with noreturn attribute Date: Thu, 6 Jan 2022 11:41:13 +0100 Message-Id: <20220106104137.732883-4-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:kVevOnxjNrQhpzT+PA/6z1ynTQwWO7QfZ6cCl2xJUGUpuvdxdG3 189dG2/ysVgxmI2NUEF76+4K3MClklRn1DTMDe1dBSp2t3f0L+3hjd/TnFSr8qtAIaa2Sx7 toy+C27U2KwwyBlZSDfluugXhFKbWGjMbng2NyKDwjxvS47tDPFM2skTu8N83bsYBfu+Him zuA3eDkSdWCexojhM1CpA== X-UI-Out-Filterresults: notjunk:1;V03:K0:7LhMDGCzNZk=:DdEsEJ8rnnbhknn6D8l+gM 18rMT2uA1ukv7+o/3iyqOw6zmeA4WVzg+Z0YSN/5gD0N7v/Il5TIk3JD9A08OQI9PpNci74eY N7F+MAMNDVtvlWUU1JAbr4WPhalE1Jvk53ZLDoOWbz+WCCXl1VprR5Pj7YtXdqgu27XLFXDIH ZdCgsbB4jWkSZY9LvxVeic8Ib6isFTM5fxuFEzSDBgWNdUsNvjwMyipfiLuS7meUScoIRN99F XOzHeoiVYftgkp74by2XjHZrwh2Ix79MT/Vb2hQ2HQHncYNDKYJWxwRsKjyEeI2Ga0FAsxCU+ bw11fGBQ37rjOhU9NwJTbXug9NW+tstCOJGA8umc8e47iw5FDsAAGb+ktkfh6V5McGdilG7wG yVCdKi2B3Aa9mNBZ8mTiigu4mcyalAbQPLBw6gTQaKMOEn2CklWXDJt/MNbNoSNIm5WHvGGHG EvRPKU82/wjAGiv5EMp5LRAn7OX3zT44mtD0gNmBIi0CPuv21ymiyMtZxXx2XwcEdaXIOLya+ WaWK3MBNxjHSLKU6mxLD0AECDhU1p8R+PnIPw7ARN61stjK2dhsUSOpSfRkNdUOkQL4QAFN+V id2GWRlN+bRRGITWo1tt/UzlCqyPkTo9rvFou08GwxkptuV5cmRrkjW15J+vaRkv3Cb9dSPxo NVDpr8aQO+BBVSRa3d/jhG5H+dhvfWkE19lklCagGMblyuACHY3Y0y4q/R4Y1DdKajio= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bin Meng , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Warner Losh , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé cpu_loop() never exits, so mark it with QEMU_NORETURN. Reviewed-by: Richard Henderson Reviewed-By: Warner Losh Reviewed-by: Bin Meng Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Warner Losh Message-Id: <20211106113916.544587-1-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/user-internals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index f71f37282994..a8fdd6933b23 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -64,7 +64,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8); extern __thread CPUState *thread_cpu; -void cpu_loop(CPUArchState *env); +void QEMU_NORETURN cpu_loop(CPUArchState *env); const char *target_strerror(int err); int get_osversion(void); void init_qemu_uname_release(void); From patchwork Thu Jan 6 10:41:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV32618q4z9sPC for ; Thu, 6 Jan 2022 21:46:54 +1100 (AEDT) Received: from localhost ([::1]:52078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QIF-000269-Vj for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:46:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDV-0007cu-0Z for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:47453) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004ia-Pd for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1My3Ad-1mArYP0Ktz-00zaqD; Thu, 06 Jan 2022 11:41:42 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/27] linux-user: Move target_signal.h generic definitions to generic/signal.h Date: Thu, 6 Jan 2022 11:41:14 +0100 Message-Id: <20220106104137.732883-5-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:+wgdF5CoUsgsMqtWkXtXNfDYrXEiscisornL7h8ZnsIh4kdCfR3 eJIhiSMdFagMrdS+Yb7JfPKm2JlAcnRcJiFAAKcxH7/EFJZQsbyJN04TdmFnXN/HoP2heVY 3G3er/nXTa1/TzpcZrbRlzxOtYta0xqrXoS5xVsL6UVaZr6NoSbaXM2BtMIqlbCVA1zM11x cJnMkEsJnWXv+8CNkEveA== X-UI-Out-Filterresults: notjunk:1;V03:K0:voXw0mK29yI=:Oj6vbPPDVSZJ31YMKNyC/z foocgqJs7+rD3U+qSBxByrFdOyDngDElo5zcBC/jKYy2sDSSNSYI7pB3IQLnCqx7/JcyUwHuH Em7ZXGtoGphbx2dXc1PBw5yEsMQ5hQPvlKq2XgtGJQOMyNOenfKWW8allm7AC17cIWZ+xPl8+ HwpEMuE4xwuHRW8Lkj+djW2sjq/V8hecU9UiSSaFcDUVMkXsNsEZn5CAw8nEOIpXogcbk+0FB MtKW9IGivnwldQWPR8yhojkk0XvEQfpjIudDNCBd6HXDfDXsBNGHANeqn1AHhmryhg//ns5LN FkK7yBvmMud8o519fKZzY+STptdZybFXKtYAV/y9SrDChkcMQK1IEVUV6j2k32cy35OxiXhCR 2JcnGdTkx5BzAu4jzr7tqGcg8oJbn6QkLtCqaWCOT/T1YP88FBM8r4iq/ZrGK0mMF0P0vk58z bUpVJLvrGR5VZi3DV9GazPrMIfRxfFOROQq0TYUarMKbGtmbnNtG6t9UJo/2Oqqcp7o6W7Pso LG4mj4cJSMTZUHlI5V/Ab6Iw42AYsbYLk9E+cxxGMPndMHGOn/iEWDjl4nER7xjj5jlryWePu 2/s45Wseiiyt2FQKZWsw0NhqP9phRx80CLqcZ0aa35r3OmtdyFsobUtEyLu3Bjwg/d2gWMHZ/ vq9OVPNsGeGT04qFd62efsGTeU/xZV321p++erxkaRCJZqWiOhTe3DIQvMMBfVw//CHM= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Song Gao , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Song Gao No code change Suggested-by: Richard Henderson Signed-off-by: Song Gao Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <1637893388-10282-2-git-send-email-gaosong@loongson.cn> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_signal.h | 18 ------------------ linux-user/arm/target_signal.h | 18 ------------------ linux-user/cris/target_signal.h | 18 ------------------ linux-user/generic/signal.h | 16 ++++++++++++++++ linux-user/hexagon/target_signal.h | 11 ----------- linux-user/i386/target_signal.h | 18 ------------------ linux-user/m68k/target_signal.h | 18 ------------------ linux-user/microblaze/target_signal.h | 18 ------------------ linux-user/nios2/target_signal.h | 16 ---------------- linux-user/openrisc/target_signal.h | 23 ----------------------- linux-user/ppc/target_signal.h | 18 ------------------ linux-user/riscv/target_signal.h | 12 ------------ linux-user/s390x/target_signal.h | 15 --------------- linux-user/sh4/target_signal.h | 18 ------------------ linux-user/x86_64/target_signal.h | 18 ------------------ linux-user/xtensa/target_signal.h | 17 ----------------- 16 files changed, 16 insertions(+), 256 deletions(-) diff --git a/linux-user/aarch64/target_signal.h b/linux-user/aarch64/target_signal.h index 7580d99403cb..40e399d9908d 100644 --- a/linux-user/aarch64/target_signal.h +++ b/linux-user/aarch64/target_signal.h @@ -1,24 +1,6 @@ #ifndef AARCH64_TARGET_SIGNAL_H #define AARCH64_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ diff --git a/linux-user/arm/target_signal.h b/linux-user/arm/target_signal.h index 1e7fb0cecbdd..0e6351d9f789 100644 --- a/linux-user/arm/target_signal.h +++ b/linux-user/arm/target_signal.h @@ -1,24 +1,6 @@ #ifndef ARM_TARGET_SIGNAL_H #define ARM_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/cris/target_signal.h b/linux-user/cris/target_signal.h index 83a515550745..ab0653fcdc06 100644 --- a/linux-user/cris/target_signal.h +++ b/linux-user/cris/target_signal.h @@ -1,24 +1,6 @@ #ifndef CRIS_TARGET_SIGNAL_H #define CRIS_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/generic/signal.h b/linux-user/generic/signal.h index 943bc1a1e220..ceaf8a876ca0 100644 --- a/linux-user/generic/signal.h +++ b/linux-user/generic/signal.h @@ -55,6 +55,22 @@ #define TARGET_SIG_UNBLOCK 1 /* for unblocking signals */ #define TARGET_SIG_SETMASK 2 /* for setting the signal mask */ +/* this struct defines a stack used during syscall handling */ +typedef struct target_sigaltstack { + abi_ulong ss_sp; + abi_int ss_flags; + abi_ulong ss_size; +} target_stack_t; + +/* + * sigaltstack controls + */ +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 2048 +#define TARGET_SIGSTKSZ 8192 + /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ /* mask for all SS_xxx flags */ diff --git a/linux-user/hexagon/target_signal.h b/linux-user/hexagon/target_signal.h index 9e0223d32225..193abac340c5 100644 --- a/linux-user/hexagon/target_signal.h +++ b/linux-user/hexagon/target_signal.h @@ -18,17 +18,6 @@ #ifndef HEXAGON_TARGET_SIGNAL_H #define HEXAGON_TARGET_SIGNAL_H -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/i386/target_signal.h b/linux-user/i386/target_signal.h index 64d09f2e75bd..9315cba241cf 100644 --- a/linux-user/i386/target_signal.h +++ b/linux-user/i386/target_signal.h @@ -1,24 +1,6 @@ #ifndef I386_TARGET_SIGNAL_H #define I386_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/m68k/target_signal.h b/linux-user/m68k/target_signal.h index 94157bf1f48d..6e0f4b74e391 100644 --- a/linux-user/m68k/target_signal.h +++ b/linux-user/m68k/target_signal.h @@ -1,24 +1,6 @@ #ifndef M68K_TARGET_SIGNAL_H #define M68K_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/microblaze/target_signal.h b/linux-user/microblaze/target_signal.h index e8b510f6b182..7dc5c45f00ac 100644 --- a/linux-user/microblaze/target_signal.h +++ b/linux-user/microblaze/target_signal.h @@ -1,24 +1,6 @@ #ifndef MICROBLAZE_TARGET_SIGNAL_H #define MICROBLAZE_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/nios2/target_signal.h b/linux-user/nios2/target_signal.h index fe266c4c51dc..46ca5948cea4 100644 --- a/linux-user/nios2/target_signal.h +++ b/linux-user/nios2/target_signal.h @@ -1,22 +1,6 @@ #ifndef NIOS2_TARGET_SIGNAL_H #define NIOS2_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* sigaltstack controls */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" /* Nios2 uses a fixed address on the kuser page for sigreturn. */ diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index 077ec3d5e8d7..5b9d40974a9e 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -1,29 +1,6 @@ #ifndef OPENRISC_TARGET_SIGNAL_H #define OPENRISC_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_long ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - -/* sigaltstack controls */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_SA_NOCLDSTOP 0x00000001 -#define TARGET_SA_NOCLDWAIT 0x00000002 -#define TARGET_SA_SIGINFO 0x00000004 -#define TARGET_SA_ONSTACK 0x08000000 -#define TARGET_SA_RESTART 0x10000000 -#define TARGET_SA_NODEFER 0x40000000 -#define TARGET_SA_RESETHAND 0x80000000 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/ppc/target_signal.h b/linux-user/ppc/target_signal.h index 82184ab8f2ef..5be24e152b7e 100644 --- a/linux-user/ppc/target_signal.h +++ b/linux-user/ppc/target_signal.h @@ -1,24 +1,6 @@ #ifndef PPC_TARGET_SIGNAL_H #define PPC_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #if !defined(TARGET_PPC64) diff --git a/linux-user/riscv/target_signal.h b/linux-user/riscv/target_signal.h index 3e36fddc9dbb..6c0470f0bc82 100644 --- a/linux-user/riscv/target_signal.h +++ b/linux-user/riscv/target_signal.h @@ -1,18 +1,6 @@ #ifndef RISCV_TARGET_SIGNAL_H #define RISCV_TARGET_SIGNAL_H -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index 64f5f422010f..41e0e34a55d7 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -1,21 +1,6 @@ #ifndef S390X_TARGET_SIGNAL_H #define S390X_TARGET_SIGNAL_H -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index 04069cba6641..eee6a1a7cda4 100644 --- a/linux-user/sh4/target_signal.h +++ b/linux-user/sh4/target_signal.h @@ -1,24 +1,6 @@ #ifndef SH4_TARGET_SIGNAL_H #define SH4_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SETUP_FRAME diff --git a/linux-user/x86_64/target_signal.h b/linux-user/x86_64/target_signal.h index 4673c5a88691..9d9717406f3b 100644 --- a/linux-user/x86_64/target_signal.h +++ b/linux-user/x86_64/target_signal.h @@ -1,24 +1,6 @@ #ifndef X86_64_TARGET_SIGNAL_H #define X86_64_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" /* For x86_64, use of SA_RESTORER is mandatory. */ diff --git a/linux-user/xtensa/target_signal.h b/linux-user/xtensa/target_signal.h index 1c7ee73154ac..e4b1bea5cb5d 100644 --- a/linux-user/xtensa/target_signal.h +++ b/linux-user/xtensa/target_signal.h @@ -1,23 +1,6 @@ #ifndef XTENSA_TARGET_SIGNAL_H #define XTENSA_TARGET_SIGNAL_H -/* this struct defines a stack used during syscall handling */ - -typedef struct target_sigaltstack { - abi_ulong ss_sp; - abi_int ss_flags; - abi_ulong ss_size; -} target_stack_t; - -/* - * sigaltstack controls - */ -#define TARGET_SS_ONSTACK 1 -#define TARGET_SS_DISABLE 2 - -#define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 - #include "../generic/signal.h" #define TARGET_ARCH_HAS_SIGTRAMP_PAGE 1 From patchwork Thu Jan 6 10:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3FR0Whyz9sPC for ; Thu, 6 Jan 2022 21:56:43 +1100 (AEDT) Received: from localhost ([::1]:58062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QRk-00005G-L2 for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:56:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDc-0007r2-2C for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:51613) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDV-0004lA-D0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:03 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MXp1Q-1mtJF439pM-00YCJq; Thu, 06 Jan 2022 11:41:43 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/27] linux-user: target_syscall.h remove definition TARGET_MINSIGSTKSZ Date: Thu, 6 Jan 2022 11:41:15 +0100 Message-Id: <20220106104137.732883-6-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:P+4YYXvdr8TVSFDawjtIrjcFujhs4NDGSefD2EvQL77pC/XqpOQ l6HHNmXe8StbTefbdvx8/WmgIcqVec7JSuIlqeR7nhR0HUNpSTVmV5p2DFWG/WUPlyLauNr DvuVFV55DBJLzmf7Vgo0R20RnsWSqsMkeSrH+oWITSE0iSnjobxlU6AT6e9+WdaGopOJoeh YptRl2o5RJivpvryAQRdg== X-UI-Out-Filterresults: notjunk:1;V03:K0:BcoB8/0vNNI=:o9IzJNNgTKcd8lFFLDSJWd zHUfZYbkkdn9XxmQepbe5HP55Yw4hzdoFYM1fvjG0Jt7T2GHXFNa9oAKwOizYKGBdMDKL4Kkj Bpw/O+3LP68eW4wjkNjWSvlp+5fzrwLmkkxiPSc4O0+V0eanOFVA+tYuegPDNaQdczlwNb7Yp GfdGZfYKbvrAkPz+8nd8uHF184U5qpsTdbqqsu4wEGNHl/3sjdOOLmSRGIGGJlJ5wy7j3Tiuv jkIbZDJQXoWz95LPKgmBT81DJf93OtCCBWHASo0tW7IIpwK8eahZ54YseXNufgTVNSSZFhaON avaLdl+ll0bOPieYCunJgYTH5d96/ickb6mPdA21uGOpbjUI266/u3ukeDspiJckhrAmvZGZi Z2Zl16wIO0WbNonvGvdC9KuoqCwX0OI3fWpWRFi8KQOyHsB4ndi75ycicewtdXT0Wp3PqJLfd 0W9TZyfDfaOI0v8dBxgvtjDr5aa/dvvF6MRH93+ttmzap0S5YIGMWn8/vv9KnL4cA2AlrPJh7 7RiJ0Qasc/wWkRwWwCfrmHiIzCXTafAMpVsXRFH2LgzVN25/vK4f2E8A+hc5U+JGHeqqQxjb9 s5pDeRFQ3vvaKih7q4AeoQ7OJoA/amWYxOUDTTK8e2em9aE1SYN3/26ZSlwVDDIS0kNDEAhru qSKJMIJfatu8kibjmxsscU3/OCCsv40UjMw13rEQl8hkokelILydBD0AymBlikx+9tI4= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Song Gao , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Song Gao TARGET_MINSIGSTKSZ has been defined in generic/signal.h or target_signal.h, We don't need to define it again. Signed-off-by: Song Gao Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <1637893388-10282-3-git-send-email-gaosong@loongson.cn> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_syscall.h | 1 - linux-user/alpha/target_syscall.h | 1 - linux-user/arm/target_syscall.h | 1 - linux-user/cris/target_syscall.h | 1 - linux-user/hppa/target_syscall.h | 1 - linux-user/i386/target_syscall.h | 1 - linux-user/m68k/target_syscall.h | 1 - linux-user/microblaze/target_syscall.h | 1 - linux-user/mips/target_syscall.h | 1 - linux-user/mips64/target_syscall.h | 1 - linux-user/nios2/target_syscall.h | 1 - linux-user/openrisc/target_syscall.h | 1 - linux-user/ppc/target_syscall.h | 1 - linux-user/riscv/target_syscall.h | 1 - linux-user/s390x/target_syscall.h | 1 - linux-user/sh4/target_syscall.h | 1 - linux-user/sparc/target_syscall.h | 1 - linux-user/x86_64/target_syscall.h | 1 - 18 files changed, 18 deletions(-) diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h index 76f6c3391d33..508219d62aba 100644 --- a/linux-user/aarch64/target_syscall.h +++ b/linux-user/aarch64/target_syscall.h @@ -15,7 +15,6 @@ struct target_pt_regs { #endif #define UNAME_MINIMUM_RELEASE "3.8.0" #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/alpha/target_syscall.h b/linux-user/alpha/target_syscall.h index 03091bf0a826..fda3a49f29be 100644 --- a/linux-user/alpha/target_syscall.h +++ b/linux-user/alpha/target_syscall.h @@ -63,7 +63,6 @@ struct target_pt_regs { #define TARGET_UAC_NOPRINT 1 #define TARGET_UAC_NOFIX 2 #define TARGET_UAC_SIGBUS 4 -#define TARGET_MINSIGSTKSZ 4096 #define TARGET_MCL_CURRENT 0x2000 #define TARGET_MCL_FUTURE 0x4000 #define TARGET_MCL_ONFAULT 0x8000 diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h index e870ed7a5468..f04f9c9e3d75 100644 --- a/linux-user/arm/target_syscall.h +++ b/linux-user/arm/target_syscall.h @@ -27,7 +27,6 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/cris/target_syscall.h b/linux-user/cris/target_syscall.h index 19e12814039c..0b5ebf1f0283 100644 --- a/linux-user/cris/target_syscall.h +++ b/linux-user/cris/target_syscall.h @@ -39,7 +39,6 @@ struct target_pt_regs { }; #define TARGET_CLONE_BACKWARDS2 -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/hppa/target_syscall.h b/linux-user/hppa/target_syscall.h index 0018bcb5c4dc..4b382c1fcf4a 100644 --- a/linux-user/hppa/target_syscall.h +++ b/linux-user/hppa/target_syscall.h @@ -22,7 +22,6 @@ struct target_pt_regs { #define UNAME_MACHINE "parisc" #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/i386/target_syscall.h b/linux-user/i386/target_syscall.h index ed356b3908dc..aaade06b136a 100644 --- a/linux-user/i386/target_syscall.h +++ b/linux-user/i386/target_syscall.h @@ -150,7 +150,6 @@ struct target_vm86plus_struct { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/m68k/target_syscall.h b/linux-user/m68k/target_syscall.h index 23359a6299dd..8d4ddbd76c8f 100644 --- a/linux-user/m68k/target_syscall.h +++ b/linux-user/m68k/target_syscall.h @@ -20,7 +20,6 @@ struct target_pt_regs { #define UNAME_MACHINE "m68k" #define UNAME_MINIMUM_RELEASE "2.6.32" -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/microblaze/target_syscall.h b/linux-user/microblaze/target_syscall.h index 7f653db34f87..43362a1664ca 100644 --- a/linux-user/microblaze/target_syscall.h +++ b/linux-user/microblaze/target_syscall.h @@ -49,7 +49,6 @@ struct target_pt_regs { }; #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/mips/target_syscall.h b/linux-user/mips/target_syscall.h index f59057493a35..7a82661fdb47 100644 --- a/linux-user/mips/target_syscall.h +++ b/linux-user/mips/target_syscall.h @@ -24,7 +24,6 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/mips64/target_syscall.h b/linux-user/mips64/target_syscall.h index cd1e1b496916..2c7a881c7434 100644 --- a/linux-user/mips64/target_syscall.h +++ b/linux-user/mips64/target_syscall.h @@ -21,7 +21,6 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/nios2/target_syscall.h b/linux-user/nios2/target_syscall.h index 78006c24d479..561b28d2816a 100644 --- a/linux-user/nios2/target_syscall.h +++ b/linux-user/nios2/target_syscall.h @@ -30,7 +30,6 @@ struct target_pt_regs { unsigned long orig_r7; }; -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/openrisc/target_syscall.h b/linux-user/openrisc/target_syscall.h index ef0d89a551d5..7fe5b73d3bea 100644 --- a/linux-user/openrisc/target_syscall.h +++ b/linux-user/openrisc/target_syscall.h @@ -15,7 +15,6 @@ struct target_pt_regs { #define UNAME_MACHINE "openrisc" #define UNAME_MINIMUM_RELEASE "2.6.32" -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/ppc/target_syscall.h b/linux-user/ppc/target_syscall.h index b9c4b813d3e4..8b364697d4a6 100644 --- a/linux-user/ppc/target_syscall.h +++ b/linux-user/ppc/target_syscall.h @@ -71,7 +71,6 @@ struct target_revectored_struct { #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 0x2000 #define TARGET_MCL_FUTURE 0x4000 #define TARGET_MCL_ONFAULT 0x8000 diff --git a/linux-user/riscv/target_syscall.h b/linux-user/riscv/target_syscall.h index 9b1316132496..7601f10c28e7 100644 --- a/linux-user/riscv/target_syscall.h +++ b/linux-user/riscv/target_syscall.h @@ -51,7 +51,6 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "4.15.0" #endif -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/s390x/target_syscall.h b/linux-user/s390x/target_syscall.h index 94f84178db79..4018988a25e1 100644 --- a/linux-user/s390x/target_syscall.h +++ b/linux-user/s390x/target_syscall.h @@ -27,7 +27,6 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_CLONE_BACKWARDS2 -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/sh4/target_syscall.h b/linux-user/sh4/target_syscall.h index c1437adafefa..148398855dfe 100644 --- a/linux-user/sh4/target_syscall.h +++ b/linux-user/sh4/target_syscall.h @@ -15,7 +15,6 @@ struct target_pt_regs { #define UNAME_MACHINE "sh4" #define UNAME_MINIMUM_RELEASE "2.6.32" -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 diff --git a/linux-user/sparc/target_syscall.h b/linux-user/sparc/target_syscall.h index 087b39d39c4c..be77e44eb860 100644 --- a/linux-user/sparc/target_syscall.h +++ b/linux-user/sparc/target_syscall.h @@ -34,7 +34,6 @@ struct target_pt_regs { * and copy_thread(). */ #define TARGET_CLONE_BACKWARDS -#define TARGET_MINSIGSTKSZ 4096 #define TARGET_MCL_CURRENT 0x2000 #define TARGET_MCL_FUTURE 0x4000 #define TARGET_MCL_ONFAULT 0x8000 diff --git a/linux-user/x86_64/target_syscall.h b/linux-user/x86_64/target_syscall.h index 3ecccb72be2d..fb558345d30b 100644 --- a/linux-user/x86_64/target_syscall.h +++ b/linux-user/x86_64/target_syscall.h @@ -100,7 +100,6 @@ struct target_msqid64_ds { #define TARGET_ARCH_SET_FS 0x1002 #define TARGET_ARCH_GET_FS 0x1003 #define TARGET_ARCH_GET_GS 0x1004 -#define TARGET_MINSIGSTKSZ 2048 #define TARGET_MCL_CURRENT 1 #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 From patchwork Thu Jan 6 10:41:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV2xD2DdNz9sPC for ; Thu, 6 Jan 2022 21:42:40 +1100 (AEDT) Received: from localhost ([::1]:44124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QEA-0007t2-3V for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:42:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60832) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDV-0007dd-Vd for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:48013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004im-QV for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mzhar-1mAJK21Hpx-00vjDn; Thu, 06 Jan 2022 11:41:43 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/27] linux-user: Remove TARGET_SIGSTKSZ Date: Thu, 6 Jan 2022 11:41:16 +0100 Message-Id: <20220106104137.732883-7-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:sEHu2G6uqFVovwX87LA38sMZn0Pu74NIWYhjQyx/LA3t7sf3q1B PCqe9vvZkxEEM7yJjK10P2b0e3W+EOhIefg29lOsHEQYXAs9NyZNR6MX/MsgLsqY317LJBh Zy4onkgs4Vg7lZXpUC+/q5EEttitSj4zsuM5V68H0tkYxZQ557GTXfppZ92L54C7/bd1mPS 714L6JNx6VvtR+Zwifx7A== X-UI-Out-Filterresults: notjunk:1;V03:K0:0AYBN3c9wHY=:jpEbHKkdApzSdjUoo/uQQ2 6LjB+AhUGeKhbIUt5BQph26MBLMjlpeaHjs/ekx5roJxGGQ6jlcpBSHbxKw7LwG5z8kKf2TVZ G608D7O7YXsokh0MxeIMANQqlZXjCsP6Vgqdbd4Uhb25/UzYzcNWYqvgsZheic0Oc5XwChXZT k2jeAzjDrqfpXmHMXKvvvXSVrCNu/JJqzlWLXecb8O17IWOMZfCb4Oj8L9x+E+M5/P6a6BJLc XrlMratN1usHEd6DnabtlrexZqVsxVOo33YaNs7/HlaP4BfueMVJhqA8GOY8nEPPa/dqAwjw4 ZkoaRXFnr/0BLi52OeSVME4VIaMqvHvnkA1YhUkqoCfkEhpfpSDAdND9ZVq1mMYa7u4Hro1+7 lQbmfwCV+x5HL2aJXKJkKdrmuVQYU0o2gMuCFQXopBAvaP1A+tlOtQTDuiWJMua1kQ4WgNjdt k1ZY57ZFs4do1J78MvmcdOqdqC4NpBrXIzBnIrKLyOHXREja7LEfvN8FFH6H34rKdi0zu8UYB IgDCtvHKGxv76s8D7ZidRjNwOfNRw8FALR2vmVJU/nbdkBWOf91OJyrSDsT3iKaLRoEx8QTf9 +reRvaytkeV5KK1ZQKH/ZNwrQrPchQJ6lu7OE3PKTLLD96yTqtu2CEabQGOAT177PrLOw2qkS Iotb7Uw9wqgwl490Iqr1hJn+Z8r0EFtvyXMw1HZBjh7h3TDvxvMT287G4BgFOhWcfcHU= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Song Gao , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Song Gao TARGET_SIGSTKSZ is not used, we should remove it. Signed-off-by: Song Gao Reviewed-by: Richard Henderson Message-Id: <1637893388-10282-4-git-send-email-gaosong@loongson.cn> Signed-off-by: Laurent Vivier --- linux-user/alpha/target_signal.h | 1 - linux-user/generic/signal.h | 1 - linux-user/hppa/target_signal.h | 1 - linux-user/mips/target_signal.h | 1 - linux-user/mips64/target_signal.h | 1 - linux-user/sparc/target_signal.h | 1 - 6 files changed, 6 deletions(-) diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index 0b6a39de6576..bbb06e546308 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -62,7 +62,6 @@ typedef struct target_sigaltstack { #define TARGET_SA_SIGINFO 0x00000040 #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_SIGSTKSZ 16384 /* From . */ #define TARGET_GEN_INTOVF -1 /* integer overflow */ diff --git a/linux-user/generic/signal.h b/linux-user/generic/signal.h index ceaf8a876ca0..6fd05b77bb3e 100644 --- a/linux-user/generic/signal.h +++ b/linux-user/generic/signal.h @@ -69,7 +69,6 @@ typedef struct target_sigaltstack { #define TARGET_SS_DISABLE 2 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signal.h index d558119ee7bd..af6c2fce589d 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -64,7 +64,6 @@ typedef struct target_sigaltstack { #define TARGET_SA_NOCLDWAIT 0x00000080 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/mips/target_signal.h b/linux-user/mips/target_signal.h index 780a4ddf29de..fa542c1f4e2e 100644 --- a/linux-user/mips/target_signal.h +++ b/linux-user/mips/target_signal.h @@ -67,7 +67,6 @@ typedef struct target_sigaltstack { #define TARGET_SA_RESTORER 0x04000000 /* Only for O32 */ #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 #if defined(TARGET_ABI_MIPSO32) /* compare linux/arch/mips/kernel/signal.c:setup_frame() */ diff --git a/linux-user/mips64/target_signal.h b/linux-user/mips64/target_signal.h index 275e9b7f9a2a..b05098f7f64e 100644 --- a/linux-user/mips64/target_signal.h +++ b/linux-user/mips64/target_signal.h @@ -65,7 +65,6 @@ typedef struct target_sigaltstack { #define TARGET_SA_RESETHAND 0x80000000 #define TARGET_MINSIGSTKSZ 2048 -#define TARGET_SIGSTKSZ 8192 /* bit-flags */ #define TARGET_SS_AUTODISARM (1U << 31) /* disable sas during sighandling */ diff --git a/linux-user/sparc/target_signal.h b/linux-user/sparc/target_signal.h index e661ddd6ab3c..87757f0c4e76 100644 --- a/linux-user/sparc/target_signal.h +++ b/linux-user/sparc/target_signal.h @@ -65,7 +65,6 @@ typedef struct target_sigaltstack { #define TARGET_ARCH_HAS_KA_RESTORER 1 #define TARGET_MINSIGSTKSZ 4096 -#define TARGET_SIGSTKSZ 16384 #ifdef TARGET_ABI32 #define TARGET_ARCH_HAS_SETUP_FRAME From patchwork Thu Jan 6 10:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3Rs67yZz9sSs for ; Thu, 6 Jan 2022 22:05:44 +1100 (AEDT) Received: from localhost ([::1]:51750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QaT-00075m-6U for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 06:05:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDc-0007r3-9k for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:41099) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDT-0004kS-B4 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:04 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLR5f-1mnTYS3Q3v-00IWrB; Thu, 06 Jan 2022 11:41:44 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/27] linux-user: Split out do_prctl and subroutines Date: Thu, 6 Jan 2022 11:41:17 +0100 Message-Id: <20220106104137.732883-8-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:dzprA5NzmlNllchFjHgPBk5X//NKNlzBhYadH7rNQ4/zgjv8pxF ExSksWYiNJoLDAK52DRBGbfC6Kj2zL/EMtdb0gCias/DODPN6FxghT/HuxR10lorgycW0Ou C+qHRXfkHruvCK7s8xK1fyLljPcC59ZmAh5Bmd4E1SDagqsaBrq/f3Mr8CXNJ2e2eJYkI54 1xXpYC/VLJvV3I1su+l5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:/d8DkJx+QCM=:wi1O8TgFwTAhNh/yi8l2kZ fYJXDaTSNPAHfp7bBIsUy1PCZuHdVdKSLORIxsQzzSiyrHvl0L3v2n0esUMstruSd/Pd3X/LK JKS50tTsRn0PRi2jPczKbmH0t1SAjRDAsNPsgE4kspL7YbZY0tmQ5ct5xU8em9GAm63iNetbv z+Kd+00qfde5UyfT0EabJbGvws+jDCljiKqSSpKrM/8v6MecZwyfRTy63Ov0CYUkYkHh/HEyd IQL+pRqxAu5y5nHa++tWtmuWAnxL/FytONa5fO8d4Kn6qrg8X006oOZHCSJFBf1g4qn9yVgcm f0EVTznB/dMgcYAS709RicFzrLVfz/BfBYFhqi/YUIS41oEmUogd4zuGPVVxKLSuB9UwNNbf4 RIXl+Aj9nfeuutDVKDOiYrIMHcZCqkT+EHALJy9YohGvg08h0z1opPHuTpc1Dtfm90gTL8iN+ aZffoofmpIfAWP4w2RSAu9efWrKvB9JEBDC0TGlqRDV9a+wikeMlgT1+xkBcgGrrSs7UVbsya FSiZ+oYJKOziJSizWh61W+2abP6ejLT34dEPG4cGSzKHuhfDVb3YL7U3YeqgQh2CyRqaGXJWL eHSmFRXb8zKTQ/ldRUv7eOKNWU+FBZXbI2ne46hXXexYumfhXyhElfhl8qcBgdMVE+M1B6mJf D48qIM66KaK+CaYyrq44C5MjPcOAwDBIcOh8fopoesaaO1ezSe+N/UivA868QoSCs+rU= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Since the prctl constants are supposed to be generic, supply any that are not provided by the host. Split out subroutines for PR_GET_FP_MODE, PR_SET_FP_MODE, PR_GET_VL, PR_SET_VL, PR_RESET_KEYS, PR_SET_TAGGED_ADDR_CTRL, PR_GET_TAGGED_ADDR_CTRL. Return EINVAL for guests that do not support these options rather than pass them on to the host. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20211227150127.2659293-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_prctl.h | 160 ++++++++++ linux-user/aarch64/target_syscall.h | 23 -- linux-user/alpha/target_prctl.h | 1 + linux-user/arm/target_prctl.h | 1 + linux-user/cris/target_prctl.h | 1 + linux-user/hexagon/target_prctl.h | 1 + linux-user/hppa/target_prctl.h | 1 + linux-user/i386/target_prctl.h | 1 + linux-user/m68k/target_prctl.h | 1 + linux-user/microblaze/target_prctl.h | 1 + linux-user/mips/target_prctl.h | 88 ++++++ linux-user/mips/target_syscall.h | 6 - linux-user/mips64/target_prctl.h | 1 + linux-user/mips64/target_syscall.h | 6 - linux-user/nios2/target_prctl.h | 1 + linux-user/openrisc/target_prctl.h | 1 + linux-user/ppc/target_prctl.h | 1 + linux-user/riscv/target_prctl.h | 1 + linux-user/s390x/target_prctl.h | 1 + linux-user/sh4/target_prctl.h | 1 + linux-user/sparc/target_prctl.h | 1 + linux-user/syscall.c | 433 +++++++++------------------ linux-user/x86_64/target_prctl.h | 1 + linux-user/xtensa/target_prctl.h | 1 + 24 files changed, 414 insertions(+), 320 deletions(-) create mode 100644 linux-user/aarch64/target_prctl.h create mode 100644 linux-user/alpha/target_prctl.h create mode 100644 linux-user/arm/target_prctl.h create mode 100644 linux-user/cris/target_prctl.h create mode 100644 linux-user/hexagon/target_prctl.h create mode 100644 linux-user/hppa/target_prctl.h create mode 100644 linux-user/i386/target_prctl.h create mode 100644 linux-user/m68k/target_prctl.h create mode 100644 linux-user/microblaze/target_prctl.h create mode 100644 linux-user/mips/target_prctl.h create mode 100644 linux-user/mips64/target_prctl.h create mode 100644 linux-user/nios2/target_prctl.h create mode 100644 linux-user/openrisc/target_prctl.h create mode 100644 linux-user/ppc/target_prctl.h create mode 100644 linux-user/riscv/target_prctl.h create mode 100644 linux-user/s390x/target_prctl.h create mode 100644 linux-user/sh4/target_prctl.h create mode 100644 linux-user/sparc/target_prctl.h create mode 100644 linux-user/x86_64/target_prctl.h create mode 100644 linux-user/xtensa/target_prctl.h diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h new file mode 100644 index 000000000000..3f5a5d3933a0 --- /dev/null +++ b/linux-user/aarch64/target_prctl.h @@ -0,0 +1,160 @@ +/* + * AArch64 specific prctl functions for linux-user + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef AARCH64_TARGET_PRCTL_H +#define AARCH64_TARGET_PRCTL_H + +static abi_long do_prctl_get_vl(CPUArchState *env) +{ + ARMCPU *cpu = env_archcpu(env); + if (cpu_isar_feature(aa64_sve, cpu)) { + return ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; + } + return -TARGET_EINVAL; +} +#define do_prctl_get_vl do_prctl_get_vl + +static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2) +{ + /* + * We cannot support either PR_SVE_SET_VL_ONEXEC or PR_SVE_VL_INHERIT. + * Note the kernel definition of sve_vl_valid allows for VQ=512, + * i.e. VL=8192, even though the current architectural maximum is VQ=16. + */ + if (cpu_isar_feature(aa64_sve, env_archcpu(env)) + && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { + ARMCPU *cpu = env_archcpu(env); + uint32_t vq, old_vq; + + old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; + vq = MAX(arg2 / 16, 1); + vq = MIN(vq, cpu->sve_max_vq); + + if (vq < old_vq) { + aarch64_sve_narrow_vq(env, vq); + } + env->vfp.zcr_el[1] = vq - 1; + arm_rebuild_hflags(env); + return vq * 16; + } + return -TARGET_EINVAL; +} +#define do_prctl_set_vl do_prctl_set_vl + +static abi_long do_prctl_reset_keys(CPUArchState *env, abi_long arg2) +{ + ARMCPU *cpu = env_archcpu(env); + + if (cpu_isar_feature(aa64_pauth, cpu)) { + int all = (PR_PAC_APIAKEY | PR_PAC_APIBKEY | + PR_PAC_APDAKEY | PR_PAC_APDBKEY | PR_PAC_APGAKEY); + int ret = 0; + Error *err = NULL; + + if (arg2 == 0) { + arg2 = all; + } else if (arg2 & ~all) { + return -TARGET_EINVAL; + } + if (arg2 & PR_PAC_APIAKEY) { + ret |= qemu_guest_getrandom(&env->keys.apia, + sizeof(ARMPACKey), &err); + } + if (arg2 & PR_PAC_APIBKEY) { + ret |= qemu_guest_getrandom(&env->keys.apib, + sizeof(ARMPACKey), &err); + } + if (arg2 & PR_PAC_APDAKEY) { + ret |= qemu_guest_getrandom(&env->keys.apda, + sizeof(ARMPACKey), &err); + } + if (arg2 & PR_PAC_APDBKEY) { + ret |= qemu_guest_getrandom(&env->keys.apdb, + sizeof(ARMPACKey), &err); + } + if (arg2 & PR_PAC_APGAKEY) { + ret |= qemu_guest_getrandom(&env->keys.apga, + sizeof(ARMPACKey), &err); + } + if (ret != 0) { + /* + * Some unknown failure in the crypto. The best + * we can do is log it and fail the syscall. + * The real syscall cannot fail this way. + */ + qemu_log_mask(LOG_UNIMP, "PR_PAC_RESET_KEYS: Crypto failure: %s", + error_get_pretty(err)); + error_free(err); + return -TARGET_EIO; + } + return 0; + } + return -TARGET_EINVAL; +} +#define do_prctl_reset_keys do_prctl_reset_keys + +static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2) +{ + abi_ulong valid_mask = PR_TAGGED_ADDR_ENABLE; + ARMCPU *cpu = env_archcpu(env); + + if (cpu_isar_feature(aa64_mte, cpu)) { + valid_mask |= PR_MTE_TCF_MASK; + valid_mask |= PR_MTE_TAG_MASK; + } + + if (arg2 & ~valid_mask) { + return -TARGET_EINVAL; + } + env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE; + + if (cpu_isar_feature(aa64_mte, cpu)) { + switch (arg2 & PR_MTE_TCF_MASK) { + case PR_MTE_TCF_NONE: + case PR_MTE_TCF_SYNC: + case PR_MTE_TCF_ASYNC: + break; + default: + return -EINVAL; + } + + /* + * Write PR_MTE_TCF to SCTLR_EL1[TCF0]. + * Note that the syscall values are consistent with hw. + */ + env->cp15.sctlr_el[1] = + deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT); + + /* + * Write PR_MTE_TAG to GCR_EL1[Exclude]. + * Note that the syscall uses an include mask, + * and hardware uses an exclude mask -- invert. + */ + env->cp15.gcr_el1 = + deposit64(env->cp15.gcr_el1, 0, 16, ~arg2 >> PR_MTE_TAG_SHIFT); + arm_rebuild_hflags(env); + } + return 0; +} +#define do_prctl_set_tagged_addr_ctrl do_prctl_set_tagged_addr_ctrl + +static abi_long do_prctl_get_tagged_addr_ctrl(CPUArchState *env) +{ + ARMCPU *cpu = env_archcpu(env); + abi_long ret = 0; + + if (env->tagged_addr_enable) { + ret |= PR_TAGGED_ADDR_ENABLE; + } + if (cpu_isar_feature(aa64_mte, cpu)) { + /* See do_prctl_set_tagged_addr_ctrl. */ + ret |= extract64(env->cp15.sctlr_el[1], 38, 2) << PR_MTE_TCF_SHIFT; + ret = deposit64(ret, PR_MTE_TAG_SHIFT, 16, ~env->cp15.gcr_el1); + } + return ret; +} +#define do_prctl_get_tagged_addr_ctrl do_prctl_get_tagged_addr_ctrl + +#endif /* AARCH64_TARGET_PRCTL_H */ diff --git a/linux-user/aarch64/target_syscall.h b/linux-user/aarch64/target_syscall.h index 508219d62aba..a98f568ab4d7 100644 --- a/linux-user/aarch64/target_syscall.h +++ b/linux-user/aarch64/target_syscall.h @@ -19,27 +19,4 @@ struct target_pt_regs { #define TARGET_MCL_FUTURE 2 #define TARGET_MCL_ONFAULT 4 -#define TARGET_PR_SVE_SET_VL 50 -#define TARGET_PR_SVE_GET_VL 51 - -#define TARGET_PR_PAC_RESET_KEYS 54 -# define TARGET_PR_PAC_APIAKEY (1 << 0) -# define TARGET_PR_PAC_APIBKEY (1 << 1) -# define TARGET_PR_PAC_APDAKEY (1 << 2) -# define TARGET_PR_PAC_APDBKEY (1 << 3) -# define TARGET_PR_PAC_APGAKEY (1 << 4) - -#define TARGET_PR_SET_TAGGED_ADDR_CTRL 55 -#define TARGET_PR_GET_TAGGED_ADDR_CTRL 56 -# define TARGET_PR_TAGGED_ADDR_ENABLE (1UL << 0) -/* MTE tag check fault modes */ -# define TARGET_PR_MTE_TCF_SHIFT 1 -# define TARGET_PR_MTE_TCF_NONE (0UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_SYNC (1UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_ASYNC (2UL << TARGET_PR_MTE_TCF_SHIFT) -# define TARGET_PR_MTE_TCF_MASK (3UL << TARGET_PR_MTE_TCF_SHIFT) -/* MTE tag inclusion mask */ -# define TARGET_PR_MTE_TAG_SHIFT 3 -# define TARGET_PR_MTE_TAG_MASK (0xffffUL << TARGET_PR_MTE_TAG_SHIFT) - #endif /* AARCH64_TARGET_SYSCALL_H */ diff --git a/linux-user/alpha/target_prctl.h b/linux-user/alpha/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/alpha/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/arm/target_prctl.h b/linux-user/arm/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/arm/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/cris/target_prctl.h b/linux-user/cris/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/cris/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/hexagon/target_prctl.h b/linux-user/hexagon/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/hexagon/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/hppa/target_prctl.h b/linux-user/hppa/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/hppa/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/i386/target_prctl.h b/linux-user/i386/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/i386/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/m68k/target_prctl.h b/linux-user/m68k/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/m68k/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/microblaze/target_prctl.h b/linux-user/microblaze/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/microblaze/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/mips/target_prctl.h b/linux-user/mips/target_prctl.h new file mode 100644 index 000000000000..e028333db95d --- /dev/null +++ b/linux-user/mips/target_prctl.h @@ -0,0 +1,88 @@ +/* + * MIPS specific prctl functions for linux-user + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef MIPS_TARGET_PRCTL_H +#define MIPS_TARGET_PRCTL_H + +static abi_long do_prctl_get_fp_mode(CPUArchState *env) +{ + abi_long ret = 0; + + if (env->CP0_Status & (1 << CP0St_FR)) { + ret |= PR_FP_MODE_FR; + } + if (env->CP0_Config5 & (1 << CP0C5_FRE)) { + ret |= PR_FP_MODE_FRE; + } + return ret; +} +#define do_prctl_get_fp_mode do_prctl_get_fp_mode + +static abi_long do_prctl_set_fp_mode(CPUArchState *env, abi_long arg2) +{ + bool old_fr = env->CP0_Status & (1 << CP0St_FR); + bool old_fre = env->CP0_Config5 & (1 << CP0C5_FRE); + bool new_fr = arg2 & PR_FP_MODE_FR; + bool new_fre = arg2 & PR_FP_MODE_FRE; + const unsigned int known_bits = PR_FP_MODE_FR | PR_FP_MODE_FRE; + + /* If nothing to change, return right away, successfully. */ + if (old_fr == new_fr && old_fre == new_fre) { + return 0; + } + /* Check the value is valid */ + if (arg2 & ~known_bits) { + return -TARGET_EOPNOTSUPP; + } + /* Setting FRE without FR is not supported. */ + if (new_fre && !new_fr) { + return -TARGET_EOPNOTSUPP; + } + if (new_fr && !(env->active_fpu.fcr0 & (1 << FCR0_F64))) { + /* FR1 is not supported */ + return -TARGET_EOPNOTSUPP; + } + if (!new_fr && (env->active_fpu.fcr0 & (1 << FCR0_F64)) + && !(env->CP0_Status_rw_bitmask & (1 << CP0St_FR))) { + /* cannot set FR=0 */ + return -TARGET_EOPNOTSUPP; + } + if (new_fre && !(env->active_fpu.fcr0 & (1 << FCR0_FREP))) { + /* Cannot set FRE=1 */ + return -TARGET_EOPNOTSUPP; + } + + int i; + fpr_t *fpr = env->active_fpu.fpr; + for (i = 0; i < 32 ; i += 2) { + if (!old_fr && new_fr) { + fpr[i].w[!FP_ENDIAN_IDX] = fpr[i + 1].w[FP_ENDIAN_IDX]; + } else if (old_fr && !new_fr) { + fpr[i + 1].w[FP_ENDIAN_IDX] = fpr[i].w[!FP_ENDIAN_IDX]; + } + } + + if (new_fr) { + env->CP0_Status |= (1 << CP0St_FR); + env->hflags |= MIPS_HFLAG_F64; + } else { + env->CP0_Status &= ~(1 << CP0St_FR); + env->hflags &= ~MIPS_HFLAG_F64; + } + if (new_fre) { + env->CP0_Config5 |= (1 << CP0C5_FRE); + if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { + env->hflags |= MIPS_HFLAG_FRE; + } + } else { + env->CP0_Config5 &= ~(1 << CP0C5_FRE); + env->hflags &= ~MIPS_HFLAG_FRE; + } + + return 0; +} +#define do_prctl_set_fp_mode do_prctl_set_fp_mode + +#endif /* MIPS_TARGET_PRCTL_H */ diff --git a/linux-user/mips/target_syscall.h b/linux-user/mips/target_syscall.h index 7a82661fdb47..08ead678104f 100644 --- a/linux-user/mips/target_syscall.h +++ b/linux-user/mips/target_syscall.h @@ -35,10 +35,4 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) return 0x40000; } -/* MIPS-specific prctl() options */ -#define TARGET_PR_SET_FP_MODE 45 -#define TARGET_PR_GET_FP_MODE 46 -#define TARGET_PR_FP_MODE_FR (1 << 0) -#define TARGET_PR_FP_MODE_FRE (1 << 1) - #endif /* MIPS_TARGET_SYSCALL_H */ diff --git a/linux-user/mips64/target_prctl.h b/linux-user/mips64/target_prctl.h new file mode 100644 index 000000000000..18da9ae6192f --- /dev/null +++ b/linux-user/mips64/target_prctl.h @@ -0,0 +1 @@ +#include "../mips/target_prctl.h" diff --git a/linux-user/mips64/target_syscall.h b/linux-user/mips64/target_syscall.h index 2c7a881c7434..358dc2d64c99 100644 --- a/linux-user/mips64/target_syscall.h +++ b/linux-user/mips64/target_syscall.h @@ -32,10 +32,4 @@ static inline abi_ulong target_shmlba(CPUMIPSState *env) return 0x40000; } -/* MIPS-specific prctl() options */ -#define TARGET_PR_SET_FP_MODE 45 -#define TARGET_PR_GET_FP_MODE 46 -#define TARGET_PR_FP_MODE_FR (1 << 0) -#define TARGET_PR_FP_MODE_FRE (1 << 1) - #endif /* MIPS64_TARGET_SYSCALL_H */ diff --git a/linux-user/nios2/target_prctl.h b/linux-user/nios2/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/nios2/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/openrisc/target_prctl.h b/linux-user/openrisc/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/openrisc/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/ppc/target_prctl.h b/linux-user/ppc/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/ppc/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/riscv/target_prctl.h b/linux-user/riscv/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/riscv/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/s390x/target_prctl.h b/linux-user/s390x/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/s390x/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/sh4/target_prctl.h b/linux-user/sh4/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/sh4/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/sparc/target_prctl.h b/linux-user/sparc/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/sparc/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 56a3e1718370..0f0f67d56721 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6294,9 +6294,155 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) return ret; } #endif /* defined(TARGET_ABI32 */ - #endif /* defined(TARGET_I386) */ +/* + * These constants are generic. Supply any that are missing from the host. + */ +#ifndef PR_SET_NAME +# define PR_SET_NAME 15 +# define PR_GET_NAME 16 +#endif +#ifndef PR_SET_FP_MODE +# define PR_SET_FP_MODE 45 +# define PR_GET_FP_MODE 46 +# define PR_FP_MODE_FR (1 << 0) +# define PR_FP_MODE_FRE (1 << 1) +#endif +#ifndef PR_SVE_SET_VL +# define PR_SVE_SET_VL 50 +# define PR_SVE_GET_VL 51 +# define PR_SVE_VL_LEN_MASK 0xffff +# define PR_SVE_VL_INHERIT (1 << 17) +#endif +#ifndef PR_PAC_RESET_KEYS +# define PR_PAC_RESET_KEYS 54 +# define PR_PAC_APIAKEY (1 << 0) +# define PR_PAC_APIBKEY (1 << 1) +# define PR_PAC_APDAKEY (1 << 2) +# define PR_PAC_APDBKEY (1 << 3) +# define PR_PAC_APGAKEY (1 << 4) +#endif +#ifndef PR_SET_TAGGED_ADDR_CTRL +# define PR_SET_TAGGED_ADDR_CTRL 55 +# define PR_GET_TAGGED_ADDR_CTRL 56 +# define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#endif +#ifndef PR_MTE_TCF_SHIFT +# define PR_MTE_TCF_SHIFT 1 +# define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT) +# define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT) +# define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT) +# define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT) +# define PR_MTE_TAG_SHIFT 3 +# define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) +#endif + +#include "target_prctl.h" + +static abi_long do_prctl_inval0(CPUArchState *env) +{ + return -TARGET_EINVAL; +} + +static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2) +{ + return -TARGET_EINVAL; +} + +#ifndef do_prctl_get_fp_mode +#define do_prctl_get_fp_mode do_prctl_inval0 +#endif +#ifndef do_prctl_set_fp_mode +#define do_prctl_set_fp_mode do_prctl_inval1 +#endif +#ifndef do_prctl_get_vl +#define do_prctl_get_vl do_prctl_inval0 +#endif +#ifndef do_prctl_set_vl +#define do_prctl_set_vl do_prctl_inval1 +#endif +#ifndef do_prctl_reset_keys +#define do_prctl_reset_keys do_prctl_inval1 +#endif +#ifndef do_prctl_set_tagged_addr_ctrl +#define do_prctl_set_tagged_addr_ctrl do_prctl_inval1 +#endif +#ifndef do_prctl_get_tagged_addr_ctrl +#define do_prctl_get_tagged_addr_ctrl do_prctl_inval0 +#endif + +static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + abi_long ret; + + switch (option) { + case PR_GET_PDEATHSIG: + { + int deathsig; + ret = get_errno(prctl(PR_GET_PDEATHSIG, &deathsig, + arg3, arg4, arg5)); + if (!is_error(ret) && arg2 && put_user_s32(deathsig, arg2)) { + return -TARGET_EFAULT; + } + return ret; + } + case PR_GET_NAME: + { + void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(PR_GET_NAME, (uintptr_t)name, + arg3, arg4, arg5)); + unlock_user(name, arg2, 16); + return ret; + } + case PR_SET_NAME: + { + void *name = lock_user(VERIFY_READ, arg2, 16, 1); + if (!name) { + return -TARGET_EFAULT; + } + ret = get_errno(prctl(PR_SET_NAME, (uintptr_t)name, + arg3, arg4, arg5)); + unlock_user(name, arg2, 0); + return ret; + } + case PR_GET_FP_MODE: + return do_prctl_get_fp_mode(env); + case PR_SET_FP_MODE: + return do_prctl_set_fp_mode(env, arg2); + case PR_SVE_GET_VL: + return do_prctl_get_vl(env); + case PR_SVE_SET_VL: + return do_prctl_set_vl(env, arg2); + case PR_PAC_RESET_KEYS: + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_reset_keys(env, arg2); + case PR_SET_TAGGED_ADDR_CTRL: + if (arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_set_tagged_addr_ctrl(env, arg2); + case PR_GET_TAGGED_ADDR_CTRL: + if (arg2 || arg3 || arg4 || arg5) { + return -TARGET_EINVAL; + } + return do_prctl_get_tagged_addr_ctrl(env); + case PR_GET_SECCOMP: + case PR_SET_SECCOMP: + /* Disable seccomp to prevent the target disabling syscalls we need. */ + return -TARGET_EINVAL; + default: + /* Most prctl options have no pointer arguments */ + return get_errno(prctl(option, arg2, arg3, arg4, arg5)); + } +} + #define NEW_STACK_SIZE 0x40000 @@ -10635,290 +10781,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; #endif case TARGET_NR_prctl: - switch (arg1) { - case PR_GET_PDEATHSIG: - { - int deathsig; - ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5)); - if (!is_error(ret) && arg2 - && put_user_s32(deathsig, arg2)) { - return -TARGET_EFAULT; - } - return ret; - } -#ifdef PR_GET_NAME - case PR_GET_NAME: - { - void *name = lock_user(VERIFY_WRITE, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 16); - return ret; - } - case PR_SET_NAME: - { - void *name = lock_user(VERIFY_READ, arg2, 16, 1); - if (!name) { - return -TARGET_EFAULT; - } - ret = get_errno(prctl(arg1, (unsigned long)name, - arg3, arg4, arg5)); - unlock_user(name, arg2, 0); - return ret; - } -#endif -#ifdef TARGET_MIPS - case TARGET_PR_GET_FP_MODE: - { - CPUMIPSState *env = ((CPUMIPSState *)cpu_env); - ret = 0; - if (env->CP0_Status & (1 << CP0St_FR)) { - ret |= TARGET_PR_FP_MODE_FR; - } - if (env->CP0_Config5 & (1 << CP0C5_FRE)) { - ret |= TARGET_PR_FP_MODE_FRE; - } - return ret; - } - case TARGET_PR_SET_FP_MODE: - { - CPUMIPSState *env = ((CPUMIPSState *)cpu_env); - bool old_fr = env->CP0_Status & (1 << CP0St_FR); - bool old_fre = env->CP0_Config5 & (1 << CP0C5_FRE); - bool new_fr = arg2 & TARGET_PR_FP_MODE_FR; - bool new_fre = arg2 & TARGET_PR_FP_MODE_FRE; - - const unsigned int known_bits = TARGET_PR_FP_MODE_FR | - TARGET_PR_FP_MODE_FRE; - - /* If nothing to change, return right away, successfully. */ - if (old_fr == new_fr && old_fre == new_fre) { - return 0; - } - /* Check the value is valid */ - if (arg2 & ~known_bits) { - return -TARGET_EOPNOTSUPP; - } - /* Setting FRE without FR is not supported. */ - if (new_fre && !new_fr) { - return -TARGET_EOPNOTSUPP; - } - if (new_fr && !(env->active_fpu.fcr0 & (1 << FCR0_F64))) { - /* FR1 is not supported */ - return -TARGET_EOPNOTSUPP; - } - if (!new_fr && (env->active_fpu.fcr0 & (1 << FCR0_F64)) - && !(env->CP0_Status_rw_bitmask & (1 << CP0St_FR))) { - /* cannot set FR=0 */ - return -TARGET_EOPNOTSUPP; - } - if (new_fre && !(env->active_fpu.fcr0 & (1 << FCR0_FREP))) { - /* Cannot set FRE=1 */ - return -TARGET_EOPNOTSUPP; - } - - int i; - fpr_t *fpr = env->active_fpu.fpr; - for (i = 0; i < 32 ; i += 2) { - if (!old_fr && new_fr) { - fpr[i].w[!FP_ENDIAN_IDX] = fpr[i + 1].w[FP_ENDIAN_IDX]; - } else if (old_fr && !new_fr) { - fpr[i + 1].w[FP_ENDIAN_IDX] = fpr[i].w[!FP_ENDIAN_IDX]; - } - } - - if (new_fr) { - env->CP0_Status |= (1 << CP0St_FR); - env->hflags |= MIPS_HFLAG_F64; - } else { - env->CP0_Status &= ~(1 << CP0St_FR); - env->hflags &= ~MIPS_HFLAG_F64; - } - if (new_fre) { - env->CP0_Config5 |= (1 << CP0C5_FRE); - if (env->active_fpu.fcr0 & (1 << FCR0_FREP)) { - env->hflags |= MIPS_HFLAG_FRE; - } - } else { - env->CP0_Config5 &= ~(1 << CP0C5_FRE); - env->hflags &= ~MIPS_HFLAG_FRE; - } - - return 0; - } -#endif /* MIPS */ -#ifdef TARGET_AARCH64 - case TARGET_PR_SVE_SET_VL: - /* - * We cannot support either PR_SVE_SET_VL_ONEXEC or - * PR_SVE_VL_INHERIT. Note the kernel definition - * of sve_vl_valid allows for VQ=512, i.e. VL=8192, - * even though the current architectural maximum is VQ=16. - */ - ret = -TARGET_EINVAL; - if (cpu_isar_feature(aa64_sve, env_archcpu(cpu_env)) - && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) { - CPUARMState *env = cpu_env; - ARMCPU *cpu = env_archcpu(env); - uint32_t vq, old_vq; - - old_vq = (env->vfp.zcr_el[1] & 0xf) + 1; - vq = MAX(arg2 / 16, 1); - vq = MIN(vq, cpu->sve_max_vq); - - if (vq < old_vq) { - aarch64_sve_narrow_vq(env, vq); - } - env->vfp.zcr_el[1] = vq - 1; - arm_rebuild_hflags(env); - ret = vq * 16; - } - return ret; - case TARGET_PR_SVE_GET_VL: - ret = -TARGET_EINVAL; - { - ARMCPU *cpu = env_archcpu(cpu_env); - if (cpu_isar_feature(aa64_sve, cpu)) { - ret = ((cpu->env.vfp.zcr_el[1] & 0xf) + 1) * 16; - } - } - return ret; - case TARGET_PR_PAC_RESET_KEYS: - { - CPUARMState *env = cpu_env; - ARMCPU *cpu = env_archcpu(env); - - if (arg3 || arg4 || arg5) { - return -TARGET_EINVAL; - } - if (cpu_isar_feature(aa64_pauth, cpu)) { - int all = (TARGET_PR_PAC_APIAKEY | TARGET_PR_PAC_APIBKEY | - TARGET_PR_PAC_APDAKEY | TARGET_PR_PAC_APDBKEY | - TARGET_PR_PAC_APGAKEY); - int ret = 0; - Error *err = NULL; - - if (arg2 == 0) { - arg2 = all; - } else if (arg2 & ~all) { - return -TARGET_EINVAL; - } - if (arg2 & TARGET_PR_PAC_APIAKEY) { - ret |= qemu_guest_getrandom(&env->keys.apia, - sizeof(ARMPACKey), &err); - } - if (arg2 & TARGET_PR_PAC_APIBKEY) { - ret |= qemu_guest_getrandom(&env->keys.apib, - sizeof(ARMPACKey), &err); - } - if (arg2 & TARGET_PR_PAC_APDAKEY) { - ret |= qemu_guest_getrandom(&env->keys.apda, - sizeof(ARMPACKey), &err); - } - if (arg2 & TARGET_PR_PAC_APDBKEY) { - ret |= qemu_guest_getrandom(&env->keys.apdb, - sizeof(ARMPACKey), &err); - } - if (arg2 & TARGET_PR_PAC_APGAKEY) { - ret |= qemu_guest_getrandom(&env->keys.apga, - sizeof(ARMPACKey), &err); - } - if (ret != 0) { - /* - * Some unknown failure in the crypto. The best - * we can do is log it and fail the syscall. - * The real syscall cannot fail this way. - */ - qemu_log_mask(LOG_UNIMP, - "PR_PAC_RESET_KEYS: Crypto failure: %s", - error_get_pretty(err)); - error_free(err); - return -TARGET_EIO; - } - return 0; - } - } - return -TARGET_EINVAL; - case TARGET_PR_SET_TAGGED_ADDR_CTRL: - { - abi_ulong valid_mask = TARGET_PR_TAGGED_ADDR_ENABLE; - CPUARMState *env = cpu_env; - ARMCPU *cpu = env_archcpu(env); - - if (cpu_isar_feature(aa64_mte, cpu)) { - valid_mask |= TARGET_PR_MTE_TCF_MASK; - valid_mask |= TARGET_PR_MTE_TAG_MASK; - } - - if ((arg2 & ~valid_mask) || arg3 || arg4 || arg5) { - return -TARGET_EINVAL; - } - env->tagged_addr_enable = arg2 & TARGET_PR_TAGGED_ADDR_ENABLE; - - if (cpu_isar_feature(aa64_mte, cpu)) { - switch (arg2 & TARGET_PR_MTE_TCF_MASK) { - case TARGET_PR_MTE_TCF_NONE: - case TARGET_PR_MTE_TCF_SYNC: - case TARGET_PR_MTE_TCF_ASYNC: - break; - default: - return -EINVAL; - } - - /* - * Write PR_MTE_TCF to SCTLR_EL1[TCF0]. - * Note that the syscall values are consistent with hw. - */ - env->cp15.sctlr_el[1] = - deposit64(env->cp15.sctlr_el[1], 38, 2, - arg2 >> TARGET_PR_MTE_TCF_SHIFT); - - /* - * Write PR_MTE_TAG to GCR_EL1[Exclude]. - * Note that the syscall uses an include mask, - * and hardware uses an exclude mask -- invert. - */ - env->cp15.gcr_el1 = - deposit64(env->cp15.gcr_el1, 0, 16, - ~arg2 >> TARGET_PR_MTE_TAG_SHIFT); - arm_rebuild_hflags(env); - } - return 0; - } - case TARGET_PR_GET_TAGGED_ADDR_CTRL: - { - abi_long ret = 0; - CPUARMState *env = cpu_env; - ARMCPU *cpu = env_archcpu(env); - - if (arg2 || arg3 || arg4 || arg5) { - return -TARGET_EINVAL; - } - if (env->tagged_addr_enable) { - ret |= TARGET_PR_TAGGED_ADDR_ENABLE; - } - if (cpu_isar_feature(aa64_mte, cpu)) { - /* See above. */ - ret |= (extract64(env->cp15.sctlr_el[1], 38, 2) - << TARGET_PR_MTE_TCF_SHIFT); - ret = deposit64(ret, TARGET_PR_MTE_TAG_SHIFT, 16, - ~env->cp15.gcr_el1); - } - return ret; - } -#endif /* AARCH64 */ - case PR_GET_SECCOMP: - case PR_SET_SECCOMP: - /* Disable seccomp to prevent the target disabling syscalls we - * need. */ - return -TARGET_EINVAL; - default: - /* Most prctl options have no pointer arguments */ - return get_errno(prctl(arg1, arg2, arg3, arg4, arg5)); - } + return do_prctl(cpu_env, arg1, arg2, arg3, arg4, arg5); break; #ifdef TARGET_NR_arch_prctl case TARGET_NR_arch_prctl: diff --git a/linux-user/x86_64/target_prctl.h b/linux-user/x86_64/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/x86_64/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ diff --git a/linux-user/xtensa/target_prctl.h b/linux-user/xtensa/target_prctl.h new file mode 100644 index 000000000000..eb53b31ad554 --- /dev/null +++ b/linux-user/xtensa/target_prctl.h @@ -0,0 +1 @@ +/* No special prctl support required. */ From patchwork Thu Jan 6 10:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV34r1pZtz9sPC for ; Thu, 6 Jan 2022 21:49:16 +1100 (AEDT) Received: from localhost ([::1]:60888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QKW-0008EP-DH for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:49:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDZ-0007ng-GK for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:59497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDS-0004k4-99 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MFsdD-1nAhOx3J0B-00HM7h; Thu, 06 Jan 2022 11:41:44 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/27] linux-user: Disable more prctl subcodes Date: Thu, 6 Jan 2022 11:41:18 +0100 Message-Id: <20220106104137.732883-9-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:exBT1H1rszwPC8FJI7xe18/8Sp8Ud31mxEMUrECmJ9fB3wCQ71j vvocxS9CmbansrTdY0gBkhLYEe7jHO08uQSeMVQJFjoFRNcKk1q4LiOKFvPoAhsNNaWqhnL xOxAbZ4Zb+DoFoCplTCXvToJpKnCrkB/eKRGPIoZACSPp8kzwud1odI+XCr/ThHtbspG7kU cU8TPj2Eyf6S+412vZ+Pw== X-UI-Out-Filterresults: notjunk:1;V03:K0:AuFtkTdDAo8=:4E1TezFD/uBa4nyFpEbkPA DoBOuHT03Xv+Fp7ObpnYGLd9za+AkkULRWILmwEeYFQkKeTO8uX8BNd4MJZ92k9cn0YHF984S gNpZKIpDCRdsR/IOyaJkBzRj4qlDoqKPW87u74zyVljGZHUjDyqMA6vAy3VHYp6J0v26iptFF ZBeanFLWRcfPqeAbi0Y9tTzoy/w36vB1bSKkG9vGWYW/+koBJEcRQ4enpTYIcDq+j5bovUdND e6FAlN1UCt6QJ+CcA6Ib80KsEtmn/nljAKmEk5nYUAgf1uRrV2G+Poer005b6YcBgYFwziAqT Y5y5AWfLq2InBylh0VyHJ0r27TsCkQa/ezMlqL0uOE8LavMGSTtbM2a4DUtbe3/K1rQCgOS5w /0uOWE7h6YHIgfcXKNl3YdW3TRXsgojCwb358/yli/ENo0Pu9IsYdg8Kh0LnLL/FgaB5DP2Xr KiqZ3EKwMaxrYjuk9rN9tJdiKwAJ4seZe0M+pVySdyObq8OyzItDokoZR357oznbB04UmSYgu O3O9DZbQ88m4Nc1r806tj2WQfEhKIMehN9GrH/nj15UKmSOPeiVjxWIninqUi37OliWVT9V6a TxXuQ2W4ilfrY2Oxsekxmeb/nilkGyahQk32cgCjB2kwIkrVwbZBYTTiNVJfYdJhY0wVGPg4t rijtSdSs/QSgXvRsAolXqZH4jB4q5WRWdQQy5HUm0ZgMmsK/4f56/R0jbToNuyPhXzC4= Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a list of subcodes that we want to pass on, a list of subcodes that should not be passed on because they would affect the running qemu itself, and a list that probably could be implemented but require extra work. Do not pass on unknown subcodes. Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20211227150127.2659293-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 58 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0f0f67d56721..d868ef291085 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6337,6 +6337,13 @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr) # define PR_MTE_TAG_SHIFT 3 # define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT) #endif +#ifndef PR_SET_IO_FLUSHER +# define PR_SET_IO_FLUSHER 57 +# define PR_GET_IO_FLUSHER 58 +#endif +#ifndef PR_SET_SYSCALL_USER_DISPATCH +# define PR_SET_SYSCALL_USER_DISPATCH 59 +#endif #include "target_prctl.h" @@ -6433,13 +6440,58 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, return -TARGET_EINVAL; } return do_prctl_get_tagged_addr_ctrl(env); + + case PR_GET_DUMPABLE: + case PR_SET_DUMPABLE: + case PR_GET_KEEPCAPS: + case PR_SET_KEEPCAPS: + case PR_GET_TIMING: + case PR_SET_TIMING: + case PR_GET_TIMERSLACK: + case PR_SET_TIMERSLACK: + case PR_MCE_KILL: + case PR_MCE_KILL_GET: + case PR_GET_NO_NEW_PRIVS: + case PR_SET_NO_NEW_PRIVS: + case PR_GET_IO_FLUSHER: + case PR_SET_IO_FLUSHER: + /* Some prctl options have no pointer arguments and we can pass on. */ + return get_errno(prctl(option, arg2, arg3, arg4, arg5)); + + case PR_GET_CHILD_SUBREAPER: + case PR_SET_CHILD_SUBREAPER: + case PR_GET_SPECULATION_CTRL: + case PR_SET_SPECULATION_CTRL: + case PR_GET_TID_ADDRESS: + /* TODO */ + return -TARGET_EINVAL; + + case PR_GET_FPEXC: + case PR_SET_FPEXC: + /* Was used for SPE on PowerPC. */ + return -TARGET_EINVAL; + + case PR_GET_ENDIAN: + case PR_SET_ENDIAN: + case PR_GET_FPEMU: + case PR_SET_FPEMU: + case PR_SET_MM: case PR_GET_SECCOMP: case PR_SET_SECCOMP: - /* Disable seccomp to prevent the target disabling syscalls we need. */ + case PR_SET_SYSCALL_USER_DISPATCH: + case PR_GET_THP_DISABLE: + case PR_SET_THP_DISABLE: + case PR_GET_TSC: + case PR_SET_TSC: + case PR_GET_UNALIGN: + case PR_SET_UNALIGN: + /* Disable to prevent the target disabling stuff we need. */ return -TARGET_EINVAL; + default: - /* Most prctl options have no pointer arguments */ - return get_errno(prctl(option, arg2, arg3, arg4, arg5)); + qemu_log_mask(LOG_UNIMP, "Unsupported prctl: " TARGET_ABI_FMT_ld "\n", + option); + return -TARGET_EINVAL; } } From patchwork Thu Jan 6 10:41:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV33g72ntz9sPC for ; Thu, 6 Jan 2022 21:48:15 +1100 (AEDT) Received: from localhost ([::1]:59290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QJZ-00077A-Oz for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:48:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0007cM-I0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:59737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004jJ-Ps for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MYeV1-1mrvX01FHX-00Vi8v; Thu, 06 Jan 2022 11:41:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/27] linux-user: Add code for PR_GET/SET_UNALIGN Date: Thu, 6 Jan 2022 11:41:19 +0100 Message-Id: <20220106104137.732883-10-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:TUEOrmH/hZxcqE7J5ubrNdT0wFbaHHCSStrL48mcd29iat3HgwG UpVGX4ga/6cgyFaOwfITFOPPQ0IuY2RNm2ICdC3a9G4OZtwtVgDBQsLzsJ6EF9vV7Okdnek 6iGzVccwIWQhdNjYvK2RosijCPmfahIjld02Hv9Th/bk3G+78pL0Ttc30RRSEwhYyg8Jq9b ThyVvWgJpWrm3+SGdPTuA== X-UI-Out-Filterresults: notjunk:1;V03:K0:O80bhlyC4cM=:gB6xfR4360QT8qahfDKlMB bX4ybgM9YzD4lo7lzTFI+6087c2MEXVQl7TB5btFV64WY4LBfZJt0VsZrVmdXOrlnfRsQNf/y Tngx+xWtDgrvxSedKZ59TuyXpChp2GNPnYKiE8m15Wi9DItcJWWL2oVV4UPj8V3y0e2/ZaOJR 3OjSSKRBNe+Fp9LLo4XG99Kxbaphd0lGOh08zSYt+p9QHfzapk39CP1k0zxBudKpqsDMsyq14 0R8FtsELFhTR4ABZchP5hBNfT8YpPqy9oXjajwhK7sH58erqKXPt8u83gY5Y4ahsKBk5GhU3r ABERrP04Oxh66MI+bcHGkypbmQX/1M9dfSPoom3eD17WqrSnJWAV3aMmEzPvKxsOq1kT6gvl+ EPIfESPZrVOIzl1iiINN5fBWWwKEXbx4yv09lw64COZFqe2xCdyDJU3GADxkDzXPWrmYu6wCC IwnGczHE+xd96Sjzb+pg+VFkPEtnxeIM9rGikAtxH3mrxStzQ77SGKCv4xdw4mayJcky5ekAf qwmAvdy7/2cmsEUfRWuqyCXVS0zvP5qSKfN2c0E774d6A8ZQd/RkN1Jm/KYsrstfv+hRNC7ex 2PBG5xRKjhyBANHMwAosX3YwmsnikTze0DplhO/KF1DyziLV+QtMzGy+Ceu57Mp2iDZ3koqAq dsdVok1a5d8fetyoJqpYYks1BN9H2jUkHIjjA5669LmptdnlOmcu+avLTGK/4heWnhc8= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier , Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This requires extra work for each target, but adds the common syscall code, and the necessary flag in CPUState. Reviewed-by: Warner Losh Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20211227150127.2659293-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- cpu.c | 20 ++++++++++++----- include/hw/core/cpu.h | 3 +++ linux-user/generic/target_prctl_unalign.h | 27 +++++++++++++++++++++++ linux-user/syscall.c | 13 +++++++++-- 4 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 linux-user/generic/target_prctl_unalign.h diff --git a/cpu.c b/cpu.c index 945dd3dded4a..016bf06a1aec 100644 --- a/cpu.c +++ b/cpu.c @@ -174,13 +174,23 @@ void cpu_exec_unrealizefn(CPUState *cpu) cpu_list_remove(cpu); } +/* + * This can't go in hw/core/cpu.c because that file is compiled only + * once for both user-mode and system builds. + */ static Property cpu_common_props[] = { -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + /* + * Create a property for the user-only object, so users can + * adjust prctl(PR_SET_UNALIGN) from the command-line. + * Has no effect if the target does not support the feature. + */ + DEFINE_PROP_BOOL("prctl-unalign-sigbus", CPUState, + prctl_unalign_sigbus, false), +#else /* - * Create a memory property for softmmu CPU object, - * so users can wire up its memory. (This can't go in hw/core/cpu.c - * because that file is compiled only once for both user-mode - * and system builds.) The default if no link is set up is to use + * Create a memory property for softmmu CPU object, so users can + * wire up its memory. The default if no link is set up is to use * the system address space. */ DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index e948e81f1a97..76ab3b851c87 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -413,6 +413,9 @@ struct CPUState { bool ignore_memory_transaction_failures; + /* Used for user-only emulation of prctl(PR_SET_UNALIGN). */ + bool prctl_unalign_sigbus; + struct hax_vcpu_state *hax_vcpu; struct hvf_vcpu_state *hvf; diff --git a/linux-user/generic/target_prctl_unalign.h b/linux-user/generic/target_prctl_unalign.h new file mode 100644 index 000000000000..bc3b83af2a6b --- /dev/null +++ b/linux-user/generic/target_prctl_unalign.h @@ -0,0 +1,27 @@ +/* + * Generic prctl unalign functions for linux-user + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef GENERIC_TARGET_PRCTL_UNALIGN_H +#define GENERIC_TARGET_PRCTL_UNALIGN_H + +static abi_long do_prctl_get_unalign(CPUArchState *env, target_long arg2) +{ + CPUState *cs = env_cpu(env); + uint32_t res = PR_UNALIGN_NOPRINT; + if (cs->prctl_unalign_sigbus) { + res |= PR_UNALIGN_SIGBUS; + } + return put_user_u32(res, arg2); +} +#define do_prctl_get_unalign do_prctl_get_unalign + +static abi_long do_prctl_set_unalign(CPUArchState *env, target_long arg2) +{ + env_cpu(env)->prctl_unalign_sigbus = arg2 & PR_UNALIGN_SIGBUS; + return 0; +} +#define do_prctl_set_unalign do_prctl_set_unalign + +#endif /* GENERIC_TARGET_PRCTL_UNALIGN_H */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d868ef291085..b5112891b046 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6378,6 +6378,12 @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2) #ifndef do_prctl_get_tagged_addr_ctrl #define do_prctl_get_tagged_addr_ctrl do_prctl_inval0 #endif +#ifndef do_prctl_get_unalign +#define do_prctl_get_unalign do_prctl_inval1 +#endif +#ifndef do_prctl_set_unalign +#define do_prctl_set_unalign do_prctl_inval1 +#endif static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5) @@ -6441,6 +6447,11 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, } return do_prctl_get_tagged_addr_ctrl(env); + case PR_GET_UNALIGN: + return do_prctl_get_unalign(env, arg2); + case PR_SET_UNALIGN: + return do_prctl_set_unalign(env, arg2); + case PR_GET_DUMPABLE: case PR_SET_DUMPABLE: case PR_GET_KEEPCAPS: @@ -6483,8 +6494,6 @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2, case PR_SET_THP_DISABLE: case PR_GET_TSC: case PR_SET_TSC: - case PR_GET_UNALIGN: - case PR_SET_UNALIGN: /* Disable to prevent the target disabling stuff we need. */ return -TARGET_EINVAL; From patchwork Thu Jan 6 10:41:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV34S1Dvtz9sPC for ; Thu, 6 Jan 2022 21:48:56 +1100 (AEDT) Received: from localhost ([::1]:60466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QKD-0007vZ-VV for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:48:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDX-0007hT-LG for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:42329) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004ie-Hz for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:58 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MlwBf-1medty3FQp-00ixdp; Thu, 06 Jan 2022 11:41:45 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/27] target/alpha: Implement prctl_unalign_sigbus Date: Thu, 6 Jan 2022 11:41:20 +0100 Message-Id: <20220106104137.732883-11-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:/w194w6AUFk/pPGKVSE8+c/8Eou0scAsl6irsRgodjQ0NHtE7Sn H6X4R/3oSwy8U58hfJI6bCsN4GuhgyvjQ76dS7EbowUL9jngnRVTrjRRe9+lwpOpKPUZqNn H8dVZReDy+uNSHeRn38izaZW99+gK+U/TqfzqtfxZcCGtLuFBLNB8gREj0EYcWqt1O3AN2X /8z0L4ZkJ8fudUyA7cQ+g== X-UI-Out-Filterresults: notjunk:1;V03:K0:oQS3X5SDv0Q=:SWezH0zMpSpoBB0lf3ODxd E8O8jS9XoSgjzO1pc3FRg3IfX1s6mQU+O54ffQn3BQ2SFoUIUXCnVU6GHGp0XN9JD+/WWTuz9 BPDg/3eE8USmYChEWNHiu8/3zV3hxeQe4y7sAEnDM1xMuoQb+ieIiaDDG3xvQmoqDnKEB2f27 p/MuvkXrmglbhin9HTLoreeexCswl0sH++ORmLfXoQ/fH2OObuNivdP7VbKR9/PcU0GTiO23g D8ufBSigI0zaz1rSZrbwaQRKM5FgRflF8Dn/7pVIwV0snclGctDXRkqDhHxg46Y/v5qkglK6g UJMcQIng1VqRRoTFwKVtJkDtp7VshTYecAx1r+kZW43zTcrZ3lT/tNXoDSe02t+y1PGNcmGBn Gr66cuw6OH/ejVW0mAQVGD0bXdh/mcW3WV3VV49EexlD5W8NkIZ9r/d80m5LOeTy+AEW2i8db a+Iz5e+nWeFegRVkk2ONEQYhsVgVGqVW4A0h82uzLULX/ZSfr2ctEM1DbeDIcGHLoqRAejBQN bw/cPMhO54Mpr5pMTR8KzYZb24ny9HLDkDRflu8jqAAY/bDxPUZA2oLPVVN4xI7dtf7jX38wy bDh5v8azkIgLBuemLCitO47B2L1bIuv4b9nSxMia+cpVncd9EGE5WT5vrIwr59+ZhEMhzuJyW /cdmFLnmL5a0W39y1elk14LHn4+iVo6HO4G+zZeqOG6EV5j3mIW2ACpCiPlkjYP3PXfE= Received-SPF: none client-ip=212.227.126.131; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Leave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211227150127.2659293-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/alpha/target_prctl.h | 2 +- target/alpha/cpu.h | 5 +++++ target/alpha/translate.c | 31 ++++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/linux-user/alpha/target_prctl.h b/linux-user/alpha/target_prctl.h index eb53b31ad554..5629ddbf39cd 100644 --- a/linux-user/alpha/target_prctl.h +++ b/linux-user/alpha/target_prctl.h @@ -1 +1 @@ -/* No special prctl support required. */ +#include "../generic/target_prctl_unalign.h" diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index afd975c87801..e81921150392 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -383,6 +383,8 @@ enum { #define ENV_FLAG_TB_MASK \ (ENV_FLAG_PAL_MODE | ENV_FLAG_PS_USER | ENV_FLAG_FEN) +#define TB_FLAG_UNALIGN (1u << 1) + static inline int cpu_mmu_index(CPUAlphaState *env, bool ifetch) { int ret = env->flags & ENV_FLAG_PS_USER ? MMU_USER_IDX : MMU_KERNEL_IDX; @@ -470,6 +472,9 @@ static inline void cpu_get_tb_cpu_state(CPUAlphaState *env, target_ulong *pc, *pc = env->pc; *cs_base = 0; *pflags = env->flags & ENV_FLAG_TB_MASK; +#ifdef CONFIG_USER_ONLY + *pflags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; +#endif } #ifdef CONFIG_USER_ONLY diff --git a/target/alpha/translate.c b/target/alpha/translate.c index a4c3f43e720a..208ae5fbd50d 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -45,7 +45,9 @@ typedef struct DisasContext DisasContext; struct DisasContext { DisasContextBase base; -#ifndef CONFIG_USER_ONLY +#ifdef CONFIG_USER_ONLY + MemOp unalign; +#else uint64_t palbr; #endif uint32_t tbflags; @@ -68,6 +70,12 @@ struct DisasContext { TCGv sink; }; +#ifdef CONFIG_USER_ONLY +#define UNALIGN(C) (C)->unalign +#else +#define UNALIGN(C) 0 +#endif + /* Target-specific return values from translate_one, indicating the state of the TB. Note that DISAS_NEXT indicates that we are not exiting the TB. */ @@ -270,7 +278,7 @@ static inline DisasJumpType gen_invalid(DisasContext *ctx) static void gen_ldf(DisasContext *ctx, TCGv dest, TCGv addr) { TCGv_i32 tmp32 = tcg_temp_new_i32(); - tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL); + tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx)); gen_helper_memory_to_f(dest, tmp32); tcg_temp_free_i32(tmp32); } @@ -278,7 +286,7 @@ static void gen_ldf(DisasContext *ctx, TCGv dest, TCGv addr) static void gen_ldg(DisasContext *ctx, TCGv dest, TCGv addr) { TCGv tmp = tcg_temp_new(); - tcg_gen_qemu_ld_i64(tmp, addr, ctx->mem_idx, MO_LEQ); + tcg_gen_qemu_ld_i64(tmp, addr, ctx->mem_idx, MO_LEQ | UNALIGN(ctx)); gen_helper_memory_to_g(dest, tmp); tcg_temp_free(tmp); } @@ -286,14 +294,14 @@ static void gen_ldg(DisasContext *ctx, TCGv dest, TCGv addr) static void gen_lds(DisasContext *ctx, TCGv dest, TCGv addr) { TCGv_i32 tmp32 = tcg_temp_new_i32(); - tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL); + tcg_gen_qemu_ld_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx)); gen_helper_memory_to_s(dest, tmp32); tcg_temp_free_i32(tmp32); } static void gen_ldt(DisasContext *ctx, TCGv dest, TCGv addr) { - tcg_gen_qemu_ld_i64(dest, addr, ctx->mem_idx, MO_LEQ); + tcg_gen_qemu_ld_i64(dest, addr, ctx->mem_idx, MO_LEQ | UNALIGN(ctx)); } static void gen_load_fp(DisasContext *ctx, int ra, int rb, int32_t disp16, @@ -324,6 +332,8 @@ static void gen_load_int(DisasContext *ctx, int ra, int rb, int32_t disp16, tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16); if (clear) { tcg_gen_andi_i64(addr, addr, ~0x7); + } else if (!locked) { + op |= UNALIGN(ctx); } dest = ctx->ir[ra]; @@ -340,7 +350,7 @@ static void gen_stf(DisasContext *ctx, TCGv src, TCGv addr) { TCGv_i32 tmp32 = tcg_temp_new_i32(); gen_helper_f_to_memory(tmp32, addr); - tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL); + tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx)); tcg_temp_free_i32(tmp32); } @@ -348,7 +358,7 @@ static void gen_stg(DisasContext *ctx, TCGv src, TCGv addr) { TCGv tmp = tcg_temp_new(); gen_helper_g_to_memory(tmp, src); - tcg_gen_qemu_st_i64(tmp, addr, ctx->mem_idx, MO_LEQ); + tcg_gen_qemu_st_i64(tmp, addr, ctx->mem_idx, MO_LEQ | UNALIGN(ctx)); tcg_temp_free(tmp); } @@ -356,13 +366,13 @@ static void gen_sts(DisasContext *ctx, TCGv src, TCGv addr) { TCGv_i32 tmp32 = tcg_temp_new_i32(); gen_helper_s_to_memory(tmp32, src); - tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL); + tcg_gen_qemu_st_i32(tmp32, addr, ctx->mem_idx, MO_LEUL | UNALIGN(ctx)); tcg_temp_free_i32(tmp32); } static void gen_stt(DisasContext *ctx, TCGv src, TCGv addr) { - tcg_gen_qemu_st_i64(src, addr, ctx->mem_idx, MO_LEQ); + tcg_gen_qemu_st_i64(src, addr, ctx->mem_idx, MO_LEQ | UNALIGN(ctx)); } static void gen_store_fp(DisasContext *ctx, int ra, int rb, int32_t disp16, @@ -383,6 +393,8 @@ static void gen_store_int(DisasContext *ctx, int ra, int rb, int32_t disp16, tcg_gen_addi_i64(addr, load_gpr(ctx, rb), disp16); if (clear) { tcg_gen_andi_i64(addr, addr, ~0x7); + } else { + op |= UNALIGN(ctx); } src = load_gpr(ctx, ra); @@ -2942,6 +2954,7 @@ static void alpha_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) #ifdef CONFIG_USER_ONLY ctx->ir = cpu_std_ir; + ctx->unalign = (ctx->tbflags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN); #else ctx->palbr = env->palbr; ctx->ir = (ctx->tbflags & ENV_FLAG_PAL_MODE ? cpu_pal_ir : cpu_std_ir); From patchwork Thu Jan 6 10:41:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV37h35drz9sPC for ; Thu, 6 Jan 2022 21:51:43 +1100 (AEDT) Received: from localhost ([::1]:39488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QMt-0004WR-Nc for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:51:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDV-0007dX-Nc for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:34251) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004ii-Q9 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mgvj3-1mT5C30ruv-00hNCZ; Thu, 06 Jan 2022 11:41:46 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/27] target/hppa: Implement prctl_unalign_sigbus Date: Thu, 6 Jan 2022 11:41:21 +0100 Message-Id: <20220106104137.732883-12-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:kiwqWioa8pwH62vt2bj2DK8vZUodcrthSFww0+yA4gGf7F37kT7 Scm4mzJPzGjTU7zWY8HhnkDwdop+QIjYtN69i+X35I+AJpRXy8KEu9LS+uSWVzSP4KTsu5z us69Oz+Kemk2mn4tomo3Gx/tDJJ19Ybh/VuNFcZ7B0F4sU9APturR7XeeIAP14qLncxZhQ6 dI0peWLWzOz6xyPqvH1Aw== X-UI-Out-Filterresults: notjunk:1;V03:K0:9KTJbbrXwsY=:U0o8JBZbyFi+M/6JHRuTUa KfqJPaWY9AggjFa71hQYg5QVIRyOstHiznM7PZGrpp0Lc5wLoslyyFEOipRCiNNPTf3PDau5c t/+Mr7jf6HDi8BXeigWOwLXEXCwJ6GxOGAQp5y8PDsNuAVmA5DxaBeHb06dq0cJanov0zVv38 ctPcCAurv3J91A8NpCnTB+DCzX1E/UsPtbPlmn2+5rLXIn50Wo6KQBVCx2IGseHlKi74dndpB uDWSI6XLwIgRi7QWkcK3IMvWmGf4lcZ3Rv43DydyDGf1Tbrrh4O/D4e5/CBG8obvFqydA0K3f ModusbRllON/yYkGsQlufvTxQkxkrHkBFPPIPi6/8KUBQe3znbkXAzQ5pUO8rubNBoBIgTofu DydYZje8DZduWke6bSLj6koQy4Y86VsPaRWWOBfRi3ZJ/jhcUWuCuKu6c4gZjuY9kJrLkXiLU 89awLaolkmdbJC1ooEAv0yrPqwqMmUkEPM7h6wJLUQOQqQ9fR94APU3gK7PXc1Tf3EIpFl2gj lgIn1iRqAARcKHt8m2JkTy/G/aJFOIV5gAMlmGR1pliBOpouA1WnsXMSgA+mKOy0uAVl6N5kY p3m9JJhuoB80KNaUoPoimMnOFyL6q9+aMj/UKGdzTa8tiiAUWJFrSbqIbqIdJEyyU2MI8uNyX hsI1/wHoZ0voSiN29NscXm5QYo08ZBGctpXlHT3tl0lvVYwuuDUPknPBy1b2aRDch0pE= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Leave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211227150127.2659293-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/hppa/target_prctl.h | 2 +- target/hppa/cpu.h | 5 ++++- target/hppa/translate.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/linux-user/hppa/target_prctl.h b/linux-user/hppa/target_prctl.h index eb53b31ad554..5629ddbf39cd 100644 --- a/linux-user/hppa/target_prctl.h +++ b/linux-user/hppa/target_prctl.h @@ -1 +1 @@ -/* No special prctl support required. */ +#include "../generic/target_prctl_unalign.h" diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 294fd7297f91..45fd338b02f8 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -259,12 +259,14 @@ static inline target_ulong hppa_form_gva(CPUHPPAState *env, uint64_t spc, return hppa_form_gva_psw(env->psw, spc, off); } -/* Since PSW_{I,CB} will never need to be in tb->flags, reuse them. +/* + * Since PSW_{I,CB} will never need to be in tb->flags, reuse them. * TB_FLAG_SR_SAME indicates that SR4 through SR7 all contain the * same value. */ #define TB_FLAG_SR_SAME PSW_I #define TB_FLAG_PRIV_SHIFT 8 +#define TB_FLAG_UNALIGN 0x400 static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc, target_ulong *cs_base, @@ -279,6 +281,7 @@ static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc, #ifdef CONFIG_USER_ONLY *pc = env->iaoq_f & -4; *cs_base = env->iaoq_b & -4; + flags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; #else /* ??? E, T, H, L, B, P bits need to be here, when implemented. */ flags |= env->psw & (PSW_W | PSW_C | PSW_D); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 952027a28e12..a2392a1b64a4 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -274,8 +274,18 @@ typedef struct DisasContext { int mmu_idx; int privilege; bool psw_n_nonzero; + +#ifdef CONFIG_USER_ONLY + MemOp unalign; +#endif } DisasContext; +#ifdef CONFIG_USER_ONLY +#define UNALIGN(C) (C)->unalign +#else +#define UNALIGN(C) 0 +#endif + /* Note that ssm/rsm instructions number PSW_W and PSW_E differently. */ static int expand_sm_imm(DisasContext *ctx, int val) { @@ -1475,7 +1485,7 @@ static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_ld_reg(dest, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_ld_reg(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1493,7 +1503,7 @@ static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_ld_i64(dest, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_ld_i64(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1511,7 +1521,7 @@ static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_st_i32(src, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_st_i32(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1529,7 +1539,7 @@ static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_st_i64(src, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_st_i64(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -4107,6 +4117,7 @@ static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->mmu_idx = MMU_USER_IDX; ctx->iaoq_f = ctx->base.pc_first | MMU_USER_IDX; ctx->iaoq_b = ctx->base.tb->cs_base | MMU_USER_IDX; + ctx->unalign = (ctx->tb_flags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN); #else ctx->privilege = (ctx->tb_flags >> TB_FLAG_PRIV_SHIFT) & 3; ctx->mmu_idx = (ctx->tb_flags & PSW_D ? ctx->privilege : MMU_PHYS_IDX); From patchwork Thu Jan 6 10:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV32647Ymz9t6S for ; Thu, 6 Jan 2022 21:46:54 +1100 (AEDT) Received: from localhost ([::1]:52160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QIG-00029T-CI for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:46:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDW-0007eJ-5Q for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:58 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:49959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004it-QT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:57 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MKbc4-1morGY2nVM-00L126; Thu, 06 Jan 2022 11:41:46 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/27] target/sh4: Implement prctl_unalign_sigbus Date: Thu, 6 Jan 2022 11:41:22 +0100 Message-Id: <20220106104137.732883-13-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qK3IYWdXldFT2qs49de94K53jCPohICyfYxMavRxHaGPipJZUI3 v7fxV4WWtOGYlZqDPO/SyOTIsSRFe/yDNz3Hs385v4chADh+EdpC39bc9HgPyHd27gNlc3K dYwRhigvRmN4y7lLCji4Nz4RnO6v2e4rLcj8OtVMX14qOGyjm94rEt0n9OqgeH6frE/kO4i D3LFPOcgnHlRKTZjjJ/Og== X-UI-Out-Filterresults: notjunk:1;V03:K0:iCTP67RgF8k=:pMbXKyIdwmMTT/QB8FghSA qV3BorisA4cTYu49oQNIms+EXNs0FyyUSusCNCQ58JX61FOExpEEETgdzST6IMOqlaN2Sf9bn XJi61m6Ie12/+wJh6u+kBygwGv9aX19wZWOfl+NaZyyDtMeu2LrU+txeeyjWPtRUIjADK/zli KjkxuKArESgyR/1jnqEUW49MoU0Wy3395A6smJYP+br+qJeLlxA4geSuomv/kec/Gi39O4zmL p8NNgDM62e07kQl+I/Odx3q9CRc4k+yliiKpXDuqN9368rMfUdDS7U3cg65rYHOebBy2VTGCn 039jdx4sYdFu1N6L1LOn2IqtbXGkubR3Yow32InohRxaqLHiavYUDViqmknEQG0MwUDK79Gf6 hcUavI1ClhfVW4qdW/RrK4TBgizZzq790MDHlPEn86bC3SikitiRYOsu85nCbhnHb/XWLxAFN T9hWH5BQb56dUBZdDTtgQnBUc1f5HNIzL93Jk/SBlzjw/xCk0EDcXVOvhOtrUOV1FIhWaEZne shCDhYU9m8FKKBlx0pgO5wIpKweumCAvCRHF4b863IHbKsR7gv1Oa9pviQ1qaidNy/uaxoHnd GAWEnk2euzaMu41mraUI/vJxGsZiEL9EuahjC77mhBi1cBOv0Lk/jskKdqlAhpgKT+mSa0EJ5 1mQh2VpGV6p5Sd6mrioN7VNuhiJDvxhRlchHH7i2BRn1rvLaHrIOKWA092CP1qM8uIHs= Received-SPF: none client-ip=212.227.126.130; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Leave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap. The Linux kernel does not handle all memory operations: no floating-point and no MAC. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211227150127.2659293-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/sh4/target_prctl.h | 2 +- target/sh4/cpu.h | 4 +++ target/sh4/translate.c | 50 ++++++++++++++++++++++++----------- 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/linux-user/sh4/target_prctl.h b/linux-user/sh4/target_prctl.h index eb53b31ad554..5629ddbf39cd 100644 --- a/linux-user/sh4/target_prctl.h +++ b/linux-user/sh4/target_prctl.h @@ -1 +1 @@ -/* No special prctl support required. */ +#include "../generic/target_prctl_unalign.h" diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 4cfb109f5668..fb9dd9db2ffd 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -83,6 +83,7 @@ #define DELAY_SLOT_RTE (1 << 2) #define TB_FLAG_PENDING_MOVCA (1 << 3) +#define TB_FLAG_UNALIGN (1 << 4) #define GUSA_SHIFT 4 #ifdef CONFIG_USER_ONLY @@ -373,6 +374,9 @@ static inline void cpu_get_tb_cpu_state(CPUSH4State *env, target_ulong *pc, | (env->sr & ((1u << SR_MD) | (1u << SR_RB))) /* Bits 29-30 */ | (env->sr & (1u << SR_FD)) /* Bit 15 */ | (env->movcal_backup ? TB_FLAG_PENDING_MOVCA : 0); /* Bit 3 */ +#ifdef CONFIG_USER_ONLY + *flags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; +#endif } #endif /* SH4_CPU_H */ diff --git a/target/sh4/translate.c b/target/sh4/translate.c index ce5d674a520e..50493c61ea65 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -50,8 +50,10 @@ typedef struct DisasContext { #if defined(CONFIG_USER_ONLY) #define IS_USER(ctx) 1 +#define UNALIGN(C) (ctx->tbflags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN) #else #define IS_USER(ctx) (!(ctx->tbflags & (1u << SR_MD))) +#define UNALIGN(C) 0 #endif /* Target-specific values for ctx->base.is_jmp. */ @@ -495,7 +497,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_addi_i32(addr, REG(B11_8), B3_0 * 4); - tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL); + tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, + MO_TEUL | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -503,7 +506,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 4); - tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESL); + tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, + MO_TESL | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -558,19 +562,23 @@ static void _decode_opc(DisasContext * ctx) tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_UB); return; case 0x2001: /* mov.w Rm,@Rn */ - tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_TEUW); + tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, + MO_TEUW | UNALIGN(ctx)); return; case 0x2002: /* mov.l Rm,@Rn */ - tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, MO_TEUL); + tcg_gen_qemu_st_i32(REG(B7_4), REG(B11_8), ctx->memidx, + MO_TEUL | UNALIGN(ctx)); return; case 0x6000: /* mov.b @Rm,Rn */ tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_SB); return; case 0x6001: /* mov.w @Rm,Rn */ - tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESW); + tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, + MO_TESW | UNALIGN(ctx)); return; case 0x6002: /* mov.l @Rm,Rn */ - tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESL); + tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, + MO_TESL | UNALIGN(ctx)); return; case 0x2004: /* mov.b Rm,@-Rn */ { @@ -586,7 +594,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_subi_i32(addr, REG(B11_8), 2); - tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUW); + tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, + MO_TEUW | UNALIGN(ctx)); tcg_gen_mov_i32(REG(B11_8), addr); tcg_temp_free(addr); } @@ -595,7 +604,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_subi_i32(addr, REG(B11_8), 4); - tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL); + tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, + MO_TEUL | UNALIGN(ctx)); tcg_gen_mov_i32(REG(B11_8), addr); tcg_temp_free(addr); } @@ -606,12 +616,14 @@ static void _decode_opc(DisasContext * ctx) tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 1); return; case 0x6005: /* mov.w @Rm+,Rn */ - tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESW); + tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, + MO_TESW | UNALIGN(ctx)); if ( B11_8 != B7_4 ) tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 2); return; case 0x6006: /* mov.l @Rm+,Rn */ - tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, MO_TESL); + tcg_gen_qemu_ld_i32(REG(B11_8), REG(B7_4), ctx->memidx, + MO_TESL | UNALIGN(ctx)); if ( B11_8 != B7_4 ) tcg_gen_addi_i32(REG(B7_4), REG(B7_4), 4); return; @@ -627,7 +639,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_add_i32(addr, REG(B11_8), REG(0)); - tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUW); + tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, + MO_TEUW | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -635,7 +648,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_add_i32(addr, REG(B11_8), REG(0)); - tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, MO_TEUL); + tcg_gen_qemu_st_i32(REG(B7_4), addr, ctx->memidx, + MO_TEUL | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -651,7 +665,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_add_i32(addr, REG(B7_4), REG(0)); - tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESW); + tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, + MO_TESW | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -659,7 +674,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_add_i32(addr, REG(B7_4), REG(0)); - tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, MO_TESL); + tcg_gen_qemu_ld_i32(REG(B11_8), addr, ctx->memidx, + MO_TESL | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -1253,7 +1269,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2); - tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, MO_TEUW); + tcg_gen_qemu_st_i32(REG(0), addr, ctx->memidx, + MO_TEUW | UNALIGN(ctx)); tcg_temp_free(addr); } return; @@ -1269,7 +1286,8 @@ static void _decode_opc(DisasContext * ctx) { TCGv addr = tcg_temp_new(); tcg_gen_addi_i32(addr, REG(B7_4), B3_0 * 2); - tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, MO_TESW); + tcg_gen_qemu_ld_i32(REG(0), addr, ctx->memidx, + MO_TESW | UNALIGN(ctx)); tcg_temp_free(addr); } return; From patchwork Thu Jan 6 10:41:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV2x72x1Nz9sPC for ; Thu, 6 Jan 2022 21:42:35 +1100 (AEDT) Received: from localhost ([::1]:43888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QE5-0007eO-5q for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:42:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0007c2-E0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:49495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDO-0004is-QF for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:56 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MplPh-1mbusg0abt-00q8dz; Thu, 06 Jan 2022 11:41:47 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/27] linux-user/signal: Map exit signals in SIGCHLD siginfo_t Date: Thu, 6 Jan 2022 11:41:23 +0100 Message-Id: <20220106104137.732883-14-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:IGLAv4PjXYRfNf36+tR4WJxewjJ2zrK51lwaDARSuCBxwc637fm TPlWvs6fPylXQ0Nd3iVgSQ6TcseJrKBLzCgb70vWG9tHAFNgDt1oDsemG/CLcd0IIandZ57 PJ9AJkC/hhPw1mKRtyjo91a0miib5IticlzVvDclapTjJWB2hiiPZbtHhKEGz2wgSLeGsEb BJzcFG1QIE80jFvKxwxRQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:484e/hbesAY=:q1HoRBV46w+D19TDtzaPkY 55r3lXTvFOww9iD/D4WlPT2+KDDkDIOYebGsLRYzo73KgP5/nMgA8EwwRD4fByl9ZE9KIwfe+ a/8Bgc1rV+kPazxn1M9+qzC2Kq6siK8k+9tdgkGO9tbkHJ70HViEZ69r8h0J/2S6jaYuF8Yho kDB3ahCdqPrkw8jK8pOT8Rsfq+4r4jwJthp83mdB/IFxd8ZbNbQaGgWhQnNSOtxKKpzrRBBxL q4B/3hIggWk3MSqUK9Ewsx+yXAlAZ7PPe2QeejGL6DQu+7tAZmkGhHSbCKUbGRFwvSoCATwGN FCvaN63rCl1rW4fFTCHeS7xfSYAWIpkjLtj16Scpxu/v/43uW71var9sCzTBPp5yiaLeetsXx RcR6ocQ9z2gf7Utz4y6QYVDfKDNXybqucOfDJlyEMR+zlyvBeZpN5l84qReAnQoPINyxZUh0e uD5VBP+A5X3KyDHeYYDveCPsRO3v+7BjNGiKW0JvqM3CXAig8nPJTKMBwyJtohLK8Rd4+FLF9 IGoFX7BZJEI53E1X8oBtUnkl/qljsYu3eK2mGogyGNvHp76idx/KLHPb+h4QMT8o+X/fZ/TZy IseR8eE/OTxSHJ21DJooeDT1x7fM8EGM3Hod6EYLZPQAM4XRCi3YM0+wTGHMEh1+BX1864zmT 9UhFyWs3z8zO5Qhb1x8bbhaE4zOjFJg9iX2UqnsTgjzB3OeEN0hUS/C+Q4VTmHYiUlGA= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Schiffer , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Matthias Schiffer When converting a siginfo_t from waitid(), the interpretation of si_status depends on the value of si_code: For CLD_EXITED, it is an exit code and should be copied verbatim. For other codes, it is a signal number (possibly with additional high bits from ptrace) that should be mapped. This code was previously changed in commit 1c3dfb506ea3 ("linux-user/signal: Decode waitid si_code"), but the fix was incomplete. Tested with the following test program: #include #include #include #include int main() { pid_t pid = fork(); if (pid == 0) { exit(12); } else { siginfo_t siginfo = {}; waitid(P_PID, pid, &siginfo, WEXITED); printf("Code: %d, status: %d\n", (int)siginfo.si_code, (int)siginfo.si_status); } pid = fork(); if (pid == 0) { raise(SIGUSR2); } else { siginfo_t siginfo = {}; waitid(P_PID, pid, &siginfo, WEXITED); printf("Code: %d, status: %d\n", (int)siginfo.si_code, (int)siginfo.si_status); } } Output with an x86_64 host and mips64el target before 1c3dfb506ea3 (incorrect: exit code 12 is translated like a signal): Code: 1, status: 17 Code: 2, status: 17 After 1c3dfb506ea3 (incorrect: signal number is not translated): Code: 1, status: 12 Code: 2, status: 12 With this patch: Code: 1, status: 12 Code: 2, status: 17 Signed-off-by: Matthias Schiffer Reviewed-by: Laurent Vivier Message-Id: <81534fde7cdfc6acea4889d886fbefdd606630fb.1635019124.git.mschiffer@universe-factory.net> Signed-off-by: Laurent Vivier --- linux-user/signal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 510db73c3424..1229fecf5cd4 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -406,7 +406,12 @@ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, case TARGET_SIGCHLD: tinfo->_sifields._sigchld._pid = info->si_pid; tinfo->_sifields._sigchld._uid = info->si_uid; - tinfo->_sifields._sigchld._status = info->si_status; + if (si_code == CLD_EXITED) + tinfo->_sifields._sigchld._status = info->si_status; + else + tinfo->_sifields._sigchld._status + = host_to_target_signal(info->si_status & 0x7f) + | (info->si_status & ~0x7f); tinfo->_sifields._sigchld._utime = info->si_utime; tinfo->_sifields._sigchld._stime = info->si_stime; si_type = QEMU_SI_CHLD; From patchwork Thu Jan 6 10:41:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576021 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV32963TLz9sPC for ; Thu, 6 Jan 2022 21:46:57 +1100 (AEDT) Received: from localhost ([::1]:52484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QIJ-0002Ok-LP for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:46:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDX-0007iQ-Ul for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:57159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004j2-I0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N63NQ-1mL4x12H7I-016Qbi; Thu, 06 Jan 2022 11:41:47 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/27] linux-user: add sched_getattr support Date: Thu, 6 Jan 2022 11:41:24 +0100 Message-Id: <20220106104137.732883-15-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:SV4a/XRVJ3D42ofnmFsE0qxbCh4YpfwnQhpbIzxVwb/wS5ei9Bs x53LaPSQzdvTzdw43MPA0OXpbtHbe0dYPb0HD+6lPUbORb93pAiHGTrTxeqFiPjY5/a5S3Y eFnc/ULJUIi8hRQWUqEWf20/kS5CAEjqmMdHhdOJiIkzfYiGlKAcsG++wEeGpCbdNS/S+qO J7J/6us0fG7BD8lvizrtQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:0i4fSjI8n90=:A9uqGWAsNJJKzU4+6fimkF /igf0F57YHBDKOth0itLrnSNrCF/s2MyFGpB2hltX9gRHVV9La5JvkRWizKoZOHUA44OE2oXN TX3JtMzggPS1DK2KKp6yxFe8GHqS5gziEp6M+OB15GR4KFlula3ieY9Cz2cAUu1TqazDyxFIR VWg3NnloRWTexH5MiK5jwi5OX5hcmGqGcGP+o7uie99S4BMOW5wexpuBpy3HxIGhNyjBO9IAh kUAGpnEeliG+7aCqOBta4bELLXwUnuVtsl6+AnrDBUWUOrT+t1qTBgFmIATzRmlhzXIZSZCgQ hWCiBe2GolImpbh86+lns/iaNKt4OLuXAPivtSWxqwDgsHuUI2lYSWpJHYvPH96Rj0H0RGoWB phMmRytJHnDzEcuHGnVJh5rS5D+O1cLrSScvdc8HL9EMxdWk7Ke13T1l4aTTIs6MzLD/ZQMTG CTHnu4nYTPQ/SCnE8+qtvMRHkmj+WqEeFFWlPBVijidtwxeA9pEiY3v+U1VxOj+bYoN/yPvs6 nfOCduBYjnV3TId2a2n+TDKHFSExfjkGcAtgk1S0b5wiHoIY0O6cj+fGbJkqEgWiJmwYyvugw HEHRg/XSdbIfU51b5TboIKpxW9OyBe0S6xSQ2RbRnCDlUJr6TMOPGL5zb/LMnwwekCOoKdSr/ FP6DzZE58HHbSwCnEULlIIrNPgk+I5UY3smAmwKjrRl3IPlVUyYTUCcaPg5PlbxpbeSY= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tonis Tiigi , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tonis Tiigi These syscalls are not exposed by glibc. The struct type need to be redefined as it can't be included directly before https://lkml.org/lkml/2020/5/28/810 . sched_attr type can grow in future kernel versions. When client sends values that QEMU does not understand it will return E2BIG with same semantics as old kernel would so client can retry with smaller inputs. Signed-off-by: Tonis Tiigi Message-Id: <20220105041819.24160-2-tonistiigi@gmail.com> Reviewed-by: Laurent Vivier Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 123 ++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 14 +++++ 2 files changed, 137 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b5112891b046..6de116eb90cb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -340,6 +340,25 @@ _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len, #define __NR_sys_sched_setaffinity __NR_sched_setaffinity _syscall3(int, sys_sched_setaffinity, pid_t, pid, unsigned int, len, unsigned long *, user_mask_ptr); +/* sched_attr is not defined in glibc */ +struct sched_attr { + uint32_t size; + uint32_t sched_policy; + uint64_t sched_flags; + int32_t sched_nice; + uint32_t sched_priority; + uint64_t sched_runtime; + uint64_t sched_deadline; + uint64_t sched_period; + uint32_t sched_util_min; + uint32_t sched_util_max; +}; +#define __NR_sys_sched_getattr __NR_sched_getattr +_syscall4(int, sys_sched_getattr, pid_t, pid, struct sched_attr *, attr, + unsigned int, size, unsigned int, flags); +#define __NR_sys_sched_setattr __NR_sched_setattr +_syscall3(int, sys_sched_setattr, pid_t, pid, struct sched_attr *, attr, + unsigned int, flags); #define __NR_sys_getcpu __NR_getcpu _syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache); _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd, @@ -558,6 +577,24 @@ const char *target_strerror(int err) return strerror(target_to_host_errno(err)); } +static int check_zeroed_user(abi_long addr, size_t ksize, size_t usize) +{ + int i; + uint8_t b; + if (usize <= ksize) { + return 1; + } + for (i = ksize; i < usize; i++) { + if (get_user_u8(b, addr + i)) { + return -TARGET_EFAULT; + } + if (b != 0) { + return 0; + } + } + return 1; +} + #define safe_syscall0(type, name) \ static type safe_##name(void) \ { \ @@ -10801,6 +10838,92 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, } case TARGET_NR_sched_getscheduler: return get_errno(sched_getscheduler(arg1)); + case TARGET_NR_sched_getattr: + { + struct target_sched_attr *target_scha; + struct sched_attr scha; + if (arg2 == 0) { + return -TARGET_EINVAL; + } + if (arg3 > sizeof(scha)) { + arg3 = sizeof(scha); + } + ret = get_errno(sys_sched_getattr(arg1, &scha, arg3, arg4)); + if (!is_error(ret)) { + target_scha = lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!target_scha) { + return -TARGET_EFAULT; + } + target_scha->size = tswap32(scha.size); + target_scha->sched_policy = tswap32(scha.sched_policy); + target_scha->sched_flags = tswap64(scha.sched_flags); + target_scha->sched_nice = tswap32(scha.sched_nice); + target_scha->sched_priority = tswap32(scha.sched_priority); + target_scha->sched_runtime = tswap64(scha.sched_runtime); + target_scha->sched_deadline = tswap64(scha.sched_deadline); + target_scha->sched_period = tswap64(scha.sched_period); + if (scha.size > offsetof(struct sched_attr, sched_util_min)) { + target_scha->sched_util_min = tswap32(scha.sched_util_min); + target_scha->sched_util_max = tswap32(scha.sched_util_max); + } + unlock_user(target_scha, arg2, arg3); + } + return ret; + } + case TARGET_NR_sched_setattr: + { + struct target_sched_attr *target_scha; + struct sched_attr scha; + uint32_t size; + int zeroed; + if (arg2 == 0) { + return -TARGET_EINVAL; + } + if (get_user_u32(size, arg2)) { + return -TARGET_EFAULT; + } + if (!size) { + size = offsetof(struct target_sched_attr, sched_util_min); + } + if (size < offsetof(struct target_sched_attr, sched_util_min)) { + if (put_user_u32(sizeof(struct target_sched_attr), arg2)) { + return -TARGET_EFAULT; + } + return -TARGET_E2BIG; + } + + zeroed = check_zeroed_user(arg2, sizeof(struct target_sched_attr), size); + if (zeroed < 0) { + return zeroed; + } else if (zeroed == 0) { + if (put_user_u32(sizeof(struct target_sched_attr), arg2)) { + return -TARGET_EFAULT; + } + return -TARGET_E2BIG; + } + if (size > sizeof(struct target_sched_attr)) { + size = sizeof(struct target_sched_attr); + } + + target_scha = lock_user(VERIFY_READ, arg2, size, 1); + if (!target_scha) { + return -TARGET_EFAULT; + } + scha.size = size; + scha.sched_policy = tswap32(target_scha->sched_policy); + scha.sched_flags = tswap64(target_scha->sched_flags); + scha.sched_nice = tswap32(target_scha->sched_nice); + scha.sched_priority = tswap32(target_scha->sched_priority); + scha.sched_runtime = tswap64(target_scha->sched_runtime); + scha.sched_deadline = tswap64(target_scha->sched_deadline); + scha.sched_period = tswap64(target_scha->sched_period); + if (size > offsetof(struct target_sched_attr, sched_util_min)) { + scha.sched_util_min = tswap32(target_scha->sched_util_min); + scha.sched_util_max = tswap32(target_scha->sched_util_max); + } + unlock_user(target_scha, arg2, 0); + return get_errno(sys_sched_setattr(arg1, &scha, arg3)); + } case TARGET_NR_sched_yield: return get_errno(sched_yield()); case TARGET_NR_sched_get_priority_max: diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 585e933140ac..66244589aa3d 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2890,4 +2890,18 @@ struct target_statx { /* 0x100 */ }; +/* from kernel's include/linux/sched/types.h */ +struct target_sched_attr { + abi_uint size; + abi_uint sched_policy; + abi_ullong sched_flags; + abi_int sched_nice; + abi_uint sched_priority; + abi_ullong sched_runtime; + abi_ullong sched_deadline; + abi_ullong sched_period; + abi_uint sched_util_min; + abi_uint sched_util_max; +}; + #endif From patchwork Thu Jan 6 10:41:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV37v5YJFz9t6S for ; Thu, 6 Jan 2022 21:51:55 +1100 (AEDT) Received: from localhost ([::1]:40488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QN7-0005GD-Ir for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:51:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDY-0007kv-Gu for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:32871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004jG-I0 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MWAaw-1mtrTF47Z4-00Xe5Q; Thu, 06 Jan 2022 11:41:48 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 15/27] linux-user: call set/getscheduler set/getparam directly Date: Thu, 6 Jan 2022 11:41:25 +0100 Message-Id: <20220106104137.732883-16-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:MJpgKlmKT5ovh0uv15NA323MEfOcEzgeK7cvYL9SlT7cjCGFtZw 0kFAap0fllfglK6lRaozoW9HiTu5Ei2Sjsgau2atfksJPG6Gr31NhGJg7ihgXKWuBYdP5Pm ruTPo6edPbHDn/UEYvAqn3ABWkJVLKlN+Z/DVqIxzB3d9uuTHvY/qh8kY19wr+sCZThnhSp scRheWGd/f38NRA7jzp6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:jlRtTYvRutw=:wEcw4w8PuATUG+0uFXVHG3 UiReeri/uAL6SCrUmkpOWC2t/4BHq4/0ZJi5pcpSM/8DMz8vMmjD5vNiMzXV4AfhCbTknW6l9 4Sddg6C6FkSLNjWoPtJWhmO2ZrYJbh6sj2vD8NXK7aw/Q8+MVRA9A3qaUetMfAiXlRpxJ9E77 WQLoBhc93Im0Rl0k0WQoOJ8b8LR5ROWJnJVaKlBhk9vKxk72o2/o6GUhzZsUK7pfI/N6gckO4 er1mzrS2qTXgF9580HaknWSd3v654FLN97Wlh64iz/3j3hai64hRNTJHGBUalYwbAtD+qpjbg 1BVlH7cDMvlqCAocjmmdNIZ13Cj+hX4Gw9OULwJAjb7t18L1P7bMf7zG2PrfF7sP6Qyx+r7bp I9HBLwS+EOTQBkER3IfMhefm8K6jVqFL8yrvyN4fgjPihulSmohIAxc4ZgMaWByQm+1IWt7Wa ZM1di3zwk82GamaEokpr9ElBa3JeMqj9GwyQfvVhkMh7gOmc11P/LE27z9El+dR3Z8eWGmeZE tznyiSFyY6qK89RWzEbZqOWiZkBLDV0HJQTOeyXFXv/PcohSL75UF34TorBtZUACtJsbjfAXg r5Zg1axLQ+x0VyXrelC63uPSZZq6WyBJBC7vUAKEyFdvcLXRcBAlC2ijpLji9ZEy4PnAmR1Km Vu7yJmMgIYgABlNHeiEPKDPVpTmQFk/oVFA9pOTo9UKrQ5uuudOtwepBGVGLU354NYCQ= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tonis Tiigi , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Tonis Tiigi There seems to be difference in syscall and libc definition of these methods and therefore musl does not implement them (1e21e78bf7). Call syscall directly to ensure the behavior of the libc of user application, not the libc that was used to build QEMU. Signed-off-by: Tonis Tiigi Message-Id: <20220105041819.24160-3-tonistiigi@gmail.com> Reviewed-by: Laurent Vivier Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 34 ++++++++++++++++++++++++---------- linux-user/syscall_defs.h | 4 ++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6de116eb90cb..01cd59cdce53 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -359,6 +359,17 @@ _syscall4(int, sys_sched_getattr, pid_t, pid, struct sched_attr *, attr, #define __NR_sys_sched_setattr __NR_sched_setattr _syscall3(int, sys_sched_setattr, pid_t, pid, struct sched_attr *, attr, unsigned int, flags); +#define __NR_sys_sched_getscheduler __NR_sched_getscheduler +_syscall1(int, sys_sched_getscheduler, pid_t, pid); +#define __NR_sys_sched_setscheduler __NR_sched_setscheduler +_syscall3(int, sys_sched_setscheduler, pid_t, pid, int, policy, + const struct sched_param *, param); +#define __NR_sys_sched_getparam __NR_sched_getparam +_syscall2(int, sys_sched_getparam, pid_t, pid, + struct sched_param *, param); +#define __NR_sys_sched_setparam __NR_sched_setparam +_syscall2(int, sys_sched_setparam, pid_t, pid, + const struct sched_param *, param); #define __NR_sys_getcpu __NR_getcpu _syscall3(int, sys_getcpu, unsigned *, cpu, unsigned *, node, void *, tcache); _syscall4(int, reboot, int, magic1, int, magic2, unsigned int, cmd, @@ -10794,30 +10805,32 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_sched_setparam: { - struct sched_param *target_schp; + struct target_sched_param *target_schp; struct sched_param schp; if (arg2 == 0) { return -TARGET_EINVAL; } - if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) + if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1)) { return -TARGET_EFAULT; + } schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg2, 0); - return get_errno(sched_setparam(arg1, &schp)); + return get_errno(sys_sched_setparam(arg1, &schp)); } case TARGET_NR_sched_getparam: { - struct sched_param *target_schp; + struct target_sched_param *target_schp; struct sched_param schp; if (arg2 == 0) { return -TARGET_EINVAL; } - ret = get_errno(sched_getparam(arg1, &schp)); + ret = get_errno(sys_sched_getparam(arg1, &schp)); if (!is_error(ret)) { - if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) + if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0)) { return -TARGET_EFAULT; + } target_schp->sched_priority = tswap32(schp.sched_priority); unlock_user_struct(target_schp, arg2, 1); } @@ -10825,19 +10838,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; case TARGET_NR_sched_setscheduler: { - struct sched_param *target_schp; + struct target_sched_param *target_schp; struct sched_param schp; if (arg3 == 0) { return -TARGET_EINVAL; } - if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) + if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1)) { return -TARGET_EFAULT; + } schp.sched_priority = tswap32(target_schp->sched_priority); unlock_user_struct(target_schp, arg3, 0); - return get_errno(sched_setscheduler(arg1, arg2, &schp)); + return get_errno(sys_sched_setscheduler(arg1, arg2, &schp)); } case TARGET_NR_sched_getscheduler: - return get_errno(sched_getscheduler(arg1)); + return get_errno(sys_sched_getscheduler(arg1)); case TARGET_NR_sched_getattr: { struct target_sched_attr *target_scha; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 66244589aa3d..cca561f62268 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2904,4 +2904,8 @@ struct target_sched_attr { abi_uint sched_util_max; }; +struct target_sched_param { + abi_int sched_priority; +}; + #endif From patchwork Thu Jan 6 10:41:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV39d4FK3z9sPC for ; Thu, 6 Jan 2022 21:53:25 +1100 (AEDT) Received: from localhost ([::1]:48952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QOZ-0002Vd-CY for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:53:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qb-EG for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:37273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDS-0004kG-Sf for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mz9d5-1m9l5q0PQZ-00wHS5; Thu, 06 Jan 2022 11:41:49 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 16/27] linux-user/syscall.c: fix missed flag for shared memory in open_self_maps Date: Thu, 6 Jan 2022 11:41:26 +0100 Message-Id: <20220106104137.732883-17-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:rc82XZCseiQhpRjWWvL1cUo+kyozYgxeHPpDt/35jsOh0VLl8od E+Kg8XOcYpUvTrk4cmT/kIH6owN+pvknzdfdf8aDBykPJmm8Ui+GBDpYlH8t7XLL6D1uJnj YlhkIH16dj+roOtMHtmdYqY6WrQFhR3L2d0K87PIGhN/zcxXnORg+dpfkbWanppxE5EaVTY Q9eTu52W/RpRl52NQs0Mg== X-UI-Out-Filterresults: notjunk:1;V03:K0:D7dgpBHsxWQ=:jCZciblkHUlvAz5ug+1fO/ xOTv3uq21qbwA64Ekdk7ElnzZHY1NzQ3M1Lt14v2pEoeJQTaLvn+Qijb8P+VtHWXGK3ODZqSQ PrQjjjf9GyhdW0N7spigtT/II3Ws8DC1AUxWD87RtRMCKw1cDPLaPWQ/iKDwtIukKxomrbwsG 595BOGW20Wvy7FN/WNx3AkvUAo4uWXuDx5Lq7l1bWUqgJ+At+GQ9cHrKnYUPk8f/AJ3xTwO4Y 7f/7h4m90BtwLvcOAohMXq9NiMHi8hvXG4uQhuqSQuUp5csn/vHXQ2aOJrc9ksA3C8uCoP9vT mYMI1jj+6vephHpSOsxj4RQDsLcFq/cadXuUjDlAYWDflOHruBn/7hz9Y7N1y78eV5JI2vV/g 1Rapbfa2DkKVidd27LsntNpqD2eibStaGjN4dLg0v1hYQPE752X4eGiVjAozsLAxLtfgD3cJj lKzA+ezQmfCG42byGvFQuIqYZaJHyWV6MSJTkb1zZoCGRtTaddnsFgavimCh5jVMoVGIvoUsI yg4ZRc8Cr6gLmNWlUdaV8Mja0xVRvlftmNwriNJeG+8VOxNNakUlTTQtiMkrRy7cV20BGMd7f uS2prKnUGZalv3LHuvNQr5NBN7gNKYQhk8ilzMmQX6Q4+DaxE38CX4rdnK/qdcRq9+YPjLbwY 0+OA28QPgIUPTJ3bcnqhkC2R08dDuJ610pot9wIcx5tHZBwm5K3Hf7Mgqyf1z4DKeWKQ= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier , Andrey Kazmin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Andrey Kazmin The possible variants for region type in /proc/self/maps are either private "p" or shared "s". In the current implementation, we mark shared regions as "-". It could break memory mapping parsers such as included into ASan/HWASan sanitizers. Fixes: 01ef6b9e4e4e ("linux-user: factor out reading of /proc/self/maps") Signed-off-by: Andrey Kazmin Reviewed-by: Laurent Vivier Acked-by: Alex Bennée Message-Id: <20211227125048.22610-1-a.kazmin@partner.samsung.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 01cd59cdce53..3160d77154b5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8045,7 +8045,7 @@ static int open_self_maps(void *cpu_env, int fd) (flags & PAGE_READ) ? 'r' : '-', (flags & PAGE_WRITE_ORG) ? 'w' : '-', (flags & PAGE_EXEC) ? 'x' : '-', - e->is_priv ? 'p' : '-', + e->is_priv ? 'p' : 's', (uint64_t) e->offset, e->dev, e->inode); if (path) { dprintf(fd, "%*s%s\n", 73 - count, "", path); From patchwork Thu Jan 6 10:41:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV34P589mz9sPC for ; Thu, 6 Jan 2022 21:48:53 +1100 (AEDT) Received: from localhost ([::1]:60492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QKB-0007wY-H2 for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:48:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDX-0007hZ-Ns for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:45181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004jZ-Hz for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MVNF1-1mvCmY2Uvn-00SOlJ; Thu, 06 Jan 2022 11:41:49 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 17/27] linux-user/nios2: Properly emulate EXCP_TRAP Date: Thu, 6 Jan 2022 11:41:27 +0100 Message-Id: <20220106104137.732883-18-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qG6vv5OFKb6Yy0S4W/IXZOP6sug6DV/0tU8kkyuNGlqZutDa2aL HLnE19xMVs8u1U0bxGyEjNMBjfpVWQ5pa+aMyn2JGA9YlqoZu63Lu649Yo4KwDVLHH+eftQ B+hiC95yAbzQXyYW8sJPLMH0t2/A7DHJwqQQY6l71ogrgWzGMGyi17flnBsZDJbkZ+vp5ZN 2b1JeI/yGQFm32bOfBN2A== X-UI-Out-Filterresults: notjunk:1;V03:K0:07BPLdb04k4=:gslS6L2yedPYlWz7JPzWS+ 7/L/46a+zXc8/MY/5CZU6NVV4ITrbS44Ncyz7NVAtT1RCAMs6ax6jyvpn0W7SmNihUBUy4Ruv b2IiC9m2jlL2OdZhXa8Clm5xKw8TuYPSy7zZuOlsuIYtDLN99Y4IZFka3W1uNbXomX4NbsO6K VMrv98p71KtXOvqf8dXk5svNBxa+y4n+l30cqJDVuq2CL7fm2oCSo9rES0/LfEUwmLwqkiTzh U1eb5PAdrgW7QpeFOvr2MwYI/JNLL5raHH5awGD2YTWnNTW8BEu/4fy4HFLxDU5Ta3g4QPbur Y8FaFwOhyjBdPPMI4a3XmXFJ7xWiiJvA/ESkUpe8nUEggv9J/SNXsHk7ocAsLm38vnyIp68i8 i8zg8MLfcpKi2JgHM4Un0zrN55HE9Cf/gTnZIxUDEC7rhNTAzU6lRab8YjaDFu2IwN3kIXSxW A6kAIQqMs9g39ZqlljqMxCH4NONxvP/kdIsmFBZvPeCDrftkTr/Xja1K8mqkDBErjYhf9tnbe 65XbaIWE6grWdmxibbY8KFWpq9F5W1BCTPq7kUp6OGAp0Tk1d9diWCl3A9mTM/f1u2Q0ws1rB QkzdTIJG8Gn3t6WWOjGQrbvjdou3F4lpNlme4p1K3OiEy103qa1FcCQWUA67HXypkKcLBi4I/ Rq7iLyeUa5DPdu9vzn6vmT6qIRQ4nqupcZezvCjlWCnFTq2SZ65zzu1nN4VZd6qs0I2k= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The real kernel has to load the instruction and extract the imm5 field; for qemu, modify the translator to do this. The use of R_AT for this in cpu_loop was a bug. Handle the other trap numbers as per the kernel's trap_table. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211221025012.1057923-2-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/cpu_loop.c | 40 ++++++++++++++++++++----------------- target/nios2/cpu.h | 2 +- target/nios2/translate.c | 17 +++++++++++++++- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 34290fb3b51c..5c3d01d22dd7 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -26,7 +26,6 @@ void cpu_loop(CPUNios2State *env) { CPUState *cs = env_cpu(env); - Nios2CPU *cpu = NIOS2_CPU(cs); target_siginfo_t info; int trapnr, ret; @@ -39,9 +38,10 @@ void cpu_loop(CPUNios2State *env) case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; + case EXCP_TRAP: - if (env->regs[R_AT] == 0) { - abi_long ret; + switch (env->error_code) { + case 0: qemu_log_mask(CPU_LOG_INT, "\nSyscall\n"); ret = do_syscall(env, env->regs[2], @@ -55,26 +55,30 @@ void cpu_loop(CPUNios2State *env) env->regs[2] = abs(ret); /* Return value is 0..4096 */ - env->regs[7] = (ret > 0xfffffffffffff000ULL); - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] &= ~0x3; - env->regs[R_EA] = env->regs[R_PC] + 4; + env->regs[7] = ret > 0xfffff000u; env->regs[R_PC] += 4; break; - } else { - qemu_log_mask(CPU_LOG_INT, "\nTrap\n"); - - env->regs[CR_ESTATUS] = env->regs[CR_STATUS]; - env->regs[CR_STATUS] &= ~0x3; - env->regs[R_EA] = env->regs[R_PC] + 4; - env->regs[R_PC] = cpu->exception_addr; - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case 1: + qemu_log_mask(CPU_LOG_INT, "\nTrap 1\n"); + force_sig_fault(TARGET_SIGUSR1, 0, env->regs[R_PC]); + break; + case 2: + qemu_log_mask(CPU_LOG_INT, "\nTrap 2\n"); + force_sig_fault(TARGET_SIGUSR2, 0, env->regs[R_PC]); + break; + case 31: + qemu_log_mask(CPU_LOG_INT, "\nTrap 31\n"); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[R_PC]); + break; + default: + qemu_log_mask(CPU_LOG_INT, "\nTrap %d\n", env->error_code); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + env->regs[R_PC]); break; } + break; + case EXCP_DEBUG: info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 1a69ed7a49c7..d2ba0c5bbd82 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -160,9 +160,9 @@ struct CPUNios2State { #if !defined(CONFIG_USER_ONLY) Nios2MMU mmu; - uint32_t irq_pending; #endif + int error_code; }; /** diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 08d7ac539834..a75987751926 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -636,6 +636,21 @@ static void divu(DisasContext *dc, uint32_t code, uint32_t flags) tcg_temp_free(t0); } +static void trap(DisasContext *dc, uint32_t code, uint32_t flags) +{ +#ifdef CONFIG_USER_ONLY + /* + * The imm5 field is not stored anywhere on real hw; the kernel + * has to load the insn and extract the field. But we can make + * things easier for cpu_loop if we pop this into env->error_code. + */ + R_TYPE(instr, code); + tcg_gen_st_i32(tcg_constant_i32(instr.imm5), cpu_env, + offsetof(CPUNios2State, error_code)); +#endif + t_gen_helper_raise_exception(dc, EXCP_TRAP); +} + static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION(eret), /* eret */ @@ -682,7 +697,7 @@ static const Nios2Instruction r_type_instructions[] = { INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), INSTRUCTION_ILLEGAL(), - INSTRUCTION_FLG(gen_excp, EXCP_TRAP), /* trap */ + INSTRUCTION(trap), /* trap */ INSTRUCTION(wrctl), /* wrctl */ INSTRUCTION_ILLEGAL(), INSTRUCTION_FLG(gen_cmpxx, TCG_COND_LTU), /* cmpltu */ From patchwork Thu Jan 6 10:41:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3DL3Cclz9sPC for ; Thu, 6 Jan 2022 21:55:46 +1100 (AEDT) Received: from localhost ([::1]:56504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QQo-0007Vi-0r for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:55:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDX-0007hX-N9 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:33365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDQ-0004jg-I2 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:41:59 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M6DSi-1n3FQM0VAm-006f0M; Thu, 06 Jan 2022 11:41:50 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 18/27] linux-user/nios2: Fixes for signal frame setup Date: Thu, 6 Jan 2022 11:41:28 +0100 Message-Id: <20220106104137.732883-19-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:n4PmSp8DhyGWOJ+w0pJKMyIQ3ECft+pn8dPmJGnpNAzTTRNyJMB El5Z4w1fWDcY8bu9mIkI68XBmHQd4DaEVT4GjT5P4QOjCqIyrMbbHUmbM32gbLNac4ZS8iB Z8jtl5CHmhceOBqi5kmfW4gXjs1859/8IdK2hirYtJW1xdtgSsPzvUA2Prb2XtN+3r07AHi 7qkgG3mkD5Jf/D4M+gVYA== X-UI-Out-Filterresults: notjunk:1;V03:K0:Y+ARbSwUk8k=:oOPBZU+KZovnxBROXNetay cgAFpcbGmghQpTlwud9Qi94YRAp4dxrsxUsD/2XFASheg1Q9iJFIzG/oMEl0MvtN81QF+yzIY sZm1lvwGSWXQBmlvu1H0SS+3ZKCf46yO8ANIvna+7h0nE+KeLdiHgd1r2YI7lff8XIKA2gFLz pYYmUsfDrRZJQGl31VHHhzn506yqOP7oYb7b+X6OQ48Vqd/QjnRkRrcbXqdIaldP7RQ6T8JTe KtU/SQr/oRMwoyqmi8vqXPWEChKV8LAFmPpGv+HeVwtSU6WKaQy/2RfLSYC6Zl/oe/+1KBtRZ oT5tQqcpMSW1bJ99rMWEZCt1Xsv2WHiPT3Px6h1PymeO9z8bDrWfTzUW1rq0CFg4NPaNMGNXr CStskYnVYgjlIVwXN5zZYPX759TZmCcYR+pytFR2SvK1RtrjqK44l+nm0A2DAbki2VGAZZGjG 3L7yuU2HeKu8aIjKq4xDNgMu+g8UjPMlhVnuNAD8DIPL/bLJjbx7eyHTLbSyjrrXb+CHB9uds xjaN+73O0vyJOGSMhmncygkeofgeygsEMuM21hlogmmgB6uSQ6qbLuZPh+nTAuX5RXqwVg4ZG IawqLs3JjnMKgNDaN7BKTEiMlmTmqxPfuq3SiGi/v62BQsAOdJ3EsdNdX/yhHJgBo0nG8vCDs z6CUDbZNDktlMhUwTJ48W3H8dHNfRMfP88myhjPOD6kLEh5f2mKtroZbnOXZInZ8cM8Q= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Laurent Vivier , Peter Maydell Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Do not confuse host and guest addresses. Lock and unlock the target_rt_sigframe structure in setup_rt_sigframe. Since rt_setup_ucontext always returns 0, drop the return value entirely. This eliminates the only write to the err variable in setup_rt_sigframe. Always copy the siginfo structure. Reviewed-by: Alex Bennée Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-Id: <20211221025012.1057923-3-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/signal.c | 51 ++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index a77e8a40f468..adbffe32e3c8 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -42,7 +42,7 @@ struct target_rt_sigframe { struct target_ucontext uc; }; -static int rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) +static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) { unsigned long *gregs = uc->tuc_mcontext.gregs; @@ -75,8 +75,6 @@ static int rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_GP], &gregs[25]); __put_user(env->regs[R_EA], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); - - return 0; } static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, @@ -135,8 +133,8 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, return 0; } -static void *get_sigframe(struct target_sigaction *ka, CPUNios2State *env, - size_t frame_size) +static abi_ptr get_sigframe(struct target_sigaction *ka, CPUNios2State *env, + size_t frame_size) { unsigned long usp; @@ -144,7 +142,7 @@ static void *get_sigframe(struct target_sigaction *ka, CPUNios2State *env, usp = target_sigsp(get_sp_from_cpustate(env), ka); /* Verify, is it 32 or 64 bit aligned */ - return (void *)((usp - frame_size) & -8UL); + return (usp - frame_size) & -8; } void setup_rt_frame(int sig, struct target_sigaction *ka, @@ -153,26 +151,25 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, CPUNios2State *env) { struct target_rt_sigframe *frame; - int i, err = 0; + abi_ptr frame_addr; + int i; - frame = get_sigframe(ka, env, sizeof(*frame)); - - if (ka->sa_flags & SA_SIGINFO) { - tswap_siginfo(&frame->info, info); + frame_addr = get_sigframe(ka, env, sizeof(*frame)); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + force_sigsegv(sig); + return; } + tswap_siginfo(&frame->info, info); + /* Create the ucontext. */ __put_user(0, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); target_save_altstack(&frame->uc.tuc_stack, env); - err |= rt_setup_ucontext(&frame->uc, env); + rt_setup_ucontext(&frame->uc, env); for (i = 0; i < TARGET_NSIG_WORDS; i++) { __put_user((abi_ulong)set->sig[i], - (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); - } - - if (err) { - goto give_sigsegv; + (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); } /* Set up to return from userspace; jump to fixed address sigreturn @@ -180,19 +177,13 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[R_RA] = (unsigned long) (0x1044); /* Set up registers for signal handler */ - env->regs[R_SP] = (unsigned long) frame; - env->regs[4] = (unsigned long) sig; - env->regs[5] = (unsigned long) &frame->info; - env->regs[6] = (unsigned long) &frame->uc; - env->regs[R_EA] = (unsigned long) ka->_sa_handler; - return; - -give_sigsegv: - if (sig == TARGET_SIGSEGV) { - ka->_sa_handler = TARGET_SIG_DFL; - } - force_sigsegv(sig); - return; + env->regs[R_SP] = frame_addr; + env->regs[4] = sig; + env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); + env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); + env->regs[R_EA] = ka->_sa_handler; + + unlock_user_struct(frame, frame_addr, 1); } long do_sigreturn(CPUNios2State *env) From patchwork Thu Jan 6 10:41:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3Mx2vrYz9sSs for ; Thu, 6 Jan 2022 22:02:21 +1100 (AEDT) Received: from localhost ([::1]:44528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QXB-0002Gw-7C for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 06:02:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDZ-0007ne-Gi for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:50397) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDR-0004jr-El for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbC5g-1mYINz1zlw-00bYSd; Thu, 06 Jan 2022 11:41:51 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 19/27] linux-user/elfload: Rename ARM_COMMPAGE to HI_COMMPAGE Date: Thu, 6 Jan 2022 11:41:29 +0100 Message-Id: <20220106104137.732883-20-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:1lauh6L71dtd4UvQ6MPHlgdYKC13fq8DbNE3emgtpe6t1q7k8I3 AS1g0EV4RqyYkFGHHNucHEfZ8WyqF+02c8/rrQ9axMdER9LHDHpIaAoC8hM0qzvBvmwoUJb OnD9ESsPsqV1lc1s8zjWe7biBPBSePirW0Ff9pO9TpjigCG/9ohzaf6OdB2urY2N+3p8qLI 1UDqt25vnwPBP5AmsL6mQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:JoTCOb9r2TM=:QwMel8YmCwgzyyeLCpGTGY p56kRD+OLSIrpNrumIeF8h9buLfjBmrqTkUUUud7WLFHgbzkfFgjofuoSgbER9JUnnLVc50fs xjBwQTUnADaQsaO3DIV+wZ9IIwsVFI3KpUBZVNO8SdqZWaEcS8urGMsfqXotKFYSzE19C6pwk 1Nf/hLJ4buv15BA+SOcTP9eGLTtqhDRQEky4BwskFsHujg25B9VnoJZceRS/6j6iq5ZW7tLMb 4wlXFIh/KXzyhsYWQ/Hg+d+uffvaTCgxOjSlg39LjZ5wlY7ACKwAK5OXX8mu5su4wdR/RDRU4 MSHW7QzilAYsTIciTKkxBB2RhH9BQZfYTJR1P3luS7tr4ErVHjAhubmFmBe6cMfEZIuMl+tTv znCOVK+MrACSywnKD8bbCPMRyOXbloH7SV+cLv+SBFG15ROMEY6O/Nhc04p5Y9haT1vnPSAVv Iz9wxQqnSAUZzeAKQHT15//XSc1TwU2FgyI4IJFbOvnDbU2EdVhexTmAQs4eOiE+9P0/vnGuj sDkJbU6xRvjtXCAYhUjfkj9FYhmSsZ0/mpcLPJleZDrH3y1fRkVfVvgY8q5Y4k8MPBWdYRWUR FwgSLxjvfvP8QpF6A3t+QHnrh2S7dNHGkzhnjvox2UHLlVSvewuni719CAgHUhiM4GTgQknWk 7lHft5H15epwQTlIw7h2nu0xZkmCeLBbhpZWSqBHAe2ny/RWmZC5SZrZRmW7/I4n+rsw= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Arm will no longer be the only target requiring a commpage, but it will continue to be the only target placing the page at the high end of the address space. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Message-Id: <20211221025012.1057923-4-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 767f54c76dc5..d34cd4fe43fb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -390,11 +390,11 @@ enum { /* The commpage only exists for 32 bit kernels */ -#define ARM_COMMPAGE (intptr_t)0xffff0f00u +#define HI_COMMPAGE (intptr_t)0xffff0f00u static bool init_guest_commpage(void) { - void *want = g2h_untagged(ARM_COMMPAGE & -qemu_host_page_size); + void *want = g2h_untagged(HI_COMMPAGE & -qemu_host_page_size); void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); @@ -2160,8 +2160,8 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, return sp; } -#ifndef ARM_COMMPAGE -#define ARM_COMMPAGE 0 +#ifndef HI_COMMPAGE +#define HI_COMMPAGE 0 #define init_guest_commpage() true #endif @@ -2361,7 +2361,7 @@ static void pgb_static(const char *image_name, abi_ulong orig_loaddr, } loaddr &= -align; - if (ARM_COMMPAGE) { + if (HI_COMMPAGE) { /* * Extend the allocation to include the commpage. * For a 64-bit host, this is just 4GiB; for a 32-bit host we @@ -2372,14 +2372,14 @@ static void pgb_static(const char *image_name, abi_ulong orig_loaddr, if (sizeof(uintptr_t) == 8 || loaddr >= 0x80000000u) { hiaddr = (uintptr_t) 4 << 30; } else { - offset = -(ARM_COMMPAGE & -align); + offset = -(HI_COMMPAGE & -align); } } addr = pgb_find_hole(loaddr, hiaddr - loaddr, align, offset); if (addr == -1) { /* - * If ARM_COMMPAGE, there *might* be a non-consecutive allocation + * If HI_COMMPAGE, there *might* be a non-consecutive allocation * that can satisfy both. But as the normal arm32 link base address * is ~32k, and we extend down to include the commpage, making the * overhead only ~96k, this is unlikely. @@ -2400,7 +2400,7 @@ static void pgb_dynamic(const char *image_name, long align) * All we need is a commpage that satisfies align. * If we do not need a commpage, leave guest_base == 0. */ - if (ARM_COMMPAGE) { + if (HI_COMMPAGE) { uintptr_t addr, commpage; /* 64-bit hosts should have used reserved_va. */ @@ -2410,7 +2410,7 @@ static void pgb_dynamic(const char *image_name, long align) * By putting the commpage at the first hole, that puts guest_base * just above that, and maximises the positive guest addresses. */ - commpage = ARM_COMMPAGE & -align; + commpage = HI_COMMPAGE & -align; addr = pgb_find_hole(commpage, -commpage, align, 0); assert(addr != -1); guest_base = addr; From patchwork Thu Jan 6 10:41:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3Jb5Fykz9sSs for ; Thu, 6 Jan 2022 21:59:26 +1100 (AEDT) Received: from localhost ([::1]:36722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QUM-000528-Od for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:59:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDZ-0007nh-H4 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:59149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDR-0004k0-Sj for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:00 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MEUaQ-1nBWsf3hRS-00Fz6D; Thu, 06 Jan 2022 11:41:52 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 20/27] linux-user/nios2: Map a real kuser page Date: Thu, 6 Jan 2022 11:41:30 +0100 Message-Id: <20220106104137.732883-21-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:V5mQcKaknO/dQ4BbmLpggz5nfGAs+HZS3fVhdM6wIjkh2Ad7UL0 1L1fNRnQucUCeLWne5MuHKdr6GsX60NyWZZKIvVnQ/ACchBbsPnN+jYfNVPunCEJjZfHcYN J2GSHVFq8EBEadz3TQlUpSAMZn00+GTGL2QomnCWmlUCjgsAeCzpUgfShIviQ0VX0634egF /6oFDU6ISk7lpSM5BQCUw== X-UI-Out-Filterresults: notjunk:1;V03:K0:vhlb68p/hRI=:Ur7CfeKUJdJCW9RQU1SpOo YTfRgyBsVJTF00lFf3BGWXrJsslqTqCOBJGQl73qji9fNfnyMn2SQmO08JF+hvMs9FcHZDhM/ ++kJhAMik7gpIdEvcdSiy7oKmnu8UdpmHrEqQX2nY9nZxS4gJTh0bvfkg9O3346mRXXL9oopt NU3gvUQ0jKnq63ncfj8p6lAjBrFW6m1S6KkzkxhvaHEGrSY5pNEpMvT+7h53GJ93ra0kuz5He Mihw9MHPi0zFCgz4OjKx3srq1u7acVEwLqcNENBVj/6R2oPoF5nL9drdbOAGhRPEBI72dbqyF QDzE3WPjcqbZ/Or07X/KYbNjqsBrMb4b15KXEq0y2R+mixeX5KZDDvx5y814EIG3JKpK6qoJc yGDh4WP4EJPTDD/kjpm8+fDElEUWul5z87Q6R+Rq8U+MtZy0ZMWUMhq6gq7Jw9n/h4oKHngkJ YO5QmKIAidl48HchrEsA+5qMgiSaw4jJC9N2k0QTxu7PTVFVbH6C56UEG1uGafrOVTDjrmLe3 fclk4Sk8aykKoYGMarSQ65WVFwFyvb9EPjeg/WtAqrgmPUPnbaqcD+oas3NZqYZxEojFqOXXK jMJInVuuRAVp81fvMGZzDhbej+qKUoSH+bwRnMzmewqh4X6tZlqxX7fXnl2RNEBNvToy5hxKM mZF8zd0GmHugjeptuv1SPlBbTPXDu4VPGPaFD9COGiQUB1ew2pn0IeDKjju8pvSl5ZWk= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The first word of page1 is data, so the whole thing can't be implemented with emulation of addresses. Use init_guest_commpage for the allocation. Hijack trap number 16 to implement cmpxchg. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211221025012.1057923-5-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 50 ++++++++++++++++++++++++++++++++++++- linux-user/nios2/cpu_loop.c | 50 ++++++++++++++++++++----------------- target/nios2/translate.c | 9 ------- 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index d34cd4fe43fb..329b2375ef15 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1099,6 +1099,47 @@ static void init_thread(struct target_pt_regs *regs, struct image_info *infop) regs->estatus = 0x3; } +#define LO_COMMPAGE TARGET_PAGE_SIZE + +static bool init_guest_commpage(void) +{ + static const uint8_t kuser_page[4 + 2 * 64] = { + /* __kuser_helper_version */ + [0x00] = 0x02, 0x00, 0x00, 0x00, + + /* __kuser_cmpxchg */ + [0x04] = 0x3a, 0x6c, 0x3b, 0x00, /* trap 16 */ + 0x3a, 0x28, 0x00, 0xf8, /* ret */ + + /* __kuser_sigtramp */ + [0x44] = 0xc4, 0x22, 0x80, 0x00, /* movi r2, __NR_rt_sigreturn */ + 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ + }; + + void *want = g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); + void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr != want) { + return false; + } + + memcpy(addr, kuser_page, sizeof(kuser_page)); + + if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + perror("Protecting guest commpage"); + exit(EXIT_FAILURE); + } + + page_set_flags(LO_COMMPAGE, LO_COMMPAGE + TARGET_PAGE_SIZE, + PAGE_READ | PAGE_EXEC | PAGE_VALID); + return true; +} + #define ELF_EXEC_PAGESIZE 4096 #define USE_ELF_CORE_DUMP @@ -2160,8 +2201,13 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, return sp; } -#ifndef HI_COMMPAGE +#if defined(HI_COMMPAGE) +#define LO_COMMPAGE 0 +#elif defined(LO_COMMPAGE) +#define HI_COMMPAGE 0 +#else #define HI_COMMPAGE 0 +#define LO_COMMPAGE 0 #define init_guest_commpage() true #endif @@ -2374,6 +2420,8 @@ static void pgb_static(const char *image_name, abi_ulong orig_loaddr, } else { offset = -(HI_COMMPAGE & -align); } + } else if (LO_COMMPAGE) { + loaddr = MIN(loaddr, LO_COMMPAGE & -align); } addr = pgb_find_hole(loaddr, hiaddr - loaddr, align, offset); diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index 5c3d01d22dd7..de0fc63e2196 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -76,6 +76,32 @@ void cpu_loop(CPUNios2State *env) force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, env->regs[R_PC]); break; + + case 16: /* QEMU specific, for __kuser_cmpxchg */ + { + abi_ptr g = env->regs[4]; + uint32_t *h, n, o; + + if (g & 0x3) { + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, g); + break; + } + ret = page_get_flags(g); + if (!(ret & PAGE_VALID)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, g); + break; + } + if (!(ret & PAGE_READ) || !(ret & PAGE_WRITE)) { + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_ACCERR, g); + break; + } + h = g2h(cs, g); + o = env->regs[5]; + n = env->regs[6]; + env->regs[2] = qatomic_cmpxchg(h, o, n) - o; + env->regs[R_PC] += 4; + } + break; } break; @@ -86,29 +112,7 @@ void cpu_loop(CPUNios2State *env) queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case 0xaa: - switch (env->regs[R_PC]) { - /*case 0x1000:*/ /* TODO:__kuser_helper_version */ - case 0x1004: /* __kuser_cmpxchg */ - start_exclusive(); - if (env->regs[4] & 0x3) { - goto kuser_fail; - } - ret = get_user_u32(env->regs[2], env->regs[4]); - if (ret) { - end_exclusive(); - goto kuser_fail; - } - env->regs[2] -= env->regs[5]; - if (env->regs[2] == 0) { - put_user_u32(env->regs[6], env->regs[4]); - } - end_exclusive(); - env->regs[R_PC] = env->regs[R_RA]; - break; - /*case 0x1040:*/ /* TODO:__kuser_sigtramp */ - default: - ; -kuser_fail: + { info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; /* TODO: check env->error_code */ diff --git a/target/nios2/translate.c b/target/nios2/translate.c index a75987751926..f9abc2fdd200 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -795,15 +795,6 @@ static void nios2_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) dc->base.pc_next = pc + 4; /* Decode an instruction */ - -#if defined(CONFIG_USER_ONLY) - /* FIXME: Is this needed ? */ - if (pc >= 0x1000 && pc < 0x2000) { - t_gen_helper_raise_exception(dc, 0xaa); - return; - } -#endif - code = cpu_ldl_code(env, pc); op = get_opcode(code); From patchwork Thu Jan 6 10:41:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3KG2WP9z9sSs for ; Thu, 6 Jan 2022 22:00:02 +1100 (AEDT) Received: from localhost ([::1]:38502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QUy-0006Do-7C for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 06:00:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qa-Eb for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:36477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDS-0004k7-9w for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MgiPE-1mSoCy1N5I-00h2dv; Thu, 06 Jan 2022 11:41:52 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 21/27] linux-user/nios2: Fix EA vs PC confusion Date: Thu, 6 Jan 2022 11:41:31 +0100 Message-Id: <20220106104137.732883-22-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:fpma7rgrQfMkXeh/gmxujbOIZZ+gON8IEBva0thvttFJabWTRgz AmoD1gUIwMuMBRE9ZqtYOYoMHOvnKy8K0LmMAepdPM2VoIlcc8qOq0s5yDjs9hyPp9H/TjE j2smxwB4W0SdbFH0ntiWcQdJ35t9Dp8k0F07t5S3H9CcqRo84/j6y8iR38ybqzBoI5k9Sts 4EwQeBHT9SbabDo1pQS8Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:Q+38r0NksW0=:1tS/clRubEgF3TQxL3cesn 9krz+O1NahMe+fxec3/9zevP8aXsG7SnyUIKOV7Ccxtsv064ZCmncFfzyYeBma8IKarZh8vW5 oMe8fXjHAbc2wpIfogqYskdK7bzWVPur2w4dWNR5rmLLQdo1KmyvrzaTclQitur+ijbCIJsA2 l8kiE5ZY7IeP5DWu8wAs5Kfsq1SwUTb0XVmUnjW+NqKnRqbzfSRPXnMELRxkDN3Qh0PbPhdvo zAbvAwX/BTZxZxYl8/1B/gA+uqXh/wa+0DWbVfRROu4MwjWFXTB0UW4NIhdWj37GIP25qF5qK T+yffcczYSHEGSmISLi++0RSqVw1JM8FK2fhphaNN4bQpF1wqCHXVCqDxUpZLfNUbhw33X+sW JdybWTAaMkkxeOzftkculPPmQJcruQ/5yjMaKHo8mNOPqHr9OUSuvI0EPkjyXkWFTkEWa4ORV 1fOm91EnPOHWk0+ypNGPETrrMiD++v0N3mIcidu26wQxYlfyZdAvFJyQ7bVVaTWRy1IIvTimu UfGzsJMiwvgkGMIATpwgtc7c2xde81TfWQNEPgRCM6dKqn6OLGLpy3reicuUOct4eh0vwr7CG j3ZIse0Tj7Bc5ACyCuA8lHPn3UnCBFXYvj3FfJruyn8guPfTjE6Zw/zX4svib9Km6cdCLumKc duYNqNdmKWh+H70NRnkIgtLtf5K3X1DG5F0u5kysq2ez1iWSzawnxGIpzXup4VAfo7pg= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The real kernel will talk about the user PC as EA, because that's where the hardware will have copied it, and where it expects to put it to then use ERET. But qemu does not emulate all of the exception stuff while emulating user-only. Manipulate PC directly. This fixes signal entry and return, and eliminates some slight confusion from target_cpu_copy_regs. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20211221025012.1057923-6-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/cpu_loop.c | 5 +---- linux-user/nios2/signal.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c index de0fc63e2196..1e93ef34e649 100644 --- a/linux-user/nios2/cpu_loop.c +++ b/linux-user/nios2/cpu_loop.c @@ -155,9 +155,6 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) env->regs[R_SP] = regs->sp; env->regs[R_GP] = regs->gp; env->regs[CR_ESTATUS] = regs->estatus; - env->regs[R_EA] = regs->ea; - /* TODO: unsigned long orig_r7; */ - - /* Emulate eret when starting thread. */ env->regs[R_PC] = regs->ea; + /* TODO: unsigned long orig_r7; */ } diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index adbffe32e3c8..20b65aa06e08 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -73,7 +73,7 @@ static void rt_setup_ucontext(struct target_ucontext *uc, CPUNios2State *env) __put_user(env->regs[R_RA], &gregs[23]); __put_user(env->regs[R_FP], &gregs[24]); __put_user(env->regs[R_GP], &gregs[25]); - __put_user(env->regs[R_EA], &gregs[27]); + __put_user(env->regs[R_PC], &gregs[27]); __put_user(env->regs[R_SP], &gregs[28]); } @@ -122,7 +122,7 @@ static int rt_restore_ucontext(CPUNios2State *env, struct target_ucontext *uc, __get_user(env->regs[R_GP], &gregs[25]); /* Not really necessary no user settable bits */ __get_user(temp, &gregs[26]); - __get_user(env->regs[R_EA], &gregs[27]); + __get_user(env->regs[R_PC], &gregs[27]); __get_user(env->regs[R_RA], &gregs[23]); __get_user(env->regs[R_SP], &gregs[28]); @@ -181,7 +181,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, env->regs[4] = sig; env->regs[5] = frame_addr + offsetof(struct target_rt_sigframe, info); env->regs[6] = frame_addr + offsetof(struct target_rt_sigframe, uc); - env->regs[R_EA] = ka->_sa_handler; + env->regs[R_PC] = ka->_sa_handler; unlock_user_struct(frame, frame_addr, 1); } From patchwork Thu Jan 6 10:41:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV39d6JN1z9t6S for ; Thu, 6 Jan 2022 21:53:25 +1100 (AEDT) Received: from localhost ([::1]:48998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QOZ-0002XV-MO for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:53:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qc-FC for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:44273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDS-0004kE-Ob for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:01 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mm9NA-1mev9U3GYy-00iCIx; Thu, 06 Jan 2022 11:41:52 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 22/27] linux-user/nios2: Fix sigmask in setup_rt_frame Date: Thu, 6 Jan 2022 11:41:32 +0100 Message-Id: <20220106104137.732883-23-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:JuM+arCOkuDblzDDdPbSmwupkdklfOxrrbLKq8HEAz63N/0VEJS uDBGl357/KcVQNgddT5b0WXO+rdyUZZtw4zNgvUI/e6oNskEaALVFEs0aspnuMFFDVhA1cY 8XyulpOyo/oIp05e1oochfwE1LVgJIwvn88ZzI8GirFT7N2qj3/E5Z4+K1hTMk5+VZKzJhN NjVBfHSPz7VrSwTyXO0Kg== X-UI-Out-Filterresults: notjunk:1;V03:K0:yiBBcNyWuDI=:hRj3wpdN8QKgW2ZD6SZAZR eB/aG3o62qxX2CtSWAvARo9/THPqhY8f9WQJZsrK2k/RHILqvu5g+wcZBJ4c5yV49emRmzX0f uN8qgwx4wMDBv2a7PmsXnis+d01n3zIAbKxq4cLG4w2rLXgz1hSFAXaQUxRFHQmOQsdspILUs AkbcrWrQxMsSeTqgx0H6AbNul8LMGfw1bOCL0JwoX6RlUThKqXgNOFAhnkCHX2VkZ4wIBtT5z VgaR1E3+mNsUM9NGmQc1ehTw1rcsIDFzSjoroFwC4NWLl8nxK6SEQr00YbpCQQKQtJt9aU/Ix EZyYerx/brdLTR6D02QOVJh7mtcua6lePOj14L9Yl8qezWdBJINdfX91BSw8q2mZDo/vHLxAM IqL8RbJrLGJMpI4PWKyMBVskHLc5b/fDpJJyV8DqLLt/8UzC6cQPNFppxCXcVVqbAiLDKh0ty 9Ojwpvw498iXEKPhL/nke4swp6b5otHnPsQuCHG+ODVRRhgG9JCLtHmNuMXWmQPIkD8Mgd9ZS ZE1HMTN79SWTDhht2Q27Oguqvmv7MkogZRVvGYOV/D5TLb3o5G3VpHNgGIAlO21e4+jlOviG+ b14UNTlWIsj3k8tccndaRzTB+bNpS9EjNfBna+4VM6gV0LIMWiEqjRYp2vKJ8/kCmolIq/k+t tyzGhVDogqG/NpcNXvIdJs+FlyPgEjstnH7O9jXALONmPmgT/UBGCgPkVJUsax4/LMQU= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Do not cast the signal mask elements; trust __put_user. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Message-Id: <20211221025012.1057923-7-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/signal.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 20b65aa06e08..80e3d42fc965 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -168,8 +168,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_save_altstack(&frame->uc.tuc_stack, env); rt_setup_ucontext(&frame->uc, env); for (i = 0; i < TARGET_NSIG_WORDS; i++) { - __put_user((abi_ulong)set->sig[i], - (abi_ulong *)&frame->uc.tuc_sigmask.sig[i]); + __put_user(set->sig[i], &frame->uc.tuc_sigmask.sig[i]); } /* Set up to return from userspace; jump to fixed address sigreturn From patchwork Thu Jan 6 10:41:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV37z4Y7jz9sPC for ; Thu, 6 Jan 2022 21:51:59 +1100 (AEDT) Received: from localhost ([::1]:41016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QNB-0005fS-Dc for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:51:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qe-G9 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:37973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDT-0004kK-1l for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:02 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N1u2b-1mPjeS0iXx-012KWU; Thu, 06 Jan 2022 11:41:53 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 23/27] linux-user/nios2: Use set_sigmask in do_rt_sigreturn Date: Thu, 6 Jan 2022 11:41:33 +0100 Message-Id: <20220106104137.732883-24-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:G1CYcwi24EKj4DBof4R5whAD+q4axTF8BdkqPd4/LM9HETQdRz1 p9Qu1FHaQcIfOPszPbz57EuQrtp8LhBkuS19OvWw8ToQKsbbujGblzWqaCkD7XiM38cB3cn I3bnFyBWT4kM4OCtyyO+mw347TV+8cG9Rn5utEFnlCSC/d71M4SyIp2p+5kPXYbyQkIXQwV 1Z7ibGtFFrnBDNKF2gkKg== X-UI-Out-Filterresults: notjunk:1;V03:K0:kg3W/yigEMI=:lHWSmiuO1Xyi95l9MiNAMI VPPYvKPV6NTdzzRl7eJnJeBt1k1BvuFJY1DgIa6GZIwnxEDt1X88z3f1eydEkgRJ8sW5V7wSC Vci/TpPoviqwA2JlTg7CJLjRhnH7MZi/xxtQUeHzORLnm6VleAEKDa/b5tnfvSCKwvGltV2wb 90n2uKetZUXGPsPXUMKh9JB45isX+rRkR8eZjTS15vk/BlFptK0sc2FlPX36rz97e04uYSebA MBZQ9i1ivt4UJAbqn8I0uLXemSiqK/QcWcdhzUE7b46JMrXOko1deTapqB8t6+K7uLvKX8zKl rpFJci1a6+TE3DZD1v2iLQM1xLht1YQ1jCGyBQrk3eOOigKO0aDo7ErR7xM1n2Xy11PUhB1UQ W6mluu033uD9dMvQFj9J8M5QDkpu7kQAxooERDYSR+1nD9FhRRHJDrYfcxXDUx7JIwX1Md/qW 7ARfb1Is8W6umDKajAgu9wDGCJb+0r4qMRcM2mULaK1hNu06B2cUWU84At7/5EEJqMiItbUEg FTfZYij0FP5rSfaD1Z9a2cRaIvzzYIPEjqO504YTnYwspUKxL80UDxon15ZxPpLxFz/PtFO8y NooZ4j5Rn9dI0cRitAqsyJ0QdrnnS7q3EDbI7QPzWUD3EO+BdhHt760kYxIi3mmfW3E9aP3gy lRlKYVcOKpv3jJIgTvE0CfDZJthCH/Xg9Ea2hAUDtXgUHR5zWEEdDD7SLU4xBM9ShhnQ= Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Using do_sigprocmask directly was incorrect, as it will leave the signal blocked by the outer layers of linux-user. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Message-Id: <20211221025012.1057923-8-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/nios2/signal.c | 2 +- linux-user/signal.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linux-user/nios2/signal.c b/linux-user/nios2/signal.c index 80e3d42fc965..517cd392701c 100644 --- a/linux-user/nios2/signal.c +++ b/linux-user/nios2/signal.c @@ -205,7 +205,7 @@ long do_rt_sigreturn(CPUNios2State *env) } target_to_host_sigset(&set, &frame->uc.tuc_sigmask); - do_sigprocmask(SIG_SETMASK, &set, NULL); + set_sigmask(&set); if (rt_restore_ucontext(env, &frame->uc, &rval)) { goto badframe; diff --git a/linux-user/signal.c b/linux-user/signal.c index 1229fecf5cd4..f813b4f18e44 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -258,7 +258,6 @@ int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) return 0; } -#if !defined(TARGET_NIOS2) /* Just set the guest's signal mask to the specified value; the * caller is assumed to have called block_signals() already. */ @@ -268,7 +267,6 @@ void set_sigmask(const sigset_t *set) ts->signal_mask = *set; } -#endif /* sigaltstack management */ From patchwork Thu Jan 6 10:41:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3Jn3G9pz9sSs for ; Thu, 6 Jan 2022 21:59:37 +1100 (AEDT) Received: from localhost ([::1]:37510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QUZ-0005XZ-7s for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:59:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDc-0007r4-Kq for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:32915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0004nf-52 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:04 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MGQ85-1nBFd62gJB-00GoZu; Thu, 06 Jan 2022 11:41:53 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 24/27] linux-user/syscall.c: malloc to g_try_malloc Date: Thu, 6 Jan 2022 11:41:34 +0100 Message-Id: <20220106104137.732883-25-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qtp+GW+R7zQfcw4EWrY/8LmY2s+BahHnM2ggoGxSvKVds44RRoy r5vOeXpvlmLzLMJ+c9192Z7GGFvAD+itFbQ7seC/YKc68RWNqFhY1R4AtAP+WQWC86RCkEj pegUYkxk9ZBgSpP1ruf9WqUzpJ8AHLsIi0nfhR6IQ8n3VFcET8pE6pQP2uC+dhiTt1ejGUA Ip4re/f+2mA/0V2Ucmd1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:9WymBe0aqcw=:kMgAKhxSsB0oQkyR/d69AE RI+kiCo+etYGQxlSYm08C9FTw6Iaa+VrkEKjJ3bGw4eHZsa4i8puCAaNoY/xoX8c/65mn2Qtb jytA2dQ5npYe4XC+9xDehnQjHdgqKS86kk79dGZ7QRzbwAZb9KwOj1M5ma2J3OetXSkniQYiy dUPl1h58VUUGRYx2G1gkAu21ynyjpojO2Ig3o7jw8gn/KDp9RXjLOl16u+hCFdiOtFmSRwBn9 WEvdhG7LHuO0sSf8nu5/peIbbktmy/uugMu35hokA9hRvfsD0mQtqDB130l35IP3HYGGM78d9 3aS3agOsSh4g0Ur+J8aEXHvCWwHxxrmrrfs/5+fuqh+yAUyfmUx4B3C6ZL36g2k1fRSYM9JaW tTKV22yXH4tKrBuJlyflyrVhy6eRnck4dpTXGs4yJ59N7Ihq97Oe7bPkgiPeEoaLhnEO7lM3w DGKf/lbhyyQm/zTDGyx3+YG/tGu3nvykrx5TiDldK2AtwfQWuVVquYiaL/qRIHyKOHFjIghlb 9qwJRAHTxvEqyrjs7hypg+vCpvQMi3qNjFN8x+wUjDLZ5Quu5Bt8lDFhbzYrMi7mxg/ano1DZ LeE1B3Hpc6IwOyY4mipnHqsNt9GiNo+i3uI7kvbL1o7yHgsemSVLgVxmrAT/53R6Ki7flyfe3 0jh4okNzpeudnQqK1RQwo5e8TJ6aLHrGTbXnHHfmhcOemPvFnlFDuLukhZxfG/GuUcys= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmed Abouzied , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ahmed Abouzied Use g_try_malloc instead of malloc to alocate the target ifconfig. Also replace the corresponding free with g_free. Signed-off-by: Ahmed Abouzied Message-Id: <20220104143841.25116-1-email@aabouzied.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 3160d77154b5..ce9d64896cb8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4915,7 +4915,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, * We can't fit all the extents into the fixed size buffer. * Allocate one that is large enough and use it instead. */ - host_ifconf = malloc(outbufsz); + host_ifconf = g_try_malloc(outbufsz); if (!host_ifconf) { return -TARGET_ENOMEM; } @@ -4963,7 +4963,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, } if (free_buf) { - free(host_ifconf); + g_free(host_ifconf); } return ret; From patchwork Thu Jan 6 10:41:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV39j6zw5z9sPC for ; Thu, 6 Jan 2022 21:53:29 +1100 (AEDT) Received: from localhost ([::1]:49446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QOd-0002pO-PI for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:53:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qd-G6 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:51829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0004kc-1n for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:02 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mv3M8-1mEQ3W0TDc-00r1yZ; Thu, 06 Jan 2022 11:41:54 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 25/27] linux-user: netlink: update IFLA entries Date: Thu, 6 Jan 2022 11:41:35 +0100 Message-Id: <20220106104137.732883-26-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:to9HmmIBhb8v6OzzSBs/Yui6qw5GuUVzV+HNSdIY2inzoOoBezn MbxtOc/KUVX6E1ArNy194/4a3UJg6yxPKU6BphLVexbKnhwUA+QX2ZlUpJRWNRidR+zdKjf aaRM6Zt02tE4SzK+SuB2IVus801Q68d6UzWULLrHYtQ2ErqPVhC49nsp4fFueOXtOEtXBO+ QnVS2bZqrwA6Lb4XAl3Rg== X-UI-Out-Filterresults: notjunk:1;V03:K0:U8kV77ecKfY=:GR4+3g+kZmVr/yfiSR/FFP NKsK/NuCjDaRKhIWp4apbKk1nUGNQ+jdzpu8F9Mx3AIkzIBkPI2wk8Lqyjd2u0Xkuu4/5j/yw 1s10x3ue5dDY6Es/4Ajvu3OcK8x5xbZVG5udK12dK0c3pEkpY1554NW0sQ7DVNuSVQdOg/kIX jrhGipzQs04teVdHz2FP8W93WNoaQnXFp8xXRswlpxSQlPhgzH+roc/SvWGQF3j5ktad/Tzp0 wMLtgM15VxnZ+AWYvwJrEX44Uwy53XwvSmiU5gb/4NOQvRB06oTMI7+i2B1HJV6VO3MKu0voT BaMmSK3pVNtwSLMF+zaGUiFKhZotRZHEm9JmRxkHdju/qxdjiEvrvg2wAJXf3Gdr8HlHzYneu LTXL638V3D9xvXrjFCNcQnkjVSnG0d/hrZnZ35QtB1o8vbJn/5C0DsHH0s7oPLD9k5mzsR299 3wFYi1e9sYqDJweSiX6I/AsFrQSebLoH0rpOVdcMPqufMI7eFUJLiUSccjiDfyaVkYjcobrQz VXnvITszGIHz6Id8UAJHGdVaCAvI5iCbdUDV9qe677KCFs1fJtM1YtQ8AOtsfN1mmNJnVj8fR 91rNsRuL3WM9U13AxZtGjbXv5Gc2Pzg9ZVyuH1i3/eTWht0jH/QtH6fDD/Z6E0S/bpLDye0q8 RH/PPa/P/EZp2yG+LNBm/Epqd+jEj9DKC1M76FH0hDmoSu3wDyFMx3+90Q4TBIHB6wqY= Received-SPF: none client-ip=212.227.126.134; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add IFLA_PHYS_PORT_ID, IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME # QEMU_LOG=unimp ip a Unknown host QEMU_IFLA type: 56 Unknown host QEMU_IFLA type: 57 Unknown host QEMU_IFLA type: 34 Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20211219154514.2165728-1-laurent@vivier.eu> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 69410899590c..14c19a90b2b0 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -138,6 +138,9 @@ enum { QEMU_IFLA_PROP_LIST, QEMU_IFLA_ALT_IFNAME, QEMU_IFLA_PERM_ADDRESS, + QEMU_IFLA_PROTO_DOWN_REASON, + QEMU_IFLA_PARENT_DEV_NAME, + QEMU_IFLA_PARENT_DEV_BUS_NAME, QEMU___IFLA_MAX }; @@ -818,9 +821,12 @@ static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr) case QEMU_IFLA_ADDRESS: case QEMU_IFLA_BROADCAST: case QEMU_IFLA_PERM_ADDRESS: + case QEMU_IFLA_PHYS_PORT_ID: /* string */ case QEMU_IFLA_IFNAME: case QEMU_IFLA_QDISC: + case QEMU_IFLA_PARENT_DEV_NAME: + case QEMU_IFLA_PARENT_DEV_BUS_NAME: break; /* uin8_t */ case QEMU_IFLA_OPERSTATE: From patchwork Thu Jan 6 10:41:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3NN5w9Qz9t6S for ; Thu, 6 Jan 2022 22:02:44 +1100 (AEDT) Received: from localhost ([::1]:45296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QXa-0002mO-In for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 06:02:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qg-H1 for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:48667) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDU-0004kg-IM for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:03 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLAZe-1mnCZk2A0g-00IFBl; Thu, 06 Jan 2022 11:41:54 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 26/27] linux-user: netlink: Add IFLA_VFINFO_LIST Date: Thu, 6 Jan 2022 11:41:36 +0100 Message-Id: <20220106104137.732883-27-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:eiifYzr1qyRugzBiB+78b5FMYMIzG3SEyquWuxy/9ot7TWf2OKv IhbTVWs7bxWOIQDceYyu+TLIMqYgrol+voLRt77ObRwV5IAEx4K167yUR7C1mJa78MNHUu+ zr5Uby//1ZJlLwF4TE75ocQ62kCUN0oxgCVeO1KxjH4tGz2IL3McwZat244WQLTIQBYwHP3 5pb0CUejCfLn2O+NiPrbA== X-UI-Out-Filterresults: notjunk:1;V03:K0:+mExXe28UlI=:YECONTIK4j+wbdNUt2zPwH POGE1f/r8JzHf1rFXIulXIakFxcCiQ7FmwStwwmcDCZkOeSdqia1gEM7qDr8GpVkCw4yDpWB2 ygf3lF/haHuzWKIpacq+2F6SazZ5cTjaFSP683BH6DnP+jpAV5J75tgbRLjuPkoXn15tGKckG 86SVHY3/ZfBLo4dtQZXtotNDel3Aq+WSSazwBZU+QStlgksc5EFOi7QaIYnramZJutRivdSxK RQS+RaL5gfTsHo5BsrwPTy2b17XPr4Bxh5g4Qccd3CTUA+qeyVsGKR/nUYrmqsI9yEcj0PCJI 9yOm8Lu/dTvZiGxYL1sHNY4gow5/53o3ObwZavuZk0K0R5K6vvUnBWLD705teU3BznTkIrNZJ xscfWfZsfbVF4QF8G6kfVsrBzGzT7/HikZEdJmS7+yIPqwGq39AM+OJBniqflC9bbQcQQaWQq HoUlM1C7n/QRJ6kDGXbhbxWag1ZqX7+/zm8gN/emRrk687tthpsDQ+KRdQBQG1YDmgaEUAMV9 X6Kf+YafTljKKY3WWlY8XY1vcZXWPrEet38K13fC6TFqkFcFZT/tv3diRqW0tRDE4fyubi+Zh hHit0DYncqZTVVQwNxuvKFZoVUD3MGNdaXyTnv3vlZHVz38UnPnQXdBNS0sMmmtL4fq0RppEn 72tiAdedXX0HZEIExq9VPSCOGi1xGTrqZyyV6JG6GX5/0/eI6Z+titMz5az8XY+gutbg= Received-SPF: none client-ip=212.227.126.133; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" # QEMU_LOG=unimp ip a Unknown host QEMU_IFLA type: 22 Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20211219154514.2165728-2-laurent@vivier.eu> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 174 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 14c19a90b2b0..36e4a4c2aae8 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -271,6 +271,37 @@ enum { QEMU___RTA_MAX }; +enum { + QEMU_IFLA_VF_STATS_RX_PACKETS, + QEMU_IFLA_VF_STATS_TX_PACKETS, + QEMU_IFLA_VF_STATS_RX_BYTES, + QEMU_IFLA_VF_STATS_TX_BYTES, + QEMU_IFLA_VF_STATS_BROADCAST, + QEMU_IFLA_VF_STATS_MULTICAST, + QEMU_IFLA_VF_STATS_PAD, + QEMU_IFLA_VF_STATS_RX_DROPPED, + QEMU_IFLA_VF_STATS_TX_DROPPED, + QEMU__IFLA_VF_STATS_MAX, +}; + +enum { + QEMU_IFLA_VF_UNSPEC, + QEMU_IFLA_VF_MAC, + QEMU_IFLA_VF_VLAN, + QEMU_IFLA_VF_TX_RATE, + QEMU_IFLA_VF_SPOOFCHK, + QEMU_IFLA_VF_LINK_STATE, + QEMU_IFLA_VF_RATE, + QEMU_IFLA_VF_RSS_QUERY_EN, + QEMU_IFLA_VF_STATS, + QEMU_IFLA_VF_TRUST, + QEMU_IFLA_VF_IB_NODE_GUID, + QEMU_IFLA_VF_IB_PORT_GUID, + QEMU_IFLA_VF_VLAN_LIST, + QEMU_IFLA_VF_BROADCAST, + QEMU__IFLA_VF_MAX, +}; + TargetFdTrans **target_fd_trans; QemuMutex target_fd_trans_lock; unsigned int target_fd_max; @@ -808,6 +839,145 @@ static abi_long host_to_target_data_xdp_nlattr(struct nlattr *nlattr, return 0; } +static abi_long host_to_target_data_vlan_list_nlattr(struct nlattr *nlattr, + void *context) +{ + struct ifla_vf_vlan_info *vlan_info; + + switch (nlattr->nla_type) { + /* struct ifla_vf_vlan_info */ + case IFLA_VF_VLAN_INFO: + vlan_info = NLA_DATA(nlattr); + vlan_info->vf = tswap32(vlan_info->vf); + vlan_info->vlan = tswap32(vlan_info->vlan); + vlan_info->qos = tswap32(vlan_info->qos); + break; + default: + qemu_log_mask(LOG_UNIMP, "Unknown host VLAN LIST type: %d\n", + nlattr->nla_type); + break; + } + return 0; +} + +static abi_long host_to_target_data_vf_stats_nlattr(struct nlattr *nlattr, + void *context) +{ + uint64_t *u64; + + switch (nlattr->nla_type) { + /* uint64_t */ + case QEMU_IFLA_VF_STATS_RX_PACKETS: + case QEMU_IFLA_VF_STATS_TX_PACKETS: + case QEMU_IFLA_VF_STATS_RX_BYTES: + case QEMU_IFLA_VF_STATS_TX_BYTES: + case QEMU_IFLA_VF_STATS_BROADCAST: + case QEMU_IFLA_VF_STATS_MULTICAST: + case QEMU_IFLA_VF_STATS_PAD: + case QEMU_IFLA_VF_STATS_RX_DROPPED: + case QEMU_IFLA_VF_STATS_TX_DROPPED: + u64 = NLA_DATA(nlattr); + *u64 = tswap64(*u64); + break; + default: + qemu_log_mask(LOG_UNIMP, "Unknown host VF STATS type: %d\n", + nlattr->nla_type); + break; + } + return 0; +} + +static abi_long host_to_target_data_vfinfo_nlattr(struct nlattr *nlattr, + void *context) +{ + struct ifla_vf_mac *mac; + struct ifla_vf_vlan *vlan; + struct ifla_vf_vlan_info *vlan_info; + struct ifla_vf_spoofchk *spoofchk; + struct ifla_vf_rate *rate; + struct ifla_vf_link_state *link_state; + struct ifla_vf_rss_query_en *rss_query_en; + struct ifla_vf_trust *trust; + struct ifla_vf_guid *guid; + + switch (nlattr->nla_type) { + /* struct ifla_vf_mac */ + case QEMU_IFLA_VF_MAC: + mac = NLA_DATA(nlattr); + mac->vf = tswap32(mac->vf); + break; + /* struct ifla_vf_broadcast */ + case QEMU_IFLA_VF_BROADCAST: + break; + /* struct struct ifla_vf_vlan */ + case QEMU_IFLA_VF_VLAN: + vlan = NLA_DATA(nlattr); + vlan->vf = tswap32(vlan->vf); + vlan->vlan = tswap32(vlan->vlan); + vlan->qos = tswap32(vlan->qos); + break; + /* struct ifla_vf_vlan_info */ + case QEMU_IFLA_VF_TX_RATE: + vlan_info = NLA_DATA(nlattr); + vlan_info->vf = tswap32(vlan_info->vf); + vlan_info->vlan = tswap32(vlan_info->vlan); + vlan_info->qos = tswap32(vlan_info->qos); + break; + /* struct ifla_vf_spoofchk */ + case QEMU_IFLA_VF_SPOOFCHK: + spoofchk = NLA_DATA(nlattr); + spoofchk->vf = tswap32(spoofchk->vf); + spoofchk->setting = tswap32(spoofchk->setting); + break; + /* struct ifla_vf_rate */ + case QEMU_IFLA_VF_RATE: + rate = NLA_DATA(nlattr); + rate->vf = tswap32(rate->vf); + rate->min_tx_rate = tswap32(rate->min_tx_rate); + rate->max_tx_rate = tswap32(rate->max_tx_rate); + break; + /* struct ifla_vf_link_state */ + case QEMU_IFLA_VF_LINK_STATE: + link_state = NLA_DATA(nlattr); + link_state->vf = tswap32(link_state->vf); + link_state->link_state = tswap32(link_state->link_state); + break; + /* struct ifla_vf_rss_query_en */ + case QEMU_IFLA_VF_RSS_QUERY_EN: + rss_query_en = NLA_DATA(nlattr); + rss_query_en->vf = tswap32(rss_query_en->vf); + rss_query_en->setting = tswap32(rss_query_en->setting); + break; + /* struct ifla_vf_trust */ + case QEMU_IFLA_VF_TRUST: + trust = NLA_DATA(nlattr); + trust->vf = tswap32(trust->vf); + trust->setting = tswap32(trust->setting); + break; + /* struct ifla_vf_guid */ + case QEMU_IFLA_VF_IB_NODE_GUID: + case QEMU_IFLA_VF_IB_PORT_GUID: + guid = NLA_DATA(nlattr); + guid->vf = tswap32(guid->vf); + guid->guid = tswap32(guid->guid); + break; + /* nested */ + case QEMU_IFLA_VF_VLAN_LIST: + return host_to_target_for_each_nlattr(RTA_DATA(nlattr), nlattr->nla_len, + NULL, + host_to_target_data_vlan_list_nlattr); + case QEMU_IFLA_VF_STATS: + return host_to_target_for_each_nlattr(RTA_DATA(nlattr), nlattr->nla_len, + NULL, + host_to_target_data_vf_stats_nlattr); + default: + qemu_log_mask(LOG_UNIMP, "Unknown host VFINFO type: %d\n", + nlattr->nla_type); + break; + } + return 0; +} + static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr) { uint32_t *u32; @@ -945,6 +1115,10 @@ static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr) return host_to_target_for_each_nlattr(RTA_DATA(rtattr), rtattr->rta_len, NULL, host_to_target_data_xdp_nlattr); + case QEMU_IFLA_VFINFO_LIST: + return host_to_target_for_each_nlattr(RTA_DATA(rtattr), rtattr->rta_len, + NULL, + host_to_target_data_vfinfo_nlattr); default: qemu_log_mask(LOG_UNIMP, "Unknown host QEMU_IFLA type: %d\n", rtattr->rta_type); From patchwork Thu Jan 6 10:41:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1576037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV3Dy72gHz9t6S for ; Thu, 6 Jan 2022 21:56:18 +1100 (AEDT) Received: from localhost ([::1]:57384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5QRM-00084k-PB for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 05:56:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDb-0007qf-Gu for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:05 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:57085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5QDV-0004kv-3B for qemu-devel@nongnu.org; Thu, 06 Jan 2022 05:42:03 -0500 Received: from quad ([82.142.12.178]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N3omW-1mNFkA40GW-00zrgF; Thu, 06 Jan 2022 11:41:55 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 27/27] linux-user: netlink: update IFLA_BRPORT entries Date: Thu, 6 Jan 2022 11:41:37 +0100 Message-Id: <20220106104137.732883-28-laurent@vivier.eu> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106104137.732883-1-laurent@vivier.eu> References: <20220106104137.732883-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qMlJa67lAwAatw8J0ptJJtYadK0yHDP3nzuKOVdVq6sd2nzmwkI mrTIkSfHQaGPQr50DWje2ByRa31gAA/0YlWXkKgFKgFLz0jaGg0k0SsbSPKtwcH9rxc6oK6 B7yLLY5pNcD6etMe9rPIw/gWDoun9Sl9p9OyCrT3JkyjqS0O0KY2OCOSimSthb34CUw6+1b CgKRKOpOLAu9gEJCAQGEA== X-UI-Out-Filterresults: notjunk:1;V03:K0:LvGLgAU4T8c=:uGyChumY6LkBvXo9FvxTEF jI9/KfLc84O0RS90Umv1f+JYQpouViupVQKGm706VT9oS/hluNIqmt9zR9AAW9ovL3tp+aW4n h1MApnWfNlJ/dX41G7KQQg70OBZa/S/Azt9RDukGrX61DNsodYHIZEfxXVOUcVeXXieCayJ1U ftVTh+hsJuZjy5acqsZwNjnxNzcz5loZpxUi+ZiW3KQl7SGLWXmZ6WMGONBR2kzFJYculG4jU PNHAmBJ9z3hZ8VPbYUIjhwpPk/Tecv/EXQCBgjg224/OoK6nKSLNdv0rjaq6S+ckrk1utEz/F 2Gf9hVaoM681HTr1g5/084/CeCMpgSCMQZeqJRvG05sd9aKQfkS2z610RAQ2uGMjHeXMWZ91b vvO72+pXB/dpoL6JGM3YRudbHTejsOKXXTnrmtOOYieCB8NwJVeh7jziGA7IEIGvsGeYUvIIP wLdwj6RH8Gaa/fZbgBYDlp3TOAJ+NHwbAl2THzW/biRlVIxS1esL1FhWG7qTjLhMT1+N4yrbK 9VdbAErISownm+QK9tF0RvPtl92H372NHPGMU42OpsvV0RGeeIQRgyeRDe72ArSTaohgFnBE6 Mql80DuYZMI48Bxn4ewYv9DTyYLA/SU2SbY+RNGJBaLLaZgF06TbtgWc//qvnN+CfXBvkKAY2 SH8yvgdnFXydqlptq4KUep63ufTgYKPQB+d8qviK3g73F7e/sUDOH4m9QWoDMt541Em0= Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" add IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT and IFLA_BRPORT_MCAST_EHT_HOSTS_CNT # QEMU_LOG=unimp ip a Unknown QEMU_IFLA_BRPORT type 37 Unknown QEMU_IFLA_BRPORT type 38 Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20211219154514.2165728-3-laurent@vivier.eu> Signed-off-by: Laurent Vivier --- linux-user/fd-trans.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 36e4a4c2aae8..a17d05c07923 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -182,6 +182,8 @@ enum { QEMU_IFLA_BRPORT_BACKUP_PORT, QEMU_IFLA_BRPORT_MRP_RING_OPEN, QEMU_IFLA_BRPORT_MRP_IN_OPEN, + QEMU_IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT, + QEMU_IFLA_BRPORT_MCAST_EHT_HOSTS_CNT, QEMU___IFLA_BRPORT_MAX }; @@ -607,6 +609,8 @@ static abi_long host_to_target_slave_data_bridge_nlattr(struct nlattr *nlattr, /* uin32_t */ case QEMU_IFLA_BRPORT_COST: case QEMU_IFLA_BRPORT_BACKUP_PORT: + case QEMU_IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT: + case QEMU_IFLA_BRPORT_MCAST_EHT_HOSTS_CNT: u32 = NLA_DATA(nlattr); *u32 = tswap32(*u32); break;