From patchwork Thu Mar 9 20:16:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 661130 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp504177wrb; Thu, 9 Mar 2023 12:25:47 -0800 (PST) X-Google-Smtp-Source: AK7set/xat4zX9JGKB+XNloMHaP2sCt5sOMIKv25d+nD67ncO8Be1G6g9+aarhc6OBOPIgcUgJqB X-Received: by 2002:a05:622a:1895:b0:3bf:b504:d5ea with SMTP id v21-20020a05622a189500b003bfb504d5eamr6193461qtc.48.1678393547628; Thu, 09 Mar 2023 12:25:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678393547; cv=none; d=google.com; s=arc-20160816; b=vKZ/5F1CZN+BVw5xlYWvYW0HKGEw6nGbS+IeHW3C7ntsATuD0wXksH7DCnckpdniCK VoHwHXXt/UUeb8l4uADtd4U+nwAafar1HPCzXgz9zJMTG4QUaw4/v1zwDnpQeVTn09On ML4fd+R5GKlGSyXxPxzz7atr5QAQBPCvRvnJu7jAtML83EkRcuGD9xOl2HO58xCa3WO3 SJrdIXQI42nkgfqIoFB187PrtZtHeucyPAFqjKrvA7vdKyN1NNDmmv6H9Xnhvmr6Agqi FDNCEFUNL2BlzclcP9PVVjO7YbmPGjwt5iO2EUuoM29kxkl/5/nnGT3i7yiudGfmC6VK lSvw== 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=dMeG1HwbQDXPwGHTmyb1B+zs2kscYWiAZRcxkV3XrFk=; b=S+dI2FDfK8k8Tk2uBkn9eAZuTRQgMO9b7jgL3PAPZDsGk4/OfQSdxVKcSPcaXrSkzM MLFotxgXPMqaQvMhoiXUtmn3gUhSNnaxN7pUg44fWlMgGt/NQLJoq4VxwBMRVmy8200D YdbOw2BCkusD5bq7HGoHjiAmKbZ68RHv0zxtLyN3ZQXDKAjxbw7Sks8sZ/RfgkPozIcl eWiFwSBEpvKsiPA5XcdX71DZMrMpomaoS6L+hwRd29T2VME7C3mG1J3cVfm/fi2j/zXE G6an7WfnaM3WYSrnfCo7acPSpvzQO9tvgHfFqS2fYbh8uAxqJV1DLryOmKCWb4eeQfOL qJng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bVJ+aaPA; 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 p18-20020a05622a00d200b003ba114d6520si15911073qtw.317.2023.03.09.12.25.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Mar 2023 12:25:47 -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=bVJ+aaPA; 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 1paMgV-0007DQ-63; Thu, 09 Mar 2023 15:16:19 -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 1paMgN-0006QT-EZ for qemu-devel@nongnu.org; Thu, 09 Mar 2023 15:16:11 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1paMgL-0002s7-4F for qemu-devel@nongnu.org; Thu, 09 Mar 2023 15:16:11 -0500 Received: by mail-pj1-x102f.google.com with SMTP id nn12so3160909pjb.5 for ; Thu, 09 Mar 2023 12:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678392967; 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=dMeG1HwbQDXPwGHTmyb1B+zs2kscYWiAZRcxkV3XrFk=; b=bVJ+aaPAh0RouOjtJTNFrr/yOv+/aYxxMYjxuwDhsU71tKfMCz+a+EkUKWKSuMZ1OA GAHoCjOQrer2jWvByBJPFf2tXAr4jxixT+QgcC1BbHmdof6YdUbLrPU/zZ0Tely4aV52 aLFyHXWMBCiNWLDhjWnEIv3ah9KNL+xRS3Pn4eT7POpn7aCQXGZ0Z42xRPJmwGKVF4n5 2P6iVrJMamynCxgIi9z/U8EfpZtjNlMaVAqZ5p8CNCraRSYb74rL1yWlEvJ+vco3xSYB VbrYI9LZMpk4O7CPzRBOY/v+x0b9hyosjaBcUWBum/uVjuziwDjnV53wA1E5HzMpQjlI ryPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678392967; 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=dMeG1HwbQDXPwGHTmyb1B+zs2kscYWiAZRcxkV3XrFk=; b=3crPar8V7EfZb5TpeNqkuyw10YIhPpboUclU26rKfyk58k0sKkkLj9CFb6rFQoM8RQ lxCIzS+wO4dpXpHffT/BIPZzQcsGhEMQSTLYT1lmTthHHXW0SkFvd7jUZB8L36vSd16z Ai/Jot92AP3AzDjW/U5HDkCqo4cuYdfXUsr+QTCUSPhURq2jagYtIhCHb3NhOYtXV5Tk ndx7jjN6kkIZkkwkBMX6D5gm6SP1M9C17UUHYpjsIqOXQVK/yMO883AocHJqceJfNKWm tesN4weEK7XMR1xIISfhlr0XcVvmWFUTSNyiPxWNoEC6CGf5KtWooF5/UjwECJ1VO/eW 6Upw== X-Gm-Message-State: AO0yUKViX9qlva7aEL7yeJ0qpqdnzv6by1EJXnxpItO0E4KPbB3NfVdw GuCA0ukUPT9MmRpoXtCcx7342HGFKzzseV577uI= X-Received: by 2002:a17:90b:38c7:b0:234:b03:5a70 with SMTP id nn7-20020a17090b38c700b002340b035a70mr23946139pjb.35.1678392967338; Thu, 09 Mar 2023 12:16:07 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:bf7f:79a0:a976:bdaf]) by smtp.gmail.com with ESMTPSA id w4-20020a17090a1b8400b0023377b98c7csm304094pjc.38.2023.03.09.12.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 12:16:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu Subject: [PATCH v2 2/2] linux-user/m68k: Handle EXCP_ADDRESS in cpu_loop Date: Thu, 9 Mar 2023 12:16:04 -0800 Message-Id: <20230309201604.3885359-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309201604.3885359-1-richard.henderson@linaro.org> References: <20230309201604.3885359-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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 This exception can be raised by illegal instructions. Signed-off-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/m68k/cpu_loop.c | 5 ++++- tests/tcg/m68k/excp-address.c | 32 ++++++++++++++++++++++++++++++++ tests/tcg/m68k/Makefile.target | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/m68k/excp-address.c diff --git a/linux-user/m68k/cpu_loop.c b/linux-user/m68k/cpu_loop.c index caead1cb74..84b5d290c0 100644 --- a/linux-user/m68k/cpu_loop.c +++ b/linux-user/m68k/cpu_loop.c @@ -35,7 +35,10 @@ void cpu_loop(CPUM68KState *env) cpu_exec_end(cs); process_queued_cpu_work(cs); - switch(trapnr) { + switch (trapnr) { + case EXCP_ADDRESS: + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, env->pc); + break; case EXCP_ILLEGAL: case EXCP_LINEA: case EXCP_LINEF: diff --git a/tests/tcg/m68k/excp-address.c b/tests/tcg/m68k/excp-address.c new file mode 100644 index 0000000000..1dbdddef58 --- /dev/null +++ b/tests/tcg/m68k/excp-address.c @@ -0,0 +1,32 @@ +/* + * Test m68k address exception + */ + +#define _GNU_SOURCE 1 +#include +#include + +static void sig_handler(int sig, siginfo_t *si, void *puc) +{ + exit(0); +} + +int main(int argc, char **argv) +{ + struct sigaction act = { + .sa_sigaction = sig_handler, + .sa_flags = SA_SIGINFO + }; + + sigaction(SIGBUS, &act, NULL); + + /* + * addl %d0,#0 -- with immediate as destination is illegal. + * Buggy qemu interpreted the insn as 5 words: 2 for immediate source + * and another 2 for immediate destination. Provide all that padding + * so that abort gets called. + */ + asm volatile(".word 0xd1bc,0,0,0,0"); + + abort(); +} diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 1163c7ef03..d3b0bc48a3 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -4,6 +4,7 @@ # VPATH += $(SRC_PATH)/tests/tcg/m68k +TESTS += excp-address TESTS += trap # On m68k Linux supports 4k and 8k pages (but 8k is currently broken)