From nobody Mon Jan 29 18:37:25 2024 X-Original-To: riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TNxqV2YD7z59B4r for ; Mon, 29 Jan 2024 18:37:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TNxqV1VFDz58Bh for ; Mon, 29 Jan 2024 18:37:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706553446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l1IetuNJOdi+I7xHQ7wbKrq3aM9sIHK7ricvkKtd76A=; b=eeH4JiiwOuD12xnBA/5ZclrSeEwxQdRzCMscw1oiZC9yfAPcqfG6e4dTHiqvega+BFMT8d mPwP0Lw3r0zw/IDHRK1oOH8vYJxsV4z8k1fqY7Dehb6W/5x0NxeZvwYqN6ktapYBWWkAYm XE2GMnxVl/JkK3pxqnTSo4p24VME1oz5VdF8jLE8SB8ctDVPU5R7w2sis/Dcoe1AfMZg6c Rwev1KsQO2QWOiyQ8+qtOoElEEwWB7nHakNbghca0L9oJri0xk4mBngdtCy7pRZK2WM3h4 hhAuxgoPdYQIPr4eZOT/+0SRZM7/EluGj2O9XhYzQytLC9ybnTK1wtwB3/iIQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706553446; a=rsa-sha256; cv=none; b=wJk/6OapzElcKcJnUnf1XF/rCmzYHz3W9WIav9Wn28OQtH1GaiJANcfMXncbfdq87vEksA UwieV0m8ALealLBQB9SHCPD+2I4Pxcz/zC5141P/TCAYb0bN2QrGYSE5uEZHjVVXu7NeJG t6uVPpFU7dkHscY5bAncJXbWQIH7UK1h9oQ9QIL6xD8oiOUrX+mu0iwf7B56GpiKPDMeIJ 971NTMeOb2BKVmxqudpmc4F6VDI94dqpLM+f2IGY1sDv4ycN0mSK3gdY51/uDTNmnVnH3h tpP2bl4rtEJZgjw+a8JoDxJNLahN/8ASTahtC/OsED7oKlBrf0CV8qvldWn84w== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TNxqV0VXKz12bh for ; Mon, 29 Jan 2024 18:37:26 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40TIbQZC084964 for ; Mon, 29 Jan 2024 18:37:26 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40TIbQ25084959 for riscv@FreeBSD.org; Mon, 29 Jan 2024 18:37:26 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: riscv@FreeBSD.org Subject: [Bug 273438] PANIC: memory modified after free on relatively idle riscv -CURRENT Date: Mon, 29 Jan 2024 18:37:25 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: mhorne@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D273438 Mitchell Horne changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mhorne@freebsd.org --- Comment #7 from Mitchell Horne --- I looked at the back traces provided, and the allocation is speculatively belonging to the 'dbuf_kmem_cache' UMA zone, in dbuf_create(). Unfortunatel= y, the core.txt does not provide the context of the thread responsible for the store-after-free, so there is not enough here to deconstruct what might have happened, and whether this is an OpenZFS bug, an OpenZFS/riscv bug, or a FreeBSD/riscv bug. Commit a03c23931eec (Nov. 2023) adds additional information to the panic message, which would help in confirming some details of the allocation in question, including the offset of the store-after-free. If you update past = this point it would aid in further diagnosis. Also, inclusion of 'alltrace' ddb command output after the panic _might_ he= lp. https://cgit.freebsd.org/src/commit/?id=3Da03c23931eec567b0957c2a0b1102dba8= d538d98 --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Tue Jan 30 14:00:15 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPRdV5f7lz58tVw for ; Tue, 30 Jan 2024 14:00:30 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPRdT2g6Dz4gJx for ; Tue, 30 Jan 2024 14:00:29 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=Cw3+4SRe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of leelin2602@gmail.com designates 2607:f8b0:4864:20::433 as permitted sender) smtp.mailfrom=leelin2602@gmail.com Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6ddc268ce2bso2251161b3a.0 for ; Tue, 30 Jan 2024 06:00:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706623227; x=1707228027; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=sQ4FW8jg01GElFFUuxcx6AZBA4OrX9dyDk4Gj5z9sFU=; b=Cw3+4SReJIVBsXE+EtTo7bjgfrBUh5ScUnvr5zQMmjWUGYRIau1UK3PAA/hZ6n9FiC 3+FQ2lT+dLyPfwHrFv3DiXb2gB1HtqbWJs0yLmFwSeXf6ppRv7hSnYqi6vNQPAmOK2zu gyyq/5sbSp4geciMZ9jSsuNkFkQH3y062p4nDvoX/SUbVfcDsjvfWWPL0D4htqAo3xXK K2RNs0cgFB+7SVDEsdXHzNkPEXQz6475tiynQ1rsRn5Z1RDgREs6Kl6uJ5wje0T/iIB1 fIkqDI62RKpCA1mRfmsxd8TfT0jHlouPRG9SwmjgkM/kUlaHS+UnKuSeuLyEPMURc84A yYyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706623227; x=1707228027; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sQ4FW8jg01GElFFUuxcx6AZBA4OrX9dyDk4Gj5z9sFU=; b=PagOYZUpTcQG04nvb8LuHBIH1n93L5KSP3ZzYp3i6r1IADKQoEFAsfxWpaU0xERT8s MKUJ5OR55B2dKNJfXCFePuZmX/rQ/xqsbtTiqMXw/BcV4k9NbCKmQeJRImJ80QQbWp2M 1SzruGvoF8v4hWHgtHOsQmpL+7SrKhWKP5z6lXCIZXNisF1kfA14YHzzFy8Gdmla3vS7 QasJfgQFpyB+izMH2Xw6otKJQbIuuAj5s0agAXkz/QnAlKF+Yl403C5RmHsCbgi7vKtH 26pAqARMKZLbXmqqmSYsvTAzQl+vNij27yacvE+KdqNco57JsQeLekIuKvRgvPhP/HTC DvbA== X-Gm-Message-State: AOJu0YwMejCxx/C5Wf01p1lILVkoBJv2PMarnsBp/KLS7Wv3cmv4Ov+v JpYaHJwyKaSnVNDWuS9mMKnruLsdpUpUB8D+sQyusFaj7BOVrvYpEGijlm9hdJI= X-Google-Smtp-Source: AGHT+IHGwfcjoqpNEV7YE/I9J1TGcp94DwA7IJm0t7MSbWNWw66G5DFU/+55uNPmWeAGM4KskTOgcQ== X-Received: by 2002:a05:6a00:1992:b0:6de:1b57:ca8c with SMTP id d18-20020a056a00199200b006de1b57ca8cmr5395052pfl.23.1706623226406; Tue, 30 Jan 2024 06:00:26 -0800 (PST) Received: from [10.1.2.5] (123-193-26-19.dynamic.kbronet.com.tw. [123.193.26.19]) by smtp.gmail.com with ESMTPSA id jw16-20020a056a00929000b006d99056c4edsm7852219pfb.187.2024.01.30.06.00.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2024 06:00:25 -0800 (PST) Date: Tue, 30 Jan 2024 22:00:15 +0800 From: Lin Lee To: freebsd-riscv@freebsd.org Message-ID: <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> In-Reply-To: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> Subject: A little bit wondering about how a syscall works X-Readdle-Message-ID: 8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65b900f5_63760c8f_4d5" X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.29 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.79)[-0.787]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-riscv@freebsd.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; MLMMJ_DEST(0.00)[freebsd-riscv@freebsd.org]; MISSING_XM_UA(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::433:from] X-Rspamd-Queue-Id: 4TPRdT2g6Dz4gJx --65b900f5_63760c8f_4d5 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I am wondering about the function ecall=5Fhandler(https://github.com/free= bsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c=23L195), which later exe= cuting syscallenter, where=C2=A0&td->td=5Fsa =C2=A0Is used. I have no idea where the value of=C2=A0td->td=5Fsa is=C2=A0= being set. It is a little bit confusing. Someone asks me to read=C2=A0cpu=5Ffetch=5Fsyscall=5Fargs(https://github.= com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c=23L99), and it i= ndeed explains how=C2=A0td->td=5Fsa is being set. But however, I still ha= ve no idea how it works. It is called as a function member in=C2=A0elf64=5Ffreebsd=5Fsysvec(https:= //github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff754= 0c241/sys/riscv/riscv/elf=5Fmachdep.c=23L61C25-L61C45), and I think there= is nothing to do with syscall here. Could somebody please figure it out=3F How does a system call works=3F Where the value of=C2=A0td->td=5Fsa is=C2= =A0being set. Thank you very much. Best Regards, Lin Lee --65b900f5_63760c8f_4d5 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I am wondering about the function ecall=5Fhandler(<= a href=3D=22https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/ri= scv/trap.c=23L195=22 target=3D=22=5Fblank=22>https://github.com/freebsd/f= reebsd-src/blob/main/sys/riscv/riscv/trap.c=23L195), which later exec= uting syscallenter, where&=23160;&td->td=5Fsa
&=23160;Is used. I have no idea = where the value of&=23160;td->td=5Fsa is&=23160;be= ing set. It is a little bit confusing.

<= span style=3D=22color:=23000000;font-family:Helvetica Neue;font-size: sma= ll=22>Someone asks me to read&=23160;cpu=5Ffetch=5Fsyscall=5Fargs(= https://github.com/freebsd/f= reebsd-src/blob/main/sys/riscv/riscv/trap.c=23L99), and it indeed exp= lains how&=23160;td->td=5Fsa is being set. But however, I still= have no idea how it works.
It is c= alled as a function member in&=23160;elf64=5Ffreebsd=5Fsysvec(https://github.com/freebsd/freebsd-sr= c/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf=5Fmac= hdep.c=23L61C25-L61C45), and I think there is nothing to do with sysc= all here.

Could somebody please figure it out=3F
How does a system call works=3F Where the value of&=23160;td->td=5F= sa is&=23160;being set.


Thank you very much= .

Best Regards,
Lin Lee
--65b900f5_63760c8f_4d5-- From nobody Tue Jan 30 17:16:59 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPX0G17QQz59CjY for ; Tue, 30 Jan 2024 17:17:02 +0000 (UTC) (envelope-from mhorne@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPX0G0MMwz4J7l; Tue, 30 Jan 2024 17:17:02 +0000 (UTC) (envelope-from mhorne@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706635022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=u/Yp5MCIx1+zwmCCT4tFruZhejSshH6bj1TBBPfgHiw=; b=GvtjKh2oLdyH40hRHdAntVB28EO7RDpK1K/LYakIypDD3uqFs9IaAOqTgyKd+SHBlp/65K SEbRwzWwPpZOq55soWu9SXl7nOoqtSLxcq56TzH7M5UV5jGSp2a6KXxo0aTF6FVZ0sO4qC H7ApQtiio8KaCcO4reLan226rHqrld3pb9iApwrNJvrc28GZn8lcO/p8eounIdyBW01Drc bsUMMifd7lhC3xkXS4jfc22ZbX0pPLvZETvrhs4APa6eTbsOK2+xteF5RA0ReHDNbTkdbh RROK5RyNkFCBP2L9TDQAfGsV4rdkNDxy0ypcvuBbL/gr0rgj/f/NGryMtT2Fmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706635022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=u/Yp5MCIx1+zwmCCT4tFruZhejSshH6bj1TBBPfgHiw=; b=HOrR30e3YPBL0C4NEWwZbJnb1KzzbG/+bjVMUwVqMhQtsmaHljmWtLimsWbuADp0eeoLrV xC3HSumk8tUmY12PXU9wZtcrnzIccvFzBseNS4MWNRKWL4YWAIqsr7HCvIGcf0MAm3Cyxa fFIhpKiLehBFIuseAzDbk0A1DwS55UOrtFdDD8g+cYCQ+FGqZZLAGuOL0/FHfzLg2SeP07 s2Q/+lZbLP9ybOOVs83JWOXwqOgQE866jhbift8MaMMDae2JwvF9rnOp1te4WSkO2vmCjw UND1/7FY343kKueIg1c4cCHRtu5emzRq6pCdnbiiVxxKPZpHgbc7MGK2UOXBpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706635022; a=rsa-sha256; cv=none; b=V9D215yKh3UunGRLDM/0C9Zelg0/1gAmTVVOWLagB/Z2it46UaUUHTDmC+ACNBMsedInGo BANOnZz0YTXohCi7r5t2m0MmdHq78uh1pwNIajqtsqwksP+q0ppxafBhMTJ/eyq6v14WQ3 9mQvh6Fc1V5Tcvc4RZiZJnIqv7enAqNmTJ0AzYxF28IuU7sfZPs8pqBmPWApsNmoR0CA4T k3zDy4XlW5+PPlcBLx02mGIb2/bZajxgFbfbYfg3egV72VqrZEOzAZl0YJmgUNEKHfcsLH 2RAYgpQeRZrJlxgYHDpFD8GqROLE1MJptWHZn3BaeXEHajvaY42Gi4JbDds9iQ== Received: from [192.168.1.151] (host-173-212-76-127.public.eastlink.ca [173.212.76.127]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mhorne) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TPX0F5P4mzG5M; Tue, 30 Jan 2024 17:17:01 +0000 (UTC) (envelope-from mhorne@freebsd.org) Message-ID: <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> Date: Tue, 30 Jan 2024 13:16:59 -0400 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A little bit wondering about how a syscall works To: Lin Lee , freebsd-riscv@freebsd.org References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> Content-Language: en-CA From: Mitchell Horne Autocrypt: addr=mhorne@freebsd.org; keydata= xsBNBFyS2dQBCADdiXBG8hBVLmYbxu7aSzbwLwUf3HkGFz3rooS1kwyy+SfmjZ4UKNnl9WMx WKrJ7OAZpiNH6bLQ5nsqfx09OnpWL8c/QuPbhNdUywQoqqYpRI0K8GEn//nS9Gs0KTYwVpWb XlrzP+jf3Uh/9L5mcQmStLIH4zaaqMYHW+pMuPrvBmLIHTvLj2QjOkxslrcUdord9uvxe5Ht LU8RuTpQpHOKz705Z9/v7twFdi2HtKzpLwO6SzVyu351di1J+GihsVpcT5josQV5cHbIP3Un x+kmtKBEEc/jl/zBglF7ruWUtwgbryID+2ZPEaO1Mj+RResX4LFVMusq3uUpWRb5WJXxABEB AAHNI01pdGNoZWxsIEhvcm5lIDxtaG9ybmVARnJlZUJTRC5vcmc+wsCUBBMBCgA+AhsDBQsJ CAcCBhUKCQgLAgQWAgMBAh4BAheAFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDpUFCQtC z0EACgkQi/gnTOdUid8IsQf+N8IptrrCgifT5Z0/WUVFfnHThFOKf4zBjaGswsIM8+VKsKnF 15jCWHODUHP6s+dcQ4nQi81PHPsnMfBSkGPvN/X3ess2/1KUVkH+6tAJbqXDjXhD8HT+i0NM QEFIXlLnotpgIKW3yOHjKv3ZvKw9LCvUjyNY9vOJmLk/6AbbkFh+INo65nXtQWb/hM5FVEHW S+zUoU8AqZRJoVAQfj9wmIfg/HdsxeDGKL0zkv5AwKpccvb8VJNGJbCVMgoy5uQYcUeXxcie cg0VlbFLshNQTfyhVQ85vyuHahARrUWs/k8KiYODoBnW1ChtyF8yM6VZTzSYx7pINqPq2YZy i/Htd87ATQRcktnUAQgA3zt4M4ecoQqfxpjliNLujt9klDqvmkJvWmzMuMXdzlPgGRJ0doio 9YIeEdkOt6xN0pPTK/ReCZ8WqFQ8zo23u1pwGuo0CnR58XF19wyxyUuKu/PHbt+56mC8tNHm AXsMyXQmlDqWvn/WzLY7euNRtNS4QQIwtxfM5EC4GGa5KQwxn0kM7dkUSOE/cxr+/kNbHHzb gagZR4cnNUqtPPr3dYXcibCTzgz96Lyt3/qMLXX9RTBRzu+O6E+byxWOe8ar/ZlwY2b4wTQG mhgNttkSxKtxMpZnd8+DGV/bI1P5Ct/K2GeCwNyupQGON5ymn6o7jTch+qmFX0ItkBWO4zn4 9QARAQABwsB8BBgBCgAmAhsMFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDtwFCQtCz4gA CgkQi/gnTOdUid/i5gf/aQ75pJR4TJFM2vVVr6PDIwTdl0b5EchB4w4s4g/zE84XNbMOQanb BginLYEhAacLQVAvM3XdvUEhwrhaMQdjdSEB1krResL3/mbxrtKwdHSMbHA3IS3XdvxFWTB7 P5JjUSPsW6hqgoidbn4w3OxaNHhs45H2b0Nx5QiKcSyepmCZuB52gCEHnEnrdaz8TFQMXOLq 94WbTmZeIjChW3FB61m1gTf0UEFjoZAfTAUB+pbwoCa4AykIeZnDC19vjsruVU9Gy5rLglwd bjsZNfXIJGOZNEvdF8FOBwM7DlXx7SYvTJcUNoNJjOKtQ0bYGVgGqYOB/y2mTjVuKeU0eOkN Uw== In-Reply-To: <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/30/24 10:00, Lin Lee wrote: > I am wondering about the function > ecall_handler(https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L195 ), which later executing syscallenter, where &td->td_sa >  Is used. I have no idea where the value of td->td_sa is being set. It > is a little bit confusing. > The td_sa member is a struct syscall_args embedded within the larger struct thread. Therefore, it does not need to be set/allocated. The expression "&td->td_sa" obtains a pointer to the syscall_args structure belonging to the struct thread, pointed at by td. > Someone asks me to read > cpu_fetch_syscall_args(https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/riscv/trap.c#L99 ), and it indeed explains how td->td_sa is being set. But however, I still have no idea how it works. > So in this function, we obtain the pointer to the syscall_args structure: struct syscall_args *sa; ... sa = &td->td_sa; From there, we update a few fields of "sa", most notably the "code" which is the actual syscall number we are trying to execute. sa->code = td->td_frame->tf_t[0]; This could be written identically as: td->td_sa.code = td->td_frame->tf_t[0]; Therefore we have updated the syscall information within the thread structure, pointed at by td. sa->code is then used as the index into the system call vector (sysvec), to decide which function we should call. Now, td_frame is the "trapframe", containing the CPU register contents at the time of the exception, generated by the system call instruction "ecall". So, CPU register t0 contains the syscall number, but where is this set? If we look in the libc sources, the part executed by userspace, we find the SYSCALL() macro. https://github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/lib/libc/riscv/SYS.h#L39 This short bit of assembly will: 1. Set the t0 register with the appropriate numeric constant (e.g. SYS_fork) 2. Execute the ecall instruction (which will trap into the kernel, and jump to the cpu_exception_handler assembly function in sys/riscv/riscv/exception.S) (How exactly this macro gets used within libc is a little magic, and outside the scope here.) Hope this helps! Mitchell > It is called as a function member in > elf64_freebsd_sysvec(https://github.com/freebsd/freebsd-src/blob/7aa4e4eb36171d349c7f3948e16c09ff7540c241/sys/riscv/riscv/elf_machdep.c#L61C25-L61C45 ), and I think there is nothing to do with syscall here. > > Could somebody please figure it out? > How does a system call works? Where the value of td->td_sa is being set. > > > Thank you very much > > Best Regards, > Lin Lee From nobody Tue Jan 30 20:30:23 2024 X-Original-To: riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPcHN0ZCJz59VlH for ; Tue, 30 Jan 2024 20:30:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPcHM3T9lz4jvw for ; Tue, 30 Jan 2024 20:30:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706646623; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rbk9ae9LRcLJP6mCkLCqPCvf/BV7Pn3Vxp81vsccNBs=; b=RTXvJJhzjS5vteMgNA88twLCMy3uFJe0gwLGBwdwPdYuPcR/3Llm2GcnqWEzxMtoAbKhvX i0518GOrkjV2qjW/P7nQ4bELpGzIeDNINxCudfg6ID+Wnu8fSlcKvPCUBSnjbz0xOjdYMF LtV1QsYFi3r6I1qaitrBh3TZrqrSnEY2TZcvIbVoNUppQRccMEtrHfHKvWQ3p2nlLb8Kdx 0rx95bBZxiL7IYJA9/i39RGaF/+5oPOo7SinCrtWcF9loT0UjLaRKeIUxWs9ZDmAy0BdYM ze8oYHkA5N7ZFz5WSRRZJK3TfAUuUbNpqunQ1/D6uEEgwv1tb/kyYglrTpOU9w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706646623; a=rsa-sha256; cv=none; b=H46XJJz0eXGWl4rnCYSfE4XaaD9d6jI6WBArqOexeLoLIt/QWjI0S0ll+7XX7VSbSnLRmo 4QxwGdLM9S16xCrolsKpMVOaOUrEoOLIDFJELERGVmTYuFsu9nEbaZUzvZEST/FkrEwsHK PCFzlSQ3YsnhVf7NnfRodLJ7gWdhqLasNIlx59IlWn7CXkUI2HMTWL94SgjNKRQWONjeXY bzLqvUXnHfWxP5ikryGuC8tABlDRPYxsslcRxeK6t4sDxnnWnw5zY6QuseWyo4cqLyKYUp 4cEFgRs36u0NvYu4lgXVKVoM6mFqwMQxyxvNlcRUZS/Tlr6Viv0HOT0H/RukUA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TPcHM2XKjzqV0 for ; Tue, 30 Jan 2024 20:30:23 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40UKUNgG085759 for ; Tue, 30 Jan 2024 20:30:23 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40UKUNlm085758 for riscv@FreeBSD.org; Tue, 30 Jan 2024 20:30:23 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: riscv@FreeBSD.org Subject: [Bug 273438] PANIC: memory modified after free on relatively idle riscv -CURRENT Date: Tue, 30 Jan 2024 20:30:23 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: mhorne@freebsd.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D273438 Mitchell Horne changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |Open --- Comment #8 from Mitchell Horne --- (In reply to Mitchell Horne from comment #7) Okay I spoke too soon re: the offset; it is trivially calculated as 0x908 - 0x7f8 =3D 0x188 =3D 392. According to gdb, the struct dmu_buf_impl member a= t offset 392, for your revision, is db_user, an 8 byte pointer.=20 The expected contents of uninitialized memory is 0xdeadc0deadc0de, but your reports consistently show the affected address as 0x00000000de00c0de. So it= is only partially overwritten, and therefore not an abuse of the db_user field= in a dmu_buf_impl_t object. So, I'm thinking this allocation missed the zone's cache (empty), and the memory could have belonged to anything before that, meaning use-after-free could exist anywhere...=20 I'll have to see what other tips I can learn to help identify this. On other platforms we could use KASAN, but for riscv it is not implemented yet. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Tue Jan 30 21:29:32 2024 X-Original-To: riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPdbd2Wpgz57d0K for ; Tue, 30 Jan 2024 21:29:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPdbc6Zycz4tkZ for ; Tue, 30 Jan 2024 21:29:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706650172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nYPrITc3VU5GwonCL79fQfWN/5LjZ1jNUAHkZkWggrw=; b=c2AVj7eh6blkxzujAvVjBT3Uo/nuNq+HtTuj1a42bUpA4MOemrMmm6ZFGnH90Gui+pLJNF /+04vMDL8kdZenjbkEvZnVZZYxwHRzbGBKmvXjxfNySaRSBH13oxyLmANpp/UTM4GAfR7P fpeh7gFnWAwBP/OYIem4v9fvYs7LdHboObhbNS+PYNM1FUAJuSzts33jcRT+DcN4Tviaz7 uuYn+QaUAyDiXG60GclT+WWgbEmhLIULxwhdBSMk/75l7PICVz0/GWPTjGpMzXEs/bgblY zB6DOfnQkYPH29BFrJP+We1t06Kwqt+FLiBWOapag2zguTAt7qOqLo2KA0xH9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706650172; a=rsa-sha256; cv=none; b=JaPNlSsVm4aa51wdPgG/q87IaPlapy8DsN6gFdBT429Umu953UxBVJ+knuxF79QIIHi6s0 /UG+LmXIwXJXWACIwPVvkANI7IZ5DywQebecT4rjFgWy1AaA2+2utdp6doCOMC8tfIGfKO bpwpzx6Jm0NMoP6qu6T4+iiLccZ8uKjKCVssJUx3vg0NMtokpfETccrutJakl++sFdw8Kb t9uZ46ZlgVT/R8ajjbvWuZeKv0aZNg0ZaengbZMY1HMEVbbYYmGymMrdHfTknvrEiOf8CI GNCz61OtvojvVbhnhzdPEwntt925GPQ6q92+1x9rJqLNfUsr54bhepKgLTefVw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TPdbc5fy5zryl for ; Tue, 30 Jan 2024 21:29:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40ULTWMt088227 for ; Tue, 30 Jan 2024 21:29:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40ULTWCJ088225 for riscv@FreeBSD.org; Tue, 30 Jan 2024 21:29:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: riscv@FreeBSD.org Subject: [Bug 273438] PANIC: memory modified after free on relatively idle riscv -CURRENT Date: Tue, 30 Jan 2024 21:29:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: dgilbert@eicat.ca X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D273438 --- Comment #9 from dgilbert@eicat.ca --- Certainly this isn't an unusual configuration for an AMD64 in my world. 16G ram, 2T nvme, ethernet. My home router isn't dissimilar, but it doesn't exhibit this crash. So I'm proceeding with the theory that it's RISC-V related. I've started t= he few-day-long compile (I like my machines to be self-hosted --- which, BTW, = is one bug of RISC-V (it needs a patch to be self-hosted) to bring it up to th= is week. It would be faster, but I also zapped the ccache out of abundance of caution. I should be booted on the new load before the weekend. On average, we shou= ld know in two weeks or so... maybe four. I might be able to bring it on with= a poudriere build. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Wed Jan 31 05:03:04 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TPqg83hNwz58QqF for ; Wed, 31 Jan 2024 05:03:16 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TPqg81HVLz4ZsG; Wed, 31 Jan 2024 05:03:16 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3be61772d9aso1230819b6e.3; Tue, 30 Jan 2024 21:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706677394; x=1707282194; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=nbLCORbVTsdDntB+Roxw9FkB7vciVRfVsqZzgIdxY18=; b=WSo6fXdErlOoA4iL6RP1p6e/gj9agcAb/GpPZnzMCleZfyurgSjaA4nCqrHmEkm0x9 //4OqwZhXnC86fpfWcokyPPZ6xlZLmW8xmeK0MJ9Gkf8g4AQUW6VRc1VUO8rGOh6GsAS l3zC5vh/sYAAAxNrFcJQUprPbv9NvoDhwJbFHEK/HpnL70y89pjso2agXtAsL6fbdy2X BWuRh1I4QVC3Kq5nQatSOC2kC8UsiJtR9U3x3fDZX9+uxGM/lKHD0i9LpUaXKUUAIoqB GSUsX7EKOf36O8a+tPVPDGXtVaxwLlIwhmBGP0TiyRQORkz45ohut9bh7T3jB1iF+2jV 9OLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706677394; x=1707282194; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nbLCORbVTsdDntB+Roxw9FkB7vciVRfVsqZzgIdxY18=; b=iCh6kSY1Xl34aYKLp8A4yGSgND8whhAd3pUh8BWoASmtkwdAoo6qymoZj8q/QgnVjE d0NQjB7X3XjSEZm6WA0P1/H738KQo4nwVbAtqrJe2Zrb2HKDckq7/RH2mS5iz7OPjU33 nNs0wSRrocran50dw9HnHA5IjTtzHpgINFJcSYwMvtElQueomjhjR+oCZLe7G8Dkhhxz tjjBhsXHyrMvAVJNI7Fe1ttIa7B97W+d9aTbZRMVBCgiDQWhNcq4yJdKf25PrQnVJ9ZP 587dGLS5gtg5eVk0Oz4EO3bYXGhyu6JhMHYV8dKqv1W57MGhMpZsscqC3esBthVD8e12 6Iug== X-Gm-Message-State: AOJu0YzrKQgKuB+nk89cQQ3ut3TBLWCoct0EZZAq+0Kf+dgyX3CyEDXd zAQculE40S1sMygxrLThi9hkGwgAtuM6vhoMhc1Ecfut4hpIxhhq/6uxPhwj X-Google-Smtp-Source: AGHT+IFU/J2B286dyL2n/qLiFKOsawnaZqCcC4Gsrkp890kYOlCNnxsypmT9UeBC/Kb/xZ+ahnVz2g== X-Received: by 2002:a05:6358:5bcc:b0:176:c94a:ec03 with SMTP id i12-20020a0563585bcc00b00176c94aec03mr439088rwf.17.1706677393879; Tue, 30 Jan 2024 21:03:13 -0800 (PST) Received: from [172.20.10.2] (114-137-55-104.emome-ip.hinet.net. [114.137.55.104]) by smtp.gmail.com with ESMTPSA id t12-20020a63460c000000b005d24e5ae4e3sm9313224pga.2.2024.01.30.21.03.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jan 2024 21:03:13 -0800 (PST) Date: Wed, 31 Jan 2024 13:03:04 +0800 From: Lin Lee To: freebsd-riscv@freebsd.org, Mitchell Horne Message-ID: In-Reply-To: <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> Subject: Re: A little bit wondering about how a syscall works X-Readdle-Message-ID: f2213278-0807-4a36-ab90-6d2a9555fc8c@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65b9d48d_3c9f4828_4d5" X-Rspamd-Queue-Id: 4TPqg81HVLz4ZsG X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --65b9d48d_3c9f4828_4d5 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Mitchell, Thank you for your kindly responding. Now I have still a question, when does the function cpu_fetch_syscall_args be called? As the previous letter mentions, I traced the code and entered the elf_machdep.c. I have no idea if there are something to do between elf_machdep.c and system calll. If not, when(how) the cpu_fetch_syscall_args is called? Thank you very much. Best Regards, Lin Lee On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne , wrote: > > Mitchell --65b9d48d_3c9f4828_4d5 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hello Mitchell,

Thank you for your kindly responding.

Now I have still a question, when does the function cpu=5Ffetch=5Fsyscall= =5Fargs be called=3F&=23160;

As the previous letter mentions, I traced the code and entered the elf=5F= machdep.c.

I have no idea if there are something to do between elf=5Fmachdep.c and s= ystem calll.

If not, when(how) the cpu=5Ffetch=5Fsyscall=5Fargs is called=3F

Thank you very much.

Best Regards,
Lin Lee
On Jan 31, 2024 at 1:17 AM +0800, M= itchell Horne <mhorne=40freebsd.org>, wrote:

Mitchell
--65b9d48d_3c9f4828_4d5-- From nobody Wed Jan 31 16:27:58 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TQ6sC2hhFz58qmK for ; Wed, 31 Jan 2024 16:27:59 +0000 (UTC) (envelope-from mhorne@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQ6sC1zczz4CrF; Wed, 31 Jan 2024 16:27:59 +0000 (UTC) (envelope-from mhorne@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706718479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YmYFB1yHfNGI26fu8hru6ZquY9qX9SYATsBM4+yJaLQ=; b=GM7s7YJdOH0q/+FWFO53jdYqWbD5Pm3ftE64nnx46bmpvaOfOAfnfcmMmQ4VBvijMWUSO+ H2koHLTdjHf1sO/RrCx8BsGxiOFd21AkgRqW5kRfP/Vhls6MyUkY4Nrol+1M8Tti9eGn4j E2iAUIg00ERSPasNCzBhR/XAcdSXQr1ElmLxl57slcOol2WoC+wxsIEMpxOfpB5mysFtQc NJewHZA2Hc/CSC02PoJLNhUenBFEUuUbe526Edf59/PCMF1HDWEFUOB4+WO4i/hkQgD/mp QVPzIP5CbYcyZu9p8w3wsZF+NarfKkqym+uyoPi1CDMplTDJjpxT95OsTau4xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706718479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=YmYFB1yHfNGI26fu8hru6ZquY9qX9SYATsBM4+yJaLQ=; b=vnOmfiZGsNQdbIh9U4JH5D4naYi/JPoWAEb3pAc1BrY+6I7VTgIdtXzDfwxuNrPZqPCUe1 g9kGOMrPkh1bcU7SV0O39cgpV4ZrQVUVN+XduPWQih5phRtjRRSnRu7rEfjzXLXGjBUbn4 iOdf84rhzpaTJ+YJMVThbHTMi2zyTijnPb60+5R333bQISBCUhdmhJP/y+QgEHQC8vYbaq fbQwlTNfv+ATY9/nBEu8YSjRaLX3XfOjpvf+8DF3g8zTnizQi+9dfNDSaJEvK2B2atvsRN UA1y9309iZhBrq31H0fPkAal8Wd6vKBHqwrmXAWIcMhzHKf0DMw/I3ELDPKK4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706718479; a=rsa-sha256; cv=none; b=PwSADcoKac1gdqot8Ox6/rwervMj7GHT3JHDeuubN61ows6tGTmYgsMSpxcSLJcxhjZLcB qvEMETOZGxI3d+6XlMuXB4nyWNJCMRDQTUG579Qf3V9Tnp7EtVMfW7hwg1ZrBDEkoDjN7L mQpJ4x2cDDury+UbtSaWJdvtWg5OZc6gL7mD1u5VlvKlcQ7GPN+Zgpl4s4rsABl4i24hrL e0c1do5HnblhHsbxvv7O/+V4UHE7mN45UkyVuk2/yM0G3boygCWyxz9PZ+75bvqUcZ/XG0 k0/zgdppBHWek9ZZeV+WQ58EKc+vbwo/UsJJ/yEUBAbziXzbld8Brub/+/R2Bg== Received: from [192.168.1.151] (host-173-212-76-127.public.eastlink.ca [173.212.76.127]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mhorne) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TQ6sB7241zhx4; Wed, 31 Jan 2024 16:27:58 +0000 (UTC) (envelope-from mhorne@freebsd.org) Message-ID: Date: Wed, 31 Jan 2024 12:27:58 -0400 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A little bit wondering about how a syscall works Content-Language: en-CA To: Lin Lee , freebsd-riscv@freebsd.org References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> From: Mitchell Horne Autocrypt: addr=mhorne@freebsd.org; keydata= xsBNBFyS2dQBCADdiXBG8hBVLmYbxu7aSzbwLwUf3HkGFz3rooS1kwyy+SfmjZ4UKNnl9WMx WKrJ7OAZpiNH6bLQ5nsqfx09OnpWL8c/QuPbhNdUywQoqqYpRI0K8GEn//nS9Gs0KTYwVpWb XlrzP+jf3Uh/9L5mcQmStLIH4zaaqMYHW+pMuPrvBmLIHTvLj2QjOkxslrcUdord9uvxe5Ht LU8RuTpQpHOKz705Z9/v7twFdi2HtKzpLwO6SzVyu351di1J+GihsVpcT5josQV5cHbIP3Un x+kmtKBEEc/jl/zBglF7ruWUtwgbryID+2ZPEaO1Mj+RResX4LFVMusq3uUpWRb5WJXxABEB AAHNI01pdGNoZWxsIEhvcm5lIDxtaG9ybmVARnJlZUJTRC5vcmc+wsCUBBMBCgA+AhsDBQsJ CAcCBhUKCQgLAgQWAgMBAh4BAheAFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDpUFCQtC z0EACgkQi/gnTOdUid8IsQf+N8IptrrCgifT5Z0/WUVFfnHThFOKf4zBjaGswsIM8+VKsKnF 15jCWHODUHP6s+dcQ4nQi81PHPsnMfBSkGPvN/X3ess2/1KUVkH+6tAJbqXDjXhD8HT+i0NM QEFIXlLnotpgIKW3yOHjKv3ZvKw9LCvUjyNY9vOJmLk/6AbbkFh+INo65nXtQWb/hM5FVEHW S+zUoU8AqZRJoVAQfj9wmIfg/HdsxeDGKL0zkv5AwKpccvb8VJNGJbCVMgoy5uQYcUeXxcie cg0VlbFLshNQTfyhVQ85vyuHahARrUWs/k8KiYODoBnW1ChtyF8yM6VZTzSYx7pINqPq2YZy i/Htd87ATQRcktnUAQgA3zt4M4ecoQqfxpjliNLujt9klDqvmkJvWmzMuMXdzlPgGRJ0doio 9YIeEdkOt6xN0pPTK/ReCZ8WqFQ8zo23u1pwGuo0CnR58XF19wyxyUuKu/PHbt+56mC8tNHm AXsMyXQmlDqWvn/WzLY7euNRtNS4QQIwtxfM5EC4GGa5KQwxn0kM7dkUSOE/cxr+/kNbHHzb gagZR4cnNUqtPPr3dYXcibCTzgz96Lyt3/qMLXX9RTBRzu+O6E+byxWOe8ar/ZlwY2b4wTQG mhgNttkSxKtxMpZnd8+DGV/bI1P5Ct/K2GeCwNyupQGON5ymn6o7jTch+qmFX0ItkBWO4zn4 9QARAQABwsB8BBgBCgAmAhsMFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDtwFCQtCz4gA CgkQi/gnTOdUid/i5gf/aQ75pJR4TJFM2vVVr6PDIwTdl0b5EchB4w4s4g/zE84XNbMOQanb BginLYEhAacLQVAvM3XdvUEhwrhaMQdjdSEB1krResL3/mbxrtKwdHSMbHA3IS3XdvxFWTB7 P5JjUSPsW6hqgoidbn4w3OxaNHhs45H2b0Nx5QiKcSyepmCZuB52gCEHnEnrdaz8TFQMXOLq 94WbTmZeIjChW3FB61m1gTf0UEFjoZAfTAUB+pbwoCa4AykIeZnDC19vjsruVU9Gy5rLglwd bjsZNfXIJGOZNEvdF8FOBwM7DlXx7SYvTJcUNoNJjOKtQ0bYGVgGqYOB/y2mTjVuKeU0eOkN Uw== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/31/24 01:03, Lin Lee wrote: > Hello Mitchell, > > Thank you for your kindly responding. > > Now I have still a question, when does the function > cpu_fetch_syscall_args be called? > > As the previous letter mentions, I traced the code and entered the > elf_machdep.c. > > I have no idea if there are something to do between elf_machdep.c and > system calll. > The short answer is yes, it is related. In syscallenter() we have: error = (p->p_sysent->sv_fetch_syscall_args)(td); And as you saw, the sv_fetch_syscall_args hook is set to cpu_fetch_syscall_args() for elf64_freebsd_sysvec. Similarly, there is an sv_set_syscall_retval hook, called by syscallret() when we are done executing the system call. Each process 'p' has a corresponding sysentvec (p_sysent). On the riscv architecture there is currently only one registered systentvec, elf64_freebsd_sysvec, because we can only execute 64-bit FreeBSD ELF binaries on this platform. By contrast, on amd64 there are several registered sysentvecs. This allows it to execute, for example, 32-bit FreeBSD ELF binaries, or 64-bit Linux ELF binaries. The sysentvec enables different handling for these different types of executables, e.g. the system call table is different for Linux processes (.sv_table = linux_sysent). You will see also that Linux processes have a different function for sv_fetch_syscall_args, take a look in sys/amd64/linux/linux_sysvec.c. Mitchell > If not, when(how) the cpu_fetch_syscall_args is called? > > Thank you very much. > > Best Regards, > Lin Lee > On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne , > wrote: >> >> Mitchell From nobody Wed Jan 31 19:26:26 2024 X-Original-To: riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TQBq73Gc5z587DK for ; Wed, 31 Jan 2024 19:26:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQBq70wkFz4Zdd for ; Wed, 31 Jan 2024 19:26:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706729187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLerQFbRHGCFKo+Lnf8kp03vAWs0CZ0nmaXSd3oyyxI=; b=ANi8N5WlCvo5NuoK73HaJtAavAvEqeiAHtddNWEXZRl62YE9zEyFrMwd/iaLqVKJTnO21N s3DQFdbZQ1OnZW23t5hvEmU3mO+REDQsbJcsZRw+fEvaK1FPTizz9p6jCJR/avE9oscaB2 gJK4Ko0mz6z1D5t39kWlBDNp5f+si2oe555EWAVt3Tqu8ZBJq01dKAaliNJ/oVyqxg+NOR LHbagt4wAytbknfQJlBxLEsdci20C0Z4exd40sM3785gQ+4l0l/YIxhnx5rrd9JTiwFS7q tx+206WeYu7ZYKoGRm2qOMXmlrbwXEzgX7IZ1A6NUMqYphgMjZrH40OqpYkj0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706729187; a=rsa-sha256; cv=none; b=tpM6pFzJMDnUYCGcqbz5j5czO8iU33EMBbzBl//9tWtbhXkpFRIntcox2/VedCVOZVqaQH hTy+ags9W/oExrRXbkrkyy9N+SRT6rgznGTb4WhoNk8s6++9T8aHWBbzkGre+SngEVSgR1 BpGBAmp5U345YO6jKDumIHHbqy7hHT+9DrW0DtRY2n6eqSj4giWD7oOgPDAg0PuPgS9D8g 7DDokSyvLlYOokci+QSWdQrhBmsjw/jWz2gDCgFu/afuMHkVs1+hf69kutE+UsZnwsOiH0 6vUfhjOMa0232cP8GK7HvAQ76/kFkaTa/XISUO2I1+fR0lHcxy0I+srRCLb59w== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TQBq700QvzXGd for ; Wed, 31 Jan 2024 19:26:27 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40VJQQEt026450 for ; Wed, 31 Jan 2024 19:26:26 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40VJQQLS026447 for riscv@FreeBSD.org; Wed, 31 Jan 2024 19:26:26 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: riscv@FreeBSD.org Subject: [Bug 273438] PANIC: memory modified after free on relatively idle riscv -CURRENT Date: Wed, 31 Jan 2024 19:26:26 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: dgilbert@eicat.ca X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D273438 --- Comment #10 from dgilbert@eicat.ca --- Created attachment 248101 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D248101&action= =3Dedit Another core.txt file from the problem. This file does _not_ reflect an upgrade to post November. It happened while making world. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Thu Feb 1 04:47:50 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TQRH65gRKz592jt for ; Thu, 1 Feb 2024 04:48:02 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQRH65Bdvz4qXM; Thu, 1 Feb 2024 04:48:02 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3be9e11ee59so265430b6e.1; Wed, 31 Jan 2024 20:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706762881; x=1707367681; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ixzgqkGCd13CzqN+XJuPcpwVKqOBMNnFka4nA9vC7H0=; b=iN0+oaMj135P38MeogD+FjrHl0HbwFyUalNCddKcXXfAKDOoMKsV2ZbMJHkijcT1WJ 3BrWVYvWhRMlKoBXSwOJdFDNcQxHgO7IsPMpJrsrjePk/jnMIifkUUb+77ciSR2mJYW7 3K4FiZtgqkdwbVzPOe490D1vfw52yNhRQgD6ZpuQJKxQc21tvY7lZMXdYA0gV7G/ILQt tDYHI7Qs4c2kiVAQKtPGNJU48a4wBOH2JUx7ti/y4VeTwaDma8lfe/qU9XhKgZ8gRKEx Nadgg8ymxvSD5IFl4DbTk2hYB9a5dr1dZvtvFhxasYBnrzjNarY33Rsrfqmffqb7Jq+g 4vIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706762881; x=1707367681; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ixzgqkGCd13CzqN+XJuPcpwVKqOBMNnFka4nA9vC7H0=; b=LhyPe4GzazUhBP42BZgqv6YlDhuuBoiwZBjOYFt/bJCAhFmOHzBKkSVp1PRQ8tOrtq 7J3tUoueJIPm9yqJR5f5dSGqB+3nkjiA+/clwXrhFsAZlaBaRNW6VC7ePctocsCCDRNx 3+Vc/+jJ3Rn/dJNdW1jSna5ZluPsNCyooVkj2FnTBfrINk6Lin5LQtyiRsFhlTXchKzX MZgrGKDfdFNNiHy6nVq/FiMUnE6uuDyyHjBWo45VEySbj/MPlpVAmp3GXHbY+P/E62f4 Suo+vvOPIdL8XDbjE07Eu415EbQ246xSzLkKvOKD/eAUxHLkXydWGJaYb5U3n2HM00lr kPeg== X-Gm-Message-State: AOJu0YwfLZL4uKgJ5Xy4af98SQWtF04QM8GY7xyaxlpEQoEQYjPRktMQ gwt1Jco4lnlIBTlEVzFT5bJhUJXrYMv0R2MDigopFvhoSROM6Crm2XSkmae1 X-Google-Smtp-Source: AGHT+IFXnQGjde4FeKw+/t3Xavm/t4iUNAiMMwYUITYsF51btMeOsS1fUFc4VhkDB6FMZbAItIr8Vw== X-Received: by 2002:a05:6808:1201:b0:3be:685e:b209 with SMTP id a1-20020a056808120100b003be685eb209mr1151550oil.35.1706762880534; Wed, 31 Jan 2024 20:48:00 -0800 (PST) Received: from [172.20.10.2] (114-137-55-104.emome-ip.hinet.net. [114.137.55.104]) by smtp.gmail.com with ESMTPSA id jw3-20020a056a00928300b006dbd2231184sm10727735pfb.70.2024.01.31.20.47.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2024 20:48:00 -0800 (PST) Date: Thu, 1 Feb 2024 12:47:50 +0800 From: Lin Lee To: freebsd-riscv@freebsd.org, Mitchell Horne Message-ID: <8867a483-7e92-4579-9236-32b4a704713e@Spark> In-Reply-To: References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> Subject: Re: A little bit wondering about how a syscall works X-Readdle-Message-ID: 8867a483-7e92-4579-9236-32b4a704713e@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65bb227b_41b5c1d5_c55" X-Rspamd-Queue-Id: 4TQRH65Bdvz4qXM X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --65bb227b_41b5c1d5_c55 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, So, if I understand correctly, Each thread's sv_fetch_syscall_args hook function is initialized as cpu_fetch_syscall_args(), And when it enter syscallenter, it first use `error = (p->p_sysent->sv_fetch_syscall_args)(td);` to read the system call number, then use `error = (se->sy_call)(td, sa->args)` to execute the system call. Do I understand corrected? Thank you very much. Best Regards, Lin Lee On Feb 1, 2024 at 12:27 AM +0800, Mitchell Horne , wrote: > On 1/31/24 01:03, Lin Lee wrote: > > Hello Mitchell, > > > > Thank you for your kindly responding. > > > > Now I have still a question, when does the function > > cpu_fetch_syscall_args be called? > > > > As the previous letter mentions, I traced the code and entered the > > elf_machdep.c. > > > > I have no idea if there are something to do between elf_machdep.c and > > system calll. > > > > The short answer is yes, it is related. In syscallenter() we have: > > error = (p->p_sysent->sv_fetch_syscall_args)(td); > > And as you saw, the sv_fetch_syscall_args hook is set to cpu_fetch_syscall_args() for elf64_freebsd_sysvec. Similarly, there is an sv_set_syscall_retval hook, called by syscallret() when we are done executing the system call. > > Each process 'p' has a corresponding sysentvec (p_sysent). On the riscv architecture there is currently only one registered systentvec, elf64_freebsd_sysvec, because we can only execute 64-bit FreeBSD ELF binaries on this platform. > > By contrast, on amd64 there are several registered sysentvecs. This allows it to execute, for example, 32-bit FreeBSD ELF binaries, or 64-bit Linux ELF binaries. The sysentvec enables different handling for these different types of executables, e.g. the system call table is different for Linux processes (.sv_table = linux_sysent). > > You will see also that Linux processes have a different function for sv_fetch_syscall_args, take a look in sys/amd64/linux/linux_sysvec.c. > > Mitchell > > > If not, when(how) the cpu_fetch_syscall_args is called? > > > > Thank you very much. > > > > Best Regards, > > Lin Lee > > On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne , > > wrote: > > > > > > Mitchell > --65bb227b_41b5c1d5_c55 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi,

So, if I understand correctly,

Each thread's sv=5Ffetch=5Fsyscall=5Fargs hook function is initialized as= cpu=5Ffetch=5Fsyscall=5Fargs(),

And when it enter syscallenter, it first use =60error =3D (p->p=5Fsyse= nt->sv=5Ffetch=5Fsyscall=5Fargs)(td);=60 to read the system call numbe= r, then use =60error =3D (se->sy=5Fcall)(td, sa->args)=60 to execut= e the system call.

Do I understand corrected=3F

Thank you very much.

Best Regards,
Lin Lee
On =46eb 1, 2024 at 12:27 AM +0800,= Mitchell Horne <mhorne=40freebsd.org>, wrote:
On 1/31/24 01:03, Lin Lee wrote:
Hello Mitchell,

Thank you for your kindly responding.

Now I have still a question, when does the function
cpu=5Ffetch=5Fsyscall=5Fargs be called=3F

As the previous letter mentions, I traced the code and entered the
elf=5Fmachdep.c.

I have no idea if there are something to do between elf=5Fmachdep.c and system calll.


The short answer is yes, it is related. In syscallenter() we have:

error =3D (p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td);

And as you saw, the sv=5Ffetch=5Fsyscall=5Fargs hook is set to cpu=5Ffetc= h=5Fsyscall=5Fargs() for elf64=5Ffreebsd=5Fsysvec. Similarly, there is an= sv=5Fset=5Fsyscall=5Fretval hook, called by syscallret() when we are don= e executing the system call.

Each process 'p' has a corresponding sysentvec (p=5Fsysent). On the riscv= architecture there is currently only one registered systentvec, elf64=5F= freebsd=5Fsysvec, because we can only execute 64-bit =46reeBSD EL=46 bina= ries on this platform.

By contrast, on amd64 there are several registered sysentvecs. This allow= s it to execute, for example, 32-bit =46reeBSD EL=46 binaries, or 64-bit = Linux EL=46 binaries. The sysentvec enables different handling for these = different types of executables, e.g. the system call table is different f= or Linux processes (.sv=5Ftable =3D linux=5Fsysent).

You will see also that Linux processes have a different function for sv=5F= fetch=5Fsyscall=5Fargs, take a look in sys/amd64/linux/linux=5Fsysvec.c.<= br />
Mitchell

If not, when(how) the cpu=5Ffetch=5Fsyscall= =5Fargs is called=3F

Thank you very much.

Best Regards,
Lin Lee
On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne <mhorne=40freebsd.org= >,
wrote:

Mitchell

--65bb227b_41b5c1d5_c55-- From nobody Thu Feb 1 16:19:56 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TQkdV2ppHz58wDX for ; Thu, 1 Feb 2024 16:19:58 +0000 (UTC) (envelope-from mhorne@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQkdV2JB4z3x79; Thu, 1 Feb 2024 16:19:58 +0000 (UTC) (envelope-from mhorne@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706804398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=BtR6WPERKU6fLXe1ciCK7PkzIRPElsStY7kg+p5cVek=; b=ZzIFQ62hTKuUC98EbNgQxKyiywO/9wJNrNvThJ/sjumsejr4xHLTwlCtqVr1rke2MDzBfR 6FsHTEcs985AsxuZ/sVTjpO1D//0E/1I1y5bzV/vrMZf1IPRhrw/yGCVGX6Ml+vuQQzMBD I7K4HNq/sVSVq9oumzTk/R80ONfCg+OkOJwUo89YEdEGBNtPm8Jo3KOOgP1IjD0xUVH1t/ 13NrzE9v61FL0PcOQ/fLSHoeK9ZyjdaWBmSW73BZfwgKWFVhU549BV2L7UujisaP2sme2R dWT/12GTqZzbXdpQzoqnc+9on8APlyvJ9mxc+NTWA7OkNIwzfJjhma5TMeYaAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706804398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=BtR6WPERKU6fLXe1ciCK7PkzIRPElsStY7kg+p5cVek=; b=qT9+4WRpKfaVYmbRMq12GhDhYen9nDS85jMQH6sdgzqOKHE+nDm59kzkjvWUarJh8DgttP vJetpeEwGq+viMValjcCNkoOV9GHOEqP2chl5GoIxDz8Hl4XzU595KxmvmpdIh22Oas/ko K0tRA3g7uM+AMy7guusqYHULQZfXhWswXCh1/e8peUnDpFHFR+OGYfwS3F2iyUzyb95lil fNdvLRRBZ22y1KmIEsuc209uHGzSW/mO19xG2Pq+PZ9SN8Y2TDdUKs8KO4HuOTS3613rHl O8L0X7fJnaDT+k4CLW90xUnCHoIPHAPHGRe7jUWbuPTJhzBdnlGN0m7HJ0P/6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706804398; a=rsa-sha256; cv=none; b=ZhBWqx7ZFGTKewVpHmX+AzvOjT1xkQ5dAEyq3Vv8tHF2wl2Tpb5+g1rbXyC3uF/z5HaT90 iRZUwzq94+rRLnlYO0SOgpCpHMomuvQnELiUdwaWNSEHiXyeuzanr5UwIrlWnDvXvFLTlz 0KLXCRg2TzaeYWyxo3/1lcW1rejgvABcu6OoDUucx77cVkCHecaFrObhemafrAKKwZlXfv BVclpQE7aVqRCkr1D17UnL1bqa6KqELPQf4PP5uu7K3JFGcSehDRN9ungxgUms6NXQUj7j O4LZH+rOlCwpbl3WvEJJl6bJmf/LX0LW92GEPeN7t6UUmTqQiwzhQQQbhirTfA== Received: from [192.168.1.151] (host-173-212-76-127.public.eastlink.ca [173.212.76.127]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mhorne) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TQkdV059jz1Qvq; Thu, 1 Feb 2024 16:19:57 +0000 (UTC) (envelope-from mhorne@freebsd.org) Message-ID: <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> Date: Thu, 1 Feb 2024 12:19:56 -0400 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: A little bit wondering about how a syscall works To: Lin Lee , freebsd-riscv@freebsd.org References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> Content-Language: en-CA From: Mitchell Horne Autocrypt: addr=mhorne@freebsd.org; keydata= xsBNBFyS2dQBCADdiXBG8hBVLmYbxu7aSzbwLwUf3HkGFz3rooS1kwyy+SfmjZ4UKNnl9WMx WKrJ7OAZpiNH6bLQ5nsqfx09OnpWL8c/QuPbhNdUywQoqqYpRI0K8GEn//nS9Gs0KTYwVpWb XlrzP+jf3Uh/9L5mcQmStLIH4zaaqMYHW+pMuPrvBmLIHTvLj2QjOkxslrcUdord9uvxe5Ht LU8RuTpQpHOKz705Z9/v7twFdi2HtKzpLwO6SzVyu351di1J+GihsVpcT5josQV5cHbIP3Un x+kmtKBEEc/jl/zBglF7ruWUtwgbryID+2ZPEaO1Mj+RResX4LFVMusq3uUpWRb5WJXxABEB AAHNI01pdGNoZWxsIEhvcm5lIDxtaG9ybmVARnJlZUJTRC5vcmc+wsCUBBMBCgA+AhsDBQsJ CAcCBhUKCQgLAgQWAgMBAh4BAheAFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDpUFCQtC z0EACgkQi/gnTOdUid8IsQf+N8IptrrCgifT5Z0/WUVFfnHThFOKf4zBjaGswsIM8+VKsKnF 15jCWHODUHP6s+dcQ4nQi81PHPsnMfBSkGPvN/X3ess2/1KUVkH+6tAJbqXDjXhD8HT+i0NM QEFIXlLnotpgIKW3yOHjKv3ZvKw9LCvUjyNY9vOJmLk/6AbbkFh+INo65nXtQWb/hM5FVEHW S+zUoU8AqZRJoVAQfj9wmIfg/HdsxeDGKL0zkv5AwKpccvb8VJNGJbCVMgoy5uQYcUeXxcie cg0VlbFLshNQTfyhVQ85vyuHahARrUWs/k8KiYODoBnW1ChtyF8yM6VZTzSYx7pINqPq2YZy i/Htd87ATQRcktnUAQgA3zt4M4ecoQqfxpjliNLujt9klDqvmkJvWmzMuMXdzlPgGRJ0doio 9YIeEdkOt6xN0pPTK/ReCZ8WqFQ8zo23u1pwGuo0CnR58XF19wyxyUuKu/PHbt+56mC8tNHm AXsMyXQmlDqWvn/WzLY7euNRtNS4QQIwtxfM5EC4GGa5KQwxn0kM7dkUSOE/cxr+/kNbHHzb gagZR4cnNUqtPPr3dYXcibCTzgz96Lyt3/qMLXX9RTBRzu+O6E+byxWOe8ar/ZlwY2b4wTQG mhgNttkSxKtxMpZnd8+DGV/bI1P5Ct/K2GeCwNyupQGON5ymn6o7jTch+qmFX0ItkBWO4zn4 9QARAQABwsB8BBgBCgAmAhsMFiEEkp/cYPcfabAiQvACi/gnTOdUid8FAmIyDtwFCQtCz4gA CgkQi/gnTOdUid/i5gf/aQ75pJR4TJFM2vVVr6PDIwTdl0b5EchB4w4s4g/zE84XNbMOQanb BginLYEhAacLQVAvM3XdvUEhwrhaMQdjdSEB1krResL3/mbxrtKwdHSMbHA3IS3XdvxFWTB7 P5JjUSPsW6hqgoidbn4w3OxaNHhs45H2b0Nx5QiKcSyepmCZuB52gCEHnEnrdaz8TFQMXOLq 94WbTmZeIjChW3FB61m1gTf0UEFjoZAfTAUB+pbwoCa4AykIeZnDC19vjsruVU9Gy5rLglwd bjsZNfXIJGOZNEvdF8FOBwM7DlXx7SYvTJcUNoNJjOKtQ0bYGVgGqYOB/y2mTjVuKeU0eOkN Uw== In-Reply-To: <8867a483-7e92-4579-9236-32b4a704713e@Spark> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/1/24 00:47, Lin Lee wrote: > Hi, > > So, if I understand correctly, > > Each thread's sv_fetch_syscall_args hook function is initialized as > cpu_fetch_syscall_args(), > > And when it enter syscallenter, it first use `error = > (p->p_sysent->sv_fetch_syscall_args)(td);` to read the system call > number, then use `error = (se->sy_call)(td, sa->args)` to execute the > system call. > > Do I understand corrected? > That's right. > Thank you very much. > > Best Regards, > Lin Lee > On Feb 1, 2024 at 12:27 AM +0800, Mitchell Horne , > wrote: >> On 1/31/24 01:03, Lin Lee wrote: >>> Hello Mitchell, >>> >>> Thank you for your kindly responding. >>> >>> Now I have still a question, when does the function >>> cpu_fetch_syscall_args be called? >>> >>> As the previous letter mentions, I traced the code and entered the >>> elf_machdep.c. >>> >>> I have no idea if there are something to do between elf_machdep.c and >>> system calll. >>> >> >> The short answer is yes, it is related. In syscallenter() we have: >> >> error = (p->p_sysent->sv_fetch_syscall_args)(td); >> >> And as you saw, the sv_fetch_syscall_args hook is set to >> cpu_fetch_syscall_args() for elf64_freebsd_sysvec. Similarly, there is >> an sv_set_syscall_retval hook, called by syscallret() when we are done >> executing the system call. >> One correction: the sv_set_syscall_retval hook is actually called at the very end of syscallenter(), after the execution of the syscall has completed. >> Each process 'p' has a corresponding sysentvec (p_sysent). On the >> riscv architecture there is currently only one registered systentvec, >> elf64_freebsd_sysvec, because we can only execute 64-bit FreeBSD ELF >> binaries on this platform. >> >> By contrast, on amd64 there are several registered sysentvecs. This >> allows it to execute, for example, 32-bit FreeBSD ELF binaries, or >> 64-bit Linux ELF binaries. The sysentvec enables different handling >> for these different types of executables, e.g. the system call table >> is different for Linux processes (.sv_table = linux_sysent). >> >> You will see also that Linux processes have a different function for >> sv_fetch_syscall_args, take a look in sys/amd64/linux/linux_sysvec.c. >> >> Mitchell >> >>> If not, when(how) the cpu_fetch_syscall_args is called? >>> >>> Thank you very much. >>> >>> Best Regards, >>> Lin Lee >>> On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne , >>> wrote: >>>> >>>> Mitchell >> From nobody Fri Feb 2 05:49:16 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TR4bk10T1z59V0K for ; Fri, 2 Feb 2024 05:49:38 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TR4bj41hbz4S8T; Fri, 2 Feb 2024 05:49:37 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6dddee3ba13so1234002b3a.1; Thu, 01 Feb 2024 21:49:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706852975; x=1707457775; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=uEWQcerBgr5U3NhCdZaVckhv6TjCYP3Ep82iyWcT4hE=; b=L/6GmEo6SSjIVf7pKrFIQiK+8Xw+rs+7DEXe1Xo05Rj52y+oPNGufktRNR5rUT8rgh lIYiFYocKSzPpmi9w99saMRnp1MzjcugAAii/WxecOoStIJhP9cm8obH/ElAEu5DQUol jMlwUfGm+ao2ZKO7Mg0m8MpMuxaVyxR3aVv+CUMA+cl/5fnizy4dtctuGaBDNgYm98wL 83HT2sVUYC15qS/t8nK1NLAU/R0yGoFNI0Ig5BzjHbEKxFHG0HKBUe9giOdFGNO5+YP8 g0r50PGmy7khaq66jsBRbWzICiW3odPwITCkxKQQhnry35YGPEckB4rTTbpD+Fqxulra kifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706852975; x=1707457775; h=mime-version:subject:references:in-reply-to:message-id:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uEWQcerBgr5U3NhCdZaVckhv6TjCYP3Ep82iyWcT4hE=; b=RroPPoZv/kXYQDRYgivdB+sjFF3ql7fu91fQ11D23rfXHpag6LMiJtmdHarVoS95+5 JiQ1+CL2yThxx7wDlUf1iy0KebhHkC/eGChIaGik1z/bxmgfSlHEMhMuhti6Qk2rvoal PCYNAlt9iQoVsvoNeO64JlMx+jqSAdw3j6mr5FP9vIxtCnuseM03d3U5xv3/Zu8UzbSb dHcjKmaqs0kmZqu8bO1lBNXDRRcfWegx/zObtKJ8Eoy1KxO2AQ8ANIeJhNmZ7d9js6oA bedsOt3rbCISoZL1KlwPkFyKq9OSNTgKqrfLeL+UbMV8Ri5OKRwUUuSQ0I1Ug6JDyjRa K3wA== X-Gm-Message-State: AOJu0Yw5smDzpL+YJzYSmIAJQoB2St/3XgJ+1H0oNDvJ1WuJm5SZIOiW JCwFmtqZBvUDv77JH+mGrN2THgztDMoYlTLpj3LepqA3FK/Ny4yxMz34KESXCiY= X-Google-Smtp-Source: AGHT+IHUkqlRN3v9Q46U1ULsAeQ0S4m3VoCI4/SgN15wSLmnwmj/YDvpVHT/RlGmCwBa2Dg4xBiPOA== X-Received: by 2002:a05:6a00:88b:b0:6dd:a072:867 with SMTP id q11-20020a056a00088b00b006dda0720867mr1844038pfj.15.1706852974743; Thu, 01 Feb 2024 21:49:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUQgrXcAbDBYicUW7LikZOE6Anbb3RklP61QtpoERX4wYkohESRaQEAxuxePgqNKRl3VwAkinOIDLUpsmCf9Jj32qM= Received: from [10.1.2.5] (123-193-26-19.dynamic.kbronet.com.tw. [123.193.26.19]) by smtp.gmail.com with ESMTPSA id z7-20020a630a47000000b005cfbdf71baasm793083pgk.47.2024.02.01.21.49.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2024 21:49:34 -0800 (PST) Date: Fri, 2 Feb 2024 13:49:16 +0800 From: Lin Lee To: freebsd-riscv@freebsd.org, Mitchell Horne Message-ID: In-Reply-To: <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> Subject: Re: A little bit wondering about how a syscall works X-Readdle-Message-ID: bd2bd011-be87-4f87-825b-dd533198bcc9@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65bc826a_5236e554_c55" X-Rspamd-Queue-Id: 4TR4bj41hbz4S8T X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --65bc826a_5236e554_c55 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, But what I see in=C2=A0https://github.com/freebsd/freebsd-src/blob/main/s= ys/kern/subr=5Fsyscall.c=C2=A0is(after removing some condition branching)= : 77 error =3D (p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td); 78 se =3D sa->callp; 156=C2=A0=C2=A0error =3D (se->sy=5Fcall)(td, sa->args); It seems that =60sv=5Fset=5Fsyscall=5Fretval hook=60 is called earlier th= an syscall is executed. Thank you so much for your replying. Best Regards, Lin Lee On =46eb 2, 2024 at 12:19 AM +0800, Mitchell Horne = , wrote: > On 2/1/24 00:47, Lin Lee wrote: > > Hi, > > > > So, if I understand correctly, > > > > Each thread's sv=5Ffetch=5Fsyscall=5Fargs hook function is initialize= d as > > cpu=5Ffetch=5Fsyscall=5Fargs(), > > > > And when it enter syscallenter, it first use =60error =3D > > (p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td);=60 to read the syst= em call > > number, then use =60error =3D (se->sy=5Fcall)(td, sa->args)=60 to exe= cute the > > system call. > > > > Do I understand corrected=3F > > > > That's right. > > > Thank you very much. > > > > Best Regards, > > Lin Lee > > On =46eb 1, 2024 at 12:27 AM +0800, Mitchell Horne , > > wrote: > > > On 1/31/24 01:03, Lin Lee wrote: > > > > Hello Mitchell, > > > > > > > > Thank you for your kindly responding. > > > > > > > > Now I have still a question, when does the function > > > > cpu=5Ffetch=5Fsyscall=5Fargs be called=3F > > > > > > > > As the previous letter mentions, I traced the code and entered th= e > > > > elf=5Fmachdep.c. > > > > > > > > I have no idea if there are something to do between elf=5Fmachdep= .c and > > > > system calll. > > > > > > > > > > The short answer is yes, it is related. In syscallenter() we have: > > > > > > error =3D (p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td); > > > > > > And as you saw, the sv=5Ffetch=5Fsyscall=5Fargs hook is set to > > > cpu=5Ffetch=5Fsyscall=5Fargs() for elf64=5Ffreebsd=5Fsysvec. Simila= rly, there is > > > an sv=5Fset=5Fsyscall=5Fretval hook, called by syscallret() when we= are done > > > executing the system call. > > > > > One correction: the sv=5Fset=5Fsyscall=5Fretval hook is actually called= at the > very end of syscallenter(), after the execution of the syscall has > completed. > > > > Each process 'p' has a corresponding sysentvec (p=5Fsysent). On the= > > > riscv architecture there is currently only one registered systentve= c, > > > elf64=5Ffreebsd=5Fsysvec, because we can only execute 64-bit =46ree= BSD EL=46 > > > binaries on this platform. > > > > > > By contrast, on amd64 there are several registered sysentvecs. This= > > > allows it to execute, for example, 32-bit =46reeBSD EL=46 binaries,= or > > > 64-bit Linux EL=46 binaries. The sysentvec enables different handli= ng > > > for these different types of executables, e.g. the system call tabl= e > > > is different for Linux processes (.sv=5Ftable =3D linux=5Fsysent). > > > > > > You will see also that Linux processes have a different function fo= r > > > sv=5Ffetch=5Fsyscall=5Fargs, take a look in sys/amd64/linux/linux=5F= sysvec.c. > > > > > > Mitchell > > > > > > > If not, when(how) the cpu=5Ffetch=5Fsyscall=5Fargs is called=3F > > > > > > > > Thank you very much. > > > > > > > > Best Regards, > > > > Lin Lee > > > > On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne , > > > > wrote: > > > > > > > > > > Mitchell > > > > --65bc826a_5236e554_c55 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Hi,

But what I see in&=23160;https:= //github.com/freebsd/freebsd-src/blob/main/sys/kern/subr=5Fsyscall.c&= =23160;is(after removing some condition branching):

77 error =3D (p->p=5Fsysent->s= v=5Ffetch=5Fsyscall=5Fargs)(td);
78 se =3D sa->callp;
156&=23160;&=23160;error =3D (se->sy=5Fcall)(td, sa->args);

It seems that =60sv=5Fset=5Fsyscall=5Fretval hook=60 is called earlier th= an syscall is executed.

Thank you so much for your replying.&=23160;

Best Regards,
Lin Lee
On =46eb 2, 2024 at 12:19 AM +0800,= Mitchell Horne <mhorne=40freebsd.org>, wrote:
On 2/1/24 00:47, Lin Lee wrote:
Hi,

So, if I understand correctly,

Each thread's sv=5Ffetch=5Fsyscall=5Fargs hook function is initialized as=
cpu=5Ffetch=5Fsyscall=5Fargs(),

And when it enter syscallenter, it first use =60error =3D
(p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td);=60 to read the sy= stem call
number, then use =60error =3D (se->sy=5Fcall)(td, sa->args)=60 to e= xecute the
system call.

Do I understand corrected=3F


That's right.

Thank you very much.

Best Regards,
Lin Lee
On =46eb 1, 2024 at 12:27 AM +0800, Mitchell Horne <mhorne=40freebsd.o= rg>,
wrote:
On 1/31/24 01:03, Lin Lee wrote:
Hello Mitchell,

Thank you for your kindly responding.

Now I have still a question, when does the function
cpu=5Ffetch=5Fsyscall=5Fargs be called=3F

As the previous letter mentions, I traced the code and entered the
elf=5Fmachdep.c.

I have no idea if there are something to do between elf=5Fmachdep.c and system calll.


The short answer is yes, it is related. In syscallenter() we have:

error =3D (p->p=5Fsysent->sv=5Ffetch=5Fsyscall=5Fargs)(td);

And as you saw, the sv=5Ffetch=5Fsyscall=5Fargs hook is set to
cpu=5Ffetch=5Fsyscall=5Fargs() for elf64=5Ffreebsd=5Fsysvec. Similarly, t= here is
an sv=5Fset=5Fsyscall=5Fretval hook, called by syscallret() when we are d= one
executing the system call.


One correction: the sv=5Fset=5Fsyscall=5Fretval hook is actually called a= t the
very end of syscallenter(), after the execution of the syscall has
completed.

Each process 'p' has a corresponding sysent= vec (p=5Fsysent). On the
riscv architecture there is currently only one registered systentvec,
elf64=5Ffreebsd=5Fsysvec, because we can only execute 64-bit =46reeBSD EL= =46
binaries on this platform.

By contrast, on amd64 there are several registered sysentvecs. This
= allows it to execute, for example, 32-bit =46reeBSD EL=46 binaries, or 64-bit Linux EL=46 binaries. The sysentvec enables different handling
for these different types of executables, e.g. the system call table
is different for Linux processes (.sv=5Ftable =3D linux=5Fsysent).

You will see also that Linux processes have a different function for
sv=5Ffetch=5Fsyscall=5Fargs, take a look in sys/amd64/linux/linux=5Fsysve= c.c.

Mitchell

If not, when(how) the cpu=5Ffetch=5Fsyscall= =5Fargs is called=3F

Thank you very much.

Best Regards,
Lin Lee
On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne <mhorne=40freebsd.org= >,
wrote:

Mitchell


--65bc826a_5236e554_c55-- From nobody Fri Feb 2 06:11:30 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TR55D1SXQz59WM2 for ; Fri, 2 Feb 2024 06:11:44 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TR55C6570z4VtR for ; Fri, 2 Feb 2024 06:11:43 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40fb804e4deso14959205e9.0 for ; Thu, 01 Feb 2024 22:11:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706854301; x=1707459101; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GHN31K4YQjC4cCGp+NkVzUjymXI/bpApqhFM/8QVBgI=; b=nvzI8//LIXDyWhkjXA16GvpGBf3g7NXNQMNUaGgRRXvEGVqKmsl9BwR51etyvaKiME 7IHmVkzqcDR9PbL88J7C8n+8dtBXOEgiS05lypVFQCC0+HqryrFk/BNZPL0qjGb3SZyq BHImr8kgCwwqL/vu0TuITySUpltxS6GMTWqmPz/ZJ+LkRYuXgzgOuVJBGl46ZGUwyi/B Y+FriJqF5+2ymeKhHQB8EL5xkLnw0lzoZQ6bdgREoClScy5xiqaEz1+chzZF5MmNds+b spKlJM0/rZst051zhe8mfyrDi5/yctKVjobRBpU7FslGeyrtm8KPxU1G4jTYj2vDlls3 EM0A== X-Gm-Message-State: AOJu0Ywe8SBZ5qsFBmHoemo2ioWVW5GyF1dmGaIA0ZN/CZjLiQ6YnQjK BcWYhRd09jAM3bWkrNAVv4mYf1wo6Td0dSG68eu5Rr/RP68P/TseV2/kEnOqfh02l8dm53whC0W 3 X-Google-Smtp-Source: AGHT+IFiPXdcx6Qj/1e+TOv5VqA0DuzeD5btluTzZgr4ILJkcx7IeftjR4oERVnK9z7JOK+tuwOs1A== X-Received: by 2002:a05:600c:511e:b0:40f:b783:ad2e with SMTP id o30-20020a05600c511e00b0040fb783ad2emr3738369wms.21.1706854301541; Thu, 01 Feb 2024 22:11:41 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWXPHEUwXESCp+hO/fwafPavIeRa/0Oa0BOU79nlkoMdp56sgkhznFfw5MNxVJlR4FgCg8IywoaUFwfLQFagdbKba4= Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id fa6-20020a05600c518600b0040efb445698sm6360990wmb.5.2024.02.01.22.11.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2024 22:11:41 -0800 (PST) Content-Type: text/plain; charset=utf-8 List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) Subject: Re: A little bit wondering about how a syscall works From: Jessica Clarke In-Reply-To: Date: Fri, 2 Feb 2024 06:11:30 +0000 Cc: freebsd-riscv , Mitchell Horne Content-Transfer-Encoding: quoted-printable Message-Id: <1D587966-19FD-47C9-B362-B55068665C2E@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> To: Lin Lee X-Mailer: Apple Mail (2.3774.200.91.1.1) X-Rspamd-Queue-Id: 4TR55C6570z4VtR X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] On 2 Feb 2024, at 05:49, Lin Lee wrote: >=20 > Hi, >=20 > But what I see in = https://github.com/freebsd/freebsd-src/blob/main/sys/kern/subr_syscall.c = is(after removing some condition branching): >=20 > 77 error =3D (p->p_sysent->sv_fetch_syscall_args)(td); > 78 se =3D sa->callp; > 156 error =3D (se->sy_call)(td, sa->args); >=20 > It seems that `sv_set_syscall_retval hook` is called earlier than = syscall is executed. And sv_set_syscall_retval is called on line 204 after all of that. What=E2=80=99s making you think otherwise? Jess > Thank you so much for your replying.=20 >=20 > Best Regards,=20 > Lin Lee > On Feb 2, 2024 at 12:19 AM +0800, Mitchell Horne , = wrote: >> On 2/1/24 00:47, Lin Lee wrote: >>> Hi, >>>=20 >>> So, if I understand correctly, >>>=20 >>> Each thread's sv_fetch_syscall_args hook function is initialized as >>> cpu_fetch_syscall_args(), >>>=20 >>> And when it enter syscallenter, it first use `error =3D >>> (p->p_sysent->sv_fetch_syscall_args)(td);` to read the system call >>> number, then use `error =3D (se->sy_call)(td, sa->args)` to execute = the >>> system call. >>>=20 >>> Do I understand corrected? >>>=20 >>=20 >> That's right. >>=20 >>> Thank you very much. >>>=20 >>> Best Regards, >>> Lin Lee >>> On Feb 1, 2024 at 12:27 AM +0800, Mitchell Horne = , >>> wrote: >>>> On 1/31/24 01:03, Lin Lee wrote: >>>>> Hello Mitchell, >>>>>=20 >>>>> Thank you for your kindly responding. >>>>>=20 >>>>> Now I have still a question, when does the function >>>>> cpu_fetch_syscall_args be called? >>>>>=20 >>>>> As the previous letter mentions, I traced the code and entered the >>>>> elf_machdep.c. >>>>>=20 >>>>> I have no idea if there are something to do between elf_machdep.c = and >>>>> system calll. >>>>>=20 >>>>=20 >>>> The short answer is yes, it is related. In syscallenter() we have: >>>>=20 >>>> error =3D (p->p_sysent->sv_fetch_syscall_args)(td); >>>>=20 >>>> And as you saw, the sv_fetch_syscall_args hook is set to >>>> cpu_fetch_syscall_args() for elf64_freebsd_sysvec. Similarly, there = is >>>> an sv_set_syscall_retval hook, called by syscallret() when we are = done >>>> executing the system call. >>>>=20 >>=20 >> One correction: the sv_set_syscall_retval hook is actually called at = the >> very end of syscallenter(), after the execution of the syscall has >> completed. >>=20 >>>> Each process 'p' has a corresponding sysentvec (p_sysent). On the >>>> riscv architecture there is currently only one registered = systentvec, >>>> elf64_freebsd_sysvec, because we can only execute 64-bit FreeBSD = ELF >>>> binaries on this platform. >>>>=20 >>>> By contrast, on amd64 there are several registered sysentvecs. This >>>> allows it to execute, for example, 32-bit FreeBSD ELF binaries, or >>>> 64-bit Linux ELF binaries. The sysentvec enables different handling >>>> for these different types of executables, e.g. the system call = table >>>> is different for Linux processes (.sv_table =3D linux_sysent). >>>>=20 >>>> You will see also that Linux processes have a different function = for >>>> sv_fetch_syscall_args, take a look in = sys/amd64/linux/linux_sysvec.c. >>>>=20 >>>> Mitchell >>>>=20 >>>>> If not, when(how) the cpu_fetch_syscall_args is called? >>>>>=20 >>>>> Thank you very much. >>>>>=20 >>>>> Best Regards, >>>>> Lin Lee >>>>> On Jan 31, 2024 at 1:17 AM +0800, Mitchell Horne = , >>>>> wrote: >>>>>>=20 >>>>>> Mitchell >>>>=20 >>=20 From nobody Fri Feb 2 06:14:30 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TR58f5gSRz59WTx for ; Fri, 2 Feb 2024 06:14:42 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TR58f3sb2z4VvY; Fri, 2 Feb 2024 06:14:42 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6e1352dd653so1079277a34.2; Thu, 01 Feb 2024 22:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706854481; x=1707459281; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=cyL51y8JZGqaNASHL8eJvSUObjBUaGka4Q5YMjlLcRo=; b=YMfSe/DLTFvd6jlGfym/eUq5zPAggpticwPN5ba2Yt/7s4E0BLgnIHiTcJB988NNIk XyqQ5Gz3b1k6ZaPE0V4IliGi6fJhTDWpLXaUgSdDTwhRun5Fn8KP/Sk3Cj43QdOJKf0O d2pht3cGhEIR7+UWORJ2CrZQkMRCEnfYafmF8Q2E4LNTOGfjS1kKY0I38LFSdbHq6wIo X5D2vY2hf702UJtUCd5RcZB33J7KFsun/ypwM8PPdWWnTmx08b65UAO7mr9HtQhc1kng 5ZRcpfjcL3bdVJic253s4lAsbBRfz0XnWE+OUjRLSBwccYie4AdFkzDCjLPBhpfNLVHI GfKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706854481; x=1707459281; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cyL51y8JZGqaNASHL8eJvSUObjBUaGka4Q5YMjlLcRo=; b=NfnGYFE+xhEHwMBUW48I6l8RbyYHX2oMv41DM278gRvewPfo6otNSOk07ij8HssWA4 7MGR8aIIIRkM/sp8UEqytpeBHzRcPmnaZSKFOr0q++qhSU7mj5eI9g4xyAGJdyd6Jv+G fwgPdEqc7qYNoiuQNLEMUgNT5PiPsvckyKFiwPizLhJcgpVVVShYukja2abVUtCPDwsc o+UFpOFDk9MCpxqQTs3MG5A7VDYzEBaBw+CSle/t7fzzxVljT1nxH9Ul22f9mc8LtHt3 f2AGsP68Q20LPmx0isr2VaLqP4eBdO2EkTHW7LRWBjXlFaZh8lXsqh7xKK2OJW/uL/lL I/hw== X-Gm-Message-State: AOJu0Yx7gWPeUZ8F57IwJtT1ojTOCfVEy7V8KpqQt8eyWJGF3gm18teE +6Nvfe1NkVMMeitO2RdoFmY8i5YveGyOAv14nk3EuvJNsGcML6qcZdfLbYTYOfM= X-Google-Smtp-Source: AGHT+IG7YXUG6q/QSmsIo7W0c4ldThcdKAkaEYrvMc+V0FqJ0bEb1O7qOiGW/OBpfTVg9geuapvhPw== X-Received: by 2002:a05:6358:7f1b:b0:176:a512:e63e with SMTP id p27-20020a0563587f1b00b00176a512e63emr1095967rwn.29.1706854480563; Thu, 01 Feb 2024 22:14:40 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX/RbsQqYBMKardlbeS5TINOmjhW83sCe1X5Imt+50LX3qRl1tkbUnO0XcKoRUbI67DDE6QHqFn1w53WXrwWwRBOFA= Received: from [10.1.2.5] (123-193-26-19.dynamic.kbronet.com.tw. [123.193.26.19]) by smtp.gmail.com with ESMTPSA id y2-20020a63fa02000000b005d880b41598sm826592pgh.94.2024.02.01.22.14.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2024 22:14:40 -0800 (PST) Date: Fri, 2 Feb 2024 14:14:30 +0800 From: Lin Lee To: Jessica Clarke Cc: freebsd-riscv , Mitchell Horne Message-ID: In-Reply-To: <1D587966-19FD-47C9-B362-B55068665C2E@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> <1D587966-19FD-47C9-B362-B55068665C2E@freebsd.org> Subject: Re: A little bit wondering about how a syscall works X-Readdle-Message-ID: e7d6c75d-58eb-4bb5-a684-33943af3df81@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65bc884c_15b9bf5d_c55" X-Rspamd-Queue-Id: 4TR58f3sb2z4VvY X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --65bc884c_15b9bf5d_c55 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Opps, it's a typo. I meant sv_fetch_syscall_args. It executes `sv_fetch_syscall_args`, then it runs system calls. It is right, isn't? Best Regards, Lin Lee On Feb 1, 2024 at 12:47 AM +0800, wrote: > > sv_fetch_syscall_args --65bc884c_15b9bf5d_c55 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Opps, it's a typo. I meant sv=5Ffetch=5Fsyscall=5Fa= rgs.

It executes =60sv=5Ffetch=5Fsyscall=5Fargs=60, then it runs system calls.= &=23160;

It is right, isn't=3F

Best Regards,
Lin Lee
On =46eb 1, 2024 at 12:47 AM +0800,= wrote:

sv=5Ffetch=5Fsyscall=5Fargs
--65bc884c_15b9bf5d_c55-- From nobody Fri Feb 2 06:16:08 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TR5BY2YCqz59X6C for ; Fri, 2 Feb 2024 06:16:21 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TR5BY0tXmz4X00 for ; Fri, 2 Feb 2024 06:16:21 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40fb020de65so15084785e9.2 for ; Thu, 01 Feb 2024 22:16:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706854580; x=1707459380; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/rdH+OuwVHtgRtF73Vk2plzr56dKjhl+ZblpkvYWDRA=; b=H0u4Nv/+bbHp/gYvgz2POoFADWSOjMhSkMu1+7l1mCUB9lOADo0IhawOZFuIGI3dbm yTIXbKfAt/7+zUeIPQVeqHb7hE2+kSFBwQd+nyQKmdQob4bUtxxIsk7wuPCB0AyXZePZ WxFvj04fhz+6LghISy34LmsqMkV2YzFDdRqV/1FyjODbzO4D4eZH9UmUMx4APwfqjp0+ QrFvV7YTP3L5exW/E/4QuJQRIIgVGiOBVqne7RmLnPssfS4B7Ta40cBME5TQeW3YQIVO xw5UiL2wyOHfGA8GFas/Z7miNNhMXYAbxyqAeIxZHSVTZm8WHYgLibzNyFC9A85DG0WQ +S4w== X-Gm-Message-State: AOJu0YxorNAUcHS4EV7KSXvwyUpvZo/OGOvvx4j6zZ/pWTTZB0KEjoYW 6ZibOkzY7PZ/XWb6z/OQ2O2360n/VxZfkq6E+oeHiBjYXDLSup/QlipWRkXqsq0= X-Google-Smtp-Source: AGHT+IHx2moQzjQclTUT/ZRZq/LY1jj6NIU+uWpr26YlYLOVSNmNbEgPfhREw8cZcqHvceIm71s2Kw== X-Received: by 2002:a05:600c:450f:b0:40e:f736:8152 with SMTP id t15-20020a05600c450f00b0040ef7368152mr5257832wmo.14.1706854579704; Thu, 01 Feb 2024 22:16:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVeoyRxbur9rpd4zG3p339BBpCSG9JmhyCw6xA5ewbs+xsQZ29RaSZ546/oRUM/XGZEE5nez42zjE00QrCmnktoMFs= Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id o1-20020a5d6481000000b0033af26545c8sm1129164wri.50.2024.02.01.22.16.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2024 22:16:19 -0800 (PST) Content-Type: text/plain; charset=us-ascii List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) Subject: Re: A little bit wondering about how a syscall works From: Jessica Clarke In-Reply-To: Date: Fri, 2 Feb 2024 06:16:08 +0000 Cc: freebsd-riscv , Mitchell Horne Content-Transfer-Encoding: 7bit Message-Id: <44422F40-D64C-493D-B3DA-600FE2F0D833@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> <1D587966-19FD-47C9-B362-B55068665C2E@freebsd.org> To: Lin Lee X-Mailer: Apple Mail (2.3774.200.91.1.1) X-Rspamd-Queue-Id: 4TR5BY0tXmz4X00 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] On 2 Feb 2024, at 06:14, Lin Lee wrote: > > Opps, it's a typo. I meant sv_fetch_syscall_args. > > It executes `sv_fetch_syscall_args`, then it runs system calls. > > It is right, isn't? Yes, you need to fetch the arguments before you can use them. Jess > Best Regards, > Lin Lee > On Feb 1, 2024 at 12:47 AM +0800, wrote: >> >> sv_fetch_syscall_args From nobody Fri Feb 2 06:49:08 2024 X-Original-To: freebsd-riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TR5wd1rgrz586HF for ; Fri, 2 Feb 2024 06:49:21 +0000 (UTC) (envelope-from leelin2602@gmail.com) Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TR5wc67tRz4ZCm; Fri, 2 Feb 2024 06:49:20 +0000 (UTC) (envelope-from leelin2602@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-595d24ad466so1101954eaf.0; Thu, 01 Feb 2024 22:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706856558; x=1707461358; darn=freebsd.org; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=CdYFBSAdLvQH7jTfCpKRX6CePZruJmPDHOM7+LAURrk=; b=aW2PEelJHHbTnKrzAtRYA9BuziaIuy1wV1aH+2aWL1gwkTRYMEvMaM/aW8N/a3Ssok 7zhEHyQvbt0VaD4WMIIOUYksN4eNQp7r39Cd7iS3u2/f5VOeIXFuVgtC9LnFyZGKrh9H 2nFEAveMxtR64SjZ2vPkl8KTKOiypdn2DfzLf6Cu65b1Ln+NzlBK3NYBvDVkt0POM6lq KiNRDNMIEBXw8RpFPg9a1d53pgExSRYIb0yl0fZH7c1z9r3dJbG9WKqcw1hGtbzWpcLt VSGPwceEbzxGmFvzuSn9RtvZsQF33ZWlTIyZQBbTxnnuxQwcNeH/rNKwOU60VPC2wav7 G3aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706856558; x=1707461358; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CdYFBSAdLvQH7jTfCpKRX6CePZruJmPDHOM7+LAURrk=; b=DZfCPhkpReRP9QM15FnkOG2Zd0sEJMZVRfaKHjsifAfSwID3z4sCBwEAR1Tmkc6SS3 JbHh8BEUL0ZAOElK4aNc5AclzNhuz5Gva26h42XOsea82ijU/AB6re+wi3thMkQRkj2B tC2StKC1tWGKn7DAcOmtf1g/OVnPAlDAVOThPQbJoMnf8XDnTGloK7lJ7nohlDbhySeE x+TaygmPLwEYaS7+Z4jIuj6PyMbgHA92XKIc7zmiWbbHNWydCYxA3HVBrM8crktxc98Y LSUbNPThpHjIKWCr7KTHwyEn6y40xKGupDcMYs2sYv+WrxDmhjMEV75kN8MNcnYrZpMH xduA== X-Gm-Message-State: AOJu0YwN5MjJ2vYmOJm7/x/SaxNZcBDXFpzv3HbkJwd7l0u15oHgTPn9 0CNFmwUe8CAapj0bvUlGKjUVLVoKunSMkLQ4fah6BEhbp9wfPTN9CMhFHUtw3Gk= X-Google-Smtp-Source: AGHT+IGsx7UvRK5DDdr+T+yP092CkIBDX5psmgKpp4vXmtjmKUTh4HnRiW0lEhfCZdCsou9LqjpV1w== X-Received: by 2002:a05:6359:4112:b0:178:7568:3b57 with SMTP id kh18-20020a056359411200b0017875683b57mr4999377rwc.30.1706856558070; Thu, 01 Feb 2024 22:49:18 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXE34YlHvfsFLguPXfG3jGLr5CjAkIBGkGPV3FVPF4ZRiikkjTYLaYuPVF2oBcF62/iYT0wJ5zC/90Afg8Hcmp4/7M= Received: from [10.1.2.5] (123-193-26-19.dynamic.kbronet.com.tw. [123.193.26.19]) by smtp.gmail.com with ESMTPSA id y1-20020aa78541000000b006d9ce7d3258sm832005pfn.204.2024.02.01.22.49.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2024 22:49:17 -0800 (PST) Date: Fri, 2 Feb 2024 14:49:08 +0800 From: Lin Lee To: Jessica Clarke Cc: freebsd-riscv , Mitchell Horne Message-ID: <9ff23e5d-f320-4004-a7a2-1db3f6cb8fcd@Spark> In-Reply-To: <44422F40-D64C-493D-B3DA-600FE2F0D833@freebsd.org> References: <9204b5c5-63bc-4c29-af19-1f1bb85f74e8@Spark> <8f66f3ed-2a49-4ebc-89eb-66c53e6d22bb@Spark> <9bfbdbe2-ff30-4c2f-abf3-2763aa433107@freebsd.org> <8867a483-7e92-4579-9236-32b4a704713e@Spark> <51285fdf-dbcf-4d71-82cb-f49353db95cd@freebsd.org> <1D587966-19FD-47C9-B362-B55068665C2E@freebsd.org> <44422F40-D64C-493D-B3DA-600FE2F0D833@freebsd.org> Subject: Re: A little bit wondering about how a syscall works X-Readdle-Message-ID: 9ff23e5d-f320-4004-a7a2-1db3f6cb8fcd@Spark List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="65bc9069_65199124_c55" X-Rspamd-Queue-Id: 4TR5wc67tRz4ZCm X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US] --65bc9069_65199124_c55 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks, now I think I understand How a system call works. Thank you=C2=A0Mitchell and=C2=A0Jess. Best Regards, Lin Lee On =46eb 1, 2024 at 12:47 AM +0800, wrote: > > sv=5Ffetch=5Fsyscall=5Fargs --65bc9069_65199124_c55 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Thanks, now I think I understand How a system call = works.

Thank you&=23160;Mitchell and&=23160;Jess.

Best Regards,
Lin Lee
On =46eb 1, 2024 at 12:47 AM +0800,= wrote:

sv=5Ffetch=5Fsyscall=5Fargs
--65bc9069_65199124_c55-- From nobody Sat Feb 3 13:43:30 2024 X-Original-To: riscv@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TRv424rMWz59Q0T for ; Sat, 3 Feb 2024 13:43:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TRv4204XHz439s for ; Sat, 3 Feb 2024 13:43:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706967810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=W0LieSRB59rgCnAgUcmOmms7I7iKSPUCWMNQ170tuSU=; b=GmSelUDlTHazvLIKYDvSLdMKFxq+SoxRQl+/yI77+/4m1pbWUYgA0IWicgR2VLxPXzkRY7 OLgvYWLuPsQvTfz/8Z5iAXuZYyTyarYfD/1jEARsiUWhLKMoOkHPlUvbl/wJPvJ1l1SZOE mbyf4YIAC8acFjECww0elk0MlR9gTS2ZiqkG8aCdbbYyQJxCHzvKUMJJ5bEw/+64emK8q/ QDJY1fKdaF4jL8IOV5R9uKElcrf7BrZI6a9PsuIb3RJzS0msyEGdC94iqJ1KegHj91sCeK OSwuKFgJDXyNVTSD7BDrfKl9D/gqJatU96+sRnh10BI4ySakCld9Vjxt+x9OcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706967810; a=rsa-sha256; cv=none; b=NgiK7JiO4Xbvi9faAP6JIeTGzwfEmkcxVskL4EfNKVaeN8vsT6/jL8SLdANiJqCwgchyHi U7sKC7qMPMenHVL2e1a/nbZaRlCVhbnKTELQNuweeXrRX6H/PU6/ez3lif393hNhi3PIes OU2x8/9W6SPgRBRKzD84VSn1Ylaf8zFuTtYYnj4ZZOVffeSltBSiKHHdSil5ygGOc8IMAH vVjUdCEm/gGw5nYyh6dVwLgtn2heFhVvNs1lSLc80//7loroGEMIuDD8cwjfvgaQ6ZzxNm DEnnfJzmYn0s6PoagQevCOnjL4fvGJHGFq9oCbSPIN2yH2jWVJ0HgTvuDu4BeQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TRv416J03zG9j for ; Sat, 3 Feb 2024 13:43:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 413DhTRh075780 for ; Sat, 3 Feb 2024 13:43:29 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 413DhTXC075778 for riscv@FreeBSD.org; Sat, 3 Feb 2024 13:43:29 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: riscv@FreeBSD.org Subject: [Bug 276805] starfive-vf2 no storage devices found Date: Sat, 03 Feb 2024 13:43:30 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: riscv X-Bugzilla-Version: 14.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: rdunkle@smallcatbrain.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: riscv@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: FreeBSD on the RISC-V instruction set architecture List-Archive: https://lists.freebsd.org/archives/freebsd-riscv List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-riscv@freebsd.org X-BeenThere: freebsd-riscv@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276805 Bug ID: 276805 Summary: starfive-vf2 no storage devices found Product: Base System Version: 14.0-STABLE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: riscv Assignee: riscv@FreeBSD.org Reporter: rdunkle@smallcatbrain.com starfive vf2- booting from sdcard using the sysutils/u-boot-starfive-visionfive2. I am using the dtb file from: https://github.com/starfive-tech/VisionFive2/releases/download/JH7110_VF2_5= 15_v5.10.3/jh7110-visionfive-v2.dtb I am using memstick image. FreeBSD 14.0-STABLE #0 stable/14-dcae96578 There appears to be no storage devices found. OK load /boot/kernel/kernel /boot/kernel/kernel text=3D0x5b7ae4 text=3D0x14a52c data=3D0xf0720 data=3D0x216c+0x1beacc 0x8+0x2158ed8+0x8+0xf2722 OK lsmod 0xffffffc000000000: /boot/kernel/kernel (elf kernel, 0x2c00968) modules: riscv_syscon.1 xdr.1 ufs.1 kernel_mac_support.5 krpc.1 cryptosof= t.1 crypto.1 nfslockd.1 nfssvc.1 netlink.1 ipsec_support.1 ertt.1 cubic.2 if_vl= an.3 if_tap.1 if_tun.1 if_tuntap.1 if_gif.1 ether.1 zlib.1 aio.1 sysvshm.1 sysvs= em.1 sysvmsg.1 firmware.1 acl_posix1e.1 acl_nfs4.1 kernel.1400507 cd9660.1 geom_raid.0 geom_part_mbr.0 geom_part_gpt.0 geom_part_bsd.0 g_part.0 geom_label.0 pseudofs.1 procfs.1 nfsd.1 nfscl.1 nfs.1 nfscommon.1 msdosfs.1 virtio_blk.1 vtnet.1 virtio_mmio.1 virtio_pci.1 virtio.1 usb_quirk.1 ukbd.1 uhub.1 usb.1 umass.1 tcp_log_dev.1 spibus.1 ofw_spibus.1 random_device.1 random_harvestq.1 pci.1 ofwbus.1 ofw_firmware.1 nvme.1 nvd.1 null.1 mii_bitbang.1 miibus.1 mem.1 geom_md.0 ofw_iicbus.1 iicbus.1 hidquirk.1 hid= .1 ofw_gpiobus.1 gpioc.1 gpiobus.1 simple_mfd.1 fbd.1 syscon_generic.1 clk_fix= ed.1 ofw_clkbus.1 cam.1 OK OK lsdev disk devices: disk0: 61405184 X 512 blocks (removable) disk0p1: EFI disk0p2: FreeBSD UFS http: (unknown) net devices: net0: OK boot -v Using DTB provided by EFI at 0xfe6e7000. Kernel entry at 0xf680002e... Kernel args: -v ---<>--- Physical memory chunk(s): 0x40000000 - 0x23fffffff, 8192 MB (2097152 pages) Excluded memory regions: 0x40000000 - 0x401fffff, 2 MB ( 512 pages) NoAlloc NoDump 0xf6800000 - 0xf9495fff, 44 MB ( 11414 pages) NoAlloc Found 4 CPUs in the device tree Copyright (c) 1992-2023 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD is a registered trademark of The FreeBSD Foundation. FreeBSD 14.0-STABLE #0 stable/14-dcae96578: Sat Feb 3 10:50:17 EET 2024 =20=20=20 root@sky22.smallcatbrain.com:/usr/obj/usr/src-stable-14/riscv.riscv64/sys/G= ENERIC riscv FreeBSD clang version 17.0.6 (https://github.com/llvm/llvm-project.git llvmorg-17.0.6-0-g6009708b4367) VT: init without driver. Preloaded elf kernel "/boot/kernel/kernel" at 0xffffffc002c70000. Preloaded boot_entropy_platform "efi_rng_seed" at 0xffffffc002c792f8. Preloaded TSLOG data "TSLOG" at 0xffffffc002c79350. SBI: OpenSBI v1.4 SBI Specification Version: 2.0 CPU 0 : Vendor=3DSiFive Core=3D6/7/P200/X200-Series Processor (Hart 1) marchid=3D0x8000000000000007, mimpid=3D0x4210427 MMU: 0x1 ISA: 0x112d S-mode Extensions: 0 real memory =3D 8589934592 (8192 MB) Physical memory chunk(s): 0x0000000040200000 - 0x00000000f67fffff, 3059744768 bytes (747008 pages) 0x00000000f9496000 - 0x000000023356efff, 5268934656 bytes (1286361 pages) avail memory =3D 8300789760 (7916 MB) No static device mappings. Starting CPU 1 (hart 2) Starting CPU 2 (hart 3) Starting CPU 3 (hart 4) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs CPU 1 : Vendor=3DSiFive Core=3D6/7/P200/X200-Series Processor (Hart 2) CPU 2 : Vendor=3DSiFive Core=3D6/7/P200/X200-Series Processor (Hart 3) CPU 3 : Vendor=3DSiFive Core=3D6/7/P200/X200-Series Processor (Hart 4) random: no preloaded entropy cache random: read 2048 bytes from platform bootloader random: unblocking device. VIMAGE (virtualized network stack) enabled hostuuid: using 00000000-0000-0000-0000-000000000000 ULE: setup cpu 0 ULE: setup cpu 1 ULE: setup cpu 2 ULE: setup cpu 3 random: entropy device external interface kbd0 at kbdmux0 mem: null: openfirm: tcp_log: tcp_log device crypto: ofwbus0: clk_fixed0: on ofwbus0 clk_fixed1: on ofwbus0 clk_fixed2: on ofwbus0 clk_fixed3: on ofwbus0 clk_fixed4: on ofwbus0 clk_fixed5: on ofwbus0 clk_fixed6: on ofwbus0 clk_fixed7: on ofwbus0 clk_fixed8: on ofwbus0 clk_fixed9: on ofwbus0 clk_fixed10: on ofwbus0 clk_fixed11: on ofwbus0 clk_fixed12: on ofwbus0 clk_fixed13: on ofwbus0 clk_fixed14: on ofwbus0 clk_fixed15: on ofwbus0 clk_fixed16: on ofwbus0 clk_fixed17: on ofwbus0 clk_fixed18: on ofwbus0 clk_fixed19: on ofwbus0 simplebus0: on ofwbus0 plic0: mem 0xc000000-0xfffffff irq 14,15,16,17,18,19,20,21,22= on simplebus0 timer0: Timecounter "RISC-V Timecounter" frequency 4000000 Hz quality 1000 Event timer "RISC-V Eventtimer" frequency 4000000 Hz quality 1000 ram0: reserving memory region: 40200000-f6800000 ram0: reserving memory region: f9496000-240000000 ram0: reserving excluded region: 40000000-401fffff ram0: reserving excluded region: f6800000-f9495fff rcons0: ofwbus0: compat operating-points-v2 (no driver attached) cpulist0: on ofwbus0 cpu0: on cpulist0 cpu0: missing 'clock-frequency' property riscv64_cpu0: register <0> cpu1: on cpulist0 cpu1: missing 'clock-frequency' property riscv64_cpu1: register <1> cpu2: on cpulist0 cpu2: missing 'clock-frequency' property riscv64_cpu2: register <2> cpu3: on cpulist0 cpu3: missing 'clock-frequency' property riscv64_cpu3: register <3> cpu4: on cpulist0 cpu4: missing 'clock-frequency' property ofwbus0: compat starfive,mailbox-test (no driver attached) simplebus0: mem 0x2010000-0x2013fff,0x8000000-0x9ffffff irq 0,1,2,3 compat sifive,fu740-c000-ccache (no driver attached) syscon_generic_dev0: mem 0x17010000-0x17010fff on simplebus0 simplebus0: mem 0x10210000-0x1021ffff compat starfive,phyctrl (no driver attached) simplebus0: mem 0x10220000-0x1022ffff compat starfive,phyctrl (no driver attached) syscon_generic_dev1: mem 0x10240000-0x10240fff on simplebus0 syscon_generic_dev2: mem 0x13030000-0x13030fff on simplebus0 simplebus0: mem 0x2000000-0x200ffff irq 4,5,6,7,8,9,10,11,1= 2,13 compat riscv,clint0 (no driver attached) simplebus0: mem 0x13020000-0x1302ffff,0x10230000-0x1023ffff,0x17000000-0x1700ffff compat starfive,jh7110-clkgen (no driver attached) simplebus0: mem 0x295c0000-0x295cffff compat starfive,jh7110-clk-vout (no driver attached) simplebus0: mem 0x19810000-0x1981ffff compat starfive,jh7110-clk-isp (no driver attached) simplebus0: mem 0x13010000-0x1301ffff,0x21000000-0x213fffff = irq 23 compat cdns,qspi-nor (no driver attached) simplebus0: mem 0x17050000-0x1705ffff compat starfive,jh7110= -otp (no driver attached) simplebus0: mem 0x10210000-0x10210fff,0x10200000-0x10200fff compat starfive,jh7110-cdns3 (no driver attached) simplebus0: mem 0x13050000-0x1305ffff irq 24,25,26,27 comp= at starfive,jh7110-timers (no driver attached) simplebus0: mem 0x13070000-0x1307ffff irq 28 compat starfive,jh7110-wdt (no driver attached) simplebus0: mem 0x17040000-0x1704ffff irq 29,30,31 compat starfive,jh7110-rtc (no driver attached) simplebus0: mem 0x17030000-0x1703ffff irq 32 co= mpat starfive,jh7110-pmu (no driver attached) simplebus0: mem 0x10000000-0x1000ffff irq 33 compat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x10010000-0x1001ffff irq 34 disabled com= pat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x10020000-0x1002ffff irq 35 disabled com= pat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x12000000-0x1200ffff irq 36 disabled com= pat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x12010000-0x1201ffff irq 37 disabled com= pat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x12020000-0x1202ffff irq 38 disabled com= pat snps,dw-apb-uart (no driver attached) simplebus0: mem 0x16050000-0x1605ffff irq 39 comp= at starfive,jh7110-axi-dma (no driver attached) simplebus0: mem 0x13040000-0x1304ffff irq 40 compat starfive,jh7110-sys-pinctrl (no driver attached) simplebus0: mem 0x17020000-0x1702ffff irq 41 compat starfive,jh7110-aon-pinctrl (no driver attached) simplebus0: mem 0x120e0000-0x120effff irq 42 compat starfive,jh7110-temp (no driver attached) simplebus0: mem 0x1600c000-0x1600ffff irq 43 compat starfive,jh7110-trng (no driver attached) simplebus0: mem 0x16008000-0x1600bfff irq 44 compat arm,pl080 (no driver attached) simplebus0: mem 0x16000000-0x16003fff,0x16008000-0x1600bf= ff irq 45,46 compat starfive,jh7110-sec (no driver attached) simplebus0: mem 0x10030000-0x1003ffff irq 47 compat snps,designware-i2c (no driver attached) simplebus0: mem 0x10040000-0x1004ffff irq 48 disabled compat snps,designware-i2c (no driver attached) simplebus0: mem 0x10050000-0x1005ffff irq 49 compat snps,designware-i2c (no driver attached) simplebus0: mem 0x12030000-0x1203ffff irq 50 disabled compat snps,designware-i2c (no driver attached) simplebus0: mem 0x12040000-0x1204ffff irq 51 disabled compat snps,designware-i2c (no driver attached) simplebus0: mem 0x12050000-0x1205ffff irq 52 compat snps,designware-i2c (no driver attached) simplebus0: mem 0x12060000-0x1206ffff irq 53 compat snps,designware-i2c (no driver attached) simplebus0: mem 0x16010000-0x1601ffff irq 54 compat starfive,jh7110-sdio (no driver attached) simplebus0: mem 0x16020000-0x1602ffff irq 55 compat starfive,jh7110-sdio (no driver attached) simplebus0: mem 0x19800000-0x1980ffff,0x19810000-0x1981ffff,0x19820000-0x1982ffff,0x1984000= 0-0x1984ffff,0x19870000-0x1989ffff,0x11840000-0x1184ffff,0x17030000-0x1703f= fff,0x13020000-0x1302ffff irq 56,57,58,59,60 compat starfive,jh7110-vin (no driver attached) simplebus0: mem 0x13090000-0x130902ff irq 61 compat starfive= ,jpu (no driver attached) simplebus0: mem 0x130a0000-0x130affff irq 62 compat starfive,vdec (no driver attached) simplebus0: mem 0x130b0000-0x130bffff irq 63 compat starfive,venc (no driver attached) simplebus0: mem 0x13020000-0x1302ffff,0x10230000-0x1023ffff,0x17000000-0x1700ffff,0x1981000= 0-0x1981ffff,0x295c0000-0x295cffff compat starfive,jh7110-reset (no driver attached) simplebus0: mem 0x16030000-0x1603ffff irq 64,65,66 comp= at starfive,dwmac (no driver attached) simplebus0: mem 0x16040000-0x1604ffff irq 67,68,69 comp= at starfive,dwmac (no driver attached) simplebus0: mem 0x18000000-0x180fffff,0x130c000-0x131bfff ir= q 70 compat img-gpu (no driver attached) simplebus0: mem 0x130d0000-0x130d0fff irq 71 disabled compat starfive,jh7110-can (no driver attached) simplebus0: mem 0x130e0000-0x130e0fff irq 72 disabled compat starfive,jh7110-can (no driver attached) simplebus0: mem 0x10090000-0x10090fff disabled compat starfive,jh7110-tdm (no driver attached) simplebus0: mem 0x100a0000-0x100a0fff irq 73 disabled com= pat starfive,jh7110-spdif (no driver attached) simplebus0: mem 0x100b0000-0x100b0fff compat starfive,jh7110-pwmdac (no driver attached) simplebus0: mem 0x100c0000-0x100c0fff disabled compat snps,designware-i2stx (no driver attached) simplebus0: mem 0x100d0000-0x100d0fff compat starfive,jh7110= -pdm (no driver attached) simplebus0: mem 0x100e0000-0x100e0fff disabled compat starfive,jh7110-i2srx-master (no driver attached) simplebus0: mem 0x100e0000-0x100e0fff disabled compat starfive,jh7110-i2srx (no driver attached) simplebus0: mem 0x120b0000-0x120b0fff compat starfive,jh7110-i2stx-4ch0 (no driver attached) simplebus0: mem 0x120c0000-0x120c0fff disabled compat starfive,jh7110-i2stx-4ch1 (no driver attached) simplebus0: mem 0x120d0000-0x120dffff compat starfive,jh7110= -pwm (no driver attached) simplebus0: disabled compat linux,spdif-dit (no driver attached) simplebus0: compat starfive,jh7110-pwmdac-dit (no driv= er attached) simplebus0: disabled compat dmic-codec (no driver attached) simplebus0: mem 0x10060000-0x1006ffff irq 74 compat arm,pl022 (no driver attached) simplebus0: mem 0x10070000-0x1007ffff irq 75 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x10080000-0x1008ffff irq 76 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x12070000-0x1207ffff irq 77 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x12080000-0x1208ffff irq 78 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x12090000-0x1209ffff irq 79 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x120a0000-0x120affff irq 80 disabled compat arm,pl022 (no driver attached) simplebus0: mem 0x2b000000-0x2bffffff,0x940000000-0x94fffff= ff irq 81 type pci compat starfive,jh7110-pcie (no driver attached) simplebus0: mem 0x2c000000-0x2cffffff,0x9c0000000-0x9cfffff= ff irq 82 type pci compat starfive,jh7110-pcie (no driver attached) simplebus0: mem 0x13060000-0x13060fff irq 83,84 compat starfive,mail_box (no driver attached) simplebus0: compat starfive,jh7110-display (no driver attached) syscon_generic_dev3: mem 0x295b0000-0x295b008f on simplebus0 simplebus0: disabled compat starfive,tda998x_rgb_pin (no driv= er attached) simplebus0: disabled compat starfive,jh7110-rgb_output (no dri= ver attached) simplebus0: mem 0x29400000-0x294000ff,0x29400800-0x294027ff,0x17030000-0x17030fff irq 85 co= mpat starfive,jh7110-dc8200 (no driver attached) simplebus0: compat starfive,jh7110-display-encoder (no driver attached) simplebus0: mem 0x295e0000-0x295effff compat starfive,jh7110-mipi-dphy-tx (no driver attached) simplebus0: mem 0x295d0000-0x295dffff irq 86 compat starfive,jh7110-mipi_dsi (no driver attached) simplebus0: mem 0x29590000-0x29593fff irq 87 compat starfive,jh7110-hdmi (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: compat simple-audio-card (no driver attached) simplebus0: mem 0x6e210000-0x6e210fff,0x6e211000-0x6e24ffff compat starfive,e24 (no driver attached) simplebus0: mem 0x20020000-0x2002ffff disabled compat starfive,vf2-dsp-v1 (no driver attached) simplebus0: compat starfive,jh7110-cpufreq (no dr= iver attached) ofwbus0: compat gpio-leds (no driver attached) ofwbus0: compat pwm-backlight (no driver attached) ofwbus0: compat gpio-restart (no driver attached) crypto: assign cryptosoft0 driver id 0, flags 0x6000000 Device configuration finished. procfs registered Timecounters tick every 1.000 msec lo0: bpf attached vlan: initialized, using hash tables with chaining IPsec: Initialized Security Association Processing. tcp_init: net.inet.tcp.tcbhashsize auto tuned to 65536 usb_needs_explore_all: no devclass Release APs Secondary CPU 2 fully online Secondary CPU 1 fully online Trying to mount root from ufs:/dev/ufs/FreeBSD_Install [ro,noatime]... Secondary CPU 3 fully online mountroot: waiting for device /dev/ufs/FreeBSD_Install... Mounting from ufs:/dev/ufs/FreeBSD_Install failed with error 19. Loader variables: vfs.root.mountfrom=3Dufs:/dev/ufs/FreeBSD_Install vfs.root.mountfrom.options=3Dro,noatime Manual root filesystem specification: : [options] Mount using filesystem and with the specified (optional) option list. eg. ufs:/dev/da0s1a zfs:zroot/ROOT/default cd9660:/dev/cd0 ro (which is equivalent to: mount -t cd9660 -o ro /dev/cd0 /) ? List valid disk boot devices . Yield 1 second (for background tasks) Abort manual input mountroot> ? List of GEOM managed disk devices: mountroot> --=20 You are receiving this mail because: You are the assignee for the bug.=