All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Rex Nie <rex.nie@jaguarmicro.com>
Cc: mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com,
	linux-kernel@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org, angus.chen@jaguarmicro.com
Subject: Re: [PATCH] tools: arm64: add registers read/write tool for arm64
Date: Mon, 21 Oct 2024 18:44:04 +0100	[thread overview]
Message-ID: <86cyjt4ahn.wl-maz@kernel.org> (raw)
In-Reply-To: <20241021150112.1194-1-rex.nie@jaguarmicro.com>

On Mon, 21 Oct 2024 16:01:12 +0100,
Rex Nie <rex.nie@jaguarmicro.com> wrote:
> 
> The reg_ctrl kernel module can read/write most aarch64 system registers,
> including EL0/1/2/3, which is very useful when hardware debuger (such
> as ArmDS5/trace32) is unusable.
> 
> The primary implementation of the reg_ctrl module is as follows:
> 1. when the core can directly access the target register, it uses
>    the MRS/MSR instructions to read/write register.
> 2. Otherwise, it performs an SMC call to switch to EL3, where the
>    register read/write is completed and then return to kernel mode.
>    I implement an OEM Service in ATF to access register at EL3,
>    using one SMC function ID for reading and another for writing registers.
> 
> test steps on my platform with 16x Arm Neoverse N2:
> 1. insmod reg_ctrl.ko
> 2. cd /sys/kernel/reg_ctrl/system/
> 3. view the directory tree on DUT.
> [root@localhost system]# tree
> .
> ├── control
> │   └── VNCR_EL2
> ├── id
> │   ├── CCSIDR_EL1
> │   ├── CLIDR_EL1
> │   ├── CSSELR_EL1
> │   ├── CTR_EL0
> │   ├── DCZID_EL0
> │   ├── ID_AA64AFR0_EL1
> │   ├── ID_AA64AFR1_EL1
> │   ├── ID_AA64DFR0_EL1
> │   ├── ID_AA64DFR1_EL1
> │   ├── ID_AA64ISAR0_EL1
> │   ├── ID_AA64ISAR1_EL1
> │   ├── ID_AA64MMFR0_EL1
> │   ├── ID_AA64MMFR1_EL1
> │   ├── ID_AA64PFR0_EL1
> │   └── ID_AA64PFR1_EL1
> ├── implementation_defined
> │   ├── IMP_CPUACTLR_EL3
> │   ├── IMP_CPUECTLR_EL1
> │   ├── IMP_CPUPPMCR2_EL3
> │   ├── IMP_CPUPPMCR4_EL3
> │   ├── IMP_CPUPPMCR5_EL3
> │   ├── IMP_CPUPPMCR6_EL3
> │   └── IMP_CPUPPMCR_EL3
> └── reset
>     └── RMR_EL3
> 
> 4. read EL1 register on core 0:
> [root@localhost system]# taskset -c 0 cat id/ID_AA64PFR0_EL1
> 0x1201111123111112
> 
> 5. read EL3 register on core 1:
> [root@localhost system]# taskset -c 1 cat implementation_defined/IMP_CPUPPMCR4_EL3
> 0x2000315a10000045
> 
> 6. set bit 1 of IMP_CPUPPMCR4_EL3 regiter on core 1:
> [root@localhost system]# taskset -c 1 echo 0x2000315a10000047 > implementation_defined/IMP_CPUPPMCR4_EL3
> 
> 7. check if bit 1 is set:
> [root@localhost system]# taskset -c 1 cat implementation_defined/IMP_CPUPPMCR4_EL3
> 0x2000315a10000047
> 
> Signed-off-by: Rex Nie <rex.nie@jaguarmicro.com>

This sort of thing has been NAKed in the past (see [1]), because it is
terribly unsafe. I'm afraid the kernel is not a validation tool, and
while I understand that this can be useful in extremely narrow cases,
it has no place in the upstream kernel.

Thanks,

	M.

[1] https://lore.kernel.org/all/20201130174833.41315-1-rongwei.wang@linux.alibaba.com/

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2024-10-21 17:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 15:01 [PATCH] tools: arm64: add registers read/write tool for arm64 Rex Nie
2024-10-21 17:44 ` Marc Zyngier [this message]
2024-10-22  1:15   ` 答复: " Rex Nie

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=86cyjt4ahn.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=angus.chen@jaguarmicro.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=rex.nie@jaguarmicro.com \
    /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.