From patchwork Thu Feb 16 05:45:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 654008 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp177281wrr; Wed, 15 Feb 2023 21:46:20 -0800 (PST) X-Google-Smtp-Source: AK7set8rs5IE4BfQq07AHcXGpTbv5vBkvaeBPhraJ6Ic3sDf9eXeJrxMhiuJoZF7sxIZFzuYtuNn X-Received: by 2002:a05:622a:50c:b0:3ba:101e:88c6 with SMTP id l12-20020a05622a050c00b003ba101e88c6mr8080886qtx.48.1676526380148; Wed, 15 Feb 2023 21:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676526380; cv=none; d=google.com; s=arc-20160816; b=LEX19M0A8mqEsEjjk77VLvU5lFDQwATZeiyAEXfL7XkENHZEEvF/7l42JT5iS2I4wn f7rgNoJorLbkYl9+hHwm8abMRQI0EnLAyTc5YzVAOyC6OQvbuJlyBSyfyH0UP1vlJYyN 0MPqgV4Nd6UsAmGvwOx1Z42wHgqduu8IxT84li3gcg7rE+Z1fPXPxA/8iHnvEL2O35/R /mKNzXF3x1vmIuXZ1kJh+BgLb7qACCGmNbIOLD7hXhlBSr8T3WoqMIqZWLlq7C+FAPkc Nyv+U/K4+SUk3Je2SjlrDtoFoo9DkVEY8q0dCjbGaTqu1W2+1hFWgBKSRVSwP8JrNDJi j1Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4zhGePcD91yQ6ch+7pxzLZ4Aayz4MXPEoGj6QOyVgUM=; b=MFUrumsdyRHttfWc2bGZZLd9iwHzNlhnem1ONF4n6OjmaJNJTSJLtnb9tAiaTtcGnR 7QhORGO9BnG/LavDom4y0EpqChbUD0IyIJkAf7RGeNo1VS91L1PdDQI4+wJqy1kPEz4e B6im5gZPZ7FJ54g8l8xw1JLKxrC2ckTIOlLYuQgU2/26NiQSUD/8y0eTJzXJlvkvA5EN fDRK/+0VvWU2wojGY2KdYkC+GsQFdRyd6/94LEpQFJe8ZU0b5tHRR1K/DHgYturytYZ9 vxT/8uSrTxFD8pO5XLS2aRybkBkCnD7WCddxhWrOSyyNzPK1uMyZSxAT6lSqsnqWaEy1 KFTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PNMBYKOb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s205-20020a3745d6000000b007169c14b660si680425qka.167.2023.02.15.21.46.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Feb 2023 21:46:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PNMBYKOb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSX5X-0001G0-VV; Thu, 16 Feb 2023 00:45:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pSX5N-000115-JK for qemu-devel@nongnu.org; Thu, 16 Feb 2023 00:45:38 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSX5L-00012Y-Qs for qemu-devel@nongnu.org; Thu, 16 Feb 2023 00:45:37 -0500 Received: by mail-pl1-x62f.google.com with SMTP id jk14so974563plb.8 for ; Wed, 15 Feb 2023 21:45:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4zhGePcD91yQ6ch+7pxzLZ4Aayz4MXPEoGj6QOyVgUM=; b=PNMBYKObCsz9WrJuxjzHRldkjkZuouINoye/Ir95MRsAhV+ZdwMvogcORdZQrb048v UoKCoQRRiNCu8G+k3rdWdYhpDgDr0LTfarXVDkpw9urzp3cjI8GkPDX9kE7XLKZQBDSs ol0MUH7GlBFHWW4Qf2uT69lF7S5vUitidTYeSgmGmYECFkp0+agv/xMCNNtAzQoY/+fd PcC062P2uWm2eCeVRoi84iKESkX6eISdSS8xj2q8FU+oSnuEO/rBuH5DoxqetJ14q+DT htFObL+TRfJzZYPtHQPEQGW72zb7LOk1p0i9bIg8GHoUKcMLdNfCk1ZocfwCdXJdXOB1 HGEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4zhGePcD91yQ6ch+7pxzLZ4Aayz4MXPEoGj6QOyVgUM=; b=Xal5ItFFcvfoEhuFuBi9SVlNZD4bwJ322X14S4U0PzVffKW4b5CRnFXhhNpQ6A23kx sktpleZY8LSfBcTa0XmePu5RZoQExwXB8ttySghiZ30969RC+a2JZGPDEriVK8tuXWFN 0PFouEd7fiRbwKFNfklswnsp/d5HKB/bGCH8++Cvfw5yhqaO15XfH8phSzB4n7+0GDKZ 3Ewo2hBct/RZVigPfboAuJacV222q3wxA6ok1uOn4euR5Hrcm1ghGH4AA+bBBtF3d9fw 1fd+f/ZS/LmWkTgkchUp0Vg1nPY7bMhQ8DphAuKOkE3dmhfTL5n8cGoD9iKnXs108dDI fzhQ== X-Gm-Message-State: AO0yUKUbBhp7BkKq6dLBEfirB51xCOpxTwArOWF+ZSOut/y6olHbD7ED T7dZ4bcRAyNBo5lMoO5xm8ZOM4ueA4AeUWKnGNM= X-Received: by 2002:a05:6a20:7d95:b0:c7:23ad:63eb with SMTP id v21-20020a056a207d9500b000c723ad63ebmr1073519pzj.10.1676526334190; Wed, 15 Feb 2023 21:45:34 -0800 (PST) Received: from stoup.. (rrcs-74-87-59-234.west.biz.rr.com. [74.87.59.234]) by smtp.gmail.com with ESMTPSA id j184-20020a6380c1000000b0047917991e83sm358034pgd.48.2023.02.15.21.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Feb 2023 21:45:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, Ilya Leoshkevich Subject: [PATCH v2 01/15] linux-user/sparc: Raise SIGILL for all unhandled software traps Date: Wed, 15 Feb 2023 19:45:02 -1000 Message-Id: <20230216054516.1267305-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230216054516.1267305-1-richard.henderson@linaro.org> References: <20230216054516.1267305-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The linux kernel's trap tables vector all unassigned trap numbers to BAD_TRAP, which then raises SIGILL. Tested-by: Ilya Leoshkevich Reported-by: Ilya Leoshkevich Signed-off-by: Richard Henderson --- linux-user/sparc/cpu_loop.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 434c90a55f..c120c42278 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -248,6 +248,14 @@ void cpu_loop (CPUSPARCState *env) cpu_exec_step_atomic(cs); break; default: + /* + * Most software trap numbers vector to BAD_TRAP. + * Handle anything not explicitly matched above. + */ + if (trapnr >= TT_TRAP && trapnr <= TT_TRAP + 0x7f) { + force_sig_fault(TARGET_SIGILL, ILL_ILLTRP, env->pc); + break; + } fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE);