mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
	Madalin Bucur <madalin.bucur@nxp.com>
Cc: Andrew Lunn <andrew@lunn.ch>, Andrew Davis <afd@ti.com>,
	"David S . Miller" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Camelia Alexandra Groza <camelia.groza@nxp.com>
Subject: Re: [PATCH net] net: fman: Use physical address for userspace interfaces
Date: Wed, 19 Oct 2022 11:04:33 -0400	[thread overview]
Message-ID: <2d5ddd26-1054-5a23-4fcb-4df7edbbbe75@seco.com> (raw)
In-Reply-To: <CAMuHMdUZKQFWV8QAKmwxuhWz0ZbFmcsUuf4OUzS_C31maP5+Yg@mail.gmail.com>

On 10/19/22 02:46, Geert Uytterhoeven wrote:
> Hi Madalin,
> 
> On Wed, Oct 19, 2022 at 7:20 AM Madalin Bucur <madalin.bucur@nxp.com> wrote:
>>> -----Original Message-----
>>> From: Sean Anderson <sean.anderson@seco.com>
>>> Sent: 19 October 2022 00:47
>>> To: Andrew Lunn <andrew@lunn.ch>; Andrew Davis <afd@ti.com>
>>> Cc: David S . Miller <davem@davemloft.net>; netdev@vger.kernel.org;
>>> linux-kernel@vger.kernel.org; Madalin Bucur <madalin.bucur@nxp.com>;
>>> Jakub Kicinski <kuba@kernel.org>; Eric Dumazet <edumazet@google.com>;
>>> Paolo Abeni <pabeni@redhat.com>; Camelia Alexandra Groza
>>> <camelia.groza@nxp.com>; Geert Uytterhoeven <geert@linux-m68k.org>
>>> Subject: Re: [PATCH net] net: fman: Use physical address for userspace
>>> interfaces
>>>
>>>
>>>
>>> On 10/18/22 5:39 PM, Andrew Lunn wrote:
>>>> On Tue, Oct 18, 2022 at 01:33:55PM -0500, Andrew Davis wrote:
>>>>> On 10/18/22 12:37 PM, Sean Anderson wrote:
>>>>>> Hi Andrew,
>>>>>>
>>>>>> On 10/18/22 1:22 PM, Andrew Lunn wrote:
>>>>>>> On Mon, Oct 17, 2022 at 12:28:06PM -0400, Sean Anderson wrote:
>>>>>>>> For whatever reason, the address of the MAC is exposed to
>>> userspace in
>>>>>>>> several places. We need to use the physical address for this
>>> purpose to
>>>>>>>> avoid leaking information about the kernel's memory layout, and
>>> to keep
>>>>>>>> backwards compatibility.
>>>>>>>
>>>>>>> How does this keep backwards compatibility? Whatever is in user
>>> space
>>>>>>> using this virtual address expects a virtual address. If it now
>>> gets a
>>>>>>> physical address it will probably do the wrong thing. Unless there
>>> is
>>>>>>> a one to one mapping, and you are exposing virtual addresses
>>> anyway.
>>>>>>>
>>>>>>> If you are going to break backwards compatibility Maybe it would
>>> be
>>>>>>> better to return 0xdeadbeef? Or 0?
>>>>>>>
>>>>>>>          Andrew
>>>>>>>
>>>>>>
>>>>>> The fixed commit was added in v6.1-rc1 and switched from physical to
>>>>>> virtual. So this is effectively a partial revert to the previous
>>>>>> behavior (but keeping the other changes). See [1] for discussion.
>>>>
>>>> Please don't assume a reviewer has seen the previous
>>>> discussion. Include the background in the commit message to help such
>>>> reviewers.
> 
>>>>> I see it asked in that thread, but not answered. Why are you exposing
>>>>> "physical" addresses to userspace? There should be no reason for that.
>>>>
>>>> I don't see anything about needing physical or virtual address in the
>>>> discussion, or i've missed it.
>>>
>>> Well, Madalin originally added this, so perhaps she has some insight.
>>>
>>> I have no idea why we set the IFMAP stuff, since that seems like it's for
>>> PCMCIA. Not sure about sysfs either.
>>>
>>>> If nobody knows why it is needed, either use an obfusticated value, or
>>>> remove it all together. If somebody/something does need it, they will
>>>> report the regression.
>>>
>>> I'd rather apply this (or v2 of this) and then remove the "feature" in
>>> follow-up.
>>>
>>> --Sean
>>
>>
>> root@localhost:~# grep 1ae /etc/udev/rules.d/72-fsl-dpaa-persistent-networking.rules
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1ae0000", NAME="fm1-mac1"
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1ae2000", NAME="fm1-mac2"
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1ae4000", NAME="fm1-mac3"
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1ae6000", NAME="fm1-mac4"
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1ae8000", NAME="fm1-mac5"
>> SUBSYSTEM=="net", DRIVERS=="fsl_dpa*", ATTR{device_addr}=="1aea000", NAME="fm1-mac6"
> 
> So you rely on the physical address.
> It's a pity this uses a custom sysfs file.
> Can't you obtain this information some other way?
> Anyway, as this is in use, it became part of the ABI.

In my udev rules I use ID_PATH. Since this is a devicetree platform, the path name includes
the device address by convention.

--Sean

>> root@localhost:~# grep 1ae  /sys/devices/platform/soc/soc:fsl,dpaa/soc:fsl,dpaa:ethernet@*/net/fm1-mac*/device_addr
>> /sys/devices/platform/soc/soc:fsl,dpaa/soc:fsl,dpaa:ethernet@2/net/fm1-mac3/device_addr:1ae4000
>> /sys/devices/platform/soc/soc:fsl,dpaa/soc:fsl,dpaa:ethernet@3/net/fm1-mac4/device_addr:1ae6000
>> /sys/devices/platform/soc/soc:fsl,dpaa/soc:fsl,dpaa:ethernet@4/net/fm1-mac5/device_addr:1ae8000
>> /sys/devices/platform/soc/soc:fsl,dpaa/soc:fsl,dpaa:ethernet@5/net/fm1-mac6/device_addr:1aea000
> 
> 
> Gr{oetje,eeting}s,
> 
>                          Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                  -- Linus Torvalds


      parent reply	other threads:[~2022-10-19 15:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 16:28 Sean Anderson
2022-10-18  6:45 ` Madalin Bucur
2022-10-18 17:22 ` Andrew Lunn
2022-10-18 17:37   ` Sean Anderson
2022-10-18 18:33     ` Andrew Davis
2022-10-18 21:39       ` Andrew Lunn
2022-10-18 21:47         ` Sean Anderson
2022-10-19  5:20           ` Madalin Bucur
2022-10-19  6:46             ` Geert Uytterhoeven
2022-10-19 12:49               ` Andrew Lunn
2022-10-19 15:04               ` Sean Anderson [this message]

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=2d5ddd26-1054-5a23-4fcb-4df7edbbbe75@seco.com \
    --to=sean.anderson@seco.com \
    --cc=afd@ti.com \
    --cc=andrew@lunn.ch \
    --cc=camelia.groza@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=geert@linux-m68k.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 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®