All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: "崇文 李" <chongwen.li@outlook.com>
To: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Potential bug of arm64 SMCCC call
Date: Mon, 25 Mar 2024 13:36:37 +0000	[thread overview]
Message-ID: <DS7PR19MB4407C29AC8FF38BA192DCDFFE6362@DS7PR19MB4407.namprd19.prod.outlook.com> (raw)

Hello. I saw a potential bug when I was checking arm64 SMCCC call.

In arm-smccc.h [see link 0], from line 481 to line 497 resides the
definition of "__arm_smccc_1_1", which is in turn used to implement
the RMI interface in rmi_cmds.h [see link 1].

In the definition of "__arm_smccc_1_1", there is no clobbering of
registers x4 -- x17.  However, according to Arm SMC Calling Convention
[see link 2, page 10 of 19], registers x4 -- x17 are scratch registers. 
Upon returning from an arm64 smc instruction, x4 -- x17 registers may 
be overwritten with mysterious values from the firmware.

So it is safer to mark x4--x17 registers as clobbered registers in the
"asm" statement inside the definition of "__arm_smccc_1_1", so the
compiler avoids using x4--x17 registers around arm64 smc instructions.

Best regards.



Links
============

[0] arm-smccc.h in arm's linux kernel repository
   https://gitlab.arm.com/linux-arm/linux-cca/-/blob/cca-host/rmm-v1.0-eac5/include/linux/arm-smccc.h?ref_type=heads

[1] rmi_cmds.h in arm's linux kernel repository
   https://gitlab.arm.com/linux-arm/linux-cca/-/blob/cca-host/rmm-v1.0-eac5/arch/arm64/include/asm/rmi_cmds.h?ref_type=heads

[2] Arm SMC Calling Convention
   https://documentation-service.arm.com/static/5f8ea482f86e16515cdbe3c6?token=
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2024-03-25 13:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 13:36 崇文 李 [this message]
2024-03-25 17:00 ` Potential bug of arm64 SMCCC call Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DS7PR19MB4407C29AC8FF38BA192DCDFFE6362@DS7PR19MB4407.namprd19.prod.outlook.com \
    --to=chongwen.li@outlook.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.