IPMMU address translation enablement prototype
Subsystems (3)
Magnus Damm
maintainercover IPMMU address translation enablement prototype
IPMMU address translation enablement prototype
[PATCH/RFC 01/09] iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed [PATCH/RFC 02/09] iommu/ipmmu-vmsa: Display system memory informationn during boot [PATCH/RFC 03/09] iommu/ipmmu-vmsa: Introduce keepipmmu boot parameter [PATCH/RFC 04/09] arm64: dts: renesas: ulcb: Introduce keepipmmu boot parameter [PATCH/RFC 05/09] arm64: dts: renesas: salvator: Introduce keepipmmu boot parameter [PATCH/RFC 06/09] arm64: dts: renesas: draak: Introduce keepipmmu boot parameter [PATCH/RFC 07/09] arm64: dts: renesas: ebisu: Introduce keepipmmu boot parameter [PATCH/RFC 08/09] arm64: dts: renesas: eagle: Introduce keepipmmu boot parameter [PATCH/RFC 09/09] arm64: dts: renesas: cat874: Introduce keepipmmu boot parameter
These patches experiment with runtime detection of system memory amount and location to check if all memory exists within 32 bits physical address space or not. In case all memory exists within 32 bits then we can assume address expansion via IPMMU will not be required so the white list code will simply ignore enablement of IPMMU devices on systems with smaller amounts of system memory.
Not intended for upstream merge however patch 1/9 might be not so far off.
---
Developed on top of next-20190215
arch/arm64/boot/dts/renesas/r8a774c0-cat874.dts | 2 - arch/arm64/boot/dts/renesas/r8a77970-eagle.dts | 2 - arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts | 2 - arch/arm64/boot/dts/renesas/r8a77995-draak.dts | 2 - arch/arm64/boot/dts/renesas/salvator-common.dtsi | 2 - arch/arm64/boot/dts/renesas/ulcb.dtsi | 2 - drivers/iommu/ipmmu-vmsa.c | 29 +++++++++++++++++++++- 7 files changed, 34 insertions(+), 7 deletions(-)
Magnus Damm
maintainerPATCH 1/9 iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed
From: Magnus Damm <[email protected]>
Add a memory bank location check to the whitelist handling.
---
drivers/iommu/ipmmu-vmsa.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iommu/ipmmu-vmsa.c +7 -0
@@ -17,6 +17,7 @@#include <linux/io.h> #include <linux/io-pgtable.h> #include <linux/iommu.h> +#include <linux/memblock.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/of_iommu.h>
@@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(structif (!soc_device_match (soc_rcar_gen3_whitelist))return false; +/* In case all system memory fits within 32 bits of physical space +* then assume the IPMMU will not be needed for address expansion. +*/ +if (memblock_end_of_DRAM () <=SZ_4G ) +return false; +/* Check whether this slave device can work with the IPMMU */ for (i =0 ; i <ARRAY_SIZE (rcar_gen3_slave_whitelist); i++) {if (!strcmp (dev_name (dev), rcar_gen3_slave_whitelist[i]))
Re: [PATCH/RFC 01/09] iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed
Hi Magnus,
Quoted 5 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Add a memory bank location check to the whitelist handling.
Signed-off-by Magnus Damm <[email protected]>
Thanks for your patch!
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 static bool ipmmu_slave_whitelist(struct · line 804
Quoted 11 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +4
-0@@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct if (!soc_device_match(soc_rcar_gen3_whitelist)) return false; + /* In case all system memory fits within 32 bits of physical space + * then assume the IPMMU will not be needed for address expansion. + */ + if (memblock_end_of_DRAM() <= SZ_4G)
Can this give a compiler warning on arm32 when CONFIG_ARM_LPAE=n?
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 static bool ipmmu_slave_whitelist(struct · line 809
Quoted 5 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +2
-0+ return false; + /* Check whether this slave device can work with the IPMMU */ for (i = 0; i < ARRAY_SIZE(rcar_gen3_slave_whitelist); i++) { if (!strcmp(dev_name(dev), rcar_gen3_slave_whitelist[i]))
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Magnus Damm
maintainerRe: [PATCH/RFC 01/09] iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed
Hi Geert,
Quoted 11 lines · Geert Uytterhoeven
Hi Magnus,
Quoted 5 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Add a memory bank location check to the whitelist handling.
Signed-off-by Magnus Damm <[email protected]>Thanks for your patch!
Thanks for feedback!
Quoted 7 lines
Quoted 7 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +0
-0@@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct if (!soc_device_match(soc_rcar_gen3_whitelist)) return false;
Quoted 6 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 static bool ipmmu_slave_whitelist(struct · line 804
Quoted 4 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +4
-0+ /* In case all system memory fits within 32 bits of physical space + * then assume the IPMMU will not be needed for address expansion. + */ + if (memblock_end_of_DRAM() <= SZ_4G)Can this give a compiler warning on arm32 when
CONFIG_ARM_LPAE=n?
Not sure how, can you elaborate?
To test this I actually installed a new arm32 compiler but I failed to trigger any warnings.
Thanks,
/ magnus
Re: [PATCH/RFC 01/09] iommu/ipmmu-vmsa: Disable IPMMU when address expansion is not needed
Hi Magnus,
Quoted 9 lines · Magnus Damm
Quoted 8 lines · Geert Uytterhoeven
Quoted 7 lines · Magnus Damm
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +0
-0@@ -797,6 +798,12 @@ static bool ipmmu_slave_whitelist(struct if (!soc_device_match(soc_rcar_gen3_whitelist)) return false;
Quoted 8 lines
Quoted 6 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 static bool ipmmu_slave_whitelist(struct · line 804
Quoted 4 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 22:59:28.589893396 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +4
-0+ /* In case all system memory fits within 32 bits of physical space + * then assume the IPMMU will not be needed for address expansion. + */ + if (memblock_end_of_DRAM() <= SZ_4G)Can this give a compiler warning on arm32 when
CONFIG_ARM_LPAE=n?Not sure how, can you elaborate?
SZ_4G is 0x100000000ULL, which is always 64-bit. memblock_end_of_DRAM() returns a physaddr_t, which is 32-bit if CONFIG_ARM_LPAE=n, in which case the comparison is always true.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] 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
Magnus Damm
maintainerPATCH 2/9 iommu/ipmmu-vmsa: Display system memory informationn during boot
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Clarify runtime memory bank detection in the IPMMU driver.
---
drivers/iommu/ipmmu-vmsa.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iommu/ipmmu-vmsa.c +8 -0
@@ -1095,6 +1095,14 @@ static int ipmmu_probe(struct platform_ddev_info (&pdev->dev,"IPMMU context 0 is reserved\n" );set_bit (0 , mmu->ctx); } + +if (memblock_end_of_DRAM () <=SZ_4G ) { +dev_info (&pdev->dev,"All system memory located within 32 bits of physical address space.\n" ); +dev_info (&pdev->dev,"IPMMU address translation not needed.\n" ); + }else { +dev_info (&pdev->dev,"System memory detected outside 32 bits of physical address space.\n" ); +dev_info (&pdev->dev,"IPMMU address translation may be required.\n" ); + } }/*
Magnus Damm
maintainerPATCH 3/9 iommu/ipmmu-vmsa: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
drivers/iommu/ipmmu-vmsa.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/iommu/ipmmu-vmsa.c +13 -1
@@ -759,6 +759,17 @@ static int ipmmu_init_platform_device(streturn 0 ; } + +static int keep_ipmmu; + +static int __init keepipmmu_setup (char *__unused) +{ + keep_ipmmu =1 ; +return 1 ; +} + +__setup ("keepipmmu" , keepipmmu_setup); +static const struct soc_device_attribute soc_rcar_gen3[] = { { .soc_id ="r8a774a1" , }, { .soc_id ="r8a774c0" , },
@@ -802,7 +813,8 @@ static bool ipmmu_slave_whitelist(struct* then assume the IPMMU will not be needed for address expansion. */ if (memblock_end_of_DRAM () <=SZ_4G ) -return false; +if (!keep_ipmmu) +return false;/* Check whether this slave device can work with the IPMMU */ for (i =0 ; i <ARRAY_SIZE (rcar_gen3_slave_whitelist); i++) {
Re: [PATCH/RFC 03/09] iommu/ipmmu-vmsa: Introduce keepipmmu boot parameter
Hi Magnus,
Quoted 16 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
Not-Yet-Signed-off-by Magnus Damm <[email protected]>---
drivers/iommu/ipmmu-vmsa.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/iommu/ipmmu-vmsa.c 2019-02-20 23:17:54.038850305 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +0
-0@@ -759,6 +759,17 @@ static int ipmmu_init_platform_device(st return 0; }
drivers/iommu/ipmmu-vmsa.c 2019-02-20 23:17:54.038850305 +0900 static int ipmmu_init_platform_device(st · line 771
Quoted 10 lines
drivers/iommu/ipmmu-vmsa.c 2019-02-20 23:17:54.038850305 +0900 renamed from drivers/iommu/ipmmu-vmsa.c +10
-0+ +static int keep_ipmmu; + +static int __init keepipmmu_setup(char *__unused) +{ + keep_ipmmu = 1; + return 1; +} + +__setup("keepipmmu", keepipmmu_setup);
Documentation/admin-guide/kernel-parameters.txt shows other IOMMUs implement binary parameters, which allow to override the default, to disable or enable the IOMMU.
Perhaps you want the default to be enabled when running in HYP mode, so the IPMMU can be used for KVM+VFIO device pass-through?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Magnus Damm
maintainerPATCH 4/9 arm64: dts: renesas: ulcb: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/ulcb.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/ulcb.dtsi +1 -1
@@ -26,7 +26,7 @@ }; chosen { - bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp"; + bootargs = "keepipmmu ignore_loglevel rw root=/dev/nfs ip=dhcp"; stdout-path = "serial0:115200n8"; };
Magnus Damm
maintainerPATCH 5/9 arm64: dts: renesas: salvator: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/salvator-common.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/salvator-common.dtsi +1 -1
@@ -38,7 +38,7 @@ }; chosen { - bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp"; + bootargs = "keepipmmu ignore_loglevel rw root=/dev/nfs ip=dhcp"; stdout-path = "serial0:115200n8"; };
Magnus Damm
maintainerPATCH 6/9 arm64: dts: renesas: draak: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/r8a77995-draak.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r8a77995-draak.dts +1 -1
@@ -20,7 +20,7 @@ }; chosen { - bootargs = "ignore_loglevel"; + bootargs = "keepipmmu ignore_loglevel"; stdout-path = "serial0:115200n8"; };
Magnus Damm
maintainerPATCH 7/9 arm64: dts: renesas: ebisu: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts +1 -1
@@ -19,7 +19,7 @@ }; chosen { - bootargs = "ignore_loglevel"; + bootargs = "keepipmmu ignore_loglevel"; stdout-path = "serial0:115200n8"; };
Magnus Damm
maintainerPATCH 8/9 arm64: dts: renesas: eagle: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/r8a77970-eagle.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r8a77970-eagle.dts +1 -1
@@ -19,7 +19,7 @@ }; chosen { - bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp"; + bootargs = "keepipmmu ignore_loglevel rw root=/dev/nfs ip=dhcp"; stdout-path = "serial0:115200n8"; };
Magnus Damm
maintainerPATCH 9/9 arm64: dts: renesas: cat874: Introduce keepipmmu boot parameter
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Introduce a keepipmmu boot paramenter to let the user override.
---
arch/arm64/boot/dts/renesas/r8a774c0-cat874.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/renesas/r8a774c0-cat874.dts +1 -1
@@ -18,7 +18,7 @@ }; chosen { - bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp"; + bootargs = "keepipmmu ignore_loglevel rw root=/dev/nfs ip=dhcp"; stdout-path = "serial0:115200n8"; };