From patchwork Tue Apr 9 00:34:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 787163 Delivered-To: patch@linaro.org Received: by 2002:adf:fb4d:0:b0:346:15ad:a2a with SMTP id c13csp126883wrs; Mon, 8 Apr 2024 17:36:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXUnj7/uXdX6fRf7AC7YXM5/kQGKd8IF7I+9uG8Uxv3b3To5LXrOIm83B4KHTBmhlOK1zOrOvkTev/6/Wo6cGvp X-Google-Smtp-Source: AGHT+IHf33oleuH0mERN/NZUz9EcNtUJqQMG7UK/o+wnafnCg7/kQjkY2iJxSaQadrzyl86jJ1jP X-Received: by 2002:a05:622a:130d:b0:434:9135:4392 with SMTP id v13-20020a05622a130d00b0043491354392mr6205108qtk.38.1712622974288; Mon, 08 Apr 2024 17:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712622974; cv=none; d=google.com; s=arc-20160816; b=qyA3nnxnBmlbnCEAoGdX0CYmM7mxkjQU2qF5pvkuPO0cWf5LMAXMrrspSB1N52KzhT woku06EvFCaPbgrpZdQdR1d3/qzLol31cV7FaZIAQBw/aMkR8JQJggEU1IFjyfOltKRr hDyafGYeYp4ey18EtwmVrSayDnrbCuzzvIrlV/0TijW1oGpVBAUhiCs2O4pYj7zMCk2U cbXU3xAbme+leFAh97RPid0AWa6efV7bfdJ2FMl+/sAMgN3Y5LbUwffrbI70y6y+lMcy Vn62nTdKLjvVLuqJCZ4B/3z6o6FwymMS8uGX7pK84OkukF0JnFhJnIX3XiNKYMhVj3eF O2sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=cKLjKBRBJQg84oS4OLgjoE2usIG97HzuqeLjYhoFQH8=; fh=lSjE6Wiqd/Yk0jZIIyF0NZCJHV7Sdo9nd65rbDlF5Q0=; b=OuZyH5sZCO3vncjznqnAcvEKuv3w9NaRyW3fZhBYUFzvnbIC6MOB7jmFYLV8j7DDjn PHEdbexEqxPA763aLKJGIRgSPKPxLLiN0y0zictFtiH3t3ofxi/x2Ns2fPyCTIEK4V05 S8E9oJyVphYClFNwhD3dgAWV0+4Px38ZN4oZPXeHmRquuRIXnCt6hVtk2E5U6xMzXRXK X9Arvz6Mj02ZfPbyLMOqAuhtGKSU50sK6EAApy1EyanneWPhZR1J73qHoBY1jREBUXzY RUIFO8gzFomZgoaTKWry/mMhMu5AJyaGiy0/+PCsmI++VirGhf9vY6kEtGE+LAMLcWul gHXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H+9ieD/k"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f1-20020ac85d01000000b004346ffa7d22si6745030qtx.70.2024.04.08.17.36.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Apr 2024 17:36:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="H+9ieD/k"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtzRR-0001gI-4G; Mon, 08 Apr 2024 20:34:25 -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 1rtzRP-0001fY-My for qemu-devel@nongnu.org; Mon, 08 Apr 2024 20:34:23 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rtzRJ-0004bx-TL for qemu-devel@nongnu.org; Mon, 08 Apr 2024 20:34:23 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1e3c9300c65so26844045ad.0 for ; Mon, 08 Apr 2024 17:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712622855; x=1713227655; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cKLjKBRBJQg84oS4OLgjoE2usIG97HzuqeLjYhoFQH8=; b=H+9ieD/kYmb6ZJjDsM2D0jwCS16wqRjnXJxb/WQjdC/n2qvOFpAzZJbvuNyPEA2frS aKgKfAqZ3+rmTp9bnOu07VMqbgEEHnzV+C48UF8BB7cPWWVrFnKSAAUlsr0VEqoO8kBV Jc/GjqypIWNW2fa8Iwbjnwx2ANaXr7P3Op8EmMRiA55gWovihCc9H0+Nti8tKoCNbNtZ sXLricp/VGlurqO7oH6i80JQFzqmTM3cmehobflJEan5f6EZ7i4ufKYbuHJTKif8N1e+ cRjKpieIlfCaouGdtKMOjPqt6aJHP9DsdZmzz969KyPFfBl4DP7SygKK6AQggwSt6EFv WyKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712622855; x=1713227655; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cKLjKBRBJQg84oS4OLgjoE2usIG97HzuqeLjYhoFQH8=; b=EbKEgKY4FG5Nw6ftaigQQCQxY0ebjX8LVnb/7G1ZM6Bax3ooVADNBbw+4bsNGb1Oi4 P8BPR5W9z9lOMCeuciGSMLRxmjlqmT3g6pIxhXk0CI99c+Q+NQNOD4O/hLalUKfY8kk5 yAYsxRapOTWZE2tkvnjN8bcZqDHLEulQFjnRN6dTXCtLL/7L+4vTVfd26RzjFFcCLma2 3mHPuyFCr9hyffNto5Vrx8ZVoUZL8t1QHD6ZqFB/4tbdouSffzNeKrv+/YxU1uGqbZ39 9y0L/szkSj13fEVciZwNxWdTHOXtJUP3SIJzgkm5rQzXfXmxgS1Mhw0mCvrsxBtGLjeK Hmgw== X-Gm-Message-State: AOJu0YzED/e2k/5UuAD2El8VxReuc01575LsGElLGuYI4eTxX3MpwreE uUhqcAlHuZWkIzW9BYGPpiljsKEeSdyZIaAvXGy9RamvUjxGF4sfqayDj2WtyFPxY0ZJRgpWOW+ u X-Received: by 2002:a17:902:f64a:b0:1e3:e1c4:eaf3 with SMTP id m10-20020a170902f64a00b001e3e1c4eaf3mr6479306plg.43.1712622855088; Mon, 08 Apr 2024 17:34:15 -0700 (PDT) Received: from stoup.. (098-147-007-212.res.spectrum.com. [98.147.7.212]) by smtp.gmail.com with ESMTPSA id n4-20020a170903110400b001e45c0d6ce6sm1825290plh.306.2024.04.08.17.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 17:34:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: gustavo.romero@linaro.org Subject: [PATCH for-9.0] linux-user: Preserve unswapped siginfo_t for strace Date: Mon, 8 Apr 2024 14:34:11 -1000 Message-Id: <20240409003411.1452196-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Passing the tswapped structure to strace means that our internal si_type is also gone, which then aborts in print_siginfo. Fixes: 4d6d8a05a0a ("linux-user: Move tswap_siginfo out of target code") Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/signal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index a93148a4cb..05dc4afb52 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -1173,6 +1173,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, CPUState *cpu = env_cpu(cpu_env); abi_ulong handler; sigset_t set; + target_siginfo_t unswapped; target_sigset_t target_old_set; struct target_sigaction *sa; TaskState *ts = get_task_state(cpu); @@ -1182,9 +1183,14 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, k->pending = 0; /* - * Writes out siginfo values byteswapped, accordingly to the target. It also - * cleans the si_type from si_code making it correct for the target. + * Writes out siginfo values byteswapped, accordingly to the target. + * It also cleans the si_type from si_code making it correct for + * the target. We must hold on to the original unswapped copy for + * strace below, because si_type is still required there. */ + if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { + unswapped = k->info; + } tswap_siginfo(&k->info, &k->info); sig = gdb_handlesig(cpu, sig, NULL, &k->info, sizeof(k->info)); @@ -1197,7 +1203,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, } if (unlikely(qemu_loglevel_mask(LOG_STRACE))) { - print_taken_signal(sig, &k->info); + print_taken_signal(sig, &unswapped); } if (handler == TARGET_SIG_DFL) {