mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jon Kohler <jon@nutanix.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Jason Wang" <jasowang@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>,
	Netdev <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Borislav Petkov" <bp@alien8.de>,
	"Sean Christopherson" <seanjc@google.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Russell King" <linux@armlinux.org.uk>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Drew Fustini" <fustini@kernel.org>
Subject: Re: [PATCH net-next] vhost: use "checked" versions of get_user() and put_user()
Date: Wed, 26 Nov 2025 19:47:27 +0000	[thread overview]
Message-ID: <02B0FDF1-41D4-4A7D-A57E-089D2B69CEF2@nutanix.com> (raw)
In-Reply-To: <61102cff-bb35-4fe4-af61-9fc31e3c65e0@app.fastmail.com>



> On Nov 26, 2025, at 5:25 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
> On Wed, Nov 26, 2025, at 07:04, Jason Wang wrote:
>> On Wed, Nov 26, 2025 at 3:45 AM Jon Kohler <jon@nutanix.com> wrote:
>>>> On Nov 19, 2025, at 8:57 PM, Jason Wang <jasowang@redhat.com> wrote:
>>>> On Tue, Nov 18, 2025 at 1:35 AM Jon Kohler <jon@nutanix.com> wrote:
>>> Same deal goes for __put_user() vs put_user by way of commit
>>> e3aa6243434f ("ARM: 8795/1: spectre-v1.1: use put_user() for __put_user()”)
>>> 
>>> Looking at arch/arm/mm/Kconfig, there are a variety of scenarios
>>> where CONFIG_CPU_SPECTRE will be enabled automagically. Looking at
>>> commit 252309adc81f ("ARM: Make CONFIG_CPU_V7 valid for 32bit ARMv8 implementations")
>>> it says that "ARMv8 is a superset of ARMv7", so I’d guess that just
>>> about everything ARM would include this by default?
> 
> I think the more relevant commit is for 64-bit Arm here, but this does
> the same thing, see 84624087dd7e ("arm64: uaccess: Don't bother
> eliding access_ok checks in __{get, put}_user").

Ah! Right, this is definitely the important bit, as it makes it
crystal clear that these are exactly the same thing. The current
code is:
#define get_user	__get_user
#define put_user	__put_user

So, this patch changing from __* to regular versions is a no-op
on arm side of the house, yea?

> I would think that if we change the __get_user() to get_user()
> in this driver, the same should be done for the
> __copy_{from,to}_user(), which similarly skips the access_ok()
> check but not the PAN/SMAP handling.

Perhaps, thats a good call out. I’d file that under one battle
at a time. Let’s get get/put user dusted first, then go down
that road?

> In general, the access_ok()/__get_user()/__copy_from_user()
> pattern isn't really helpful any more, as Linus already
> explained. I can't tell from the vhost driver code whether
> we can just drop the access_ok() here and use the plain
> get_user()/copy_from_user(), or if it makes sense to move
> to the newer user_access_begin()/unsafe_get_user()/
> unsafe_copy_from_user()/user_access_end() and try optimize
> out a few PAN/SMAP flips in the process.

In general, I think there are a few spots where we might be
able to optimize (vhost_get_vq_desc perhaps?) as that gets
called quite a bit and IIRC there are at least two flips
in there that perhaps we could elide to one? An investigation
for another day I think.

Anyhow, with this info - Jason - is there anything else you
can think of that we want to double click on?

Jon

  reply	other threads:[~2025-11-26 19:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13  0:55 Jon Kohler
2025-11-13  1:09 ` Jason Wang
2025-11-14 14:53   ` Jon Kohler
2025-11-14 17:48     ` Linus Torvalds
2025-11-14 19:08       ` David Laight
2025-11-14 20:48         ` Linus Torvalds
2025-11-14 21:38           ` David Laight
2025-11-17  4:32     ` Jason Wang
2025-11-17 17:34       ` Jon Kohler
2025-11-20  1:57         ` Jason Wang
2025-11-25 19:45           ` Jon Kohler
2025-11-26  6:04             ` Jason Wang
2025-11-26 10:25               ` Arnd Bergmann
2025-11-26 19:47                 ` Jon Kohler [this message]
2025-11-26 19:58                   ` Arnd Bergmann
2025-11-26 21:42                     ` Jon Kohler
2025-11-26 21:45                       ` Linus Torvalds
2025-11-27  2:58                         ` Jon Kohler
2025-11-27  1:08                   ` Jason Wang
2025-11-27  3:11                     ` Jon Kohler
2025-11-27  6:31                       ` Michael S. Tsirkin
2025-11-27  6:32                       ` Michael S. Tsirkin
2025-12-02 16:54                         ` Jon Kohler
2025-11-14 18:54 ` David Laight
2025-11-14 19:30   ` Jon Kohler
2025-11-14 20:32     ` David Laight
2025-11-16  6:32     ` Michael S. Tsirkin

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=02B0FDF1-41D4-4A7D-A57E-089D2B69CEF2@nutanix.com \
    --to=jon@nutanix.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=eperezma@redhat.com \
    --cc=fustini@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=krzk@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.linux.dev \
    --cc=will@kernel.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

all inboxes | Powered by JetHome®