From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cross.elm.relay.mailchannels.net (cross.elm.relay.mailchannels.net [23.83.212.46]) by sourceware.org (Postfix) with ESMTPS id 545303857C4C; Mon, 26 Apr 2021 00:44:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 545303857C4C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=eagercon.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eager@eagercon.com X-Sender-Id: dreamhost|x-authsender|eager@eagerm.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id D8090701227; Mon, 26 Apr 2021 00:44:32 +0000 (UTC) Received: from pdx1-sub0-mail-a46.g.dreamhost.com (100-96-16-56.trex.outbound.svc.cluster.local [100.96.16.56]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 643967011AF; Mon, 26 Apr 2021 00:44:32 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|eager@eagerm.com Received: from pdx1-sub0-mail-a46.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.16.56 (trex/6.2.1); Mon, 26 Apr 2021 00:44:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|eager@eagerm.com X-MailChannels-Auth-Id: dreamhost X-Bottle-Eyes: 50fb7c206446bc8a_1619397872690_3469881010 X-MC-Loop-Signature: 1619397872690:1191657551 X-MC-Ingress-Time: 1619397872689 Received: from pdx1-sub0-mail-a46.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTP id 2B1FA7E3DA; Sun, 25 Apr 2021 17:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=eagercon.com; h=subject:to :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=eagercon.com; bh=Bp4l ucamUJVFM5tQQDHhn96LOP8=; b=sF+I/wrxdX6CwX1Ely0qX78xvkfDwlZBx/TK Vc4BeleWZN6Woc3JuqbJhoX17142uO1lXtUPNoH/UB+Lh268cbA6N0mMI3ZVABSh nCdIwOI7vHY8CMNyHtWFc4cFQsVF85WSzaBO5b/jnnkUcANQZwVZsOOz/qJHmBTZ O6hUY1Q= Received: from [192.168.20.41] (c-24-6-12-13.hsd1.ca.comcast.net [24.6.12.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: eager@eagerm.com) by pdx1-sub0-mail-a46.g.dreamhost.com (Postfix) with ESMTPSA id 95A687E3C4; Sun, 25 Apr 2021 17:44:30 -0700 (PDT) Subject: Re: Microblaze libgloss and gdb simulator To: Joel Sherrill , gdb@sourceware.org, Newlib , Mike Frysinger References: <30fc7511-5f60-e611-d732-57cdaad80107@eagercon.com> <6d72dbe2-efe3-f8ba-3c2b-0c248883649b@eagercon.com> X-DH-BACKEND: pdx1-sub0-mail-a46 From: Michael Eager Message-ID: Date: Sun, 25 Apr 2021 17:44:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2021 00:44:36 -0000 On 4/25/21 4:34 PM, Mike Frysinger wrote: >> If you are simulating a program which uses libgloss and you expect the >> behavior of brki to be a syscall, then this is a very reasonable way >> to implement system calls. Instead of taking the branch to the handler, >> the simulator does whatever host system call it is supposed to do, then >> returns, just as if there was an OS handling the system call. (This is >> what QEMU calls "semihosting".) > > yes, this is exactly what we were thinking. i wasn't aware of the QEMU > terminology, thanks. in the GNU sim, we call them "environments". the > default is the virtual environment which behaves this way: there is only > one privilege level, and any exception processing is handled entirely in > the sim itself. The "semihosting" terminology may be an ARM-ism, rather than a QEMU-ism, although that's where I saw it first mentioned. https://www.keil.com/support/man/docs/armcc/armcc_pge1358787046598.htm https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/What-are-none-nohost-and-semihost-libraries/m-p/475327 The debugger (or debugger agent on the target) uses a side channel to perform I/O on the host. I wasn't aware of sim environments. I haven't looked at gdb/sim in a long time. :-) >> I was thinking about the more general case, where you might be >> simulating an image which includes an exception handler. In this >> case, the behavior you want is to take the exception and jump to the >> excption handler address, instead of the simlator interpreting the >> brki as a syscall. > > absolutely this makes sense. this would be the "operating" environment > where the sim wouldn't hijack anything, and it would be responsible for > emulating the various privilege levels such as setting mode bits and > transferring control to any registered exception handlers. this would > be useful for e.g. fully simulating the Linux kernel & userland. > > it sounds like we're in agreement. if there's anyone you think we could > or should consult before moving forward, please loop them in. Go for it! -- Michael Eager