From patchwork Thu Feb 2 00:51:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 649641 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp609602pva; Wed, 1 Feb 2023 16:54:00 -0800 (PST) X-Google-Smtp-Source: AK7set8XDIEG/64ubuhXFJMyHS6IDuRn1h9FDUbsZ6oDXEHvbSFihO3/atI+ojgqsYvBLBM13Mst X-Received: by 2002:ac8:5989:0:b0:3b8:5810:5634 with SMTP id e9-20020ac85989000000b003b858105634mr7004021qte.8.1675299239922; Wed, 01 Feb 2023 16:53:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675299239; cv=none; d=google.com; s=arc-20160816; b=nC4DOVP1pNiHK/uGubHBwFFUx56plGPZe/Oxv4X38IKbKb1dRcNqIWWZEd09YoE5ZI x3cv3roGbRUiA+7TESZESB3BOwmI7gISdOJnbVRmAzWBP0/VbpmA3vzPmjSdHNdHeXb8 kKpBkxYWjtaophtYle5QIMqZ7SGxh0wVQILMRON/D+Z6xzfMAhv99YcMZNVNTkn1xSpd 58QqoDnWUwXGMvNnHytv0gzPI/poTJ4yskVKxlZiUHhA7iq36Q+0krHmcaTbF3kIvYoF M1aUP5shiQAsIUxzbFtEWXJBXtTOhE6fYTmyCugB6/60H3+9mJD8nvDiUk4LrB8K/r7+ EPMg== 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=0NlXg86UHyXHALJd4CNrXKqdR3YhnMuvIdL7EfthOjo=; b=NrxRMf0m9LI8VLZQiycQWVyBd256Vo+9F6qshOSbUUM+IrMXGkpVi8kkkeYbER/5gy XEnJ0qSW0BkErBwVf/5hql6agSp86NVSrT0sVFK+knTJp3CBTupNkmPq0gTnz//QL5Pz z0CIOD+H0itoGBT6+5EOfgXDl8wWrwKCudu6YYkEaoQRd/cFgZsXTk2pJtHjHrG6IlOo K7Sxe9BGCPOOrGWXSbS5msqrqPBKdcn5pliRl2z4seSO+00s6T6fQMWlYktejxwUHlbX uyGi6zbXgYWcLm9qd9zg+sJCrnqx+bhGW/JcdTlT9mAL1wAfNiHxzuoZ4MM8JYkgKYwd hkoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EWXTppJc; 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 pc41-20020a05620a842900b0071afd81d55bsi7916488qkn.536.2023.02.01.16.53.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2023 16:53:59 -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=EWXTppJc; 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 1pNNpn-0005zA-5m; Wed, 01 Feb 2023 19:52:15 -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 1pNNpl-0005yH-0r for qemu-devel@nongnu.org; Wed, 01 Feb 2023 19:52:13 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNNpj-0000OW-Dq for qemu-devel@nongnu.org; Wed, 01 Feb 2023 19:52:12 -0500 Received: by mail-pl1-x633.google.com with SMTP id d3so270874plr.10 for ; Wed, 01 Feb 2023 16:52:11 -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=0NlXg86UHyXHALJd4CNrXKqdR3YhnMuvIdL7EfthOjo=; b=EWXTppJcRBEzev53O9g0l9etB9YMbLO90jmFC1wOnQqMkq0TgXVsPun8yhL2UUAuzo hWQYGxTtNSHpQ1iF4HrKNaIh22ie1ug4E+lEWt3mlv6eq1xWNKGlfZMqcWG/znC1ws1v ULTtODWbHfGq9YJEIFwIaquk9HV5sGLae4ceQaeam5paDnYjq+1zrkzow1UnhofBNQr6 JoEMZj9c+sJA801DRktJXk8ERjA75Wuv8NZ0xRIlIFep2HnDTma6uiPKAIwLcHq9WNbr U8aobKq+M32DTVyRKAQNPPlIQCWPzoIbBCxF0JRFlFwIlVYzupv2Ku5YzjdNsSvu3An7 Ph1A== 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=0NlXg86UHyXHALJd4CNrXKqdR3YhnMuvIdL7EfthOjo=; b=kpTGK4dDLFP1CkdiRPaTggP/WXQevJC4miN18ERsdWPiaCkrNg/isozSEsuNWUWeFq GQhq/rsovDhYO1bcjuhZV7RWD6T/ToMV0QBn7C4ItIHoHjL6rAvSW64zmaThESb4/Xx5 e5+DaPJrhD1IRCPx2uVvuLLGMhkyKLbJ3IBdyXaYq3N4YBg/K722dWccTKs3s5P6OfFf R6PmaBHBTQSUdlApCKL2E9y4gs7dS84F4NOwBC7vYfF096lwEtdbmWqc1BZu4+tDK8KC zEB3OftIh7xw6BGVnufshC2TxOlwVU9jeLwEggs0DIpPmdBl1D6604/jIaSpLgZxR4Vx kP3Q== X-Gm-Message-State: AO0yUKXqpDuOK8lMM6BONo3KS/7X1iWyG7lWzLhkrQw1QrntRlfcNmya HZ193KC7hdsMe+ciyHwK3ERg+aQOGlu3BkWp X-Received: by 2002:a17:903:234f:b0:194:4b98:42c8 with SMTP id c15-20020a170903234f00b001944b9842c8mr5512643plh.28.1675299130093; Wed, 01 Feb 2023 16:52:10 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id z3-20020a1709028f8300b00192cf87ed25sm12391334plo.35.2023.02.01.16.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 16:52:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, laurent@vivier.eu, iii@linux.ibm.com Subject: [PATCH 01/14] linux-user/sparc: Raise SIGILL for all unhandled software traps Date: Wed, 1 Feb 2023 14:51:51 -1000 Message-Id: <20230202005204.2055899-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202005204.2055899-1-richard.henderson@linaro.org> References: <20230202005204.2055899-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.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. Reported-by: Ilya Leoshkevich Signed-off-by: Richard Henderson Tested-by: Ilya Leoshkevich --- 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);