Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8552DC3ABCD for ; Mon, 12 May 2025 12:51:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEScZ-00070C-5c; Mon, 12 May 2025 08:51:03 -0400 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 1uEScO-0006mL-Vp for qemu-riscv@nongnu.org; Mon, 12 May 2025 08:50:54 -0400 Received: from mail-vk1-xa35.google.com ([2607:f8b0:4864:20::a35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uEScJ-0005Vz-65 for qemu-riscv@nongnu.org; Mon, 12 May 2025 08:50:52 -0400 Received: by mail-vk1-xa35.google.com with SMTP id 71dfb90a1353d-52410fb2afeso3721138e0c.3 for ; Mon, 12 May 2025 05:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1747054244; x=1747659044; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QSSlv24hY/0OC75zbPVyrlSff1NxfPyECcOS06euD48=; b=aQCVxPYltLb0rbP5u+YbyF0bFEJ9NRAR2wA6piNEvEudQaJZNmUDXbu1Ghyf/WPzNR RjuRbIxQ+PM9zAdDKUbO8CdnME6UI478AnqC13GESHTuhf702XB4nqrfuC4OkDA2z/kS HOjYNiDU3MDZRY/cIT5SpKBrc9G/oxD6LIFRlL8vaAzo0OFi5clu+c0GoYbd+uv/ouTY eEHN+sAxQphw2EKRRmKiVDEfDxlYBp735/2QtszAL/o9jrfuhBLaBzXpAlqsRCajH7cY vx7eR5rkVIE5CuB1v1K58X9zQhiu0n29dNT4QiSDukda4/l/lBoCjPZVLbEwHHnDHwUY F03g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747054244; x=1747659044; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QSSlv24hY/0OC75zbPVyrlSff1NxfPyECcOS06euD48=; b=r5PibTo94Gw4vovQOkBEkEeTmpXnAvvcrQXKB4xmQ/XBN/YZ7hvSTYQQ18pwA1bCmu Zp+04NxAYZr99aBgcqf8/sTi/06YOnjZE01RkNclFG4TIFroujDStFeX0YcdnBheItfp gMiMBC9/NS0CDJeHQVA5WWlwjwvFMHQ8Lcmu1f5XRvA4Ip/xdyxIfh2Ue/5ikcqiCHoU DJfZ0lxkr3J9502fV398eH9VxVHMyq7fNdbD6ril+pkBPUrDVCrY9kbSq8viR5Gb7PvS R0Yy+aJgmyivPP1jFJDK2sbsT/vB5MnqxuOyD4dFBOJjf3Mb+nDB9GEwI0EqWeg1zLBA zHrg== X-Forwarded-Encrypted: i=1; AJvYcCWY8dLGYvHg/sg/KWOwg0BdPCV9JaprJAj1lZMCtE+6eyjwzulKpmA/5zL6qqY1XyXheiLRKjDgChTe@nongnu.org X-Gm-Message-State: AOJu0YxdMQjxrdePCFON6OYi6bNnSlnIHO3bAyvhWGB86+EYMtaMer0C G6Y4q+oi22BMJAdUCzufe6AQrX7OwYoGYF160c+aEiaBpqbtLkdsm6j967IL5Mtx0WtMBK+yr10 y X-Gm-Gg: ASbGncs4ovi+f4G86SjrZqtst6ya0hyxfsNoO6+tfpXo0GR0tZjU+e8Fpjv6W3AXR3o MWrVz9HgEs03wXwQApIY7c19Qp4WgwMgAZ9dUlWVHELBLJW3x0L6YnXoIxkeaCe9DfOiOXtYZLm WjDrCHPseaqp/3p6P4NQ0GMEnwkJJqk+vdUrPfKlIjnNzmwYrliiLArXuL7q9EaNLrGOg+4gRrR pbQe4stuwcv/stSX077m1hkR4Duxe1X/QqxmmIJgKhOziOiVctKDfPkEQ3SSWk9PHHy9QzyVfyi Y9Jo6CaKXhOXjd/LF6zT6ByPeoOhx3k3ypNM2Zib3oxQBs8CQcccutenk2sepuPQ1A== X-Google-Smtp-Source: AGHT+IH6bmtgT2/mht+6ILASt5GRwy3jNmqCtRv3qy0s4D92P1EJIgdvwpzakregeeVBeTZWlfJSCw== X-Received: by 2002:a05:6122:8c0e:b0:523:91e8:324c with SMTP id 71dfb90a1353d-52c53ce32fdmr9120311e0c.8.1747054244273; Mon, 12 May 2025 05:50:44 -0700 (PDT) Received: from [192.168.68.110] ([152.234.125.33]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-52c538a6e70sm5524272e0c.39.2025.05.12.05.50.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 May 2025 05:50:43 -0700 (PDT) Message-ID: Date: Mon, 12 May 2025 09:50:40 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 22/23] tests: add test for double-traps on rv64 To: Julian Ganz , qemu-devel@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Weiwei Li , Liu Zhiwei , "open list:RISC-V TCG CPUs" References: Content-Language: en-US From: Daniel Henrique Barboza In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::a35; envelope-from=dbarboza@ventanamicro.com; helo=mail-vk1-xa35.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@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-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org On 5/11/25 10:22 AM, Julian Ganz wrote: > We do have a number of test-caes for various architectures exercising s/test-caes/test-case > their interrupt/exception logic. However, for the recently introduced > trap API we also want to exercise the logic for double traps on at leat s/leat/least ? > one architecture. > > Signed-off-by: Julian Ganz > --- With the commit msg typos fixed: Reviewed-by: Daniel Henrique Barboza > tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ > tests/tcg/riscv64/doubletrap.S | 73 +++++++++++++++++++++++ > 2 files changed, 79 insertions(+) > create mode 100644 tests/tcg/riscv64/doubletrap.S > > diff --git a/tests/tcg/riscv64/Makefile.softmmu-target b/tests/tcg/riscv64/Makefile.softmmu-target > index 7c1d44d3f4..5fba973e18 100644 > --- a/tests/tcg/riscv64/Makefile.softmmu-target > +++ b/tests/tcg/riscv64/Makefile.softmmu-target > @@ -20,5 +20,11 @@ EXTRA_RUNS += run-issue1060 > run-issue1060: issue1060 > $(call run-test, $<, $(QEMU) $(QEMU_OPTS)$<) > > +EXTRA_RUNS += run-plugin-doubletrap > +run-plugin-doubletrap: doubletrap > + $(call run-test, $<, \ > + $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ > + $(QEMU_OPTS)$<) > + > # We don't currently support the multiarch system tests > undefine MULTIARCH_TESTS > diff --git a/tests/tcg/riscv64/doubletrap.S b/tests/tcg/riscv64/doubletrap.S > new file mode 100644 > index 0000000000..b61089c9c1 > --- /dev/null > +++ b/tests/tcg/riscv64/doubletrap.S > @@ -0,0 +1,73 @@ > + .option norvc > + > + .text > + .global _start > +_start: > + # Set up vectored interrupts > + lla t0, trap > + add t0, t0, 1 > + csrw mtvec, t0 > + > + # Enable sw interrupts > + csrrsi zero, mie, 0x8 > + csrrsi zero, mstatus, 0x8 > + > + # Engage the double trap: we trigger an machine-level software > + # interrupt, which will trap to an illegal instruction > + lui t1, 0x02000 > + li t0, 1 > + sw t0, 0(t1) > + > + # If we still not went out via the software interrupt route after a > + # short while, we failed the test. > + lui t0, 0x1 > +0: > + addi t0, t0, -1 > + bnez t0, 0b > + j fail > + > +trap: > + j illegal_insn # Exceptions > + j fail # Supervisor software interrupt > + j fail > + .insn i CUSTOM_0, 0, x0, x0, 0 # Machine software interrupt > + j fail > + j fail # Supervisor timer interrupt > + j fail > + j fail # Machine timer interrupt > + j fail > + j fail # Supervisor external interrupt > + j fail > + j fail # Machine external interrupt > + j fail > + j fail # Counter overflow interrupt > + j fail > + j fail > + > +illegal_insn: > + # Check whether we really got an illegal instruction > + csrr t0, mcause > + li t1, 2 > + bne t0, t1, fail > + li a0, 0 > + j _exit > +fail: > + li a0, 1 > +_exit: > + lla a1, semiargs > + li t0, 0x20026 # ADP_Stopped_ApplicationExit > + sd t0, 0(a1) > + sd a0, 8(a1) > + li a0, 0x20 # TARGET_SYS_EXIT_EXTENDED > + > + # Semihosting call sequence > + .balign 16 > + slli zero, zero, 0x1f > + ebreak > + srai zero, zero, 0x7 > + j . > + > + .data > + .balign 16 > +semiargs: > + .space 16