From patchwork Sun Aug 22 03:55:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 501400 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp1059085jab; Sat, 21 Aug 2021 20:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyewB2B/cwkBluBwypwsIFczFOkGNR15FWxkYW9/X1Pq+mRC4RQ3xQ8tgkrBjVUtmW3HKyY X-Received: by 2002:a25:b08d:: with SMTP id f13mr36457719ybj.399.1629604724722; Sat, 21 Aug 2021 20:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629604724; cv=none; d=google.com; s=arc-20160816; b=Dg9fmWJQXTinx26cc4jfKwZcSBdQ3UApIR16Fl6o3FFIlr2oSwWySRM8U/HZ3KITqw qH+7gpJHhTM1e87KMV1/Mop5UdWELl/IXQfyc0bNxMbVX6yZ4mH66MRynYfEgRtueE9t akDzxQe2npYHRlVekuJTtPRxdKbS10HW3vikvTeaDv5gJkbccO/Qn2GBZTeIMwNUaLdR PequJt06X3VpCwiXx2l9OIufuOi2SvLUxdDJePYJHKLlR3mEbJfucDppFKQtOQGTG5Xz CBZ0Z+gQbF0wsr33CEJhuN479ZY/utyQSO/+AGSab4OwarGGl+TZ0PHMAc+2aBUT28ZZ QLGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=P3z2Cv7lHE53m9POhYgaeHFo5xT8ZP8ac0XeVQmhvwQ=; b=nkpQu/zADkUjr98i1h/qg53Xzj93PpcDrvcg73qQVR/IuphlkGBnQwW1C9VJCnFYi6 QkdZjjUcY2K5t7V3IlBQ5bdlkaozMUTQ6Ws2+knjGKx9i0P81QLEmU6th1C3lgF76kM9 VIdd0wzCbCS0CirSwhIZ9kQ4zP93EFOVdEiOA49S+/5TLCS92Ni9PJGq4pXhra2EF6F8 +pReEtWWq0Zwe9nNBC3zewq1uusfGWWrb1YbECbZcNdHD6QVSApRxJdYsqzqEHk9eKDV GRZtgR8PkxV3UFvgMkC5eIj1UxB4rv7oidRuyCBZf6vStbbOGlrkiB8AyK1tAV9zUUYJ PBsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoxTtglY; 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 f6si10311629ybi.102.2021.08.21.20.58.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Aug 2021 20:58:44 -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=BoxTtglY; 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]:45918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHedA-00054S-3l for patch@linaro.org; Sat, 21 Aug 2021 23:58:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaG-0007gi-JZ for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:52120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaE-0000Z6-0M for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: by mail-pj1-x1030.google.com with SMTP id oa17so9841835pjb.1 for ; Sat, 21 Aug 2021 20:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P3z2Cv7lHE53m9POhYgaeHFo5xT8ZP8ac0XeVQmhvwQ=; b=BoxTtglYPFlrwXK9iX545hsKNtVKGnxuf/L2GOiyYn3L7G+M9OJjAHNPl7L9yvtd1s WF02wxLUbTSaQPlISIYyBccBonWjKtHW9jzcdXCZgQ+HMt6zBIlVz6zmr72kyae7rgN/ zQLpV3lPY1Ihg3FseIedz4+xOPcG5jIoGckeflKrR6C7FwHtt/gBiHjtlJEgBjWyDDUi n/VR9CIo/Otp8mx2dlXslzgr+a2Qm5+hXwcs/NFsel18hfrn4OILt1/5V8e7D+zQ/KW4 uGOI4Kh8HbuTgOvRR1CvsF83WpYGI2Wheu8WzG5SGIqvdO6mpe3fZUm+6MnW2SO8tk59 uboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P3z2Cv7lHE53m9POhYgaeHFo5xT8ZP8ac0XeVQmhvwQ=; b=p9ddI2vJIvA05IdDYwvgUNH5RNrfots4h3WiN0Fd0m8vZSu48Lab2x/hzTvpj7+X2i DzpIeFospdm3zJLrwsIg6qAf4kQ6L4Ib1Uo/vBI5fouipmWnxeuN8sJSdKkSCrGcU+zy R2kZqw+n/hZo1fwh3Qdmn2VlYlsv/ZmmwpR3WEQztqr1DHoqKtRhuwUyGFcfCH7HMkDG 4stpvlxkK12xtObDL8n/TYsAxww5jXpe6jLnDyDxBqODz8Shu50S9funPEzdyXv5aLm2 aKpZttRHuYeeYm5E/GaTAceGGZZzlNBPVOH/+si3J2CXh/qtPeO+QYjj/GW1M/2HIYJK /R9w== X-Gm-Message-State: AOAM532+/n+Ra+RjlGusipt7eBxSfoD5nDtjz4rYcqDCnAkUa9EOpKgN WqjBQ0D/0yKghsU6EiS2tXzXNMqjsqvSIQ== X-Received: by 2002:a17:90a:bf14:: with SMTP id c20mr12576889pjs.184.1629604540708; Sat, 21 Aug 2021 20:55:40 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 03/30] linux-user/arm: Use force_sig() to deliver fpa11 emulation SIGFPE Date: Sat, 21 Aug 2021 20:55:10 -0700 Message-Id: <20210822035537.283193-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210822035537.283193-1-richard.henderson@linaro.org> References: <20210822035537.283193-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In the Arm target code, when the fpa11 emulation code tells us we need to send the guest a SIGFPE, we do this with queue_signal(), but we are using the wrong si_type, and we aren't setting the _sifields union members corresponding to either the si_type we are using or the si_type we should be using. As the existing comment notes, the kernel code for this calls the old send_sig() function to deliver the signal. This eventually results in the kernel's signal handling code fabricating a siginfo_t with a SI_KERNEL code and a zero pid and uid. For QEMU this means we need to use QEMU_SI_KILL. We already have a function for that: force_sig() sets up the whole target_siginfo_t the way we need it. Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-4-peter.maydell@linaro.org> [rth: Include signal-common.h] Signed-off-by: Richard Henderson --- linux-user/arm/cpu_loop.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 007752f5b7..b8ece169f9 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "elf.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "semihosting/common-semi.h" #define get_user_code_u32(x, gaddr, env) \ @@ -266,16 +267,13 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint32_t opcode) ts->fpa.fpsr |= raise & ~enabled; if (raise & enabled) { - target_siginfo_t info = { }; - /* * The kernel's nwfpe emulator does not pass a real si_code. - * It merely uses send_sig(SIGFPE, current, 1). + * It merely uses send_sig(SIGFPE, current, 1), which results in + * __send_signal() filling out SI_KERNEL with pid and uid 0 (under + * the "SEND_SIG_PRIV" case). That's what our force_sig() does. */ - info.si_signo = TARGET_SIGFPE; - info.si_code = TARGET_SI_KERNEL; - - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig(TARGET_SIGFPE); } else { env->regs[15] += 4; }