From patchwork Tue Jul 30 01:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1966270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=WoSRAcf9; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXzP90Gd9z1yZD for ; Tue, 30 Jul 2024 12:16:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcOg-0008J4-Ef; Mon, 29 Jul 2024 22:15:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcOf-0008E1-4C for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:15:29 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcOd-0005Op-DY for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:15:28 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-7a103ac7be3so2266765a12.3 for ; Mon, 29 Jul 2024 19:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722305726; x=1722910526; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pH+41rL90lFjbVWqrfAC1Tzfsae8MNVaqTWvWuyk3aM=; b=WoSRAcf9cnJN3yCilx5XNjA4wos0JTF8TrlhYe3RCMjB166Enspeiy4BL6XtzN+Ck/ owaUNjIDiboxYuezc/41syLkHwvA2qG8lNP7oOooY52+szhI/zzK2KsPgtV4V9OiNQPg WIIK3ms75MLKrZ95VNBcYsZlbDI4/fjaOcZwwJETsjVt4gnNkZVCR63mx6BRfwRwiSIR kgVcrMrX2JPnIS/j6bZkKsvVD5yD2vZNN1TvQKcGoVheaHKqXleU+Gyb7E+06/mndYHW 49TdQgeWFYTEgk3LAoDqTqWxHSS4I0bzvxqA3rvHnEDwzqd9a73QOtEnNf3AQEAnXY1W 8Bgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722305726; x=1722910526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pH+41rL90lFjbVWqrfAC1Tzfsae8MNVaqTWvWuyk3aM=; b=ogFpPs1xcWoackUuzb4nXVVVnDNKF3x1QKQP7qGEphdqWd54mqr/nNkjXJyliMR0aJ HjXS4A64voa0gQrp46ZuqwH6Xr+iyrPbrS5YqOfx6smTTJg4Gs0zz54ReONbxoJLI1JS J7sPE15MgcfZUF261s6+SYYQooLFJb5zjS+2hZfZc1hXG0sWVF64pjdOo8zDPFZBkDTQ xwYakm/TFwh4tsar/6MA1uA4IllX75aLAyu4+aC5GHW/FRu43CITox9/vC7Mzv9sU9m+ wL2H26jQe4ik7OjtQ/Yx/Thj4ws9NVleC/8bmha5CBRIeWtnoH1/OBLNKbjeG1PMnWBg QMLg== X-Gm-Message-State: AOJu0YxjAWZQBBTjhsivyj4lc7WtsLXyWXGdKRAtHsdPZ/GDA5eVa6zc zKdtqYWQO3xqISfDFd92NSZdO3SF86+6hW7/jwWW0flZORXuO8hj+dIzYmjbZDmHZ4tTnTsLNjh D+JE= X-Google-Smtp-Source: AGHT+IEriPcKSuasBU2TvkAdes5dggN2edS16cT0kZQzwQVIjC2YzfjHLjc3UXZmfpY5Kxx8xdT65Q== X-Received: by 2002:a05:6e02:20e1:b0:39a:ea89:22ec with SMTP id e9e14a558f8ab-39aec2d76a3mr110796085ab.9.1722301930485; Mon, 29 Jul 2024 18:12:10 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Thomas Huth Subject: [PULL 1/5] target/rx: Use target_ulong for address in LI Date: Tue, 30 Jul 2024 11:11:57 +1000 Message-ID: <20240730011202.480829-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Using int32_t meant that the address was sign-extended to uint64_t when passing to translator_ld*, triggering an assert. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2453 Signed-off-by: Richard Henderson Tested-by: Thomas Huth --- target/rx/translate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/rx/translate.c b/target/rx/translate.c index 9b81cf20b3..9aade2b6e5 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -85,7 +85,8 @@ static uint32_t decode_load_bytes(DisasContext *ctx, uint32_t insn, static uint32_t li(DisasContext *ctx, int sz) { - int32_t tmp, addr; + target_ulong addr; + uint32_t tmp; CPURXState *env = ctx->env; addr = ctx->base.pc_next; From patchwork Tue Jul 30 01:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1966268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=SRfgQLDS; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXzDY1G7Zz1ybX for ; Tue, 30 Jul 2024 12:09:01 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcIA-00029a-9t; Mon, 29 Jul 2024 22:08:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcI8-00028Q-Vl for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:08:45 -0400 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcI4-0003EO-MZ for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:08:44 -0400 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-39865a15900so14992145ab.1 for ; Mon, 29 Jul 2024 19:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722305319; x=1722910119; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pvF0s1jQIBySSeBKtBCNdIkStj9P9gT/o0jVZTBUvsc=; b=SRfgQLDSCgy+V4bj1tnzi59BhqeBMwpPT7/WuQSo3ISmvtT4RjStcBnlAVSQtur7Za rGJet5HsgZHjDlmmXouXudrwU1l0EiHgElOQUVcnlcoUfUMJFQTDn6h9/0HwqjBBxMxP 07bD25YrZ91gfojAxtjFvbxuQiWKOruraf0IXp2UfO30xDEvzxrFVJHzsjY1nUjRytu2 hxF8tUQiJ+J1/1/UCZp/SKnXku/bcrlOJT1VeUVSgbmiyLDS/c11jv2qKkIFNWSitk3n OlQZ2EZKSumcOGKY4MG2dPYaAWp3cX8XVqhKUaBqxNJe4QxWiAkY4/v5gczM/4WtreFH cusQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722305319; x=1722910119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pvF0s1jQIBySSeBKtBCNdIkStj9P9gT/o0jVZTBUvsc=; b=j/v33bAtyrEPLg3K98waG9+kIv+qz0uwR4OYvdq6qXB/kCzGgFsPSCZdqE4zFIH5wk KowmrgGWHOx3jrvxzL1stoXJ5ITNtjoo4XYWQD5pQ7tMGYMpmFTMzQCmYRJTLe/X1Cuy KMFGrNFk/NcEJs7F6WQCRlK4uUphv5yAmPM+5aLIpy3Sjku0waeOM857E3+7JbyPPIYU SIeimbHtjWmyIdB8W1QZx/L6HCobZ4AcTAgs/f0YgOVMWRW3yuwE/Il/1/8UXrrM/1Nh C9VTbP49z2ruwSc6CO6tWLsIZKT2Is+R8kPIj3fPNle4DRKby8VW9Y06+bRQUpghUhtW JGCQ== X-Gm-Message-State: AOJu0Yw3ngQ4v+VgXDJvX7suVNnBfBpfw8HZELUsslB4S59Hf/YllHqH MxhTK9KPVwRealKNuqClINJ6G2xmFaiEU7HJe0Rs3OQu035b3gFDtu7zgqjbSnkgVVmcxaUvHtZ O4aM= X-Google-Smtp-Source: AGHT+IFTIf7LOeBm+FjgWoD0szE5P73hRxwPZGfNUF9Ox3Ri/JAmTT5m+cx07MMpvDb2M0XFQ+cyAA== X-Received: by 2002:a05:6a00:2443:b0:70d:2583:7223 with SMTP id d2e1a72fcca58-70ecea2ef3emr11413551b3a.17.1722301934907; Mon, 29 Jul 2024 18:12:14 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Vivian Wang Subject: [PULL 2/5] util/getauxval: Ensure setting errno if not found Date: Tue, 30 Jul 2024 11:11:59 +1000 Message-ID: <20240730011202.480829-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::134; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x134.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Vivian Wang Sometimes zero is a valid value for getauxval (e.g. AT_EXECFD). Make sure that we can distinguish between a valid zero value and a not found entry by setting errno. Assumes that getauxval from sys/auxv.h sets errno correctly. Signed-off-by: Vivian Wang Message-ID: <20240723100545.405476-2-uwu@dram.page> Signed-off-by: Richard Henderson --- util/getauxval.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/getauxval.c b/util/getauxval.c index b124107d61..ad4f6686a8 100644 --- a/util/getauxval.c +++ b/util/getauxval.c @@ -95,6 +95,7 @@ unsigned long qemu_getauxval(unsigned long type) } } + errno = ENOENT; return 0; } @@ -104,7 +105,10 @@ unsigned long qemu_getauxval(unsigned long type) unsigned long qemu_getauxval(unsigned long type) { unsigned long aux = 0; - elf_aux_info(type, &aux, sizeof(aux)); + int ret = elf_aux_info(type, &aux, sizeof(aux)); + if (ret != 0) { + errno = ret; + } return aux; } @@ -112,6 +116,7 @@ unsigned long qemu_getauxval(unsigned long type) unsigned long qemu_getauxval(unsigned long type) { + errno = ENOSYS; return 0; } From patchwork Tue Jul 30 01:12:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1966271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Hp7qOB5k; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXzS21sMzz1yZD for ; Tue, 30 Jul 2024 12:18:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcRb-00078H-EF; Mon, 29 Jul 2024 22:18:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcRZ-00077d-OM for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:18:29 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcRY-0005zx-8X for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:18:29 -0400 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-44fded90c41so22050061cf.3 for ; Mon, 29 Jul 2024 19:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722305907; x=1722910707; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qdOOXlcI2pXCHd0E8nwCuiMDshNmFFas8R7dthZK29c=; b=Hp7qOB5ktSXtjnD9sAfQL7RU+ERmZ/Ugbqnrqg1WrTHnQSUiP97H/FrAszL37LzP3m pX9cDHoJ3CY+ePiU5AuX7sYYKdS9Rho7pKaMKMF8vh50iMkFiEBLYpjxKgyA168x0ocC sGQ7xy2g4Ry+SRSpaCiQGSTjQq/o2iygbfsrVl5T4TD3S86jZUGf7kldrtTCpkZjA/cB AERP6miH09vC3ulOgGA+n5uyqs+MW4Uh084CMk2RhsgeSPsVBMFW65IW3wD5+33oZ8u5 ExebmW97LhR8ZfiH04CwamDoKo6b7gO/EYe1Z+uf1cO5gez/qV1LlpzImVWxs95EZEOQ CVag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722305907; x=1722910707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qdOOXlcI2pXCHd0E8nwCuiMDshNmFFas8R7dthZK29c=; b=kWguF16IST25mYBj1rGgjwDmAbPsD/y9x99seqdObWwXRikxQU7iUOYP74l9KswTeI WzQBLJ4S6lNiH/11cKGw7iAOMDQ31n9n99c/Mt1qcZYkLudcIkmzxvml7GlLgQgCIPVw EfXxUy5hGuatgTT7J13haUCmAA3X6v+f9gK2OVu0cOTCMbs9A1vjINbE5F7bMj2XJsjm rX+Huf1yZi/6b0Wd8QA//sa8/qqraOjbQeyGqsk905R1U13vL+T35YODz2IbPwO4waQI 1yDl5kDQMuGNU3IofmC/3g2nLHjrxPnqPHtn8Jhai/6O6Xgpq+TUibkoDMuBb+IW8FQM 13XQ== X-Gm-Message-State: AOJu0Yzm260h2QfW7fK/UdyQewHzw2U+rUHRoYdDlM20BqbuNoaGZJ0d sekhW15hXgzZULGSClNMU8A4FAG8Q2AdFk3ovUqPfeYKzNECwQkxhnTzGBLGBuATB1hS2j1cKzf OwvA= X-Google-Smtp-Source: AGHT+IH2iXsYm2M5romUtYcoXgvTBkWmSW/JTgHtEI8rGHEeN391KwT6ykEpR8zLdR228Gs51+03UA== X-Received: by 2002:a05:6e02:178d:b0:397:3045:9dc2 with SMTP id e9e14a558f8ab-39aec4236a0mr123455735ab.27.1722301937280; Mon, 29 Jul 2024 18:12:17 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Vivian Wang Subject: [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD Date: Tue, 30 Jul 2024 11:12:00 +1000 Message-ID: <20240730011202.480829-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x833.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Vivian Wang It's possible for AT_EXECFD to end up with a valid value of 0. Check errno when using qemu_getauxval instead of return value to handle this case. Not handling this case leads to a confusing condition where the executable ends up as fd 0, i.e. stdin. Signed-off-by: Vivian Wang Reviewed-by: Richard Henderson Fixes: 0b959cf5e4cc ("linux-user: Use qemu_getauxval for AT_EXECFD") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2448 Message-ID: <20240723100545.405476-3-uwu@dram.page> Signed-off-by: Richard Henderson --- linux-user/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 7d3cf45fa9..8143a0d4b0 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -755,8 +755,9 @@ int main(int argc, char **argv, char **envp) /* * Manage binfmt-misc open-binary flag */ + errno = 0; execfd = qemu_getauxval(AT_EXECFD); - if (execfd == 0) { + if (errno != 0) { execfd = open(exec_path, O_RDONLY); if (execfd < 0) { printf("Error while loading %s: %s\n", exec_path, strerror(errno)); From patchwork Tue Jul 30 01:12:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1966273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=JyG5lpzK; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXzc94F6lz1ybV for ; Tue, 30 Jul 2024 12:26:01 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcYW-0007S1-4U; Mon, 29 Jul 2024 22:25:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcYT-0007OP-3h for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:25:38 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcYR-0007U6-BY for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:25:36 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-5d5e1c86b83so1443039eaf.3 for ; Mon, 29 Jul 2024 19:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722306334; x=1722911134; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a2wtDHUY+HHrfRWzkSo3Bk34wWAfi1Yqji+v1/RaSkc=; b=JyG5lpzK8Fx3c8ZzS38saCfzuw4XepZ5xv32R8KrA8wcykE90EkTtv3Tt0XiAgEJHq s2vo+1IB8U1v6j1X1DpjkQgmy6EJwfI321ekTpPqP5/n5PaM5aNlJvvAcwnhQoJsWWD5 TRGLIqYY6WmJ8VQHp0sQ5PHmTYABAophEq1RvzNLnGxSIDSTpWCiUxmMpSneAi+22WkV vYvzGLD6+ac42wddIAbsLaPs4cg/lmQV0bj53ycBdU8EJa7SZd2f9hNaZNFPOUZd5Ra6 E4U6U8I1bV0YtePox/2KCNhvbWNLG+WTBXRNU3Vnq9xBP8LWWWdrkKjtfsJxL45TPpLU VUjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722306334; x=1722911134; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a2wtDHUY+HHrfRWzkSo3Bk34wWAfi1Yqji+v1/RaSkc=; b=nQyeemPqQdb+aGO7aVFaz6u+2iJ6krvNwV7VcHcG4zx/jtpIia7tiPKVo1ka30pXgD m1f2Q9AQKAstINYgT5rZuowBCeAyUJ110UE2eB76xp9Isww7Ylllo+3cxq2tn58tVFTR 5WYxJ26oeOB9LMvFmhv7sSq6IoaKrpSfrDffeF2FMozsVE4+lvTmWxbYpxbtCI6JoC8k o2Li6uTwn29XTArnn59GnPjFJes/yrrmt9EOhKRTnjHqQkl/zO3+nMYcsSsolh96pxm7 Is6H4ToNa0BlII/PsNER3gnk56CmQ6KPDvVgLU5iDtzAyAjQ0UPM4cHAOx4LXC+QxpSN 5b5g== X-Gm-Message-State: AOJu0Yw5X5DZcGvrV/0Hr/t2T+8jAPOKonFQJTTZDMAI9q7LXnE7IEa3 jfDWNYc97w0rWEY+ceqa71pu3fErKU1fswfjIz7AoETcteKPnhXFK0bJfvjJ5iIMeXd3hX6JhcB drdg= X-Google-Smtp-Source: AGHT+IHomwBW++cs9aOrDRrwgEbGxLkTpk6KKS+Upl+WfQ4f2xgaz2sRFWS8NxCihdSys9OEjz8d2A== X-Received: by 2002:a05:6870:b28e:b0:261:f4c:e08c with SMTP id 586e51a60fabf-267d4dd3eb0mr11718340fac.29.1722301939544; Mon, 29 Jul 2024 18:12:19 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Brad Smith Subject: [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD Date: Tue, 30 Jul 2024 11:12:01 +1000 Message-ID: <20240730011202.480829-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Brad Smith Signed-off-by: Brad Smith Message-ID: Signed-off-by: Richard Henderson --- util/cpuinfo-aarch64.c | 9 ++++++--- util/cpuinfo-ppc.c | 5 +++-- util/getauxval.c | 2 +- meson.build | 8 ++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/util/cpuinfo-aarch64.c b/util/cpuinfo-aarch64.c index 8ca775a14b..57468890c3 100644 --- a/util/cpuinfo-aarch64.c +++ b/util/cpuinfo-aarch64.c @@ -17,10 +17,13 @@ # define HWCAP2_BTI 0 /* added in glibc 2.32 */ # endif #endif +#ifdef CONFIG_ELF_AUX_INFO +#include +#endif #ifdef CONFIG_DARWIN # include #endif -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO) # include # include # include @@ -61,7 +64,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info = CPUINFO_ALWAYS; -#ifdef CONFIG_LINUX +#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) unsigned long hwcap = qemu_getauxval(AT_HWCAP); info |= (hwcap & HWCAP_ATOMICS ? CPUINFO_LSE : 0); info |= (hwcap & HWCAP_USCAT ? CPUINFO_LSE2 : 0); @@ -78,7 +81,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info |= sysctl_for_bool("hw.optional.arm.FEAT_PMULL") * CPUINFO_PMULL; info |= sysctl_for_bool("hw.optional.arm.FEAT_BTI") * CPUINFO_BTI; #endif -#ifdef __OpenBSD__ +#if defined(__OpenBSD__) && !defined(CONFIG_ELF_AUX_INFO) int mib[2]; uint64_t isar0; uint64_t pfr1; diff --git a/util/cpuinfo-ppc.c b/util/cpuinfo-ppc.c index 1304f9aa80..4d3d3aae0b 100644 --- a/util/cpuinfo-ppc.c +++ b/util/cpuinfo-ppc.c @@ -14,7 +14,8 @@ # include "elf.h" # endif #endif -#ifdef __FreeBSD__ +#if defined(CONFIG_ELF_AUX_INFO) +# include # include # ifndef PPC_FEATURE2_ARCH_3_1 # define PPC_FEATURE2_ARCH_3_1 0 @@ -35,7 +36,7 @@ unsigned __attribute__((constructor)) cpuinfo_init(void) info = CPUINFO_ALWAYS; -#if defined(CONFIG_LINUX) || defined(__FreeBSD__) +#if defined(CONFIG_LINUX) || defined(CONFIG_ELF_AUX_INFO) unsigned long hwcap = qemu_getauxval(AT_HWCAP); unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2); diff --git a/util/getauxval.c b/util/getauxval.c index ad4f6686a8..0735cd8271 100644 --- a/util/getauxval.c +++ b/util/getauxval.c @@ -99,7 +99,7 @@ unsigned long qemu_getauxval(unsigned long type) return 0; } -#elif defined(__FreeBSD__) +#elif defined(CONFIG_ELF_AUX_INFO) #include unsigned long qemu_getauxval(unsigned long type) diff --git a/meson.build b/meson.build index 5613b62a4f..97f63aa86c 100644 --- a/meson.build +++ b/meson.build @@ -2835,6 +2835,14 @@ config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + ''' return getauxval(AT_HWCAP) == 0; }''')) +config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(gnu_source_prefix + ''' + #include + int main(void) { + unsigned long hwcap = 0; + elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); + return hwcap; + }''')) + config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' #include From patchwork Tue Jul 30 01:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1966274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=fJqWXfgi; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WXzcm0bgJz1ybV for ; Tue, 30 Jul 2024 12:26:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sYcZ5-0000aR-Uv; Mon, 29 Jul 2024 22:26:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sYcZ4-0000Qk-H8 for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:26:14 -0400 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcZ2-0007Y1-It for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:26:13 -0400 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e05f4c63de6so2942855276.0 for ; Mon, 29 Jul 2024 19:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722306371; x=1722911171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+xjo9tP3yEe4cBC1QG8qcYKpejenHpZvG1UA2aTLnj0=; b=fJqWXfgis+sfm/FmFl9g+1ND1mMrLW3SWCcqs7D6jSYgzf/FFEub0sPp+ReZSbjbyM UOLyyHfJFAQM7KpAOMxeT4yrPUUfUZJ/ZQkxZctBM+KuVKByIix0Xye0bGYW8mTzmISy gNsM6aYB1u3suxnoQEPrimKL+NtEnP5jr97tptu3Zcif1h7U9HlLhfauGZygWUoCN4Nx aTZSVgF4Z55pjAiBVhBhFnce+Q/ISgnhk4HPSY98kPqrLwr1kludRoSVqEH92YaRwtcj Tsj4fzSo+kn9wVxP8Bs5r6qdLIv/DRG9PRzU/bB4zf8vM6mBoqPtx/o2ax+KpUjmDtDB wNoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722306371; x=1722911171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+xjo9tP3yEe4cBC1QG8qcYKpejenHpZvG1UA2aTLnj0=; b=INMKRPXLtIHWL85kirYRORXvclShvj04ZVJcx/AEa/vw3nzYMi/AXa+6OR6Yum6a+/ K2CFS8P9sorKwbOROhL7A+x0XDl8Ia6sjkOuDQZKT/VQGzS4Za14hkcm3bS3/GgGS1mt QA/JKbQQcVqJeZjOhgIBroEHONevp8UdIUOmEqqcZvZqBsc9bVt4ulz1YAR6ccrZ7kAc su/KWH0zY6RWnWx2oVWkvuY9uqbQqwljq+zWixITMa1nodNDXP6nOTWDr92dpybpqm90 75ri0+Hm5WbEpg8j+z9KbQGTH+Lu4EWLRgcItMXMc50dpIG4sMTsoYRbGr8SNGRHQ8kL n4YQ== X-Gm-Message-State: AOJu0YypV6wVVaswB/8IJqnxfiqYYc4v+TtE5GvTBTXFNom/grMwbwYD U6xXWxZdZHLIBP37t3yrcBrsDo7pYKYb13fXSlvA3TXJXHcsQeGWZmfu+zeV6JOccqLPfoGto/f AN8E= X-Google-Smtp-Source: AGHT+IEe4+S0MgzmNfCjCASGufeZErsxP3yqh31Ka/I3Flfx1FJlKbdUhJQNGAojb4TxN3J7NxCoSQ== X-Received: by 2002:a05:6e02:b42:b0:382:3c83:6acb with SMTP id e9e14a558f8ab-39aec2dcf52mr108891715ab.8.1722301942009; Mon, 29 Jul 2024 18:12:22 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Fabio D'Urso , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 5/5] linux-user: open_self_stat: Implement num_threads Date: Tue, 30 Jul 2024 11:12:02 +1000 Message-ID: <20240730011202.480829-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b2d; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Fabio D'Urso The num_threads field reports the total number of threads in the process. In QEMU, this is equal to the number of CPU instances. Signed-off-by: Fabio D'Urso Reviewed-by: Alex Bennée Message-ID: <20240619194109.248066-1-fdurso@google.com> Signed-off-by: Richard Henderson --- linux-user/syscall.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8c278b91d..9d5415674d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8168,6 +8168,16 @@ static int open_self_stat(CPUArchState *cpu_env, int fd) } else if (i == 3) { /* ppid */ g_string_printf(buf, FMT_pid " ", getppid()); + } else if (i == 19) { + /* num_threads */ + int cpus = 0; + WITH_RCU_READ_LOCK_GUARD() { + CPUState *cpu_iter; + CPU_FOREACH(cpu_iter) { + cpus++; + } + } + g_string_printf(buf, "%d ", cpus); } else if (i == 21) { /* starttime */ g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime);