From: Catalin Marinas <catalin.marinas@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: kernel test robot <lkp@intel.com>,
oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Subject: Re: arch/arm64/kernel/signal.c:1046:36: sparse: sparse: cast removes address space '__user' of expression
Date: Tue, 10 Dec 2024 11:11:47 +0000 [thread overview]
Message-ID: <Z1gh809HUGRZI258@arm.com> (raw)
In-Reply-To: <c8379d04-420b-4039-99ce-5a462d820685@sirena.org.uk>
On Mon, Dec 09, 2024 at 04:11:00PM +0000, Mark Brown wrote:
> On Mon, Dec 09, 2024 at 03:37:23PM +0000, Catalin Marinas wrote:
> > On Mon, Dec 09, 2024 at 12:47:33PM +0800, kernel test robot wrote:
> > > eaf62ce1563b85 Mark Brown 2024-10-01 1014 unsigned long __user *gcspr_el0;
> >
> > I think we should keep this as u64 since it's a sysreg.
>
> Do you mean pointer to u64 or plain u64?
Plain u64.
> The value we get from the
> sysreg is a pointer so it makes the uses of the value clearer if we keep
> it as a pointer in C code, it seems to be defeating the point of doing
> static analysis to discard the pointerness to make it happier.
We have other cases where we treat a reg as u64 and convert it to
pointer as needed. While not a sysreg, the pt_regs::sp is u64 and we end
up treating it as a pointer eventually for writing the signal stack.
Another case is user_insn_read(). It's bit of bikeshedding around the
primary use in this function, do we need more conversions one way or the
other? In general I'd consider a sysreg read to be u64, especially as
the architecture has a habit of adding bits around the actual address
occasionally.
> > > eaf62ce1563b85 Mark Brown 2024-10-01 1051 if (ret != 0)
> > > eaf62ce1563b85 Mark Brown 2024-10-01 1052 return -EFAULT;
> > > eaf62ce1563b85 Mark Brown 2024-10-01 1053
> > > eaf62ce1563b85 Mark Brown 2024-10-01 1054 write_sysreg_s(gcspr_el0 + 1, SYS_GCSPR_EL0);
>
> > And this would be +8 I guess.
>
> The variable is a pointer so we're doing pointer arithmetic here not
> working directly with the value, unless we change the value to be purely
> a u64 with no pointer in which case we would need the case above.
That's what I meant, if we go for u64 we'll need a +8 here.
Anyway, I'd like to silence sparse on this. The u64 (non-pointer) has
some precedence in the arm64 code but, if you want, I'm happy to keep it
as a pointer (and maybe just rename it to shadow_stack or something that
does not imply a sysreg). I think for the actual warning, we can
probably fix it with a __force to silence sparse on conversion to u64.
--
Catalin
next prev parent reply other threads:[~2024-12-10 11:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 4:47 arch/arm64/kernel/signal.c:1046:36: sparse: sparse: cast removes address space '__user' of expression kernel test robot
2024-12-09 15:37 ` Catalin Marinas
2024-12-09 16:11 ` Mark Brown
2024-12-10 11:11 ` Catalin Marinas [this message]
2024-12-10 12:33 ` Mark Brown
2024-12-10 12:49 ` Mark Brown
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=Z1gh809HUGRZI258@arm.com \
--to=catalin.marinas@arm.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=thiago.bauermann@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox