Commit c99f0f7e authored by Sean Anderson's avatar Sean Anderson Committed by David S. Miller

net: fman: Use physical address for userspace interfaces

Before 262f2b78 ("net: fman: Map the base address once"), the
physical address of the MAC was exposed to userspace in two places: via
sysfs and via SIOCGIFMAP. While this is not best practice, it is an
external ABI which is in use by userspace software.

The aforementioned commit inadvertently modified these addresses and
made them virtual. This constitutes and ABI break.  Additionally, it
leaks the kernel's memory layout to userspace. Partially revert that
commit, reintroducing the resource back into struct mac_device, while
keeping the intended changes (the rework of the address mapping).

Fixes: 262f2b78 ("net: fman: Map the base address once")
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
Acked-by: default avatarMadalin Bucur <madalin.bucur@oss.nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f8127476
...@@ -221,8 +221,8 @@ static int dpaa_netdev_init(struct net_device *net_dev, ...@@ -221,8 +221,8 @@ static int dpaa_netdev_init(struct net_device *net_dev,
net_dev->netdev_ops = dpaa_ops; net_dev->netdev_ops = dpaa_ops;
mac_addr = mac_dev->addr; mac_addr = mac_dev->addr;
net_dev->mem_start = (unsigned long)mac_dev->vaddr; net_dev->mem_start = (unsigned long)priv->mac_dev->res->start;
net_dev->mem_end = (unsigned long)mac_dev->vaddr_end; net_dev->mem_end = (unsigned long)priv->mac_dev->res->end;
net_dev->min_mtu = ETH_MIN_MTU; net_dev->min_mtu = ETH_MIN_MTU;
net_dev->max_mtu = dpaa_get_max_mtu(); net_dev->max_mtu = dpaa_get_max_mtu();
......
...@@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev, ...@@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev,
if (mac_dev) if (mac_dev)
return sprintf(buf, "%llx", return sprintf(buf, "%llx",
(unsigned long long)mac_dev->vaddr); (unsigned long long)mac_dev->res->start);
else else
return sprintf(buf, "none"); return sprintf(buf, "none");
} }
......
...@@ -279,7 +279,6 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -279,7 +279,6 @@ static int mac_probe(struct platform_device *_of_dev)
struct device_node *mac_node, *dev_node; struct device_node *mac_node, *dev_node;
struct mac_device *mac_dev; struct mac_device *mac_dev;
struct platform_device *of_dev; struct platform_device *of_dev;
struct resource *res;
struct mac_priv_s *priv; struct mac_priv_s *priv;
struct fman_mac_params params; struct fman_mac_params params;
u32 val; u32 val;
...@@ -338,24 +337,25 @@ static int mac_probe(struct platform_device *_of_dev) ...@@ -338,24 +337,25 @@ static int mac_probe(struct platform_device *_of_dev)
of_node_put(dev_node); of_node_put(dev_node);
/* Get the address of the memory mapped registers */ /* Get the address of the memory mapped registers */
res = platform_get_mem_or_io(_of_dev, 0); mac_dev->res = platform_get_mem_or_io(_of_dev, 0);
if (!res) { if (!mac_dev->res) {
dev_err(dev, "could not get registers\n"); dev_err(dev, "could not get registers\n");
return -EINVAL; return -EINVAL;
} }
err = devm_request_resource(dev, fman_get_mem_region(priv->fman), res); err = devm_request_resource(dev, fman_get_mem_region(priv->fman),
mac_dev->res);
if (err) { if (err) {
dev_err_probe(dev, err, "could not request resource\n"); dev_err_probe(dev, err, "could not request resource\n");
return err; return err;
} }
mac_dev->vaddr = devm_ioremap(dev, res->start, resource_size(res)); mac_dev->vaddr = devm_ioremap(dev, mac_dev->res->start,
resource_size(mac_dev->res));
if (!mac_dev->vaddr) { if (!mac_dev->vaddr) {
dev_err(dev, "devm_ioremap() failed\n"); dev_err(dev, "devm_ioremap() failed\n");
return -EIO; return -EIO;
} }
mac_dev->vaddr_end = mac_dev->vaddr + resource_size(res);
if (!of_device_is_available(mac_node)) if (!of_device_is_available(mac_node))
return -ENODEV; return -ENODEV;
......
...@@ -20,8 +20,8 @@ struct mac_priv_s; ...@@ -20,8 +20,8 @@ struct mac_priv_s;
struct mac_device { struct mac_device {
void __iomem *vaddr; void __iomem *vaddr;
void __iomem *vaddr_end;
struct device *dev; struct device *dev;
struct resource *res;
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
struct fman_port *port[2]; struct fman_port *port[2];
u32 if_support; u32 if_support;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment