From patchwork Sun Aug 22 03:55:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02DFDC4320A for ; Sun, 22 Aug 2021 03:57:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8C8B96126A for ; Sun, 22 Aug 2021 03:57:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8C8B96126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHebf-00020z-Me for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:57:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaF-0007fb-MB for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:43 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:40545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaD-0000Xn-35 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:43 -0400 Received: by mail-pj1-x1032.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso16420573pjh.5 for ; Sat, 21 Aug 2021 20:55:40 -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=+WaIHji4UVCfbzWSWYeif0ORIYit2XTMtjCt7U1K6k4=; b=h4FuiIBNN6iHZAQYRGRklNXnq+teFHvidRu7A6p5WHDv9N/ZrS4GUP2+W6fkGm5T9y b+Rn52UN61F4k4QC8cvqGjF/nVYZU/kUJbZOIQZkwne6BkzQOzZw/xwTfQ8/E3Belh0n XIryIhYA8RyksYzfb3T/Z0W0M48DvcFKyKB+nfat83HbSaDm75zXiVdz0UsmQ0ZFPzO9 9v+adFTg0Fq2PSSilbAt1S1fka1cvBNCPlgU6fP5ccNlTkFMW5X/HA6pGW03071jEbMZ Ipb8MLvI55GzY3tjnW8i68XPon8agyP28e0q0Qwmsw7rhgBI6nlQDz2wb9gM8sbzHN4w +Z2w== 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=+WaIHji4UVCfbzWSWYeif0ORIYit2XTMtjCt7U1K6k4=; b=qG/5kQ2kAY26KbEUsBwJdJywAkGRy+0+OEaH2jxK8IZaEovJCAr6deufCBWWrqh4pj GgKQ0fMI0RwkBHwaWpBXy52MVdDLQYlo2md5nb2ybA7Azd4lTJW9yqHvmY8D8gTMjzBz o6+tlKO7TrvEZHWRNE6yc/KrD3pMcu6JASG/FYVHBSRxYcMkl+B47Ua3v0yepbkVeGcN rbuF3dDd6roEceFhDNQXAyCjenN6dpYR8B3Xc5TQN1DsDLVVA57hD74j21N3pGyh5xv7 Ub6AbZB8yuEueUgdpMwI9uLZ6a1OPs3sUle+XtWQvRuXzqDaVgatCqNGHgn8vwYWwl1u Ye5Q== X-Gm-Message-State: AOAM533asicm6HMG0+YFSpl07y0YjHoKVn1ly1NvyQHi+dsT7aqfHX4u qyJ2AE4lVJDYPbs3485nTZC/nv6R/n69jQ== X-Google-Smtp-Source: ABdhPJxOZvdJvTya8mOw0k/SkeHkQS5HcyP1WE/8RIM4DL0onruHsheKeJSgsGe8kFFmMpuqQ/LxXg== X-Received: by 2002:a17:90a:404a:: with SMTP id k10mr12982277pjg.145.1629604539504; Sat, 21 Aug 2021 20:55:39 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 01/30] linux-user/aarch64: Set siginfo_t addr field for SIGTRAP signals Date: Sat, 21 Aug 2021 20:55:08 -0700 Message-Id: <20210822035537.283193-2-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Fixes: Coverity 1459154 Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-2-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- linux-user/aarch64/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index ee72a1c20f..5d8675944d 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -148,6 +148,7 @@ void cpu_loop(CPUARMState *env) info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr = env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_SEMIHOST: From patchwork Sun Aug 22 03:55:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B00C4C4320E for ; Sun, 22 Aug 2021 03:59:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6E86E6126A for ; Sun, 22 Aug 2021 03:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6E86E6126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeda-0007hH-Gr for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:59:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaG-0007hE-UF for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:43570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaD-0000Ym-9c for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: by mail-pj1-x1033.google.com with SMTP id qe12-20020a17090b4f8c00b00179321cbae7so9900605pjb.2 for ; Sat, 21 Aug 2021 20:55:40 -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=wxQXtJmn/5fHjbKQYnHYNPRKlKJ8RKfJONraii7URWo=; b=MXbarbi2spXS8eJpRD710txdVUYKuU3Oju+UFC5UZV1jMy5QJ1Ee87CNEs6F3TOEdE ez894NSfY6DhA34yqPloyFDQaf1/vw1E1EX7Ibzr9bcQznCABKLQkxz4Hd3h3TOi7aEn u+sob1uzzXzKDU5/WGE9+UpkmVCILvyUHHM8GPrqtvIhgiuOz9O6oxGhxYCUfOh+Nr7x 5bYXZDJnK9IUzVarpMedqR601CWmOgE+z+sXxvWus+t7DDVav7/bTaNLLjZfULomO8GE TErcKD57UC2zrBhgPt4k5iHCLplTuY4KB+/bja0QmkRRac1NbfRu3IkNcYsCZPefxigp TEEA== 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=wxQXtJmn/5fHjbKQYnHYNPRKlKJ8RKfJONraii7URWo=; b=FhGKT0abD6nbxOWNbDeuJZfUyTQK6xJUeMdIUmrjXkPqKI2nMh3i5fHgbhzQA6sumS TqOT7xsqANo58hXCW+PcXq/LBDLGnK5x+TheBdFliCM/ERWj/H18bKnq3hOFGp0BI1X0 7Pyl5Me4vhdL8X0eNsNih2SaGzeR+is7aOqE9wmPnsVQ2PtyG1HluIpkhSQoPxs2w72g Z4ojuWJUnVNc2oh4T0QHk1YwEBWx9mcFxLIfh9qfdsLaNUhidtY1ZgtkjWsirRgI9VCo PcK5Z1UrHAT7niHT6WbD1GyKkXtSS8TfN+/bXuBZNuWBKbTuUC88/p6RR2+7XZHBPeKr i5rQ== X-Gm-Message-State: AOAM532KKaukxAjJVWqSNLO+I6BiiJN1BH3UvdjxV7WZ0Bdg7zZxe5TW zytGsEB09zROHbVImgmo+udWNJe8jHCRNA== X-Google-Smtp-Source: ABdhPJzTVTt3gdjri++pqkyN2blSIbJ23DNQbRVX//ouqgJAwa7H07AwToifHqvUh9q5SaWgH/ehSw== X-Received: by 2002:a17:90b:4d91:: with SMTP id oj17mr4023013pjb.209.1629604540080; 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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/30] linux-user/arm: Set siginfo_t addr field for SIGTRAP signals Date: Sat, 21 Aug 2021 20:55:09 -0700 Message-Id: <20210822035537.283193-3-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell When generating a TRAP_BRKPT SIGTRAP, set the siginfo_t addr field to the PC where the breakpoint/singlestep trap occurred; this is what the kernel does for this signal for this architecture. Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-3-peter.maydell@linaro.org> Signed-off-by: Richard Henderson --- linux-user/arm/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index 69632d15be..007752f5b7 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -453,6 +453,7 @@ void cpu_loop(CPUARMState *env) info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; + info._sifields._sigfault._addr = env->regs[15]; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; case EXCP_KERNEL_TRAP: 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: 12451125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADAC3C432BE for ; Sun, 22 Aug 2021 03:59:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 68A44611F2 for ; Sun, 22 Aug 2021 03:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 68A44611F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeda-0007h1-LY for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:59:10 -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-Google-Smtp-Source: ABdhPJw6+kfd698utgXNJ4MirX5qIpS/VXOWbKzBtNf1EnIkmmdf9wmRlaSkOwJByijewVZdeakdmA== 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+qemu-devel=archiver.kernel.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(-) 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; } From patchwork Sun Aug 22 03:55:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEA10C432BE for ; Sun, 22 Aug 2021 03:57:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6709A6126A for ; Sun, 22 Aug 2021 03:57:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6709A6126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHebg-00024n-JP for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:57:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaG-0007gT-DA for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:36494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaE-0000aG-Rs for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:44 -0400 Received: by mail-pl1-x633.google.com with SMTP id f1so1365725plg.3 for ; Sat, 21 Aug 2021 20:55:42 -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=BtM7var2ggs0sC3CkTYi8ly4990ZgrcQeQZtuDarh58=; b=L2j01erIoPdFBFriRxhnvxopl6a3DUivI6y6/350cFG8fO6eUlEoFJqZ6uxsMl5r0Y CgMaVDitjhaM1LN+17BcHiKzNagTyKOIlYf5pEbUzrRV4Yw494Vxh2XIbmUyI1bkytfa exkJ11I87RDhDm0jRt6962ivO4LSKEaCGt7BaTe8MmcXwXhVu9e7ANcXkHXNuWd0wiUm boZiIopLEWHR3GjK1W2e0T4MbcWHrjnIPjC4Kx9FMY0nNPcFVx4gdRp6Rc6MLa3SND6j 6q24JFcuRCr2boV1iGsY+amfWbwaKpxz4b2N+2xlmtDIb1OO+zpkYnAlMaezcEAyJff0 3OCg== 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=BtM7var2ggs0sC3CkTYi8ly4990ZgrcQeQZtuDarh58=; b=bqASQUt0VCUhS+5Dse3OOFcUacqxkg9IUh5mu5IV2HiSi/5XXQiP40NVUlGZC9Z848 jezNnbgaI3m8divJbuVM+D8aUabkXtbjjjSmkFmyzFqLZ3rjvA9At3kbvALY0TpX6/rv Myxpup27weYoqPWwWGOuS2ESVL+TzmF6nTNhDHPS7Ic9EVIs79rMjjXpARmkMd0tgDm0 a0Sjw702dP9Uwh5wTo/86FcWPjdwVwAeY7LAdXxY0Sr4HSy2SgTF62m+DZFBAbx3TVs1 m6F8hD8bB3JEgyrLR4+mPItdNoVb4l3dhuEpZ3lIzK1cgTDvpzZkGNYDK/1WlT3yOCq/ UPTQ== X-Gm-Message-State: AOAM531l3W8uswwYvfG2IYx4uczxoauFMeKJ5pl+u8ijcrP+gorwWyT1 qy0K7nRrLXIZpQhHqgei4/x7hxn9qaClGg== X-Google-Smtp-Source: ABdhPJyZ5Zvthp3CpPKSI9GPh8HW/R81l1cqPQtoBY2XnqU+EUy9m/qOmcDnIqeTYQ/FkdfkpOB/wQ== X-Received: by 2002:a17:90a:9292:: with SMTP id n18mr12881447pjo.120.1629604541385; Sat, 21 Aug 2021 20:55:41 -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:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 04/30] linux-user: Zero out target_siginfo_t in force_sig() Date: Sat, 21 Aug 2021 20:55:11 -0700 Message-Id: <20210822035537.283193-5-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::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The target_siginfo_t we populate in force_sig() will eventually get copied onto the target's stack. Zero it out so that any extra padding in the sifields union is consistently zero when the guest sees it. Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-5-peter.maydell@linaro.org> Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index a8faea6f09..fd3c6a3e60 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -636,7 +636,7 @@ void force_sig(int sig) { CPUState *cpu = thread_cpu; CPUArchState *env = cpu->env_ptr; - target_siginfo_t info; + target_siginfo_t info = {}; info.si_signo = sig; info.si_errno = 0; From patchwork Sun Aug 22 03:55:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8335C4320E for ; Sun, 22 Aug 2021 03:57:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 87A0A611F2 for ; Sun, 22 Aug 2021 03:57:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 87A0A611F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHebg-00027a-OG for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:57:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaI-0007jb-2V for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:46 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:43983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaF-0000aT-Hb for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:45 -0400 Received: by mail-pf1-x42a.google.com with SMTP id 7so12293899pfl.10 for ; Sat, 21 Aug 2021 20:55:43 -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=979JNGT4wJobTC0t4pJ3IOQQyDJEP0/xlu4yVxqsbGA=; b=sXIQlFWXzLiSGVi1spYyK05n9F/FbpM+1VGYghNS1BTmETFZcZSldOC9MNjoKyIOM6 9Mp1HZ7cJxidGiDSHi+lUcKusX0VA6dl8zhUFR6mnxSJpAE2cQIOmLAzxeqMKhSfo1od JC6oyjniG1qBgXjEMLGZMCqBTKk3XS/lPZjPwKFHo0ngPDMIy/oBchGCx/vgqFyrJyUC UOxDTAxIADVSzWEEuyX+j6SjCcv7f9zvEUUJIUW0TwahgRDqvJcYftQckuuzSkf4RkB2 Rx+CoTQTkveKXe0EncT6MPATlbETFTiiOSiOlQ55QIcLCZJxkIMKjdZQmE9g8PkGa8Hq Bj7A== 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=979JNGT4wJobTC0t4pJ3IOQQyDJEP0/xlu4yVxqsbGA=; b=RHe7bSm+btPU2iFkO2o4LDUZovVGKmG8Xk+TGol/ieUmaYVVPJgI6RNbfe/3w7wp9w ZbhK5W7MVMQOqzimcYX7i3k2um+TXraXzcFEOa4e8UbEfC+i933TvGxGtC57xTULWIf4 j0F5Sy2ebGXn0iM8YxPlhuar+K/svDAepf2DeR3JClT7SFd2qYaccxXiPoSykVNQzix0 SFOB127LlN7A8RTQv66+Pw4l/snNF6NFELzZJQCTt+h563dsz4yDwJNn4KvuRDb0+bU3 PVWvo0DkJ/zs19aSGLMXXiivkyYqGDtKUQOulHdLqrs4M0NbHLIlGwFp56YDBWtB5bz/ Z4IA== X-Gm-Message-State: AOAM532Ehd147mrJjUphKYMcSsquuI+6J0/FAI/Y2CrRabpNWJ9MIej7 vJ6K8xWEmpu0NStqADOA/uymny5x4V48dQ== X-Google-Smtp-Source: ABdhPJyIVhfS8WPv06uOwq8+p15g0aFUJFJrfqXYqaCSvHj+kMzISFRHVL/nhH3MRQse2/AH9KTQTg== X-Received: by 2002:a63:b91d:: with SMTP id z29mr25949433pge.436.1629604542211; Sat, 21 Aug 2021 20:55:42 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/30] linux-user: Provide new force_sig_fault() function Date: Sat, 21 Aug 2021 20:55:12 -0700 Message-Id: <20210822035537.283193-6-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In many places in the linux-user code we need to queue a signal for the guest using the QEMU_SI_FAULT si_type. This requires that the caller sets up and passes us a target_siginfo, including setting the appropriate part of the _sifields union for the si_type. In a number of places the code forgets to set the _sifields union field. Provide a new force_sig_fault() function, which does the same thing as the Linux kernel function of that name -- it takes the signal number, the si_code value and the address to use in _sifields._sigfault, and assembles the target_siginfo itself. This makes the callsites simpler and means it's harder to forget to pass in an address value. We follow force_sig() and the kernel's force_sig_fault() in not requiring the caller to pass in the CPU pointer but always acting on the CPU of the current thread. Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-6-peter.maydell@linaro.org> Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/signal-common.h | 1 + linux-user/signal.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index ea86328b28..536c7ac2c2 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -40,6 +40,7 @@ void tswap_siginfo(target_siginfo_t *tinfo, void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); +void force_sig_fault(int sig, int code, abi_ulong addr); #if defined(TARGET_ARCH_HAS_SETUP_FRAME) void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUArchState *env); diff --git a/linux-user/signal.c b/linux-user/signal.c index fd3c6a3e60..5ea8e4584a 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -646,6 +646,23 @@ void force_sig(int sig) queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); } +/* + * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the + * 'force' part is handled in process_pending_signals(). + */ +void force_sig_fault(int sig, int code, abi_ulong addr) +{ + CPUState *cpu = thread_cpu; + CPUArchState *env = cpu->env_ptr; + target_siginfo_t info = {}; + + info.si_signo = sig; + info.si_errno = 0; + info.si_code = code; + info._sifields._sigfault._addr = addr; + queue_signal(env, sig, QEMU_SI_FAULT, &info); +} + /* Force a SIGSEGV if we couldn't write to memory trying to set * up the signal frame. oldsig is the signal we were trying to handle * at the point of failure. From patchwork Sun Aug 22 03:55:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC115C4338F for ; Sun, 22 Aug 2021 03:59:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8BA29611F2 for ; Sun, 22 Aug 2021 03:59:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8BA29611F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHedZ-0007fJ-OQ for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaH-0007ig-KO for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:45 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:37858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaG-0000bD-44 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:45 -0400 Received: by mail-pj1-x1032.google.com with SMTP id j10-20020a17090a94ca00b00181f17b7ef7so3615208pjw.2 for ; Sat, 21 Aug 2021 20:55:43 -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=cY+r+qc1fo0mUajc1uVUA6DlV/7AqfXH+Cyy+hdjevk=; b=ItsZ1/5YzIOYxk/YudsBeBxuLVspEi7CUCnAIl08eYp0YOfTeDLHP9oiZO3YZMUPdw FfSruxRPTHxqFd1PfBZ6iGBO4qXMVLP2+RA86h+5HZbvJfrlklrEysKgyXUmtW4ZANeu yF6HD/ayAnX4ccMJZBPnKNDf7urhP7IZ9tUXuZH90uTwrLZ83nUcwM1w83PS0aKBDoFe d3YSSUOKJEn9rH/8VUoDY9/FkwLkLdpRUx0ezxDG9HtX1vf3nlxjpIMq7h+RkK3keoPB MAMu3EI3hjPNQumjrMOavT1X70oF5/uowCFayC3xNhcyU8Fr45NOxG5Nb9Wg/Jn+BGzf RvoQ== 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=cY+r+qc1fo0mUajc1uVUA6DlV/7AqfXH+Cyy+hdjevk=; b=halBYXMFbR7CwtX9FRB1V4JlQ1UKZ6L6GAZCLJJtR/yk/agVD7ZB41NC8K1h+rbwEl xM2LcEmgkubG/N3Nvf5gvDWWtKnImGSXj0b8AbzbOKJD8Ti7zgpVTiraq8/Ct0mRvSC6 d7SVP4wnykyRzja2vgf9mNwKMtLKRB5GvBGaJpIviC7vHpnQ6pY2kDLcc1JgfWhz4lkp J+fZ5FFNaiLt+CxQQUdGTl5yB90lcNSMEZd9gzYKV90wHH3AYY7VHIW1kUHAH71GLS9y 0XMYEP/AQpw10Ch2Pi6JsW892CRLmCyr4TCoyEoQgdROr3BPB3cYpvFiYXMKu0jxV2wh 3h8w== X-Gm-Message-State: AOAM533e3SG0dfr6MtG6hZKLrnBhHPDMoxZuscAd+1w1I1nANmKTsiY7 yDQTTHaaq1g//WMxFAvUYuDNEg/K6ZI/7Q== X-Google-Smtp-Source: ABdhPJyho90SPxm6QhovpritZPQE3a3DFXuZk19yWinn8CZfpxifLPNjdgqePeF8acGFer8Yt2UH9g== X-Received: by 2002:a17:90a:116:: with SMTP id b22mr900846pjb.108.1629604542950; Sat, 21 Aug 2021 20:55:42 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 06/30] linux-user: Provide new force_sigsegv_for_addr() function Date: Sat, 21 Aug 2021 20:55:13 -0700 Message-Id: <20210822035537.283193-7-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::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Most linux-user targets so far do not distinguish between SEGV_MAPERR and SEGV_ACCERR. This function will be used to fix that. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/signal-common.h | 1 + linux-user/signal.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h index 536c7ac2c2..9090bbb315 100644 --- a/linux-user/signal-common.h +++ b/linux-user/signal-common.h @@ -40,6 +40,7 @@ void tswap_siginfo(target_siginfo_t *tinfo, void set_sigmask(const sigset_t *set); void force_sig(int sig); void force_sigsegv(int oldsig); +void force_sigsegv_for_addr(abi_ulong addr); void force_sig_fault(int sig, int code, abi_ulong addr); #if defined(TARGET_ARCH_HAS_SETUP_FRAME) void setup_frame(int sig, struct target_sigaction *ka, diff --git a/linux-user/signal.c b/linux-user/signal.c index 5ea8e4584a..0bb369c888 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -663,6 +663,24 @@ void force_sig_fault(int sig, int code, abi_ulong addr) queue_signal(env, sig, QEMU_SI_FAULT, &info); } +/* + * Force a synchronously taken SIGSEGV signal for @addr. + * Distinguish between SEGV_MAPERR and SEGV_ACCERR here, + * in preference to doing that for each target. + */ +void force_sigsegv_for_addr(abi_ulong addr) +{ + /* + * MAPERR indicates the page is not present at all. + * Otherwise, it must have been a permission problem. + */ + int si_code = TARGET_SEGV_MAPERR; + if (page_get_flags(addr) & PAGE_VALID) { + si_code = TARGET_SEGV_ACCERR; + } + force_sig_fault(TARGET_SIGSEGV, si_code, addr); +} + /* Force a SIGSEGV if we couldn't write to memory trying to set * up the signal frame. oldsig is the signal we were trying to handle * at the point of failure. From patchwork Sun Aug 22 03:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1342BC432BE for ; Sun, 22 Aug 2021 04:01:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9D859611F0 for ; Sun, 22 Aug 2021 04:01:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D859611F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeg2-0004zR-OL for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:01:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaI-0007l3-HB for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:46 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:45760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaG-0000c3-So for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:46 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d17so8184185plr.12 for ; Sat, 21 Aug 2021 20:55:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qnzdMjgcBsPzYrCkXKkHqDyfkhXP0vzUSwft+EOabQ0=; b=Q0UfAH+lsheZ+rL9/EIPlLbjIhmJghjkBazqhaoQgHeNMqmFGQFAZz0KSllGnjjhWo Nnu6fMjAaFalx9zKoYADERsIBoh9p/dRJ8u2gVjE5vyCCpunpOCd682TCgjtpm/XWgkA SPXItbBXQsMPwNV8WrTUhjztC8qj6BDNaxvmy9boZYBMftvLBYaTDVbfzdzGQrgBWjCW +hdD2LlNqNu+CKv0GJpfTcc6h7W9EotoamT/Z9rZOdoTZAGifB2D+wmxySyYUAIQjkCd 0x96RiqMOjeXst+t7eJAoeoPWT+HExTLAy90wy23dngQf1o/S2sdUILsdCyNUeOipCqC 6npg== 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=qnzdMjgcBsPzYrCkXKkHqDyfkhXP0vzUSwft+EOabQ0=; b=Q/VyUmgVwasbdpg6RSc4Ic9uGANmk96wK2v5rEC6eZQCKG2hlEGeQVM3NeSpF/9aWF y0s8ERDD6pjLVBBnyuKNDdR9+77GR3/FgRzBcbkW31DZAAmCLICzfkYn/Hb2ZiwShdCs IrXNQqzepeIm2zMy6xE/3J+A9Y09rG+ARaV1dkm05kJAOt2SMAtDk5NfI0nJBn/q0K1p 3eYQiZh+TVcgf+OIkctOprMBQ1g54PzsdOJc0EK+zzNSZQTBdDpkzMdUyzcCexACgFiW sJ1k1Uv0PuVdMQ0P6pYy98LUuE9LqZhZJ4go3j/atduTAzEm3EWBg7LcKgjuHFzghXm4 LB2w== X-Gm-Message-State: AOAM533K4zj3gDSk2VTsmHbQ1BPg0zD5KkiNslzQuYxGy+QX1+/HcxDD N7yj+arq9fSW18uGzIw8I8byTEBOo4YCUg== X-Google-Smtp-Source: ABdhPJwu+bTJP1ngLip0kcG4Gkl/3QROvxFrBd5Seb8lqvzX8U7MoEJCwPz2NK9uBhiIIaReyXlWXA== X-Received: by 2002:a17:90a:5583:: with SMTP id c3mr12634365pji.133.1629604543624; Sat, 21 Aug 2021 20:55:43 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 07/30] linux-user/arm: Use force_sig_fault() Date: Sat, 21 Aug 2021 20:55:14 -0700 Message-Id: <20210822035537.283193-8-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::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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-7-peter.maydell@linaro.org> Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/arm/cpu_loop.c | 53 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index b8ece169f9..d4b4f0c71f 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -93,7 +93,6 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env) { uint64_t oldval, newval, val; uint32_t addr, cpsr; - target_siginfo_t info; /* Based on the 32 bit code in do_kernel_trap */ @@ -142,12 +141,9 @@ segv: end_exclusive(); /* We get the PC of the entry address - which is as good as anything, on a real kernel what you get depends on which mode it uses. */ - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->exception.vaddress; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); } /* Handle a jump to the kernel code page. */ @@ -285,8 +281,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs = env_cpu(env); int trapnr; unsigned int n, insn; - target_siginfo_t info; - uint32_t addr; abi_ulong ret; for(;;) { @@ -321,11 +315,8 @@ void cpu_loop(CPUARMState *env) break; } - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, + env->regs[15]); } break; case EXCP_SWI: @@ -393,18 +384,14 @@ void cpu_loop(CPUARMState *env) * Otherwise SIGILL. This includes any SWI with * immediate not originally 0x9fxxxx, because * of the earlier XOR. + * Like the real kernel, we report the addr of the + * SWI in the siginfo si_addr but leave the PC + * pointing at the insn after the SWI. */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLTRP; - info._sifields._sigfault._addr = env->regs[15]; - if (env->thumb) { - info._sifields._sigfault._addr -= 2; - } else { - info._sifields._sigfault._addr -= 4; - } - queue_signal(env, info.si_signo, - QEMU_SI_FAULT, &info); + abi_ulong faultaddr = env->regs[15]; + faultaddr -= env->thumb ? 2 : 4; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLTRP, + faultaddr); } break; } @@ -435,24 +422,14 @@ void cpu_loop(CPUARMState *env) break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr = env->exception.vaddress; - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + /* XXX: check env->error_code */ + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, + env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: excp_debug: - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = env->regs[15]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[15]); break; case EXCP_KERNEL_TRAP: if (do_kernel_trap(env)) From patchwork Sun Aug 22 03:55:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D010C4338F for ; Sun, 22 Aug 2021 04:01:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B42556126A for ; Sun, 22 Aug 2021 04:01:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B42556126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeg4-00053j-OD for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:01:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaJ-0007mY-4N for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:47 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:37662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaH-0000cu-I3 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:46 -0400 Received: by mail-pg1-x532.google.com with SMTP id 17so13325252pgp.4 for ; Sat, 21 Aug 2021 20:55:45 -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=qGpOhcDg+ef3HF+AW1Lu1mwmMePA2ZX5mvS/TXPUc4Q=; b=xchPxoDAQ04Eb5iiEHoc4Bee7DGqSwqeKuibN8T6S2vugK8iMJU67nCOn0UYusc5sj T7NQypJaVKqFIX2/C5oIOazxz8bI3W5R78YA+iWuber2asmW5No0pltsx6lglJi0724E Klq417kaIKeITb1VGbIgys5Y/nsZVU3+G/f2Fkm4vCzKnxDkTlwZ/Tcos/GNefA95ODo gGANtF3FgxCrqj0WqyfxuVdAnBkdWOzBUpSv9YA9LfHQqSEUELfQtb+FLN1lHQ9zCy90 m1dYI0qGtkrTJp/bQ7cV6qprMlI3xlF6Y25gXUJdaQqiYdm8PNOcXby32bHrU127LEIz rhsQ== 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=qGpOhcDg+ef3HF+AW1Lu1mwmMePA2ZX5mvS/TXPUc4Q=; b=kOQHMHcOIXEFTgKsRr9oL+oyOGgkAh28bqLiDi6FxgEMucfvf4acBcE8AsOxjZ9UjS UzqfNC1JKuTO/YB0TvyTkRavDoG6K0kzKR3DutnLhs3bZMLgCXzRad2H/kOHrcI7Jm0G 6n3AtZsYj8cPwoydzBBxR2LYhwNt2N48N8GTTM7y13qHqNzTcSgMT7nkh3BQKrxBnzlR +I0EKgFNYvlTYORzyBEWlN5b0v6+vaC+QP2zqTdHZ5R1IUv0qf+UTSuVGvVRG6qDOq/d aMmt9UTn8ZppmcaSZHwOtdmst+GqgS68ibJ2/KLHGSrR1oPq57cb9yFACKpsgnYlvYOl JytQ== X-Gm-Message-State: AOAM533iDqy2LcYHu91l9wmsouwmCk9SeJH8s/NTpUqkquDrFyoDTr5y Q/ySTdESWNoUObmQEc8xNuLJD/shXnOAaQ== X-Google-Smtp-Source: ABdhPJzehx3DTdCosori/GTKqDIIqzMEJklZ5Oqbu7Ltv/5hRACjBqv3K+A+m5BTZKibTWGXarCz8Q== X-Received: by 2002:a05:6a00:a8a:b029:356:be61:7f18 with SMTP id b10-20020a056a000a8ab0290356be617f18mr27434020pfl.29.1629604544241; Sat, 21 Aug 2021 20:55:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 08/30] linux-user/aarch64: Use force_sig_fault() Date: Sat, 21 Aug 2021 20:55:15 -0700 Message-Id: <20210822035537.283193-9-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::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Use the new force_sig_fault() function instead of setting up a target_siginfo_t and calling queue_signal(). Signed-off-by: Peter Maydell Message-Id: <20210813131809.28655-8-peter.maydell@linaro.org> Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/aarch64/cpu_loop.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 5d8675944d..11e34cb100 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "qemu/guest-random.h" #include "semihosting/common-semi.h" #include "target/arm/syndrome.h" @@ -77,9 +78,8 @@ void cpu_loop(CPUARMState *env) { CPUState *cs = env_cpu(env); - int trapnr, ec, fsc; + int trapnr, ec, fsc, si_code; abi_long ret; - target_siginfo_t info; for (;;) { cpu_exec_start(cs); @@ -108,18 +108,10 @@ void cpu_loop(CPUARMState *env) /* just indicate that signals should be handled asap */ break; case EXCP_UDEF: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info._sifields._sigfault._addr = env->exception.vaddress; - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ ec = syn_get_ec(env->exception.syndrome); assert(ec == EC_DATAABORT || ec == EC_INSNABORT); @@ -128,28 +120,24 @@ void cpu_loop(CPUARMState *env) fsc = extract32(env->exception.syndrome, 0, 6); switch (fsc) { case 0x04 ... 0x07: /* Translation fault, level {0-3} */ - info.si_code = TARGET_SEGV_MAPERR; + si_code = TARGET_SEGV_MAPERR; break; case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ - info.si_code = TARGET_SEGV_ACCERR; + si_code = TARGET_SEGV_ACCERR; break; case 0x11: /* Synchronous Tag Check Fault */ - info.si_code = TARGET_SEGV_MTESERR; + si_code = TARGET_SEGV_MTESERR; break; default: g_assert_not_reached(); } - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_SEMIHOST: env->xregs[0] = do_common_semihosting(cs); @@ -169,11 +157,7 @@ void cpu_loop(CPUARMState *env) /* Check for MTE asynchronous faults */ if (unlikely(env->cp15.tfsr_el[0])) { env->cp15.tfsr_el[0] = 0; - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info._sifields._sigfault._addr = 0; - info.si_code = TARGET_SEGV_MTEAERR; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MTEAERR, 0); } process_pending_signals(env); From patchwork Sun Aug 22 03:55:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D63FBC432BE for ; Sun, 22 Aug 2021 04:05:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7F2276023D for ; Sun, 22 Aug 2021 04:05:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7F2276023D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHekA-0002Du-Hk for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:05:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaJ-0007nn-NY for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:47 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:46042) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaI-0000d8-4p for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:47 -0400 Received: by mail-pg1-x530.google.com with SMTP id n18so13344828pgm.12 for ; Sat, 21 Aug 2021 20:55:45 -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=aaG8+wKRstXR/idWhImzrCGyhK5/kWZ1S3StnyK++N8=; b=JhSE/FCD9VpeiNgtOctsp8rBwzZ3IWhSLO/0K0C75LXZxUnzmJT06E5gmwz8kVIBxo 42i+SDOuvpRUWX/gVHzjRT9xn9ioLdgafmnxhksVVDRIsM/LMGLj7EpCbUAWrEAtNcNq etwYjwJAk7fsJhVtbZwZbsrnlQQf2csbX82lxG3OpfJsMJNzN9qcmZJ0ZMvBmBDG1xzU 0ASOvagUhCEBNtUPS3824vah4EBnELLkhGPm3If0lhnaCPnoZHjl9oFl/rmYi+4HEPzC ogbSWtWEOWD31DQjeWSs80TX7ia2Y1JcAGIxwdNLAj5a9JDniZ5HDnJFaeIpzr3eouXc Gihw== 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=aaG8+wKRstXR/idWhImzrCGyhK5/kWZ1S3StnyK++N8=; b=PuT0Fd3IAAFDmo09/vZb7qI8Wl9vdrCX9MSPaA+PxfYtBI1b28NBfgKsCB7bcCcMci Q19OUpfjl85TWy2ZzflAp86+qlfCYXk2OiNYK3RPEq3Nr4kxe0GYL47Qq8v9tkEUjWbb Kh48fIBNnr47RlKE0myN/VrsUrNEJ9a2PLmQvapJ1AL4F61i32O/BCjqs8V3h8bUtl7K /F6cDP6nNw5LjtdcnPc4+o3XpK2RoHcRRIn1HZmimNhdoS7CGdfFZsxkOT5pTXbF2Ck1 m5q6Eoo56FgQz/weTPduWOozhCS//VQKhENTg3uptV67/wXT/mjvkmBv7SA5bJmg/8Go k/Qg== X-Gm-Message-State: AOAM530B73ckA381ohqiiCs0VQXSs+1aDTqd8HPT6uJXSLbog1G8iZHq NXJ8wQbztfQccd4DIuwrjsfA8ZdzdngWCA== X-Google-Smtp-Source: ABdhPJzl0gghGWHhkr4q7hrIXU1stsx7iSekDlT2ZhZf2GwHYvnt+IKysF93KU9xAjZ+hYL0fe4Arw== X-Received: by 2002:a63:2585:: with SMTP id l127mr26702754pgl.264.1629604544819; Sat, 21 Aug 2021 20:55:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 09/30] linux-user/alpha: Set TRAP_UNK for bugchk and unknown gentrap Date: Sat, 21 Aug 2021 20:55:16 -0700 Message-Id: <20210822035537.283193-10-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::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" These si_codes were changed in 535906c684fca, for linux 4.17. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/syscall_defs.h | 1 + linux-user/alpha/cpu_loop.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a5ce487dcc..55ccc6ae03 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -715,6 +715,7 @@ typedef struct target_siginfo { #define TARGET_TRAP_TRACE (2) /* process trace trap */ #define TARGET_TRAP_BRANCH (3) /* process taken branch trap */ #define TARGET_TRAP_HWBKPT (4) /* hardware breakpoint/watchpoint */ +#define TARGET_TRAP_UNK (5) /* undiagnosed trap */ struct target_rlimit { abi_ulong rlim_cur; diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index 7ce2461a02..b2e9503c50 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -99,7 +99,7 @@ void cpu_loop(CPUAlphaState *env) /* BUGCHK */ info.si_signo = TARGET_SIGTRAP; info.si_errno = 0; - info.si_code = 0; + info.si_code = TARGET_TRAP_UNK; info._sifields._sigfault._addr = env->pc; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; @@ -168,7 +168,7 @@ void cpu_loop(CPUAlphaState *env) break; default: info.si_signo = TARGET_SIGTRAP; - info.si_code = 0; + info.si_code = TARGET_TRAP_UNK; break; } info.si_errno = 0; From patchwork Sun Aug 22 03:55:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C9C4C4338F for ; Sun, 22 Aug 2021 04:01:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 114E36126A for ; Sun, 22 Aug 2021 04:01:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 114E36126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeg1-0004tV-2l for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:01:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaJ-0007oV-VY for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:48 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:56206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaI-0000dH-Hh for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:47 -0400 Received: by mail-pj1-x1033.google.com with SMTP id mq3so9789104pjb.5 for ; Sat, 21 Aug 2021 20:55:46 -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=ZSv5B26XxDivA72RLN37D0Ox9MVhtWDMvhKjh5v96B0=; b=ML8S0l2Hio8vpNRfx8XETWrB3AouCdXVXAbkTjM/xFinjCqwFb8hbS9ScROBRr2OFX GSPP+aZTEEZErNzZeQ6PFjngAVaobpr+9Alh0m35sa9Yh3grdI1kEokC5aaSq9wDDYKB H8YI9D73M1wyxXcV+2SMgzX+UBSLEeU19QSWlrqV5DREeybEcPjwfcgg6RrKdGAd50C1 4RqGpCIIC1u334KhyZ544AqS5G+/zN1/yv5BZF6cXlkEzPJaXUpcrmX9Y13mMzf+DS+K PwkiWDboKuJU3xBdUjQRBCFQjILw1EYoGwXNht4b67HWoyFbuIKXJhbVppQVhP5DYSji tJgw== 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=ZSv5B26XxDivA72RLN37D0Ox9MVhtWDMvhKjh5v96B0=; b=SBWDHx5JOEmh9TZS9PpPxfHXrtYtHjs+cvFO2nyKAXbavLhc5jGs0lUIX2eOiNzM6c pLu++cB/LonYIDvcCkdg86wrHn3EMFdq3HuLArnFnn8X4SJp+DYD4chjvNnKIBI/GGQ4 CkXaTSD3cO61PiF9+FWytFApNQmQLVef6WdVMD3VM7W6y4I7J9gGchX15XChHWZHWua2 0sJ+WQBPOi8dnG6NOirTF//rYR0S43tPpWO5oFfJmLIuXnKjAHVW2IaNe4MLecqzhrYZ 7yDcpFbxhrKzgSaNMiV7qd4AdVwXIz228SqHvukiaqJofOe3jnG+Pp7qulB/La+nrwv4 q4FA== X-Gm-Message-State: AOAM533+3UDdH73MQzgn6RR5xr7bX6+CUG3+P62i4DItA2Hoxm3Qkv47 t21kW7BhDqll0xrJQszXqEtOlat8S2BgdA== X-Google-Smtp-Source: ABdhPJxdg0cBuugwUq76Q0VQVOhrukk7gkBmLz6MrqxOXEjV/x10oMzTmdlMaEgHL+uJg561BIK18A== X-Received: by 2002:a17:90b:4b0b:: with SMTP id lx11mr13141355pjb.70.1629604545417; Sat, 21 Aug 2021 20:55:45 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/30] linux-user/alpha: Set FPE_FLTUNK for gentrap ROPRAND Date: Sat, 21 Aug 2021 20:55:17 -0700 Message-Id: <20210822035537.283193-11-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This si_code was changed in 4cc13e4f6d441, for linux 4.17. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/alpha/cpu_loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index b2e9503c50..e5f78a439a 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -164,7 +164,7 @@ void cpu_loop(CPUAlphaState *env) info.si_code = TARGET_FPE_FLTRES; break; case TARGET_GEN_ROPRAND: - info.si_code = 0; + info.si_code = TARGET_FPE_FLTUNK; break; default: info.si_signo = TARGET_SIGTRAP; From patchwork Sun Aug 22 03:55:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04E92C4338F for ; Sun, 22 Aug 2021 04:05:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 877646023D for ; Sun, 22 Aug 2021 04:05:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 877646023D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHek9-0002AZ-Ga for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:05:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaL-0007ph-0A for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:50 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:46594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaJ-0000eM-A8 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:48 -0400 Received: by mail-pf1-x436.google.com with SMTP id y11so12287632pfl.13 for ; Sat, 21 Aug 2021 20:55:46 -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=RXyNVnKqczOF3zQ3IizA0BEApi83sp6PDrOKK0oyLMQ=; b=U+ETfGt/RXBkTWmiZ88zrYtFcLjGQXvms465QbgBK7FfsVVmz47qSA+gSeFhUehYYi a9iFVayxCryuyJzpVXbroy4llGepDRzMrx7jH7r3HlBAK7Xri1xPDbZzhFY1JyLhFSJW YGiUKH7A1LVIkkA6xXW697Wr6kfoXgSEH2jaDvDxajbKfSbQKsVLyzILumGD/gKt1PQP bq/ocqQj7+Ki3/+KtU9Z01ieMR4421XJ4IPo//l9TLf5m7p6uONEBeWS4nEQB+6/pHp+ 4hTqR3fIPKipz/WgbHKjlhbEqCdx6qaYdIAgyTFVeUdCIFMQoXDn3xeQDGDhbKwRoaac mitQ== 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=RXyNVnKqczOF3zQ3IizA0BEApi83sp6PDrOKK0oyLMQ=; b=mlRvyV96QEN6yz1kKNyvKQu76+GsU+XnmH10XRKb+IiTAfsXy/ZHf72RFG3Ybat7LJ 1KCa3uxOjOnt4iWRNnWRnBdvI18aeZa7Sl/NibSdE4+598dDAVXPYjczlcHMp+91QBLy qWw5408DfF5UAEFA/thqLuS+OZr+U4s5iZQU/8iVUhX9bwjGKZ/e2e4mUMnCecHciZoW gNGHqbGM+yyxAVEnSPC1l0wQVxLZ0RqsS8SPxXprzdAgrvmpjuVd1sBW04INm4t4OB6b LzNGM48/M2LnZM/L6HSGsVGfYX8ZC6gdweJ/nrv6LSu3xx0ecq7r3R5fhIKo3nSPN2Mn 68eg== X-Gm-Message-State: AOAM533SUZXeNs2u7Yb4fj/nYgl6RywwZYAHLZzA4L5EV8hG8P4fHSy9 6NNoYdenJNmJYa1CXWmlh6NvLDEJOn8Okw== X-Google-Smtp-Source: ABdhPJy+T2RPxI49UCGIJV2I8VSgDESLdaSdV4u41vfLyaFlNMfyO02dVI3b5B1o6llVB/ZBjmh8Uw== X-Received: by 2002:a05:6a00:2405:b0:3e1:9f65:9703 with SMTP id z5-20020a056a00240500b003e19f659703mr27504036pfh.6.1629604546037; Sat, 21 Aug 2021 20:55:46 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 11/30] linux-user/alpha: Use force_sig_fault, force_sigsegv_code Date: Sat, 21 Aug 2021 20:55:18 -0700 Message-Id: <20210822035537.283193-12-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/alpha/cpu_loop.c | 76 +++++++++++-------------------------- 1 file changed, 23 insertions(+), 53 deletions(-) diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index e5f78a439a..b624311a5f 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -21,12 +21,13 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + void cpu_loop(CPUAlphaState *env) { CPUState *cs = env_cpu(env); - int trapnr; - target_siginfo_t info; + int trapnr, si_code; abi_long sysret; while (1) { @@ -53,34 +54,17 @@ void cpu_loop(CPUAlphaState *env) exit(EXIT_FAILURE); break; case EXCP_MMFAULT: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = (page_get_flags(env->trap_arg0) & PAGE_VALID - ? TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR); - info._sifields._sigfault._addr = env->trap_arg0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->trap_arg0); break; case EXCP_UNALIGN: - info.si_signo = TARGET_SIGBUS; - info.si_errno = 0; - info.si_code = TARGET_BUS_ADRALN; - info._sifields._sigfault._addr = env->trap_arg0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->trap_arg0); break; case EXCP_OPCDEC: do_sigill: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPC; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; case EXCP_ARITH: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_FLTINV; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_FLTINV, env->pc); break; case EXCP_FEN: /* No-op. Linux simply re-enables the FPU. */ @@ -89,20 +73,10 @@ void cpu_loop(CPUAlphaState *env) switch (env->error_code) { case 0x80: /* BPT */ - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_BRKPT; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; + goto do_sigtrap_brkpt; case 0x81: /* BUGCHK */ - info.si_signo = TARGET_SIGTRAP; - info.si_errno = 0; - info.si_code = TARGET_TRAP_UNK; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; + goto do_sigtrap_unk; case 0x83: /* CALLSYS */ trapnr = env->ir[IR_V0]; @@ -143,47 +117,43 @@ void cpu_loop(CPUAlphaState *env) abort(); case 0xAA: /* GENTRAP */ - info.si_signo = TARGET_SIGFPE; switch (env->ir[IR_A0]) { case TARGET_GEN_INTOVF: - info.si_code = TARGET_FPE_INTOVF; + si_code = TARGET_FPE_INTOVF; break; case TARGET_GEN_INTDIV: - info.si_code = TARGET_FPE_INTDIV; + si_code = TARGET_FPE_INTDIV; break; case TARGET_GEN_FLTOVF: - info.si_code = TARGET_FPE_FLTOVF; + si_code = TARGET_FPE_FLTOVF; break; case TARGET_GEN_FLTUND: - info.si_code = TARGET_FPE_FLTUND; + si_code = TARGET_FPE_FLTUND; break; case TARGET_GEN_FLTINV: - info.si_code = TARGET_FPE_FLTINV; + si_code = TARGET_FPE_FLTINV; break; case TARGET_GEN_FLTINE: - info.si_code = TARGET_FPE_FLTRES; + si_code = TARGET_FPE_FLTRES; break; case TARGET_GEN_ROPRAND: - info.si_code = TARGET_FPE_FLTUNK; + si_code = TARGET_FPE_FLTUNK; break; default: - info.si_signo = TARGET_SIGTRAP; - info.si_code = TARGET_TRAP_UNK; - break; + goto do_sigtrap_unk; } - info.si_errno = 0; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, si_code, env->pc); break; default: goto do_sigill; } break; case EXCP_DEBUG: - 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); + do_sigtrap_brkpt: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); + break; + do_sigtrap_unk: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_UNK, env->pc); break; case EXCP_INTERRUPT: /* Just indicate that signals should be handled asap. */ From patchwork Sun Aug 22 03:55:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1833C4320A for ; Sun, 22 Aug 2021 04:08:37 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6CB4C6125F for ; Sun, 22 Aug 2021 04:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CB4C6125F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHemi-0007vN-EN for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaL-0007py-Ek for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:51 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:44840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaJ-0000f4-VM for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:49 -0400 Received: by mail-pj1-x1035.google.com with SMTP id hv22-20020a17090ae416b0290178c579e424so9883309pjb.3 for ; Sat, 21 Aug 2021 20:55:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WrDsV8FuQ7eVHDLBH4cYkBRu3DriqEOVfUQFkxYbNm0=; b=S0ZT/QMRBhf3vVb8u/7R3LEsKkFjJBCi0HxuN7UcM4LUI160vpIAjxxwgFfhbOq4MD esdaVv+eE/DMcMWYAKlK0LdAWyvh0wr77CyfG3ZbqcgU+uEDa58xYFHRoSaSn6TZW0VP qhJ9WzWBJl964uQcDXYC2+TShzD1gW2g9O+BcGyBcs/J3uzqJHX0Z+WTDHRx06ZyQAIo epZ8+w+GTOVeeVYkM5U4SRJEHwWbY+qirUc7+QXrRgYemyDu4spdAvGexF5s8K0AmKrg sRBYuASUu+/4R62kChy2nt1twRQE/3L57/WZ3o4mwWtGeWIKp36uVhuL1Sd41ZM2RVCd UvtQ== 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=WrDsV8FuQ7eVHDLBH4cYkBRu3DriqEOVfUQFkxYbNm0=; b=d/yHyf/HE4RIjXtirK7s/9p8R2TQZUPTfIERKc4Sx3lUT/61xHWAHZ25SJoY5J6oqY aPHveYoxHY/5H6uYhj4tgwY5eBi3f7RDirka+pmQ1w9YSswqZDsNkjQm8YmNuqj778zl sfsJ/iuAr8zUhQQiMsnML88uMQCYM89ZoN7uYGDu2vZpBdv2VrV+l3t/rmPewCab5eff 3+doolE1DFnmuHnhx5373zJlwUq6+SZhRkKinrGOdSeut3mP2KIF3wWW1q9tTCwkv3Wh DII2/hD7pBedY9G4lxbvQeXxgtvY/ojt6ywqUNVlsz0AjeVXMVCVshG2CjOTWAAJ4PkV tXrw== X-Gm-Message-State: AOAM532HxslQVtzSucgCn0fOPrpT8mN4KYsdVyJHio3324iO7g93uYkc X+xr6IwoeojM13df9dgcSRreUFyQnrXslw== X-Google-Smtp-Source: ABdhPJwF7zv60YoAJZNss/UvHz3693pVGWr9LSb6BdOiTkE60tmQE2h85wNWkSUoKWAo2WXN913jAQ== X-Received: by 2002:a17:902:c401:b0:12d:8258:e07e with SMTP id k1-20020a170902c40100b0012d8258e07emr23088099plk.51.1629604546656; Sat, 21 Aug 2021 20:55:46 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 12/30] linux-user/cris: Use force_sig_fault, force_sigsegv_code Date: Sat, 21 Aug 2021 20:55:19 -0700 Message-Id: <20210822035537.283193-13-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::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/cris/cpu_loop.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index 334edddd1e..7a31402ab4 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -21,13 +21,13 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" void cpu_loop(CPUCRISState *env) { CPUState *cs = env_cpu(env); int trapnr, ret; - target_siginfo_t info; - + while (1) { cpu_exec_start(cs); trapnr = cpu_exec(cs); @@ -36,18 +36,11 @@ void cpu_loop(CPUCRISState *env) switch (trapnr) { case 0xaa: - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->pregs[PR_EDA]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + force_sigsegv_for_addr(env->pregs[PR_EDA]); break; case EXCP_INTERRUPT: - /* just indicate that signals should be handled asap */ - break; + /* just indicate that signals should be handled asap */ + break; case EXCP_BREAK: ret = do_syscall(env, env->regs[9], @@ -65,10 +58,7 @@ void cpu_loop(CPUCRISState *env) } break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC56EC4338F for ; Sun, 22 Aug 2021 04:06:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A7E056101C for ; Sun, 22 Aug 2021 04:06:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7E056101C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHekD-0002I1-Qt for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:06:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaN-0007q4-2M for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:52 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:38904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaK-0000fo-GZ for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:50 -0400 Received: by mail-pj1-x1034.google.com with SMTP id om1-20020a17090b3a8100b0017941c44ce4so16445235pjb.3 for ; Sat, 21 Aug 2021 20:55:48 -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=gD9ah6vfgzNO0EDh/fgGFyEHak0Syu4+YvWk62gPhQA=; b=yFXC0gwb+N0guip7oQqK4473UXpg3KJKiqPTY+H2ExtyAgv9Oqn5/2h7ZK71GHX/B+ phs99iKotIT3FJSGCD3PTIYvTfeBP+EsVh0lpmJ9qwizTyXWWL1nJns2CwzKs1wYpb97 fkevAy9RD8MNHOcDi858Vn8HWPZ0RGOt4lqbnQIA8lHiRMI3q8nVepMuPjKeNfKTCpF7 RrnagGtr7CCEWlSz8xehz8Ov3T/GAfAEnSrSJka0HupKViWuIKBOKIA3NGVZbXBhcpiO 0IFVPbf9UkyeBfLd78uF6KcVThiYuHqvyX7oRHs3NXQ/kAJuOfqV+iXCrnsh58/GX4Ex KDPQ== 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=gD9ah6vfgzNO0EDh/fgGFyEHak0Syu4+YvWk62gPhQA=; b=A+lv3lfGVbSvNKfcjPldIgWiodWXQKRFxsBL9BEEm8S6WfP/iR6MVElxEKbt3vfCDR 8V+PKWYjELwYwZR3bcI27UMlEbW+79eQMbJTgdgdpbzERTZ97+dm2cR/g8FSxiZuvts5 jmpMbCuybq9goP3pg6gPN4ylBN55YTlOHOoPWrv0NOnxt7453lShxTAL1zzfcS4qzdIl U7fazkd0KQaNTWq2b3Ek7oP5g/UBV37Z/ViQzG/OQ+beItgbKpW0DKu0qFBs79aLhzgD k+5RD3vm+oQQim+/w/OL3oq989xgcXfYllHMuEYEJpnHVlwcG+2IQuUbTDb2ijjwvatW RDSw== X-Gm-Message-State: AOAM530hF3LUiudzPRqyOqIWfy7SXS8RI9vTttMhfoQN4W5fFEdMlIgW lEUNl1fedSJhoW+Sw9IwD7Q+lVPF67s8iQ== X-Google-Smtp-Source: ABdhPJz9QdCKGFKOLzo5UNyLxFABH8R+f3/Sb97BqEdfS9hbNEvSBS0yItbeNdqtpLKSMoSH6W6OWA== X-Received: by 2002:a17:90a:c908:: with SMTP id v8mr4859872pjt.196.1629604547255; Sat, 21 Aug 2021 20:55:47 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 13/30] linux-user/hexagon: Use force_sigsegv_code Date: Sat, 21 Aug 2021 20:55:20 -0700 Message-Id: <20210822035537.283193-14-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::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new function instead of setting up a target_siginfo_t and calling queue_signal. Note that we were incorrectly using QEMU_SI_KILL instead of QEMU_SI_FAULT for raising SIGSEGV. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/hexagon/cpu_loop.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c index bc34f5d7c3..6095ca06ca 100644 --- a/linux-user/hexagon/cpu_loop.c +++ b/linux-user/hexagon/cpu_loop.c @@ -21,13 +21,13 @@ #include "qemu/osdep.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "internal.h" void cpu_loop(CPUHexagonState *env) { CPUState *cs = env_cpu(env); - int trapnr, signum, sigcode; - target_ulong sigaddr; + int trapnr; target_ulong syscallnum; target_ulong ret; @@ -37,10 +37,6 @@ void cpu_loop(CPUHexagonState *env) cpu_exec_end(cs); process_queued_cpu_work(cs); - signum = 0; - sigcode = 0; - sigaddr = 0; - switch (trapnr) { case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ @@ -66,8 +62,8 @@ void cpu_loop(CPUHexagonState *env) case HEX_EXCP_FETCH_NO_UPAGE: case HEX_EXCP_PRIV_NO_UREAD: case HEX_EXCP_PRIV_NO_UWRITE: - signum = TARGET_SIGSEGV; - sigcode = TARGET_SEGV_MAPERR; + /* FIXME: need to store vaddr in hexagon_tlb_fill */ + force_sigsegv_for_addr(0); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); @@ -78,16 +74,6 @@ void cpu_loop(CPUHexagonState *env) exit(EXIT_FAILURE); } - if (signum) { - target_siginfo_t info = { - .si_signo = signum, - .si_errno = 0, - .si_code = sigcode, - ._sifields._sigfault._addr = sigaddr - }; - queue_signal(env, info.si_signo, QEMU_SI_KILL, &info); - } - process_pending_signals(env); } } From patchwork Sun Aug 22 03:55:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D499C4338F for ; Sun, 22 Aug 2021 04:08:37 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2466461247 for ; Sun, 22 Aug 2021 04:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2466461247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHemi-0007wv-5K for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaM-0007q3-V5 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:51 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:54829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaL-0000gJ-Fv for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:50 -0400 Received: by mail-pj1-x1033.google.com with SMTP id n5so9807499pjt.4 for ; Sat, 21 Aug 2021 20:55:49 -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=1vrWXXk2QGk0hTQCIleqy7sIqee8vTHllkla9WWLZlc=; b=JHpHPx0ooW1Il+WvyGLE3GWbFwP+YU9ohioLo0VuVDpk1lcJuOdEcyBSCckLQI4GeM CkMFVUPjAky7dwYbnnC1cNFVb+wCuGxz0JdstwAZ5oF023fpp342zeS/M8F8Oi2MVzmO pDjxtHTJhEmZombFkvplfrottSL9+hR/eKKSmf5uyVgn3NISYvjBDGtdaIFceCGn40Tx Tl135xg8RjZMJsQWIylN0Xd8BY6BTs0QeQEJlYtWxeG/hxCx1Y/FEyQO7tsBbpGsgo7R X4Ie5/KRRo+AS3aILOHShlEFlUYe/1ZK5i7HQvbTBNLTIlnSDJrRFqDMfIOjfZ8sqY+0 MfJA== 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=1vrWXXk2QGk0hTQCIleqy7sIqee8vTHllkla9WWLZlc=; b=D0GebufwLtqzOmxr4l8cIwa2972X1aEvb/7W/EXeDQ4r6WoPIZ3Z6kFq++Ep5XTiih LDLUx64KoeRUdQ2dSAjzpSVyFT/bR6iqPDPWTkYhUbxfsyUzEYJz4ecl3OeqzPUlAsgu 9ID6c4JKiWKteQSkOsuKbYXtr6GSt6cSEcjy94oxLMfmneqlDGYYfhWpfHMJvqXs5XBK csSoPXIq904rOkQiOQiiKPXZ/6s550lyNx1DNDC/dfiTQVFcBrNLvCSPXAQQcIVTXLjZ j3N2JWXgVVuQBe/XXCjFzkz398C6Y3s6jhU+kK16AzTj2ubDprn04Lxxfy7B2qaTxmPK eKXA== X-Gm-Message-State: AOAM5322bhVBZA4dRYqPeyRONQVdlrTFDpHq+35y26eGGtsHI6rY4ZEi HPQSK1sib5CCzdlGknPQgNmOOEYhuQHEaw== X-Google-Smtp-Source: ABdhPJzkd+r6AqrVybe0sL/bzF+76RhO7126+8uRwDq5XcKeEpuVEOocqmj+zqJ4ZVX22kbQHse4DA== X-Received: by 2002:a17:90a:a087:: with SMTP id r7mr12962651pjp.84.1629604548389; Sat, 21 Aug 2021 20:55:48 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/30] linux-user/hppa: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:21 -0700 Message-Id: <20210822035537.283193-15-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::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/hppa/cpu_loop.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 82d8183821..3500b2c291 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -20,6 +20,8 @@ #include "qemu/osdep.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + static abi_ulong hppa_lws(CPUHPPAState *env) { @@ -108,7 +110,6 @@ static abi_ulong hppa_lws(CPUHPPAState *env) void cpu_loop(CPUHPPAState *env) { CPUState *cs = env_cpu(env); - target_siginfo_t info; abi_ulong ret; int trapnr; @@ -152,42 +153,23 @@ void cpu_loop(CPUHPPAState *env) case EXCP_PAGE_REF: case EXCP_DMAR: case EXCP_DMPI: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_ACCERR; - info._sifields._sigfault._addr = env->cr[CR_IOR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->cr[CR_IOR]); break; case EXCP_UNALIGN: - info.si_signo = TARGET_SIGBUS; - info.si_errno = 0; - info.si_code = 0; - info._sifields._sigfault._addr = env->cr[CR_IOR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->cr[CR_IOR]); break; case EXCP_ILL: case EXCP_PRIV_OPR: case EXCP_PRIV_REG: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = env->iaoq_f; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f); break; case EXCP_OVERFLOW: case EXCP_COND: case EXCP_ASSIST: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = 0; - info._sifields._sigfault._addr = env->iaoq_f; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, 0, env->iaoq_f); break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->iaoq_f); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ From patchwork Sun Aug 22 03:55:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B5A7C432BE for ; Sun, 22 Aug 2021 04:08:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E4A3B61247 for ; Sun, 22 Aug 2021 04:08:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E4A3B61247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHemj-00080l-3b for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:08:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaN-0007qX-HA for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:52 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:40538) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaM-0000gV-6G for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:51 -0400 Received: by mail-pj1-x102a.google.com with SMTP id n13-20020a17090a4e0d00b0017946980d8dso16420672pjh.5 for ; Sat, 21 Aug 2021 20:55:49 -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=jgJJjeTXjiUbDbukKE88rjflxSR0+x8oJyqtKcc0hjQ=; b=Gj3DeRrQ3WVvfNNZ/wsC05LHMuAg4oi87tQTGJeVeEO0w25mz8bq4D7Sl+KHxVyvNJ 72xA0UTF7cz21IrPT9dPTwwMmpDeNT61fFQY4oj69uNB962DC1SDMW+KwHp5f8o0m8Wl k8Fwczdgz/kRy652jOzwWPXu9yJcOWi4b/FCCyq4D5jtFC3qOFF9vSRF0Vozu51TG075 AEcMw5cP9+onml+cbMcjtl+OwYs3GsaT6Fp08aaj+JVwyBFrgidBCCKWeXDXDwCXqjfD oAYJiKZC2ouxuAD8LrWDrhv5h/HtVtLctlptV1c3vQBWWW7CxPN4YG9vAwuIywEgoUFK /VZg== 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=jgJJjeTXjiUbDbukKE88rjflxSR0+x8oJyqtKcc0hjQ=; b=Y8S1gX52h3zytPKopWY/xxaEzlx/UH5f2SK/vUd1rgdBlmmEVy0eoLPK89EBqqRDLp kQAs+oYTyFPN/Z0jHHngTQpnjztTY841kI8rqNv1R8hwD0eNpyxSRv5J8ADtQ3wzoMcV oMC3zYea1W3AXEXQZBNeyf4bJSMvR5KsxOeM9kCeKzEDfkZNMmGEFTw9cK6e/sqZQyJA a6SBoframuwcBAVGoNYUkNNnJ7Npny+mLnut0xP7XKgaHDEJVL7Sn+erEcHJcBLopSVy 7jNC76s/rkTHHlJNgC3Hnmh+bQYqEMuHabUCQ7SAYdzIWxjsmo+RfuLi4NE8eFlArQkA DmjA== X-Gm-Message-State: AOAM533O1jfQqlbKQRzlb/LTu2kAOyLfJNkLScxEE3/zXS2h6Eu8PrNj gVVnpxiUQasx4eRc8lMl7ouGzB0AqeQahw== X-Google-Smtp-Source: ABdhPJxwPCFuUZJyziHZuAW3ygTEfIbGyEMgRUlZNmWBQtz1/oVIJVNGGWZ+6BZ/cLX2KqYXyHEnzw== X-Received: by 2002:a17:903:2443:b0:12e:6093:2877 with SMTP id l3-20020a170903244300b0012e60932877mr20146060pls.21.1629604548904; Sat, 21 Aug 2021 20:55:48 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/30] linux-user/hppa: Use the proper si_code for PRIV_OPR, PRIV_REG, OVERFLOW Date: Sat, 21 Aug 2021 20:55:22 -0700 Message-Id: <20210822035537.283193-16-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" These si_codes have been properly set by the kernel since the beginning. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/hppa/cpu_loop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 3500b2c291..7bc85dffd0 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -159,11 +159,17 @@ void cpu_loop(CPUHPPAState *env) force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->cr[CR_IOR]); break; case EXCP_ILL: - case EXCP_PRIV_OPR: - case EXCP_PRIV_REG: force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f); break; + case EXCP_PRIV_OPR: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f); + break; + case EXCP_PRIV_REG: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVREG, env->iaoq_f); + break; case EXCP_OVERFLOW: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, env->iaoq_f); + break; case EXCP_COND: case EXCP_ASSIST: force_sig_fault(TARGET_SIGFPE, 0, env->iaoq_f); From patchwork Sun Aug 22 03:55:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C583FC4320E for ; Sun, 22 Aug 2021 04:15:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6E1136126A for ; Sun, 22 Aug 2021 04:15:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6E1136126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHetY-0001wE-Jn for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:15:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaP-0007rM-6S for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:39924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaM-0000hC-Mk for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:52 -0400 Received: by mail-pj1-x102a.google.com with SMTP id oc2-20020a17090b1c0200b00179e56772d6so6573897pjb.4 for ; Sat, 21 Aug 2021 20:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jKxkWJetc9mOamPS46VjF9q1E3iRdGdDObeSI1Rk2wY=; b=s4PImu7w7akX/eHAWYCNWLnjz0bbwMF3F+YbTeGtdfTkvEEgkKq0bNu0nTC1TwB4/x bWXaDk8OCdGewwM0ZD51LXcshT74dPWcMf5VzJ5vHY5KvN5C3BK4fWMTAqRdO8Bp5M6r YKxo3j8Xhhdn/4RtP4LYaQU6C3DCMJYPuq5+yOD6cguW9GM9zmCIKE50cCOUekqd4FIJ Rh6WMP1XK0tLeP/LHaOgdNZN9oN/1gRSmetIjK/bIssEFi+m45iTjcXGQdzLWLKkSBv1 Gre8b7QJtjiT7KMFkyx6znWlvSGx9HaxCdwnnx56lh59DSxqpzn6aJ9EcEk9I8g2Jp65 qNiA== 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=jKxkWJetc9mOamPS46VjF9q1E3iRdGdDObeSI1Rk2wY=; b=aWjULolKyyYSepXgHuUv+gUm5NjE7aFEzVuho4k1HZ9IYLwO9NSFmtoezGbUuBV0iq t8nPx10WeFJueRLOcLvajS8V+QUbhtnp/uKv2gE6U0kVwbxj4sTnIzWuZpmfpd1p13mj Nc2C4hHr6d+6vp6byOyDEiid6m833DZlEBtq8lfsB1gA+70ku2YuGTAbb5mizt+x2JkT GGOhrUuc/UTnxcrYmZwYrBS/VmHonXEPxwPt0bV/WpqJFVvEqn40ITv6sqKA0ovkEkkw oZdmBiI3wl8S/OyxYcn+bQUY1R4Rkm/iv2N5O2vV3cVl0p17e+aAR+V0zU4PF0Zl8Jm3 rY+w== X-Gm-Message-State: AOAM533rW0/HvPRaOQ7CWsIIsnhyj2ah+SiQyLjn7lMr3f3zb35qRI5q 0fBJZVJv77p/gBXnIOqAgPuCRoOX9+hTvw== X-Google-Smtp-Source: ABdhPJweM9FDrHpO38NSCUOWdLvOdCLq7L8Y8n+F7feTB4nHlTtgrMLcHPD3NtSswTmhLk2EdWFY0g== X-Received: by 2002:a17:90b:1102:: with SMTP id gi2mr12909025pjb.43.1629604549559; Sat, 21 Aug 2021 20:55:49 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 16/30] linux-user/hppa: Set FPE_CONDTRAP for COND Date: Sat, 21 Aug 2021 20:55:23 -0700 Message-Id: <20210822035537.283193-17-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This si_code was changed in 75abf64287cab, for linux 4.17. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/syscall_defs.h | 1 + linux-user/hppa/cpu_loop.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 55ccc6ae03..f9efbffe0c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -688,6 +688,7 @@ typedef struct target_siginfo { #define TARGET_FPE_FLTINV (7) /* floating point invalid operation */ #define TARGET_FPE_FLTSUB (8) /* subscript out of range */ #define TARGET_FPE_FLTUNK (14) /* undiagnosed fp exception */ +#define TARGET_FPE_CONDTRAP (15) /* trap on condition */ #define TARGET_NSIGFPE 15 /* diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c index 7bc85dffd0..cc076e7cdb 100644 --- a/linux-user/hppa/cpu_loop.c +++ b/linux-user/hppa/cpu_loop.c @@ -171,6 +171,8 @@ void cpu_loop(CPUHPPAState *env) force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, env->iaoq_f); break; case EXCP_COND: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_CONDTRAP, env->iaoq_f); + break; case EXCP_ASSIST: force_sig_fault(TARGET_SIGFPE, 0, env->iaoq_f); break; From patchwork Sun Aug 22 03:55:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3D3AC4338F for ; Sun, 22 Aug 2021 04:12:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7786F61130 for ; Sun, 22 Aug 2021 04:12:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7786F61130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:55828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeqI-0005Gj-Ew for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:12:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaQ-0007rW-2D for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:42786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaN-0000ht-Ca for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:53 -0400 Received: by mail-pj1-x102b.google.com with SMTP id mq2-20020a17090b3802b0290178911d298bso9907114pjb.1 for ; Sat, 21 Aug 2021 20:55:51 -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=Aoy4O375ZO7hM1BTzhLh8wcId79QwPq349k/5KQ0lXY=; b=ml0s82ZddlQ+EDgwGzqJngs/c9cXOYSbyW0bP5lupk5AKzJGoScFuh9IQSdNv732tu 3UzTLYNVh8WjoJfmkIxX/Hthqn5q5iMTSAs0kHL14jdqtD/aZ4+CTFzZ4KMc/710QzfF WMLzIUUpwWcx5MDzJ03TOL8S3v8VIQxYM+rtRC1jC/nPQoyP2uMlqxoswGz6HchHrt8u 8YMfHr1fDniHZKJgoxF8R0rLoIyB+0MQtv+SFMLQSx8wQoIgYP9nN6RW2EkjjYKBVVYn 61TbXMp3FRNijPYbmJcK5kd6Kw5b8YJZtfiL5YFezH2Fm7t0vtHiUqm7g+lUVQNw8xFx rvbA== 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=Aoy4O375ZO7hM1BTzhLh8wcId79QwPq349k/5KQ0lXY=; b=uYzBl+IGCggqDUX3sf+bJEWqsXVAM87I8kJehWka9NWZCuUGr6064/Jyddfowl7WdI DwDVqOMxWmDwMI15ptQBKnwuU5pDfVqWPQ13Y53u7n9gzSv+RbmkynasdlFzmdiecJg2 iZ5vD8dP1SDRW3JmGSaDTOT5MTMtRmhegophFVzYfbATgLPdDpelOSohlX4BQEe1WG9b FY3IsrgjP+A1572vX8poo+QJWpvCnr/BTCSDY5jTzKXb92nGrwz2njrRCIfid8kB3HBc SWG1w9OAVxl1nJmsHoQNfXb0zDloVarTjloT6yOZUQrNBW5XQjKT8Iq3bu2OtBJbgl5L o1oA== X-Gm-Message-State: AOAM530Ml8xbWSPj5ZPgzZKPHWpcvkvix3gWaY7Pd0Ul1cEpKZrGssqt KVpwMrREE+ikDLxsOYK3xSeWCiokWycvlw== X-Google-Smtp-Source: ABdhPJzWjNTy3YSPoNei79KOvNrFaUwOifteR5OSsHDuCvoHBc+71OtMVIdiLBA3ywmOWS5IoW8+3w== X-Received: by 2002:a17:902:b711:b029:11e:6480:258a with SMTP id d17-20020a170902b711b029011e6480258amr23135868pls.41.1629604550154; Sat, 21 Aug 2021 20:55:50 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 17/30] linux-user/i386: Split out maybe_handle_vm86_trap Date: Sat, 21 Aug 2021 20:55:24 -0700 Message-Id: <20210822035537.283193-18-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::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reduce the number of ifdefs within cpu_loop(). Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/i386/cpu_loop.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index f813e87294..5866e98441 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -195,6 +195,17 @@ static void emulate_vsyscall(CPUX86State *env) } #endif +static bool maybe_handle_vm86_trap(CPUX86State *env, int trapnr) +{ +#ifndef TARGET_X86_64 + if (env->eflags & VM_MASK) { + handle_vm86_trap(env, trapnr); + return true; + } +#endif + return false; +} + void cpu_loop(CPUX86State *env) { CPUState *cs = env_cpu(env); @@ -256,12 +267,9 @@ void cpu_loop(CPUX86State *env) break; case EXCP0D_GPF: /* XXX: potential problem if ABI32 */ -#ifndef TARGET_X86_64 - if (env->eflags & VM_MASK) { - handle_vm86_fault(env); + if (maybe_handle_vm86_trap(env, trapnr)) { break; } -#endif gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); break; case EXCP0E_PAGE: @@ -271,22 +279,16 @@ void cpu_loop(CPUX86State *env) env->cr[2]); break; case EXCP00_DIVZ: -#ifndef TARGET_X86_64 - if (env->eflags & VM_MASK) { - handle_vm86_trap(env, trapnr); + if (maybe_handle_vm86_trap(env, trapnr)) { break; } -#endif gen_signal(env, TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip); break; case EXCP01_DB: case EXCP03_INT3: -#ifndef TARGET_X86_64 - if (env->eflags & VM_MASK) { - handle_vm86_trap(env, trapnr); + if (maybe_handle_vm86_trap(env, trapnr)) { break; } -#endif if (trapnr == EXCP01_DB) { gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip); } else { @@ -295,12 +297,9 @@ void cpu_loop(CPUX86State *env) break; case EXCP04_INTO: case EXCP05_BOUND: -#ifndef TARGET_X86_64 - if (env->eflags & VM_MASK) { - handle_vm86_trap(env, trapnr); + if (maybe_handle_vm86_trap(env, trapnr)) { break; } -#endif gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); break; case EXCP06_ILLOP: From patchwork Sun Aug 22 03:55:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451163 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6424C4320E for ; Sun, 22 Aug 2021 04:12:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 320986124E for ; Sun, 22 Aug 2021 04:12:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 320986124E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:55854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeqI-0005HU-W8 for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:12:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaQ-0007rb-KP for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:36486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaO-0000jA-U7 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: by mail-pl1-x62a.google.com with SMTP id f1so1365815plg.3 for ; Sat, 21 Aug 2021 20:55:51 -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=3KgmD/eYr3iehKDdNb5+g/qn4jDvTdLMR/PvVQX5enI=; b=DWTQ3qJf7dwxazOLmwmBgb3A8U/dCCP9BCCtsASL1DJsEMT45g1ENCWiUg5rgirBRw 6LdMDAzrdv3n1n3+/j7D0QzM2lMIDploxnsOhIn8wSSnBmCOUyt2zaVle/wQU7ZECLSj DHTNgnnet+83mxemyVi93V78jdMi0K6ITt2YqW2u4ki02tzqGM7eRQo/WMu2wxMoZq/b xX1isnet37EEelqei6Ch4MXYM50+rlg9Iss5VVo60Z3iJlVeZqn5UiNjPEjR+yLQNelk NdT+9Z1kAEtmcSL68dExR+IwfcYCxRjSc4ds2OZF4rHoCLno9jEX5SB3p73bo4SoXDkw 8dSw== 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=3KgmD/eYr3iehKDdNb5+g/qn4jDvTdLMR/PvVQX5enI=; b=hfwD55xYysk3+wLkM5wAJZHbVjXiMaAL0xsnvYtHsLrFoNHjQs89u1XK4lM0XI329A 46r/zC2HUCSvz/A17C6GWZVFrTsmigKRKhGmHGZPCbOBbf7yqVhZXZUwuvAyTDnoCkEj +9qM32uZwmUp9DyRypARtjTu7qiU1bpRiJunE/Tn+XJx9c012s3xaEPoMbEkH83WZQga FCAYQHCJaY6gNr+nQx2tmPWrhGUpCs880XoWvZ1MrSndypy+w60qMo2QaHP1jq8pE7G4 Ko2NMpczdSnmwjOQ9HelebJhL/PLcyerogGlusRVJlF7XcvK1F8T0g2nIHUkp3y36ZF+ qw7w== X-Gm-Message-State: AOAM530m8kBd+xnmMFCeOy70MERMmkxCmWHogMbHm4+4GMui2Kb1lywA WMEmKArbmy4RFLNWTeb0FuQpJGSf4GIsUQ== X-Google-Smtp-Source: ABdhPJxBGqOtzgtR5Mk95Op8xqY77QyIxAPjzXFk01Q20CRV0E/UN2e4R17Qxs+JceOwuJGWRc8tHg== X-Received: by 2002:a17:90a:4e8c:: with SMTP id o12mr12781267pjh.118.1629604550790; Sat, 21 Aug 2021 20:55:50 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 18/30] linux-user/i386: Use force_sig, force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:25 -0700 Message-Id: <20210822035537.283193-19-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::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace the local gen_signal with the generic functions that match how the kernel raises signals. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/i386/cpu_loop.c | 46 +++++++++++++------------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/linux-user/i386/cpu_loop.c b/linux-user/i386/cpu_loop.c index 5866e98441..787d4ccfc0 100644 --- a/linux-user/i386/cpu_loop.c +++ b/linux-user/i386/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" /***********************************************************/ /* CPUX86 core interface */ @@ -81,17 +82,6 @@ static void set_idt(int n, unsigned int dpl) } #endif -static void gen_signal(CPUX86State *env, int sig, int code, abi_ptr addr) -{ - target_siginfo_t info = { - .si_signo = sig, - .si_code = code, - ._sifields._sigfault._addr = addr - }; - - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); -} - #ifdef TARGET_X86_64 static bool write_ok_or_segv(CPUX86State *env, abi_ptr addr, size_t len) { @@ -103,8 +93,7 @@ static bool write_ok_or_segv(CPUX86State *env, abi_ptr addr, size_t len) return true; } - env->error_code = PG_ERROR_W_MASK | PG_ERROR_U_MASK; - gen_signal(env, TARGET_SIGSEGV, TARGET_SEGV_MAPERR, addr); + force_sigsegv_for_addr(addr); return false; } @@ -190,8 +179,7 @@ static void emulate_vsyscall(CPUX86State *env) return; sigsegv: - /* Like force_sig(SIGSEGV). */ - gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); + force_sig(TARGET_SIGSEGV); } #endif @@ -263,53 +251,51 @@ void cpu_loop(CPUX86State *env) #endif case EXCP0B_NOSEG: case EXCP0C_STACK: - gen_signal(env, TARGET_SIGBUS, TARGET_SI_KERNEL, 0); + force_sig(TARGET_SIGBUS); break; case EXCP0D_GPF: /* XXX: potential problem if ABI32 */ if (maybe_handle_vm86_trap(env, trapnr)) { break; } - gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); + force_sig(TARGET_SIGSEGV); break; case EXCP0E_PAGE: - gen_signal(env, TARGET_SIGSEGV, - (env->error_code & 1 ? - TARGET_SEGV_ACCERR : TARGET_SEGV_MAPERR), - env->cr[2]); + force_sigsegv_for_addr(env->cr[2]); break; case EXCP00_DIVZ: if (maybe_handle_vm86_trap(env, trapnr)) { break; } - gen_signal(env, TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip); + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->eip); break; case EXCP01_DB: + if (maybe_handle_vm86_trap(env, trapnr)) { + break; + } + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip); + break; case EXCP03_INT3: if (maybe_handle_vm86_trap(env, trapnr)) { break; } - if (trapnr == EXCP01_DB) { - gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip); - } else { - gen_signal(env, TARGET_SIGTRAP, TARGET_SI_KERNEL, 0); - } + force_sig(TARGET_SIGTRAP); break; case EXCP04_INTO: case EXCP05_BOUND: if (maybe_handle_vm86_trap(env, trapnr)) { break; } - gen_signal(env, TARGET_SIGSEGV, TARGET_SI_KERNEL, 0); + force_sig(TARGET_SIGSEGV); break; case EXCP06_ILLOP: - gen_signal(env, TARGET_SIGILL, TARGET_ILL_ILLOPN, env->eip); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->eip); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - gen_signal(env, TARGET_SIGTRAP, TARGET_TRAP_BRKPT, 0); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->eip); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD988C4338F for ; Sun, 22 Aug 2021 03:59:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 70ABB6126A for ; Sun, 22 Aug 2021 03:59:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 70ABB6126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHedd-0007tr-IW for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 23:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaT-0007u5-EZ for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:40931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaO-0000jK-US for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:57 -0400 Received: by mail-pl1-x629.google.com with SMTP id c4so8203147plh.7 for ; Sat, 21 Aug 2021 20:55:52 -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=RYjmBhcWv8W1mWgf+iyy6mrMx77vnB1Iku9AxHwG4eY=; b=G6pOwZ/L4OJoJcA9EhSYMO4KGZADMKlqX0g0i7UPaWDKnJVQt43P33isawJ6KkRJCL iuoISLKFDkvRwwzNjFPJf4+n55Di1RnQPuka5iSUCmGuqDMr/ew5gvN7OUmq+yvJgckc qoFEev6wKnhoQmVgvohYteKyYnhphQAp6exEQS/77u7a7Xwh92N28I5eTXiDtHFk/k5N f+QXEf0xV8Jmgcorcjl9FRCZDFP8I+E64TJB2bzxbo71gHR5LAA7lJTqWUZPYkjTKLjs raArEil4QvCdBF8QWdhfAzdGNGz8tMZK15cN9hUoO1JQ6RRWvGMlvUmyDDbFvHax6GyW B8rA== 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=RYjmBhcWv8W1mWgf+iyy6mrMx77vnB1Iku9AxHwG4eY=; b=NjV37Z434CRwLygunDTMPUnO34ya5QiaqCzGwlc4BGkciwY5wlwaNJYR8K+KAydvRC HUKZ90EkTmQa6Evix8OMYCmZZCKIcb+e0YP+m5FHgUTk5CkOhIJ368jDuXWkWaCplXNl 3vdAHqVUw0GTWXw0rbUDHmfPRPX8bQfQs0Eft3315Cxh/cUbhxZLt58ZxJcZ62777Qfd CRoFuhNz1uLl1dBqUgqaTbWOjjfP+JD4lRvNd9MzizVlHaP9h9EI/6ETVMVcJ6h9jfd5 T+1YTmgBtHho8c4ycrVlklfMziXmz/J1V4qtgnvKQ45iYRL/gUtfcce7GIjkj6e/jA7S 89nQ== X-Gm-Message-State: AOAM531uFJzyHmqND2xwxho0bLq5to0R0Q3uy+Kqfs+KvUlHDC+Dh1kd y9D0s+r4h/57Q/ZItdeev8LGG5Dstv3apw== X-Google-Smtp-Source: ABdhPJweI4ZcFq7hkNZ7y/HTk6pS4zXjPkdZvCDW26V64zWeY5kONek0cbfjfkotNewLBcTRuNJGWA== X-Received: by 2002:a17:90a:d181:: with SMTP id fu1mr10146545pjb.147.1629604551393; Sat, 21 Aug 2021 20:55:51 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 19/30] linux-user/m68k: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:26 -0700 Message-Id: <20210822035537.283193-20-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::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/m68k/cpu_loop.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index c7a500b58c..aa46fdcc77 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -21,13 +21,14 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + void cpu_loop(CPUM68KState *env) { CPUState *cs = env_cpu(env); int trapnr; unsigned int n; - target_siginfo_t info; for(;;) { cpu_exec_start(cs); @@ -44,25 +45,13 @@ void cpu_loop(CPUM68KState *env) case EXCP_ILLEGAL: case EXCP_LINEA: case EXCP_LINEF: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPN; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->pc); break; case EXCP_CHK: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_INTOVF; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, env->pc); break; case EXCP_DIV0: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_INTDIV; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, env->pc); break; case EXCP_TRAP0: { @@ -89,20 +78,10 @@ void cpu_loop(CPUM68KState *env) /* just indicate that signals should be handled asap */ break; case EXCP_ACCESS: - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->mmu.ar; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + force_sigsegv_for_addr(env->mmu.ar); break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DF17C4320A for ; Sun, 22 Aug 2021 04:17:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0046A6126A for ; Sun, 22 Aug 2021 04:17:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0046A6126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHevm-0005mQ-4c for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:17:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0007sY-5W for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:55 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:53107) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaP-0000jP-95 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:54 -0400 Received: by mail-pj1-x102e.google.com with SMTP id h1so3973065pjs.2 for ; Sat, 21 Aug 2021 20:55:52 -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=dr8YFAi1pWZfR1DWEP4KGLo0RnLMDZepAc49PU2qFmg=; b=vMuzBMlqCx/9oLnvwIRAReqBvERb4fj/ZWZyQhS5wUecWJvNEku7suBaIlsm8al4aB JFhSdQBikOk0hAd/BgD0bwWxqNXyB40jORcX8k0uXhO4Qx+MlPZpWMFaJwKW4aqPGGrO ZZfkgd6X6jkGC65GiPKS5nZPyFhEZ92rVU5Yb6YEQ6GgfduBcFIupTIylUdb6j/nzlmR zk/yrcxNDobf2P4yeutaWs12v23fQ9+P5zjx0oKYuLZmIGciKyGRISP66b3ityVSZK8I pzunGrxBIIVY+6T1F99ClxzMENjmKWbp+/6pLa/BSqh02rvWa9NK/lzKOh6MSzDyuYoZ 2few== 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=dr8YFAi1pWZfR1DWEP4KGLo0RnLMDZepAc49PU2qFmg=; b=FptA7nxmPKgDRb+qL46CgRaoUTmmwXOl33QgGZbJoFCLAYmWoWhDBwTU4W5KhhhSuV VejwhosNwdzPdhwPBSTMkoionwAfvOS8BxfIMdCuws31qNEet0/FUy4Y0o5+r8M/ReEz aNMaguFAa0rd1jAlV65V/qbAxJNw1FZ6wsiHAdRMlwOKgTZ4VQ3Iih8bdq6mwxagfBvi PqvWvHtd8hhhflBEdCT2C/SEQhjlSdbfawb3QD1CSZMkGziYWMIj8R2hQcxjQTCuoiHP /DeoncqSy/loe/LAHi6RFp/qDjVdcrdivJ3EP4mS5TUUjKFfej8lC2eXakjsoa2dYfqG JcRg== X-Gm-Message-State: AOAM5339dLR1pTiQ7njk4x+xadgEnReEX5EPuBx8kVRjOx4ibQZfRX+C 7mQ2n+6xav7kwzhgFfdD/tLwsDYh7InObw== X-Google-Smtp-Source: ABdhPJwwCDhnDq+FcFqRPBqXcv6/de3VSX+jDOFY2jsItqCfjVNPCWcZeasqLGq3MzU2+qZkztkCHQ== X-Received: by 2002:a17:902:e54e:b029:12d:76cd:6744 with SMTP id n14-20020a170902e54eb029012d76cd6744mr23023566plf.0.1629604552015; Sat, 21 Aug 2021 20:55:52 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 20/30] linux-user/microblaze: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:27 -0700 Message-Id: <20210822035537.283193-21-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/microblaze/cpu_loop.c | 73 +++++++++++++------------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c index c3396a6e09..9e07e52573 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -21,13 +21,14 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + void cpu_loop(CPUMBState *env) { CPUState *cs = env_cpu(env); - int trapnr, ret; - target_siginfo_t info; - + int trapnr, ret, si_code; + while (1) { cpu_exec_start(cs); trapnr = cpu_exec(cs); @@ -36,18 +37,12 @@ void cpu_loop(CPUMBState *env) switch (trapnr) { case 0xaa: - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + /* FIXME: save vaddr in tlb_fill */ + force_sigsegv_for_addr(0); break; case EXCP_INTERRUPT: - /* just indicate that signals should be handled asap */ - break; + /* just indicate that signals should be handled asap */ + break; case EXCP_SYSCALL: /* Return address is 4 bytes after the call. */ env->regs[14] += 4; @@ -75,6 +70,7 @@ void cpu_loop(CPUMBState *env) */ env->regs[14] = env->pc; break; + case EXCP_HW_EXCP: env->regs[17] = env->pc + 4; if (env->iflags & D_FLAG) { @@ -82,42 +78,31 @@ void cpu_loop(CPUMBState *env) env->pc -= 4; /* FIXME: if branch was immed, replay the imm as well. */ } - env->iflags &= ~(IMM_FLAG | D_FLAG); - switch (env->esr & 31) { - case ESR_EC_DIVZERO: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_FLTDIV; - info._sifields._sigfault._addr = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - case ESR_EC_FPU: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - if (env->fsr & FSR_IO) { - info.si_code = TARGET_FPE_FLTINV; - } - if (env->fsr & FSR_DZ) { - info.si_code = TARGET_FPE_FLTDIV; - } - info._sifields._sigfault._addr = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - default: - fprintf(stderr, "Unhandled hw-exception: 0x%x\n", - env->esr & ESR_EC_MASK); - cpu_dump_state(cs, stderr, 0); - exit(EXIT_FAILURE); - break; + case ESR_EC_DIVZERO: + si_code = TARGET_FPE_FLTDIV; + break; + case ESR_EC_FPU: + si_code = 0; + if (env->fsr & FSR_IO) { + si_code = TARGET_FPE_FLTINV; + } + if (env->fsr & FSR_DZ) { + si_code = TARGET_FPE_FLTDIV; + } + break; + default: + fprintf(stderr, "Unhandled hw-exception: 0x%x\n", + env->esr & ESR_EC_MASK); + cpu_dump_state(cs, stderr, 0); + exit(EXIT_FAILURE); } + force_sig_fault(TARGET_SIGFPE, si_code, env->pc); break; + case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451185 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13B86C4338F for ; Sun, 22 Aug 2021 04:20:28 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 95AA761284 for ; Sun, 22 Aug 2021 04:20:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 95AA761284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeyA-0000CZ-Kh for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:20:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0007tQ-D5 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:35548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaP-0000jS-Q0 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:55 -0400 Received: by mail-pg1-x536.google.com with SMTP id e7so13334123pgk.2 for ; Sat, 21 Aug 2021 20:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V4ABiYbSFXZhLI78uqHDE/IKCat0vkJCalHfW7nxEF0=; b=Kq8r5nzYbdmfv1JWiEddnS4y948QncZZa9UzDyipdzH3flWX29k+/DkYMi/ufqYcSZ h/mLflqbN0ccYh+3S1AC/cg6NgXNcibmUZxldbtC+IJjhzN8YsPUkYIumy7NMrSd/WKS PJ9dqNzy6qEKGminyiVtOYLJYEM1mOpzvo2ZcoMUhg+mavWDOtpdUnNpVtkS5UQRxcXm nowufJUD83BUuGbY6Zn5KhWotuh0aIAKFyMR/jZWy2LDhPTwnOvIAvhtjIP90kvlFAJS 3Jx93QGJUuK9SZSUQL6pDhu6n7mjc1uq0gDYaCfYFr0qyhxLh9a5W5XDLqTFluFK2pvz 2MtQ== 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=V4ABiYbSFXZhLI78uqHDE/IKCat0vkJCalHfW7nxEF0=; b=JMr1KLEDFq9DGytkgO9LwxgrOnbrP3XXyf7ovkm6sFsz3ZgXimvrZTkHAVuYiWwYlI h6jKDXrA0T7NYt3daUhgGUzbPFxSOdg33S8HsYMdHURdKwgQVFszf9ea49UDXicnHbut JZmCwWhRcwnp729CQcj1AtPdarcDnJBwtsjvooteLnHi+AdCizfKzWeL1KvjAqc1gX43 Tdx71z/NJa+yRXNK2KlkPhJyV4HFLoxwV7cmKgIiQuqsQ4SFP32Uzpo0ODHlay6CXpGQ qX4xIoI3pSKCvKnnBGy4sqXk4XqYclCPPgxJ3TH6ZhF8DhnxbKxXWlgcDjwwtewDLi7S 71tg== X-Gm-Message-State: AOAM530YAymUcIE7wzpbI9+23/W54xEGnqW3WZkWNneNFvLL+yxVjxzt X4o3D3mSXW68BohiOmKncHQgfRZx7rAlEg== X-Google-Smtp-Source: ABdhPJyhkDsTHBfrd/vKXvwcKE7CDSqKqoqhjC7d7cbRyv+1e0HIjpxDwzrCh5hkM/DL+a/v3j7pew== X-Received: by 2002:a65:4203:: with SMTP id c3mr25638480pgq.309.1629604552594; Sat, 21 Aug 2021 20:55:52 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 21/30] linux-user/microblaze: Fix SIGFPE si_codes Date: Sat, 21 Aug 2021 20:55:28 -0700 Message-Id: <20210822035537.283193-22-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::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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Fix a typo for ESR_EC_DIVZERO, which is integral not floating-point. Fix the if ladder for decoding floating-point exceptions. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/microblaze/cpu_loop.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c index 9e07e52573..4a75c853b2 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -81,15 +81,25 @@ void cpu_loop(CPUMBState *env) env->iflags &= ~(IMM_FLAG | D_FLAG); switch (env->esr & 31) { case ESR_EC_DIVZERO: - si_code = TARGET_FPE_FLTDIV; + si_code = TARGET_FPE_INTDIV; break; case ESR_EC_FPU: - si_code = 0; - if (env->fsr & FSR_IO) { + /* + * Note that the kernel passes along fsr as si_code + * if there's no recognized bit set. Possibly this + * implies that si_code is 0, but follow the structure. + */ + si_code = env->fsr; + if (si_code & FSR_IO) { si_code = TARGET_FPE_FLTINV; - } - if (env->fsr & FSR_DZ) { + } else if (si_code & FSR_OF) { + si_code = TARGET_FPE_FLTOVF; + } else if (si_code & FSR_UF) { + si_code = TARGET_FPE_FLTUND; + } else if (si_code & FSR_DZ) { si_code = TARGET_FPE_FLTDIV; + } else if (si_code & FSR_DO) { + si_code = TARGET_FPE_FLTRES; } break; default: From patchwork Sun Aug 22 03:55:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D824AC432BE for ; Sun, 22 Aug 2021 04:12:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 73E436124E for ; Sun, 22 Aug 2021 04:12:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 73E436124E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:55822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeqI-0005Gh-Gd for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:12:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0007u0-U0 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:56198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaQ-0000jz-DE for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:55 -0400 Received: by mail-pj1-x102a.google.com with SMTP id mq3so9789198pjb.5 for ; Sat, 21 Aug 2021 20:55:54 -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=nExu9rWHCS7f7+CKti5VQfpmql22KtPSQqzBYFW5vis=; b=vRlVtLkDQeuUGXNOwTJq9XxLxmc85rhdmXv+WPiq95+z9Iinopw2EkRLV/CudT6+Ak 8cb+LW7qJ2TNEogxyg6p+YA4+RUAw8QYaEZzwS4j7mNiBL0B0wzdSY+V/1FsS9G9w3JX 6fLb0O3a7rPwL7ST/O0ZyGpzeCEZ117+kGUNCncWxL+2CjTRWcXqv6Ya2Dcvqn3PWVat xBfbClHekNWiivLTrUFQQotIFNGlqjdvWalukBdZwAHnwR7qtab4tPml1VaIvQobnPUT DkodglcctHweytH5/U4lLbKnQkaF8bWadq5wIibjFrscaJlFl3GwND/lNgC1etc5mTrn xBMQ== 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=nExu9rWHCS7f7+CKti5VQfpmql22KtPSQqzBYFW5vis=; b=PKgtg/nlk+vCqWEEyzJP2qZLmVKHihgHQcdSrEVU9Id1ZQ1P9tsGhwrMr3JbbB4AaI rnIoyqRuoFxa6aWUzm5z65D+UBkfydVNivrtZwr9C2a53uW8LpyteNfAlMyQ541gKKSr ny3rhcWsYtpnzuM2dQmsjOapZU+bWtv+qC7J3AlDo9GT8x5VkAhT7tMjbfbFL2kGh93B JNAvGYCBCYf8s+wpRcdcKF6qONFJpbAEbXELB6UHtvLmwMdChvmpUoWmulRKdpgerk25 cX5TphQQu7G2tlxRtPQw4yrbAJB/ECX4V/ikZWZSbzqhIDBVxzGJT4XaR035Ca1uYgjw jbcw== X-Gm-Message-State: AOAM533v5PFz2a/8ECvBBhT4618cpYNFINRw77AIMOo2AQ9fTPaTODgY nqVeosHKkalnwV08l4h6zitzHD8pxfZgmQ== X-Google-Smtp-Source: ABdhPJwaffrm455YIMlgCK6FFFnFtlZhmGBPgK3bgwa2gD9NRsjiVhtiA8qsezzc1oCDmGiWpayCLQ== X-Received: by 2002:a17:90a:86cc:: with SMTP id y12mr1572317pjv.127.1629604553213; Sat, 21 Aug 2021 20:55:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 22/30] linux-user/mips: Improve do_break Date: Sat, 21 Aug 2021 20:55:29 -0700 Message-Id: <20210822035537.283193-23-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rename to do_tr_or_bp, as per the kernel function. Add a 'trap' argument, akin to the kernel's si_code, but clearer. The return value is always 0, so change the return value to void. Use force_sig and force_sig_fault. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- linux-user/mips/cpu_loop.c | 47 ++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 9d813ece4e..797b6bf659 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "elf.h" #include "internal.h" #include "fpu_helper.h" @@ -38,29 +39,25 @@ enum { BRK_DIVZERO = 7 }; -static int do_break(CPUMIPSState *env, target_siginfo_t *info, - unsigned int code) +static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap) { - int ret = -1; + target_ulong pc = env->active_tc.PC; switch (code) { case BRK_OVERFLOW: + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTOVF, pc); + break; case BRK_DIVZERO: - info->si_signo = TARGET_SIGFPE; - info->si_errno = 0; - info->si_code = (code == BRK_OVERFLOW) ? FPE_INTOVF : FPE_INTDIV; - queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info); - ret = 0; + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, pc); break; default: - info->si_signo = TARGET_SIGTRAP; - info->si_errno = 0; - queue_signal(env, info->si_signo, QEMU_SI_FAULT, &*info); - ret = 0; + if (trap) { + force_sig(TARGET_SIGTRAP); + } else { + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, pc); + } break; } - - return ret; } void cpu_loop(CPUMIPSState *env) @@ -214,6 +211,13 @@ done_syscall: abi_ulong trap_instr; unsigned int code; + /* + * FIXME: It would be better to decode the trap number + * during translate, and store it in error_code while + * raising the exception. We should not be re-reading + * the opcode here. + */ + if (env->hflags & MIPS_HFLAG_M16) { if (env->insn_flags & ASE_MICROMIPS) { /* microMIPS mode */ @@ -266,9 +270,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, false); } break; case EXCP_TRAP: @@ -276,6 +278,13 @@ done_syscall: abi_ulong trap_instr; unsigned int code = 0; + /* + * FIXME: It would be better to decode the trap number + * during translate, and store it in error_code while + * raising the exception. We should not be re-reading + * the opcode here. + */ + if (env->hflags & MIPS_HFLAG_M16) { /* microMIPS mode */ abi_ulong instr[2]; @@ -302,9 +311,7 @@ done_syscall: } } - if (do_break(env, &info, code) != 0) { - goto error; - } + do_tr_or_bp(env, code, true); } break; case EXCP_ATOMIC: From patchwork Sun Aug 22 03:55:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB1EC4338F for ; Sun, 22 Aug 2021 04:15:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 75B486127B for ; Sun, 22 Aug 2021 04:15:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 75B486127B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHetX-0001v5-Jg for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:15:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaV-0007u9-3F for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:44985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0000lU-2v for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:58 -0400 Received: by mail-pf1-x430.google.com with SMTP id k19so12312884pfc.11 for ; Sat, 21 Aug 2021 20:55:54 -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=CM+P5kCp2bGplgCBuu0CKtvfrg+9JXuhdewm1jvsnkY=; b=V9g94EqcSUn8LEzZ03ro9P4HJJ+fJIPDVR3TZuO+k28P/xpmgt/ynSW9A4vZubwBdf 6+QsmIX3NUbojH0P6hiPbfdV8KEo25vMicyYTcufwivieMl4SiHAwlAXCkOnrFiOjHHy Ii5MWUc+RJERJhdGoH/a7/bkESXzRrZ9gchJbQnaOljbOiqouAd4Kz4QdzsEzBkDu8m6 xh0vpXdbGVbKwzf+wpoqZt7zdR/PcCGB+06kKg1ak/q6qp5+Ldj0+qQWoBidcURV6S8Y fhzqjbn43zr7uRQrG31q3Rm1pHYVMrSLhfn1ul0y7ncDPA0UpM2Z4NEgfuRjlVDtK+AD MB3g== 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=CM+P5kCp2bGplgCBuu0CKtvfrg+9JXuhdewm1jvsnkY=; b=T685juau3cs25IjOG3dj9/hsJPqhra67qqJguH1/xCpPKRGYK6ndhhNEbIbxOUs1bt fLIQ4vMFXZl2DYhd846bc94U1NsaQP07owpBoXXJ7fV624eAVKiuJydryfQZmWeDLZcl cQudAJJ4zCl8T+q3CcdANwP6kRXJ3Dm6HFALbdEXaQJeU5pKyL8YAX0DY+rhilJlimAf nQc+i9tkdegXCqOntTeKgFYtzG3gupwgKz1L4lzdXMuUu399SoBGLn36i2xdl+W8ytGj ftvCL8oAzlj/RU90GvpYqyBtXxzIQwHAwz5uYMLmq78qI3+NsgOHHRQiYtgP7OkYMb6G bMNA== X-Gm-Message-State: AOAM530pM0glczNSuAArkVIp9Z9XVmMwX0UGG5HrD34qzx8eukklQ4kb 25hMgaNfGFi1kMgvPMsXh+9cIidpikApTw== X-Google-Smtp-Source: ABdhPJyiowhIp/asuV9QlUxIFssrLFXjXC8Cl6+7SDDEweeKg5+lPB5G9HvVGE0PwYLZZ9ejmnEYsw== X-Received: by 2002:a63:df49:: with SMTP id h9mr26139673pgj.228.1629604553824; Sat, 21 Aug 2021 20:55:53 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/30] linux-user/mips: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:30 -0700 Message-Id: <20210822035537.283193-24-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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/mips/cpu_loop.c | 45 ++++++++++++-------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 797b6bf659..2350ac66e1 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -63,8 +63,7 @@ static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap) void cpu_loop(CPUMIPSState *env) { CPUState *cs = env_cpu(env); - target_siginfo_t info; - int trapnr; + int trapnr, si_code; abi_long ret; # ifdef TARGET_ABI_MIPSO32 unsigned int syscall_num; @@ -157,52 +156,36 @@ done_syscall: case EXCP_TLBS: case EXCP_AdEL: case EXCP_AdES: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->CP0_BadVAddr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->CP0_BadVAddr); break; case EXCP_CpU: case EXCP_RI: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = 0; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case EXCP_DSPDIS: + force_sig(TARGET_SIGILL); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - 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); - break; - case EXCP_DSPDIS: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPC; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, + env->active_tc.PC); break; case EXCP_FPE: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_FLTUNK; + si_code = TARGET_FPE_FLTUNK; if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INVALID) { - info.si_code = TARGET_FPE_FLTINV; + si_code = TARGET_FPE_FLTINV; } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_DIV0) { - info.si_code = TARGET_FPE_FLTDIV; + si_code = TARGET_FPE_FLTDIV; } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_OVERFLOW) { - info.si_code = TARGET_FPE_FLTOVF; + si_code = TARGET_FPE_FLTOVF; } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_UNDERFLOW) { - info.si_code = TARGET_FPE_FLTUND; + si_code = TARGET_FPE_FLTUND; } else if (GET_FP_CAUSE(env->active_fpu.fcr31) & FP_INEXACT) { - info.si_code = TARGET_FPE_FLTRES; + si_code = TARGET_FPE_FLTRES; } - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, si_code, env->active_tc.PC); break; + /* The code below was inspired by the MIPS Linux kernel trap * handling code in arch/mips/kernel/traps.c. */ From patchwork Sun Aug 22 03:55:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99EE4C4338F for ; Sun, 22 Aug 2021 04:01:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2FEB36126A for ; Sun, 22 Aug 2021 04:01:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2FEB36126A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeg7-0005CC-6k for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaU-0007u7-It for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:34431) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaR-0000lk-P8 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:58 -0400 Received: by mail-pl1-x635.google.com with SMTP id j2so3795438pll.1 for ; Sat, 21 Aug 2021 20:55:55 -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=y84dl2fafIHncS6Y/RS/Ptnx8qYyRhYz7fzOuToVOxw=; b=Bt3LwJ6vyI56XOGZ5kAZh2DV4rbLYWS1GM6Dxt9Qq4Qe5Qi/H0a6JzsmrxKq7zbJPm igHRtzx7uu2Jg26fbuaGoa/+5fa0AQ8oI76c3cY1xut2+LYhXHK/kFM2AtT3bCbhfAdr CseML3Ib2yMhb9fuM5z//5jQ0dHqnXAcgpZoxOBAzMXV090TGLwyMdMIjhrj/Vp45HWB v23gCdM+zRaEaAtlmyD2Kn+mN4yoAPJHUmXo0rqC6Mmf6wDVEwQEZXSX2QT5SLjJiN/d eP8dvwvl7IcFDcSN+z1qdf3sluPfy5hNX3w3vUC1o5iVGZXuEjFBtSo88pemyclK3IdU e93w== 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=y84dl2fafIHncS6Y/RS/Ptnx8qYyRhYz7fzOuToVOxw=; b=dICZ1iQ2ImgiFkSAFaZ4ue1FRj30gj7McFAhG4n1ygdhMSRTOK3mE7KK4ZkLQ9azmn x6Bk27Wd9GcuISjJIck7TpQqhVHVmeFZWYFgYOsgu4DjP3Acizcndj7hVU9CSu4TGXTk 6o/wrp76z+UeQEzLwptBhciOyV5pInPO5ti5VsRnmTSyLRH06JeXeHu5kLhAlluGAV/6 0jnqeCy0eme62l5aQFEoPi2xQWwFoBu4hrLi50dzEJWvUvm3aPkmylorOEMpl6VQDFyF wzcJrNkq/v5GH7BWIRP58pvVhTprRt4UGdfU+8LBaE9lGxSO24sGCKXfOYOIAeKhudeG CjnQ== X-Gm-Message-State: AOAM530ahV3zi6rySGuXx7vjtpl8lmq7H56pR3aFmj0S8IX9dkP9TAxk EcKkI9oCdU7Lytpjnpf2McaiEHPsqg2y2A== X-Google-Smtp-Source: ABdhPJzgO4D+R7J7dp5bVBtkCvEdwcXUqL1pud9xNirVyXXYlNxcDzBOg4l62uIo8T+x7hz90QWSgw== X-Received: by 2002:a17:902:a710:b029:12b:9b9f:c461 with SMTP id w16-20020a170902a710b029012b9b9fc461mr22639734plq.59.1629604554442; Sat, 21 Aug 2021 20:55:54 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 24/30] linux-user/openrisc: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:31 -0700 Message-Id: <20210822035537.283193-25-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson --- linux-user/openrisc/cpu_loop.c | 37 +++++++++------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/linux-user/openrisc/cpu_loop.c b/linux-user/openrisc/cpu_loop.c index b33fa77718..d2632ce6a3 100644 --- a/linux-user/openrisc/cpu_loop.c +++ b/linux-user/openrisc/cpu_loop.c @@ -21,13 +21,14 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + void cpu_loop(CPUOpenRISCState *env) { CPUState *cs = env_cpu(env); int trapnr; abi_long ret; - target_siginfo_t info; for (;;) { cpu_exec_start(cs); @@ -54,42 +55,24 @@ void cpu_loop(CPUOpenRISCState *env) break; case EXCP_DPF: case EXCP_IPF: + force_sigsegv_for_addr(env->eear); + break; case EXCP_RANGE: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case EXCP_FPE: + /* ??? The kernel vectors both of these to unhandled_exception. */ + force_sig(TARGET_SIGSEGV); break; case EXCP_ALIGN: - info.si_signo = TARGET_SIGBUS; - info.si_errno = 0; - info.si_code = TARGET_BUS_ADRALN; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->eear); break; case EXCP_ILLEGAL: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPC; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; - case EXCP_FPE: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = 0; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; case EXCP_INTERRUPT: /* We processed the pending cpu work above. */ break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA847C4338F for ; Sun, 22 Aug 2021 04:06:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4F4936103A for ; Sun, 22 Aug 2021 04:06:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4F4936103A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:39206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHekZ-0002WF-P0 for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:06:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaW-0007vP-37 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:01 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:41703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaT-0000mb-5n for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: by mail-pf1-x429.google.com with SMTP id i21so12288367pfd.8 for ; Sat, 21 Aug 2021 20:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+v1YogFzFLNFD/zLNDkuHoAqiRV8XrYV0MsKRyjw4WM=; b=jjwb8KG+wTi5FZskcK3CLLa9etTJ5kMoYZp5tV4EPJ4FP3DdagOfd3UD4MMOVesJ60 /Ph8L48o9/Y9FBiXB6X6YYaLG75KRzdTf/m4iqw322nZHwUj0DPBMyuAi2e6H56fnrXW 37xjxtVSIXEeiqVedbcx3xUVZ7FSszAObnqW4mHAdV9rT3+L9jVYQ/bS3JWlLp5ZOVU3 F8IxEOVjD/nYI8XSUxR+wDQyfg7JA3h1f0AFm02hhOby5G+MFbqKqNggOyLkNVUAIjuF FDVDHvQrXwPErO4Qmwe+Zpcxbk2FqywqLPjiQVgj+bPuCdBfaLUc26VkyTwEWm/B4XLm uirg== 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=+v1YogFzFLNFD/zLNDkuHoAqiRV8XrYV0MsKRyjw4WM=; b=HvXYhvVF/c6I+yIb8zZuP2fF/eFkvGJzztdG7RKyye0TVJ13cBEvOe5AvbNwXKvI0D eSucH5H10kzDtzRAlFMbUUhnXITsHYu3HfsdWC3x/7bMuk5WZtv4Z/FnKhtoNDjw6L/l SwSUpirestT6oGiK8u1VmAOaP9l1NO2iTR42sUnpcoSO20z1kBW8JWqRThBn1gS5SDbC zxlMVpoIdfE/wP0RouQMiXzr8BoD1I8ePQ6Eu5yiCggov2O2yOP1iozwlN/W9MM5+KNo ix7MlgceycmQjxKodjXOdCr9M/uKsqM6z3js7DScTflSjI46tePxczoBzWNEm+3SzGto MQAA== X-Gm-Message-State: AOAM530DSrRK4Op7PBRvb0Lnegyku8X9GbJgRaHzzV+mR3C0r3J26PDZ QrEUbaHnT8FQhsW1x1qZS348Lu0t3i3q5A== X-Google-Smtp-Source: ABdhPJxgMslY+FyagtGyPmE5oAmPHnO/kj6NRFKWw8/qcDGzZO8+2akrE6PWAJHnZyaQX90OCrDCsA== X-Received: by 2002:a63:480a:: with SMTP id v10mr25791903pga.113.1629604555001; Sat, 21 Aug 2021 20:55:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 25/30] linux-user/ppc: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:32 -0700 Message-Id: <20210822035537.283193-26-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. The user-only version of ppc_cpu_tlb_fill does not distinguish between the various hw codes. Drop all of that and just use the new force_sigsegv_for_addr function. The fault address for POWERPC_EXCP_ISI is nip exactly, not nip - 4. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/ppc/cpu_loop.c | 142 ++++++++------------------------------ 1 file changed, 30 insertions(+), 112 deletions(-) diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index fa91ea0eed..4893bbd021 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -21,6 +21,8 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + static inline uint64_t cpu_ppc_get_tb(CPUPPCState *env) { @@ -74,8 +76,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val) void cpu_loop(CPUPPCState *env) { CPUState *cs = env_cpu(env); - target_siginfo_t info; - int trapnr; + int trapnr, si_signo, si_code; target_ulong ret; for(;;) { @@ -100,61 +101,10 @@ void cpu_loop(CPUPPCState *env) "Aborting\n"); break; case POWERPC_EXCP_DSI: /* Data storage exception */ - /* XXX: check this. Seems bugged */ - switch (env->error_code & 0xFF000000) { - case 0x40000000: - case 0x42000000: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - break; - case 0x04000000: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLADR; - break; - case 0x08000000: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_ACCERR; - break; - default: - /* Let's send a regular segfault... */ - EXCP_DUMP(env, "Invalid segfault errno (%02x)\n", - env->error_code); - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - break; - } - info._sifields._sigfault._addr = env->spr[SPR_DAR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->spr[SPR_DAR]); break; case POWERPC_EXCP_ISI: /* Instruction storage exception */ - /* XXX: check this */ - switch (env->error_code & 0xFF000000) { - case 0x40000000: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - break; - case 0x10000000: - case 0x08000000: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_ACCERR; - break; - default: - /* Let's send a regular segfault... */ - EXCP_DUMP(env, "Invalid segfault errno (%02x)\n", - env->error_code); - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - break; - } - info._sifields._sigfault._addr = env->nip - 4; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->nip); break; case POWERPC_EXCP_EXTERNAL: /* External input */ cpu_abort(cs, "External interrupt while in user mode. " @@ -162,35 +112,30 @@ void cpu_loop(CPUPPCState *env) break; case POWERPC_EXCP_ALIGN: /* Alignment exception */ /* XXX: check this */ - info.si_signo = TARGET_SIGBUS; - info.si_errno = 0; - info.si_code = TARGET_BUS_ADRALN; - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->nip); break; case POWERPC_EXCP_PROGRAM: /* Program exception */ case POWERPC_EXCP_HV_EMU: /* HV emulation */ /* XXX: check this */ switch (env->error_code & ~0xF) { case POWERPC_EXCP_FP: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; + si_signo = TARGET_SIGFPE; switch (env->error_code & 0xF) { case POWERPC_EXCP_FP_OX: - info.si_code = TARGET_FPE_FLTOVF; + si_code = TARGET_FPE_FLTOVF; break; case POWERPC_EXCP_FP_UX: - info.si_code = TARGET_FPE_FLTUND; + si_code = TARGET_FPE_FLTUND; break; case POWERPC_EXCP_FP_ZX: case POWERPC_EXCP_FP_VXZDZ: - info.si_code = TARGET_FPE_FLTDIV; + si_code = TARGET_FPE_FLTDIV; break; case POWERPC_EXCP_FP_XX: - info.si_code = TARGET_FPE_FLTRES; + si_code = TARGET_FPE_FLTRES; break; case POWERPC_EXCP_FP_VXSOFT: - info.si_code = TARGET_FPE_FLTINV; + si_code = TARGET_FPE_FLTINV; break; case POWERPC_EXCP_FP_VXSNAN: case POWERPC_EXCP_FP_VXISI: @@ -199,51 +144,50 @@ void cpu_loop(CPUPPCState *env) case POWERPC_EXCP_FP_VXVC: case POWERPC_EXCP_FP_VXSQRT: case POWERPC_EXCP_FP_VXCVI: - info.si_code = TARGET_FPE_FLTSUB; + si_code = TARGET_FPE_FLTSUB; break; default: EXCP_DUMP(env, "Unknown floating point exception (%02x)\n", env->error_code); + si_code = 0; break; } break; case POWERPC_EXCP_INVAL: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; + si_signo = TARGET_SIGILL; switch (env->error_code & 0xF) { case POWERPC_EXCP_INVAL_INVAL: - info.si_code = TARGET_ILL_ILLOPC; + si_code = TARGET_ILL_ILLOPC; break; case POWERPC_EXCP_INVAL_LSWX: - info.si_code = TARGET_ILL_ILLOPN; + si_code = TARGET_ILL_ILLOPN; break; case POWERPC_EXCP_INVAL_SPR: - info.si_code = TARGET_ILL_PRVREG; + si_code = TARGET_ILL_PRVREG; break; case POWERPC_EXCP_INVAL_FP: - info.si_code = TARGET_ILL_COPROC; + si_code = TARGET_ILL_COPROC; break; default: EXCP_DUMP(env, "Unknown invalid operation (%02x)\n", env->error_code & 0xF); - info.si_code = TARGET_ILL_ILLADR; + si_code = TARGET_ILL_ILLADR; break; } break; case POWERPC_EXCP_PRIV: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; + si_signo = TARGET_SIGILL; switch (env->error_code & 0xF) { case POWERPC_EXCP_PRIV_OPC: - info.si_code = TARGET_ILL_PRVOPC; + si_code = TARGET_ILL_PRVOPC; break; case POWERPC_EXCP_PRIV_REG: - info.si_code = TARGET_ILL_PRVREG; + si_code = TARGET_ILL_PRVREG; break; default: EXCP_DUMP(env, "Unknown privilege violation (%02x)\n", env->error_code & 0xF); - info.si_code = TARGET_ILL_PRVOPC; + si_code = TARGET_ILL_PRVOPC; break; } break; @@ -256,28 +200,19 @@ void cpu_loop(CPUPPCState *env) env->error_code); break; } - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(si_signo, si_code, env->nip); break; case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_COPROC; - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */ + case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavail. */ + case POWERPC_EXCP_VPU: /* Vector unavailable exception */ + force_sig_fault(TARGET_SIGILL, TARGET_ILL_COPROC, env->nip); break; case POWERPC_EXCP_SYSCALL: /* System call exception */ case POWERPC_EXCP_SYSCALL_VECTORED: cpu_abort(cs, "Syscall exception while in user mode. " "Aborting\n"); break; - case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_COPROC; - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case POWERPC_EXCP_DECR: /* Decrementer exception */ cpu_abort(cs, "Decrementer interrupt while in user mode. " "Aborting\n"); @@ -298,13 +233,6 @@ void cpu_loop(CPUPPCState *env) cpu_abort(cs, "Instruction TLB exception while in user mode. " "Aborting\n"); break; - case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavail. */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_COPROC; - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case POWERPC_EXCP_EFPDI: /* Embedded floating-point data IRQ */ cpu_abort(cs, "Embedded floating-point data IRQ not handled\n"); break; @@ -361,13 +289,6 @@ void cpu_loop(CPUPPCState *env) cpu_abort(cs, "Hypervisor instruction segment exception " "while in user mode. Aborting\n"); break; - case POWERPC_EXCP_VPU: /* Vector unavailable exception */ - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_COPROC; - info._sifields._sigfault._addr = env->nip; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - break; case POWERPC_EXCP_PIT: /* Programmable interval timer IRQ */ cpu_abort(cs, "Programmable interval timer interrupt " "while in user mode. Aborting\n"); @@ -450,10 +371,7 @@ void cpu_loop(CPUPPCState *env) env->gpr[3] = ret; break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->nip); break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ From patchwork Sun Aug 22 03:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451169 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 520BFC432BE for ; Sun, 22 Aug 2021 04:15:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0BDFA6127B for ; Sun, 22 Aug 2021 04:15:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0BDFA6127B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:35306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHetY-0001w4-2V for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:15:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaU-0007u8-Mh for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:43566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaT-0000mh-5M for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:58 -0400 Received: by mail-pj1-x102e.google.com with SMTP id qe12-20020a17090b4f8c00b00179321cbae7so9900784pjb.2 for ; Sat, 21 Aug 2021 20:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9HGVPe/pQ5/XkIwVDPflmpNkSXdRjb5w/EgQJjUaxxk=; b=fJXbaeGV3G6HRxu/+VHOLCNOhZK3QnUCDHFLA32KyCWYUinJGq7nbU2KzeNm7SzBA8 Nzc4zXsa8zzOuHMEag9n446bN3Xd1oiHx02MTepUzYD7oo1ph7SCdul41/+e+G1JgOPO 0XQ1tpNX09IaC+8n+p6ppZbsQQf1szDLop5bkQnsnFmz5A2cwVvUGtvVm8Z7dy+jF6Qq okPLQ98Uk99p/29dYc1niNVrj/gwzXVoJwDBv8fKQ+/JjseRfJRDmgDxgMDIN61h1zP5 0Abcnt71dRCtygCH0IQ0vWXQzY6tnyGDhj1T+CWqxdKoMbouCWIhXLxZqop6pM7odWxJ MkAg== 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=9HGVPe/pQ5/XkIwVDPflmpNkSXdRjb5w/EgQJjUaxxk=; b=l92Tnlut0CeeDQvMoi91fbR2kHz8SRNHj6IcNJIrP7HHeitEdHU0GnXe27Y4wh0grK f3HLdiAU6Lsz074W3NqfKymD/Nc5Rbp4fO8yCk68PE4oxf+U6wFsF3Hg0VKX4d/fXUe1 4Zs1Yr+VvrfLljz0BMUR+Vmxo9hNhQzSx3GpQBgHM6Vv3irqHxeZnoV+Dqj6VtKXtoXC kt25YhTU9t9O1jifmadCtM1NfgNMQIueXP2sYauoHkUFKg0I2eQk1rq3ndwlp/4Q0jZg S0jP866oT61n2p1vW6fXP3t7/FW0sMiKhzQQgW6TrO2GuF/mogwKrNzM17RQSwR/TzKA DULQ== X-Gm-Message-State: AOAM5316TddY7a2G9zsT9UaURyUuJ+zONWU1oSRY2f0/tCgdSTzq1A14 BQFYcjboRUBZ09/c8Vw/vcI+ojZvIo07ug== X-Google-Smtp-Source: ABdhPJzdkN9EiBmGE2C7leZFebYfzHv424tcvbh1TNThHsc4az2Ue/Cy3OgqBOcDapajMqpBSfbGZw== X-Received: by 2002:a17:902:b093:b029:12c:843:b55a with SMTP id p19-20020a170902b093b029012c0843b55amr23065852plr.83.1629604555642; Sat, 21 Aug 2021 20:55:55 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 26/30] linux-user/riscv: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:33 -0700 Message-Id: <20210822035537.283193-27-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::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/riscv/cpu_loop.c | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/linux-user/riscv/cpu_loop.c b/linux-user/riscv/cpu_loop.c index 74a9628dc9..32c440365c 100644 --- a/linux-user/riscv/cpu_loop.c +++ b/linux-user/riscv/cpu_loop.c @@ -22,14 +22,14 @@ #include "qemu/error-report.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #include "elf.h" #include "semihosting/common-semi.h" void cpu_loop(CPURISCVState *env) { CPUState *cs = env_cpu(env); - int trapnr, signum, sigcode; - target_ulong sigaddr; + int trapnr; target_ulong ret; for (;;) { @@ -38,10 +38,6 @@ void cpu_loop(CPURISCVState *env) cpu_exec_end(cs); process_queued_cpu_work(cs); - signum = 0; - sigcode = 0; - sigaddr = 0; - switch (trapnr) { case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ @@ -77,46 +73,28 @@ void cpu_loop(CPURISCVState *env) } break; case RISCV_EXCP_ILLEGAL_INST: - signum = TARGET_SIGILL; - sigcode = TARGET_ILL_ILLOPC; + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; case RISCV_EXCP_BREAKPOINT: - signum = TARGET_SIGTRAP; - sigcode = TARGET_TRAP_BRKPT; - sigaddr = env->pc; + case EXCP_DEBUG: + gdbstep: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case RISCV_EXCP_INST_PAGE_FAULT: case RISCV_EXCP_LOAD_PAGE_FAULT: case RISCV_EXCP_STORE_PAGE_FAULT: - signum = TARGET_SIGSEGV; - sigcode = TARGET_SEGV_MAPERR; - sigaddr = env->badaddr; + force_sigsegv_for_addr(env->badaddr); break; case RISCV_EXCP_SEMIHOST: env->gpr[xA0] = do_common_semihosting(cs); env->pc += 4; break; - case EXCP_DEBUG: - gdbstep: - signum = TARGET_SIGTRAP; - sigcode = TARGET_TRAP_BRKPT; - break; default: EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n", trapnr); exit(EXIT_FAILURE); } - if (signum) { - target_siginfo_t info = { - .si_signo = signum, - .si_errno = 0, - .si_code = sigcode, - ._sifields._sigfault._addr = sigaddr - }; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - process_pending_signals(env); } } From patchwork Sun Aug 22 03:55:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A21A6C4338F for ; Sun, 22 Aug 2021 04:22:40 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3C29260FBF for ; Sun, 22 Aug 2021 04:22:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3C29260FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHf0J-00032A-2R for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:22:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaV-0007vN-HB for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:01 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:37703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaT-0000ms-Qg for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: by mail-pf1-x429.google.com with SMTP id j187so12285048pfg.4 for ; Sat, 21 Aug 2021 20:55:57 -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=3QatqUyjS7CHgCtyFONtgHEY/7FxQllE+nDg9ups7ko=; b=iz8vs1+PcWM8L1AkElUcu+f1PNDJWq2iaAi+VwNiRvK5JNUUyFhQ7M1Dp8lZ0l5NdK lqZxN+jbc/h7x69ASlur86PmgiCJZRSEXtrAytkYR9oNtO8UvNZd1VZy6C7Q8wfjC1t6 deor9HdXZww/KRGt0o7PcaFs/rV2SWgCee2XGHWEW57YeJuc2MKilJXd8edUc8DhPXeJ GEv5r8aMaWjv3dMrmaPyMUDfQNwlESSNUAXEPXNOCciCDJB0fWudNZ6oqcn53RMtRYGY kk4gIy6bkd6syoLZF0m60b9R2oqjqv06o7P6T7B6lZvSw1RTMvVen5UzMTnYvtl5lJsO ME8g== 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=3QatqUyjS7CHgCtyFONtgHEY/7FxQllE+nDg9ups7ko=; b=DVEK7TbLsqOV3Aqp4sV/ftEo9Th7K66Sm+w64lvN5KlfrnuWlBwvJK3fkvd5Q/HVCm 9qvQQs1j3uZGiPlEYYL35WtavFY1wNlKPTCmKvN8DrQ3qt5asbW1YavdcUzgJYENEWVE wNd5aJXf/epE3dQxGUVUoFdLpOzmzcNuYz751ccDw58TKqXLkOBKVxRlt2qs6beNUMMI wimx38vpFkEhY3kR8SM+ztHmj5l3IfulkKjrW4m3WQ2Kzc4mhqau5Cn+E1AmlACjFfbC /SnwGozJw9upAzoJFyKa4mLvg/xqO1pDdDysv6ROouVwuXMzpwRRB9P1tPHpwHwfZjMQ 0+BA== X-Gm-Message-State: AOAM5337mm1NvLLMeND9EzFpfvDk6QMZWSNtsmoUul57xkPf30OULfJz 3FgRAlLylpGAEJdjmXDr2FCmYZ0ubLZshA== X-Google-Smtp-Source: ABdhPJyS8imLASxHg9LuMcsvv5g+ukGPl0sEQNyPNZMf8Wixo4RzUgCtn4Ro9pvdK/6Gk4qog46UXw== X-Received: by 2002:a63:6705:: with SMTP id b5mr26238575pgc.69.1629604556350; Sat, 21 Aug 2021 20:55:56 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 27/30] linux-user/s390x: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:34 -0700 Message-Id: <20210822035537.283193-28-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::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/s390x/cpu_loop.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index 6a69a6dd26..8287d3dfe8 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -21,6 +21,8 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + /* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */ #define S390X_FAIL_ADDR_MASK -4096LL @@ -58,7 +60,6 @@ void cpu_loop(CPUS390XState *env) { CPUState *cs = env_cpu(env); int trapnr, n, sig; - target_siginfo_t info; target_ulong addr; abi_long ret; @@ -110,11 +111,8 @@ void cpu_loop(CPUS390XState *env) goto do_signal_pc; case PGM_PROTECTION: case PGM_ADDRESSING: - sig = TARGET_SIGSEGV; - /* XXX: check env->error_code */ - n = TARGET_SEGV_MAPERR; - addr = env->__excp_addr & S390X_FAIL_ADDR_MASK; - goto do_signal; + force_sigsegv_for_addr(env->__excp_addr & S390X_FAIL_ADDR_MASK); + break; case PGM_EXECUTE: case PGM_SPECIFICATION: case PGM_SPECIAL_OP: @@ -157,11 +155,7 @@ void cpu_loop(CPUS390XState *env) */ env->psw.addr += env->int_pgm_ilen; do_signal: - info.si_signo = sig; - info.si_errno = 0; - info.si_code = n; - info._sifields._sigfault._addr = addr; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(sig, n, addr); break; case EXCP_ATOMIC: From patchwork Sun Aug 22 03:55:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 940D4C4338F for ; Sun, 22 Aug 2021 04:08:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 57C0D6125F for ; Sun, 22 Aug 2021 04:08:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 57C0D6125F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHemv-0008Hk-C9 for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaV-0007vO-QZ for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:01 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:43582) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaU-0000od-BS for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:55:59 -0400 Received: by mail-pl1-x630.google.com with SMTP id x1so5651601plg.10 for ; Sat, 21 Aug 2021 20:55:57 -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=XrQegvQ52g51iXxP1ir/2vDYcsxCC4+2/9p/CuuRamw=; b=eYaXYCpdmhTQzkbqpVAqtILN5KqU1JrfJYNZhTfR1lk9TQlIBqoPAslWSuyiavJQwD HjYO7bMXTiUVJzkfWyKeR6iWQPTwrj/PxEpjDHxjrmsA8tLRFUQv8VcAmEV98jjW0cue oMucg5rVDTGejNoIfBETnrtYiCOi/GfS4xO4U4syCUbkbwEWcZ8P2aKGsaaTRkDYl/RK W36Vo4q58MOJN3ZfyUmDiM1rjmbfSX4i9N4VrxgIBLN7SvHRxDgiW8SB70WjQ4uLhfOQ kSzqaw8EFbRbO8X9I5u4K05PFZexE5QjyDYTvSnRop61EOBEriLvLXH2APFx6NUxhoWn h/Kw== 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=XrQegvQ52g51iXxP1ir/2vDYcsxCC4+2/9p/CuuRamw=; b=Ux0vsZVa3ZyZvJGjzTZzAe4Mvq4yquzpEPn60ekZ434nrc9B/NQGY6DXd+wyYpX4CA bjT6Zzd+YNFc4wXBKM0UKh9QUiSFmPBYqEKiKjp2I1Sk/vwLC/FOCKMoRr8gDwb+kJAn +5LdEipVdDdmhYPR9Nhu6/059ooqiQaL21NrOcdyQd1//533zQ2BhXnCAc2vk7W2Q8r5 NJS8ocEjMVWikWWhHuo/xWUbaj6Ym73gbzNMnVKkea4e0gyPGGs2liuVJrlptgycS7dS dseGjALGamKiFDqgRCoNGCIy4+0PaiMT5R6nzABLItuTBy9lRNEgft9G7CMaKrdgogkO +41g== X-Gm-Message-State: AOAM533AJXOTBxyn9CpXu8aKFIfLhLKK0PvBEOd1kR619pArvhWQaZdo s0ETKhen8lzAGHxnX8GuS9P1Wq4/y9LqFA== X-Google-Smtp-Source: ABdhPJzSM2rtYEgNxQSWcCX/CvlTwJtUKE6OGyxbi8I4oywTQBZ2RfE4kQmwIGhg5e0CIeRn79rTpg== X-Received: by 2002:a17:90a:8005:: with SMTP id b5mr637562pjn.190.1629604557070; Sat, 21 Aug 2021 20:55:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 28/30] linux-user/sh4: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:35 -0700 Message-Id: <20210822035537.283193-29-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/sh4/cpu_loop.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index 222ed1c670..0c3ec908e7 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -21,12 +21,13 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + void cpu_loop(CPUSH4State *env) { CPUState *cs = env_cpu(env); int trapnr, ret; - target_siginfo_t info; while (1) { bool arch_interrupt = true; @@ -58,18 +59,11 @@ void cpu_loop(CPUSH4State *env) /* just indicate that signals should be handled asap */ break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case 0xa0: case 0xc0: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->tea; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->tea); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451165 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FA96C4338F for ; Sun, 22 Aug 2021 04:12:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DF43761130 for ; Sun, 22 Aug 2021 04:12:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DF43761130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHeqZ-0005aZ-0c for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:12:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaW-0007vQ-Fh for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:01 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:36786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaV-0000pE-0e for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:00 -0400 Received: by mail-pj1-x102d.google.com with SMTP id u13-20020a17090abb0db0290177e1d9b3f7so16496065pjr.1 for ; Sat, 21 Aug 2021 20:55:58 -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=HZHOBf2F1kyrH2/d+/Nk4ZDYvJLaqXezPeFn7O5njyk=; b=kLKHL56ap+cW5BlPBR5VOML2MZOE9Unat0vb5GtGkta6Gy0oN6jM0MFj+iN+XvbCbu SHXbrIjrNcBHPj+0h44gTjGAq4aw5UeVoUe2LmBlMnuJDARtyMas5KF/VcgXy+X7mzbw Xa1eN8Q3UDq5MUfRoAZpUQL659CgaqxaSRnMgCzHMUqSHlzd0fHKpmg+Q2F2MvuGKuYA IKvAtAI6TNPMu97d13BTxAteDMklFGkn990z/wy1tGT6RbfntZiepOk+p3uGS2fsHeGX rlxoKlQedZhFwCgvMJ4mhexUXpcF14/J6uCwQDJO6EDYYc1zroiYRVWWmPnGQIkXysK4 j4MA== 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=HZHOBf2F1kyrH2/d+/Nk4ZDYvJLaqXezPeFn7O5njyk=; b=mZXt4Xtzu+lqTvc3YvPRR44iz5Gem8PUuiocopeAgzzJS3C38/TSQpya3CeK343n9+ +1OLMuKCcGbe8kdDRrTyyS28AtG/DR4lJXjuSbR7QHNqHUTW+L/cMHeC9cUQJD/ieZOg JDwedHAqehReuTzjrwpTHzooWcsecikUGMBjL30OgRVcGbewWgjx/YqnXVjhXk0BK5wf v+XNqTwIUMwQQVNCR8vtZ1QV7qwZ6ICidi1b21fK9VjuMT1zmRqhGxAd0Ig8OyVTXf3Y p5mXNmfUqBFtzSGO6bU4jryekqWcBtEl3RuKJN2wEnFwboI9U1E0n2vgxTBJIDeQgeGZ lqSw== X-Gm-Message-State: AOAM5312oXQ+PawWcsAE4jCr5yYccjXXTrmdnMMOIAC9GqMLJxRTqPSM Sv02etM/3EfKFk+Bh/8czMWsbjHbidv2Aw== X-Google-Smtp-Source: ABdhPJwBGZbEORaiSIoinzMM5HXuW/76O+2Ri6B1S6NBXIAwt7//bFFk9+DDmJJQQQaGPh4voLDiEQ== X-Received: by 2002:a17:90b:14d5:: with SMTP id jz21mr2973552pjb.11.1629604557758; Sat, 21 Aug 2021 20:55:57 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 29/30] linux-user/sparc: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:36 -0700 Message-Id: <20210822035537.283193-30-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::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/sparc/cpu_loop.c | 38 +++++++------------------------------ 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 02532f198d..20fca9f9f3 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -21,6 +21,7 @@ #include "qemu-common.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" #define SPARC64_STACK_BIAS 2047 @@ -153,7 +154,6 @@ void cpu_loop (CPUSPARCState *env) CPUState *cs = env_cpu(env); int trapnr; abi_long ret; - target_siginfo_t info; while (1) { cpu_exec_start(cs); @@ -219,14 +219,7 @@ void cpu_loop (CPUSPARCState *env) break; case TT_TFAULT: case TT_DFAULT: - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = env->mmuregs[4]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + force_sigsegv_for_addr(env->mmuregs[4]); break; #else case TT_SPILL: /* window overflow */ @@ -236,18 +229,10 @@ void cpu_loop (CPUSPARCState *env) restore_window(env); break; case TT_TFAULT: + force_sigsegv_for_addr(cpu_tsptr(env)->tpc); + break; case TT_DFAULT: - { - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - /* XXX: check env->error_code */ - info.si_code = TARGET_SEGV_MAPERR; - if (trapnr == TT_DFAULT) - info._sifields._sigfault._addr = env->dmmu.mmuregs[4]; - else - info._sifields._sigfault._addr = cpu_tsptr(env)->tpc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + force_sigsegv_for_addr(env->dmmu.mmuregs[4]); break; #ifndef TARGET_ABI32 case 0x16e: @@ -264,19 +249,10 @@ void cpu_loop (CPUSPARCState *env) /* just indicate that signals should be handled asap */ break; case TT_ILL_INSN: - { - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = TARGET_ILL_ILLOPC; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->pc); break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->pc); break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); From patchwork Sun Aug 22 03:55:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12451173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15361C4338F for ; Sun, 22 Aug 2021 04:17:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A6A8261284 for ; Sun, 22 Aug 2021 04:17:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A6A8261284 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHevl-0005lf-Rs for qemu-devel@archiver.kernel.org; Sun, 22 Aug 2021 00:17:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHeaX-0007vR-42 for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:02 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:36712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mHeaV-0000pW-Kh for qemu-devel@nongnu.org; Sat, 21 Aug 2021 23:56:00 -0400 Received: by mail-pg1-x535.google.com with SMTP id t1so13339285pgv.3 for ; Sat, 21 Aug 2021 20:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OTd7GpVNfJwdpnYm/hpk5WQx19kQn+kD8ce7/pdQayk=; b=Yw88Rh1dIc1WlEzidobtk/THqqQiOTwl6pdI2/Hfhmf6sVvIlJS2w8NeeUOmewmWnI iqRQ14ZziL96vLYn8T1pBHHtbd8ZbTuUykza+iPvG6k6DJzNjdCUkLZmWnlNPxNwltXm K5GcWrBdLSOZus93KGMn7erJFdJuVWFq7GFsgewvZe4euVVw1gtzLqwZ60bsXhBkIStX 081YEB/u6WJHauTMzUgN6nfhhHZvQAu1Tg0Q6o1xic/8EWdaDQKie0aIgwNAdED1GdGD a90Jq5tiZFpCjO4At0wRzOFJtegplsa00xxMdI3NkDZm8KWXdEUXt+VKkjx0JVrn0rou XZQg== 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=OTd7GpVNfJwdpnYm/hpk5WQx19kQn+kD8ce7/pdQayk=; b=NTAHyL2h3IYFjjOEOM4OIhThLos2Kmdr3s8C8Ug00JynBQnPrgxAFbB2/nKhrY2Ywx FmGLtGIUTBiqIzd2+Hat606NASMNs7NyM3tBCJ3wF6Q38vucqv0mMzbnUayzzhaNoLGT yNkwRdilbnivq4ltDdbhdPJYEqlbdEv89xQFUmxhbqfLlFWv3P/Fy1Lb9vEVKJHY88HP uZG6ID/T0DBeRudic5bO7qoQ3fv3cuEnMvj/uYNiAXi5+bjdt6P3n03iiuDbM024KGfP UdP/jQ342BFXKVeK7ZFbddSSYFtCB7J0xGvDBRnDiyabk+/+FDB8gp43pH7bNd31Yhkk EFzg== X-Gm-Message-State: AOAM5305yuWKh5aAADJDLs6+QdXoqjhUD1mVaULZVxYD83nISXgw5kyJ Zhm7mwhFoO8ylJw/QkNEpzwXCjF3CYyCwg== X-Google-Smtp-Source: ABdhPJyk8Tv2biTGIUuoZRFVRI11WbafDE79G5Q7RVLYZKy2gCjq7RlvtxZWgK/XofKtYDePwEkrjA== X-Received: by 2002:a63:1a46:: with SMTP id a6mr25749522pgm.226.1629604558362; Sat, 21 Aug 2021 20:55:58 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id x12sm11560533pfu.21.2021.08.21.20.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 20:55:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 30/30] linux-user/xtensa: Use force_sig_fault, force_sigsegv_for_addr Date: Sat, 21 Aug 2021 20:55:37 -0700 Message-Id: <20210822035537.283193-31-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::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the new functions instead of setting up a target_siginfo_t and calling queue_signal. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- linux-user/xtensa/cpu_loop.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/linux-user/xtensa/cpu_loop.c b/linux-user/xtensa/cpu_loop.c index 64831c9199..869a8501b8 100644 --- a/linux-user/xtensa/cpu_loop.c +++ b/linux-user/xtensa/cpu_loop.c @@ -20,6 +20,8 @@ #include "qemu/osdep.h" #include "qemu.h" #include "cpu_loop-common.h" +#include "signal-common.h" + static void xtensa_rfw(CPUXtensaState *env) { @@ -124,7 +126,6 @@ static void xtensa_underflow12(CPUXtensaState *env) void cpu_loop(CPUXtensaState *env) { CPUState *cs = env_cpu(env); - target_siginfo_t info; abi_ulong ret; int trapnr; @@ -161,14 +162,12 @@ void cpu_loop(CPUXtensaState *env) case EXC_USER: switch (env->sregs[EXCCAUSE]) { case ILLEGAL_INSTRUCTION_CAUSE: + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, + env->sregs[EPC1]); + break; case PRIVILEGED_CAUSE: - info.si_signo = TARGET_SIGILL; - info.si_errno = 0; - info.si_code = - env->sregs[EXCCAUSE] == ILLEGAL_INSTRUCTION_CAUSE ? - TARGET_ILL_ILLOPC : TARGET_ILL_PRVOPC; - info._sifields._sigfault._addr = env->sregs[EPC1]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, + env->sregs[EPC1]); break; case SYSCALL_CAUSE: @@ -217,20 +216,13 @@ void cpu_loop(CPUXtensaState *env) break; case INTEGER_DIVIDE_BY_ZERO_CAUSE: - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_INTDIV; - info._sifields._sigfault._addr = env->sregs[EPC1]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sig_fault(TARGET_SIGFPE, TARGET_FPE_INTDIV, + env->sregs[EPC1]); break; case LOAD_PROHIBITED_CAUSE: case STORE_PROHIBITED_CAUSE: - info.si_signo = TARGET_SIGSEGV; - info.si_errno = 0; - info.si_code = TARGET_SEGV_ACCERR; - info._sifields._sigfault._addr = env->sregs[EXCVADDR]; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + force_sigsegv_for_addr(env->sregs[EXCVADDR]); break; default: @@ -239,10 +231,8 @@ void cpu_loop(CPUXtensaState *env) } break; case EXCP_DEBUG: - 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); + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, + env->sregs[EPC1]); break; case EXC_DEBUG: default: