From nobody Mon Jun 27 16:29:05 2022 X-Original-To: freebsd-arm@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 7B24887956E for ; Mon, 27 Jun 2022 16:36:02 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from fry.fubar.geek.nz (fry.fubar.geek.nz [139.59.165.16]) by mx1.freebsd.org (Postfix) with ESMTP id 4LWtdY65ZDz4psK for ; Mon, 27 Jun 2022 16:36:01 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from smtpclient.apple (cpc91232-cmbg18-2-0-cust554.5-4.cable.virginm.net [82.2.126.43]) by fry.fubar.geek.nz (Postfix) with ESMTPSA id A18184E67E; Mon, 27 Jun 2022 16:29:06 +0000 (UTC) From: Andrew Turner Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_5E6DBBF9-54AB-482F-A909-36108AC2442A" List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: SMCCC v1.1 compliant HVC call Date: Mon, 27 Jun 2022 17:29:05 +0100 In-Reply-To: Cc: "freebsd-arm@FreeBSD.org" , Wei Hu To: Souradeep Chakrabarti References: X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Rspamd-Queue-Id: 4LWtdY65ZDz4psK X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=softfail (mx1.freebsd.org: 139.59.165.16 is neither permitted nor denied by domain of andrew@FreeBSD.org) smtp.mailfrom=andrew@FreeBSD.org X-Spamd-Result: default: False [2.99 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; FREEFALL_USER(0.00)[andrew]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MV_CASE(0.50)[]; GREYLIST(0.00)[pass,body]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; DMARC_NA(0.00)[FreeBSD.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; NEURAL_SPAM_MEDIUM(0.98)[0.977]; NEURAL_HAM_LONG(-1.00)[-0.999]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_HAM_SHORT(-0.99)[-0.989]; MLMMJ_DEST(0.00)[freebsd-arm]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:14061, ipnet:139.59.160.0/20, country:US]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N --Apple-Mail=_5E6DBBF9-54AB-482F-A909-36108AC2442A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 27 Jun 2022, at 09:57, Souradeep Chakrabarti = wrote: >=20 > Hi Andrew, > =20 > In Linux we have SMCCC v1.1 compliant HVC call arm_smccc_1_1_hvc(), = which is used for SMCCC and HVC call convention. > In FreeBSD do we have something similar? > =20 > I can arm_smccc_smc() in sys/dev/psci/smccc.h, but could not find the = implementation details of it. If I need to use SMCCC compliant > HVC call, what API should I use? > =20 > Thanks & Regards, > Souradeep You can use arm_smccc_hvc to hard code the type. Both the hvc and smc = versions are implemented in sys/dev/psci/smccc_arm64.S. They depend on = the arm64 ABI to put the arguments into the correct registers to be = passed into the hypervisor. If your code is running after the psci device has attached you can use = psci_callfn. It is a function pointer to either of the arm_smccc_* = functions depending on what is in ACPI/FDT. Andrew= --Apple-Mail=_5E6DBBF9-54AB-482F-A909-36108AC2442A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On 27 Jun 2022, at 09:57, Souradeep Chakrabarti <schakrabarti@microsoft.com> wrote:

Hi Andrew,
 
In Linux we have SMCCC v1.1 = compliant HVC call arm_smccc_1_1_hvc(), which is used for SMCCC and HVC = call convention.
In FreeBSD do we have something = similar?
 
I can = arm_smccc_smc() in sys/dev/psci/smccc.h, but could not find the = implementation details of it. If I need to use SMCCC compliant
HVC call, what API should I use?
 
Thanks & Regards,
Souradeep

You can use arm_smccc_hvc to hard = code the type. Both the hvc and smc versions are implemented = in sys/dev/psci/smccc_arm64.S. They depend on the arm64 ABI to put = the arguments into the correct registers to be passed into the = hypervisor.

If your = code is running after the psci device has attached you can = use psci_callfn. It is a function pointer to either of = the arm_smccc_* functions depending on what is in ACPI/FDT.

Andrew
= --Apple-Mail=_5E6DBBF9-54AB-482F-A909-36108AC2442A--