* Re: [PATCH 0/3] ASoC: fsl_sai: Fix some issues in fsl_sai_trigger()
From: Mark Brown @ 2014-07-25 17:52 UTC (permalink / raw)
To: Nicolin Chen
Cc: alsa-devel, b42378, b02247, linux-kernel, timur, Li.Xiubo,
linuxppc-dev
In-Reply-To: <cover.1406113865.git.nicoleotsuka@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 153 bytes --]
On Wed, Jul 23, 2014 at 07:23:37PM +0800, Nicolin Chen wrote:
> The series of patches focus on issue fix inside fsl_sai_trigger().
Applied all, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [PATCH v2 1/7] dt: Introduce the FMan 10 Gb/s MDIO binding
From: Scott Wood @ 2014-07-25 19:54 UTC (permalink / raw)
To: Xie Shaohui-B21989; +Cc: Kanetkar Shruti-B44454, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <df68a97dc8ae427f95078082ad587543@DM2PR0301MB0864.namprd03.prod.outlook.com>
On Thu, 2014-07-24 at 22:11 -0500, Xie Shaohui-B21989 wrote:
> Hello, Scott, Shruti,
>
> There are two types MDIO controllers, each MAC has a corresponding MDIO
> controller to access internal PHYs inside Serdes, another is dedicated
> MDIO controller to access external PHYs (PHYs on board or riser card,
> etc). Current MDIO driver does not distinguish the two controllers, if
> we need to distinguish the controllers, what could be the proper way?
> Perhaps a new property is needed in dts?
Are these different programming models, or just two instances of the
same type of device, with different things attached?
-Scott
^ permalink raw reply
* Re: [PATCH v2 1/7] dt: Introduce the FMan 10 Gb/s MDIO binding
From: Emil Medve @ 2014-07-25 20:00 UTC (permalink / raw)
To: Shaohui Xie, Shruti Kanetkar, Scott Wood; +Cc: linuxppc-dev@lists.ozlabs.org
In-Reply-To: <df68a97dc8ae427f95078082ad587543@DM2PR0301MB0864.namprd03.prod.outlook.com>
Hello Shao-Hui,
On 07/24/2014 10:11 PM, Shaohui Xie wrote:
> Hello, Scott, Shruti,
>
> There are two types MDIO controllers, each MAC has a corresponding
> MDIO controller to access internal PHYs inside Serdes, another is
> dedicated MDIO controller to access external PHYs (PHYs on board or
> riser card, etc). Current MDIO driver does not distinguish the two
> controllers, if we need to distinguish the controllers, what could be
> the proper way? Perhaps a new property is needed in dts?
As per the intended binding, FMan v3 MDIO must use the
"fsl,fman-memac-mdio" compatible. Why is that not enough to
differentiate the two controllers?
Cheers,
> Please comment!
> Thanks!
>
> Best Regards,
> Shaohui Xie
>> -----Original Message-----
>> From: Linuxppc-dev [mailto:linuxppc-dev-
>> bounces+b21989=freescale.com@lists.ozlabs.org] On Behalf Of Shruti
>> Kanetkar
>> Sent: Thursday, July 17, 2014 4:17 AM
>> To: Wood Scott-B07421
>> Cc: Kanetkar Shruti-B44454; linuxppc-dev@lists.ozlabs.org
>> Subject: [PATCH v2 1/7] dt: Introduce the FMan 10 Gb/s MDIO binding
>>
>> This document covers FManv2 and FManv3 mEMAC MDIO
>>
>> Signed-off-by: Shruti Kanetkar <Shruti@Freescale.com>
>> ---
>> .../devicetree/bindings/net/fsl-xgmac-phy.txt | 29
>> ++++++++++++++++++++++
>> 1 file changed, 29 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/net/fsl-xgmac-
>> phy.txt
>>
>> diff --git a/Documentation/devicetree/bindings/net/fsl-xgmac-phy.txt
>> b/Documentation/devicetree/bindings/net/fsl-xgmac-phy.txt
>> new file mode 100644
>> index 0000000..2f2d56d
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/fsl-xgmac-phy.txt
>> @@ -0,0 +1,29 @@
>> +*MDIO IO device
>> +
>> +The MDIO is a bus to which the PHY devices are connected. For each
>> +device that exists on this bus, a child node should be created.
>> +
>> +Required properties:
>> + - compatible: Currently supported strings/devices are:
>> + - "fsl,fman-xmdio" (Must be used for 10 Gb/s MDIO from
>> FMan v2.
>> + Can be used for 1/10 Gb/s MDIO from FMan v3)
>> + - "fsl,fman-memac-mdio" (Must be used for 1/10 Gb/s
>> MDIO from
>> + FMan v3)
>> + - reg
>> +
>> + Example for FMan v2:
>> + mdio@f1000 {
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> + compatible = "fsl,fman-xmdio";
>> + reg = <0xf1000 0x1000>;
>> + };
>> +
>> + Example for FMan v3:
>> +
>> + mdio@f1000 {
>> + #address-cells = <1>;
>> + #size-cells = <0>;
>> + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio";
>> + reg = <0xf1000 0x1000>;
>> + }
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* Re: [PATCH 1/6 v2] KVM: PPC: Book3E: Use common defines for SPE/FP/AltiVec int numbers
From: Scott Wood @ 2014-07-26 0:10 UTC (permalink / raw)
To: Caraman Mihai Claudiu-B02008
Cc: linuxppc-dev@lists.ozlabs.org, Alexander Graf,
kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
In-Reply-To: <3807e749871d460f90a57ad47ad2654d@BY2PR03MB508.namprd03.prod.outlook.com>
On Thu, 2014-07-24 at 04:16 -0500, Caraman Mihai Claudiu-B02008 wrote:
> Scott, Alex's request to define SPE handlers only for e500v2 implies changes
> in 32-bit FSL kernel to have exclusive configurations for e200/e500v2 and
> e500mc/e5500. We would probably need something like this, what's your take on it?
That is already a compile-time decision.
> diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
> index b497188..9d41015 100644
> --- a/arch/powerpc/kernel/head_fsl_booke.S
> +++ b/arch/powerpc/kernel/head_fsl_booke.S
> @@ -613,6 +613,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
> mfspr r10, SPRN_SPRG_RSCRATCH0
> b InstructionStorage
>
> +/* Define SPE handlers only for e500v2 and e200 */
> +#ifndef CONFIG_PPC_E500MC
> #ifdef CONFIG_SPE
> /* SPE Unavailable */
> START_EXCEPTION(SPEUnavailable)
> @@ -626,7 +628,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
> EXCEPTION(0x2020, SPE_ALTIVEC_UNAVAIL, SPEUnavailable, \
> unknown_exception, EXC_XFER_EE)
> #endif /* CONFIG_SPE */
> +#endif
This is redundant:
config SPE
bool "SPE Support"
depends on E200 || (E500 && !PPC_E500MC)
default y
> diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
> index c1faade..3ab65c2 100644
> --- a/arch/powerpc/kernel/cputable.c
> +++ b/arch/powerpc/kernel/cputable.c
> @@ -2030,6 +2030,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
> #endif /* CONFIG_PPC32 */
> #ifdef CONFIG_E500
> #ifdef CONFIG_PPC32
> +#ifndef CONFIG_PPC_E500MC
> { /* e500 */
> .pvr_mask = 0xffff0000,
> .pvr_value = 0x80200000,
> @@ -2069,6 +2070,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
> .machine_check = machine_check_e500,
> .platform = "ppc8548",
> },
> +#endif /* !CONFIG_PPC_E500MC */
> { /* e500mc */
> .pvr_mask = 0xffff0000,
> .pvr_value = 0x80230000,
>
This looks a bit strange -- e500v2 gets excluded if PPC_E500MC, but
e500mc gets included in !PPC_E500MC?
-Scott
^ permalink raw reply
* Re: [PATCH v2 1/7] dt: Introduce the FMan 10 Gb/s MDIO binding
From: Emil Medve @ 2014-07-26 8:17 UTC (permalink / raw)
To: Scott Wood, Xie Shaohui-B21989
Cc: Kanetkar Shruti-B44454, linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1406318092.29414.116.camel@snotra.buserror.net>
Hello Scott,
On 07/25/2014 02:54 PM, Scott Wood wrote:
> On Thu, 2014-07-24 at 22:11 -0500, Xie Shaohui-B21989 wrote:
>> Hello, Scott, Shruti,
>>
>> There are two types MDIO controllers, each MAC has a corresponding MDIO
>> controller to access internal PHYs inside Serdes, another is dedicated
>> MDIO controller to access external PHYs (PHYs on board or riser card,
>> etc). Current MDIO driver does not distinguish the two controllers, if
>> we need to distinguish the controllers, what could be the proper way?
>> Perhaps a new property is needed in dts?
>
> Are these different programming models, or just two instances of the
> same type of device, with different things attached?
The controllers are very similar; the FMan v3 MDIO controller is a newer
revision of the FMan v2 10 Gb/s MDIO controller
Cheers,
> -Scott
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply
* Re: Build regressions/improvements in v3.16-rc5
From: Geert Uytterhoeven @ 2014-07-26 15:46 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org; +Cc: linuxppc-dev@lists.ozlabs.org
In-Reply-To: <1406389175-9745-1-git-send-email-geert@linux-m68k.org>
On Sat, Jul 26, 2014 at 5:39 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> JFYI, when comparing v3.16-rc5[1] to v3.16-rc4[3], the summaries are:
> - build errors: +14/-11
+ /scratch/kisskb/src/mm/memory_hotplug.c: error:
'PAGES_PER_SECTION' undeclared (first use in this function): =>
1779:46, 1887:46, 1149:18
+ /scratch/kisskb/src/mm/memory_hotplug.c: error:
'PAGE_SECTION_MASK' undeclared (first use in this function): =>
1148:20
+ /scratch/kisskb/src/mm/memory_hotplug.c: error:
'PFN_SECTION_SHIFT' undeclared (first use in this function): =>
1348:31
+ /scratch/kisskb/src/mm/memory_hotplug.c: error: implicit
declaration of function '__nr_to_section'
[-Werror=implicit-function-declaration]: => 1784:3
+ /scratch/kisskb/src/mm/memory_hotplug.c: error: implicit
declaration of function 'find_memory_block_hinted'
[-Werror=implicit-function-declaration]: => 1791:3
+ /scratch/kisskb/src/mm/memory_hotplug.c: error: implicit
declaration of function 'pfn_to_section_nr'
[-Werror=implicit-function-declaration]: => 1780:3
+ /scratch/kisskb/src/mm/memory_hotplug.c: error: implicit
declaration of function 'present_section_nr'
[-Werror=implicit-function-declaration]: => 1781:3
+ /scratch/kisskb/src/mm/memory_hotplug.c: error: implicit
declaration of function 'section_nr_to_pfn'
[-Werror=implicit-function-declaration]: => 1816:3
powerpc-randconfig
(ignoring a few more R_PPC64_REL24 truncated relocations in
powerpc-allyesconfig)
> [1] http://kisskb.ellerman.id.au/kisskb/head/7665/ (all 119 configs)
> [3] http://kisskb.ellerman.id.au/kisskb/head/7639/ (all 119 configs)
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
^ permalink raw reply
* [PATCH] arch: powerpc: kernel: nvram_64.c: Cleaning up missing null-terminate in conjunction with strncpy
From: Rickard Strandqvist @ 2014-07-26 16:43 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras
Cc: Chen Gang, Cedric Le Goater, linuxppc-dev, linux-kernel,
Rickard Strandqvist
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And removed unnecessary magic numbers.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
arch/powerpc/kernel/nvram_64.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 28b898e..5ed7b74 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -292,7 +292,7 @@ int __init nvram_remove_partition(const char *name, int sig,
/* Make partition a free partition */
part->header.signature = NVRAM_SIG_FREE;
- strncpy(part->header.name, "wwwwwwwwwwww", 12);
+ strlcpy(part->header.name, "wwwwwwwwwwww", sizeof(part->header.name));
part->header.checksum = nvram_checksum(&part->header);
rc = nvram_write_header(part);
if (rc <= 0) {
@@ -395,7 +395,7 @@ loff_t __init nvram_create_partition(const char *name, int sig,
new_part->index = free_part->index;
new_part->header.signature = sig;
new_part->header.length = size;
- strncpy(new_part->header.name, name, 12);
+ strlcpy(new_part->header.name, name, sizeof(new_part->header.name));
new_part->header.checksum = nvram_checksum(&new_part->header);
rc = nvram_write_header(new_part);
--
1.7.10.4
^ permalink raw reply related
* [PATCH] arch: powerpc: platforms: powermac: bootx_init.c: Cleaning up missing null-terminate in conjunction with strncpy
From: Rickard Strandqvist @ 2014-07-26 16:45 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel, Rickard Strandqvist
Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
And removed unnecessary magic numbers.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
arch/powerpc/platforms/powermac/bootx_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powermac/bootx_init.c b/arch/powerpc/platforms/powermac/bootx_init.c
index 3e91ef5..76f5013 100644
--- a/arch/powerpc/platforms/powermac/bootx_init.c
+++ b/arch/powerpc/platforms/powermac/bootx_init.c
@@ -246,7 +246,7 @@ static void __init bootx_scan_dt_build_strings(unsigned long base,
DBG(" detected display ! adding properties names !\n");
bootx_dt_add_string("linux,boot-display", mem_end);
bootx_dt_add_string("linux,opened", mem_end);
- strncpy(bootx_disp_path, namep, 255);
+ strlcpy(bootx_disp_path, namep, sizeof(bootx_disp_path));
}
/* get and store all property names */
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3.10 54/56] locking/mutex: Disable optimistic spinning on some architectures
From: Greg Kroah-Hartman @ 2014-07-26 19:02 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Will Deacon, James Bottomley, Davidlohr Bueso,
sparclinux, Ingo Molnar, Russell King, James E.J. Bottomley,
Linus Torvalds, Catalin Marinas, Paul McKenney, James Hogan,
Chris Metcalf, Mikulas Patocka, John David Anglin,
linux-arm-kernel, Jason Low, Waiman Long, Greg Kroah-Hartman,
stable, Vineet Gupta, linuxppc-dev, David Miller
In-Reply-To: <20140726190200.061512159@linuxfoundation.org>
3.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
commit 4badad352a6bb202ec68afa7a574c0bb961e5ebc upstream.
The optimistic spin code assumes regular stores and cmpxchg() play nice;
this is found to not be true for at least: parisc, sparc32, tile32,
metag-lock1, arc-!llsc and hexagon.
There is further wreckage, but this in particular seemed easy to
trigger, so blacklist this.
Opt in for known good archs.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: David Miller <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Waiman Long <waiman.long@hp.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: John David Anglin <dave.anglin@bell.net>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/20140606175316.GV13930@laptop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm/Kconfig | 1 +
arch/arm64/Kconfig | 1 +
arch/powerpc/Kconfig | 1 +
arch/sparc/Kconfig | 1 +
arch/x86/Kconfig | 1 +
kernel/Kconfig.locks | 5 ++++-
6 files changed, 9 insertions(+), 1 deletion(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,6 +4,7 @@ config ARM
select ARCH_BINFMT_ELF_RANDOMIZE_PIE
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_HAVE_CUSTOM_GPIO_H
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_WANT_IPC_PARSE_VERSION
select BUILDTIME_EXTABLE_SORT if MMU
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,6 +1,7 @@
config ARM64
def_bool y
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
select ARCH_WANT_FRAME_POINTERS
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -138,6 +138,7 @@ config PPC
select ARCH_USE_BUILTIN_BSWAP
select OLD_SIGSUSPEND
select OLD_SIGACTION if PPC32
+ select ARCH_SUPPORTS_ATOMIC_RMW
config EARLY_PRINTK
bool
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -77,6 +77,7 @@ config SPARC64
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select HAVE_C_RECORDMCOUNT
select NO_BOOTMEM
+ select ARCH_SUPPORTS_ATOMIC_RMW
config ARCH_DEFCONFIG
string
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -121,6 +121,7 @@ config X86
select OLD_SIGACTION if X86_32
select COMPAT_OLD_SIGACTION if IA32_EMULATION
select RTC_LIB
+ select ARCH_SUPPORTS_ATOMIC_RMW
config INSTRUCTION_DECODER
def_bool y
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -220,6 +220,9 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE
endif
+config ARCH_SUPPORTS_ATOMIC_RMW
+ bool
+
config MUTEX_SPIN_ON_OWNER
def_bool y
- depends on SMP && !DEBUG_MUTEXES
+ depends on SMP && !DEBUG_MUTEXES && ARCH_SUPPORTS_ATOMIC_RMW
^ permalink raw reply
* [PATCH 3.14 81/87] locking/mutex: Disable optimistic spinning on some architectures
From: Greg Kroah-Hartman @ 2014-07-26 19:02 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Will Deacon, James Bottomley, Davidlohr Bueso,
sparclinux, Ingo Molnar, Russell King, James E.J. Bottomley,
Linus Torvalds, Catalin Marinas, Paul McKenney, James Hogan,
Chris Metcalf, Mikulas Patocka, John David Anglin,
linux-arm-kernel, Jason Low, Waiman Long, Greg Kroah-Hartman,
stable, Vineet Gupta, linuxppc-dev, David Miller
In-Reply-To: <20140726190214.530473925@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
commit 4badad352a6bb202ec68afa7a574c0bb961e5ebc upstream.
The optimistic spin code assumes regular stores and cmpxchg() play nice;
this is found to not be true for at least: parisc, sparc32, tile32,
metag-lock1, arc-!llsc and hexagon.
There is further wreckage, but this in particular seemed easy to
trigger, so blacklist this.
Opt in for known good archs.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: David Miller <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Waiman Long <waiman.long@hp.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: John David Anglin <dave.anglin@bell.net>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/20140606175316.GV13930@laptop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm/Kconfig | 1 +
arch/arm64/Kconfig | 1 +
arch/powerpc/Kconfig | 1 +
arch/sparc/Kconfig | 1 +
arch/x86/Kconfig | 1 +
kernel/Kconfig.locks | 5 ++++-
6 files changed, 9 insertions(+), 1 deletion(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -6,6 +6,7 @@ config ARM
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_MIGHT_HAVE_PC_PARPORT
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF
select ARCH_WANT_IPC_PARSE_VERSION
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2,6 +2,7 @@ config ARM64
def_bool y
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -141,6 +141,7 @@ config PPC
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_IRQ_EXIT_ON_IRQ_STACK
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
+ select ARCH_SUPPORTS_ATOMIC_RMW
config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -77,6 +77,7 @@ config SPARC64
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select HAVE_C_RECORDMCOUNT
select NO_BOOTMEM
+ select ARCH_SUPPORTS_ATOMIC_RMW
config ARCH_DEFCONFIG
string
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -127,6 +127,7 @@ config X86
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64
select HAVE_CC_STACKPROTECTOR
+ select ARCH_SUPPORTS_ATOMIC_RMW
config INSTRUCTION_DECODER
def_bool y
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -220,6 +220,9 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE
endif
+config ARCH_SUPPORTS_ATOMIC_RMW
+ bool
+
config MUTEX_SPIN_ON_OWNER
def_bool y
- depends on SMP && !DEBUG_MUTEXES
+ depends on SMP && !DEBUG_MUTEXES && ARCH_SUPPORTS_ATOMIC_RMW
^ permalink raw reply
* [PATCH 3.15 100/109] locking/mutex: Disable optimistic spinning on some architectures
From: Greg Kroah-Hartman @ 2014-07-26 19:03 UTC (permalink / raw)
To: linux-kernel
Cc: Peter Zijlstra, Will Deacon, James Bottomley, Davidlohr Bueso,
sparclinux, Ingo Molnar, Russell King, James E.J. Bottomley,
Linus Torvalds, Catalin Marinas, Paul McKenney, James Hogan,
Chris Metcalf, Mikulas Patocka, John David Anglin,
linux-arm-kernel, Jason Low, Waiman Long, Greg Kroah-Hartman,
stable, Vineet Gupta, linuxppc-dev, David Miller
In-Reply-To: <20140726190223.834037485@linuxfoundation.org>
3.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <peterz@infradead.org>
commit 4badad352a6bb202ec68afa7a574c0bb961e5ebc upstream.
The optimistic spin code assumes regular stores and cmpxchg() play nice;
this is found to not be true for at least: parisc, sparc32, tile32,
metag-lock1, arc-!llsc and hexagon.
There is further wreckage, but this in particular seemed easy to
trigger, so blacklist this.
Opt in for known good archs.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: David Miller <davem@davemloft.net>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Jason Low <jason.low2@hp.com>
Cc: Waiman Long <waiman.long@hp.com>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Paul McKenney <paulmck@linux.vnet.ibm.com>
Cc: John David Anglin <dave.anglin@bell.net>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Davidlohr Bueso <davidlohr@hp.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/20140606175316.GV13930@laptop.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm/Kconfig | 1 +
arch/arm64/Kconfig | 1 +
arch/powerpc/Kconfig | 1 +
arch/sparc/Kconfig | 1 +
arch/x86/Kconfig | 1 +
kernel/Kconfig.locks | 5 ++++-
6 files changed, 9 insertions(+), 1 deletion(-)
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -6,6 +6,7 @@ config ARM
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_HAVE_CUSTOM_GPIO_H
select ARCH_MIGHT_HAVE_PC_PARPORT
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF
select ARCH_WANT_IPC_PARSE_VERSION
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -2,6 +2,7 @@ config ARM64
def_bool y
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_SUPPORTS_ATOMIC_RMW
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_WANT_OPTIONAL_GPIOLIB
select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -145,6 +145,7 @@ config PPC
select HAVE_IRQ_EXIT_ON_IRQ_STACK
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
select HAVE_ARCH_AUDITSYSCALL
+ select ARCH_SUPPORTS_ATOMIC_RMW
config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -78,6 +78,7 @@ config SPARC64
select HAVE_C_RECORDMCOUNT
select NO_BOOTMEM
select HAVE_ARCH_AUDITSYSCALL
+ select ARCH_SUPPORTS_ATOMIC_RMW
config ARCH_DEFCONFIG
string
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -130,6 +130,7 @@ config X86
select HAVE_CC_STACKPROTECTOR
select GENERIC_CPU_AUTOPROBE
select HAVE_ARCH_AUDITSYSCALL
+ select ARCH_SUPPORTS_ATOMIC_RMW
config INSTRUCTION_DECODER
def_bool y
--- a/kernel/Kconfig.locks
+++ b/kernel/Kconfig.locks
@@ -220,6 +220,9 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE
endif
+config ARCH_SUPPORTS_ATOMIC_RMW
+ bool
+
config MUTEX_SPIN_ON_OWNER
def_bool y
- depends on SMP && !DEBUG_MUTEXES
+ depends on SMP && !DEBUG_MUTEXES && ARCH_SUPPORTS_ATOMIC_RMW
^ permalink raw reply
* [PATCH] arch: powerpc: sysdev: qe_lib: qe.c: Cleaning up in conjunction with strncpy and strcpy
From: Rickard Strandqvist @ 2014-07-26 21:26 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras
Cc: devicetree, Rickard Strandqvist, linux-kernel, Rob Herring,
Grant Likely, linuxppc-dev
Replacing strcpy and strncpy with strlcpy to avoid strings that ar to big,
or lacks null terminate.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
arch/powerpc/sysdev/qe_lib/qe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 238a07b..9f19e6c 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -498,7 +498,7 @@ int qe_upload_firmware(const struct qe_firmware *firmware)
* saved microcode information and put in the new.
*/
memset(&qe_firmware_info, 0, sizeof(qe_firmware_info));
- strcpy(qe_firmware_info.id, firmware->id);
+ strlcpy(qe_firmware_info.id, firmware->id, sizeof(qe_firmware_info.id));
qe_firmware_info.extended_modes = firmware->extended_modes;
memcpy(qe_firmware_info.vtraps, firmware->vtraps,
sizeof(firmware->vtraps));
@@ -584,8 +584,8 @@ struct qe_firmware_info *qe_get_firmware_info(void)
/* Copy the data into qe_firmware_info*/
sprop = of_get_property(fw, "id", NULL);
if (sprop)
- strncpy(qe_firmware_info.id, sprop,
- sizeof(qe_firmware_info.id) - 1);
+ strlcpy(qe_firmware_info.id, sprop,
+ sizeof(qe_firmware_info.id));
prop = of_find_property(fw, "extended-modes", NULL);
if (prop && (prop->length == sizeof(u64))) {
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH v3 02/18] KVM: PPC: Use RCU when adding to arch.spapr_tce_tables
From: Benjamin Herrenschmidt @ 2014-07-28 0:40 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-3-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:47 +1000, Alexey Kardashevskiy wrote:
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
You need a much better changeset here, explaining what you are
protecting against and why just changing that one list_add is
sufficient.
Cheers,
Ben.
> ---
> arch/powerpc/kvm/book3s_64_vio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index 54cf9bc..516f2ee 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -131,7 +131,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
> kvm_get_kvm(kvm);
>
> mutex_lock(&kvm->lock);
> - list_add(&stt->list, &kvm->arch.spapr_tce_tables);
> + list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
>
> mutex_unlock(&kvm->lock);
>
^ permalink raw reply
* Re: [PATCH v3 03/18] KVM: PPC: Account TCE pages in locked_vm
From: Benjamin Herrenschmidt @ 2014-07-28 0:43 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-4-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:47 +1000, Alexey Kardashevskiy wrote:
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
You need a description.
> arch/powerpc/kvm/book3s_64_vio.c | 35 ++++++++++++++++++++++++++++++++++-
> 1 file changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index 516f2ee..48b7ed4 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -45,18 +45,48 @@ static long kvmppc_stt_npages(unsigned long window_size)
> * sizeof(u64), PAGE_SIZE) / PAGE_SIZE;
> }
>
> +/*
> + * Checks ulimit in order not to let the user space to pin all
> + * available memory for TCE tables.
> + */
> +static long kvmppc_account_memlimit(long npages)
> +{
> + unsigned long ret = 0, locked, lock_limit;
> +
> + if (!current->mm)
> + return -ESRCH; /* process exited */
> +
> + down_write(¤t->mm->mmap_sem);
> + locked = current->mm->locked_vm + npages;
> + lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
> + if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
> + pr_warn("RLIMIT_MEMLOCK (%ld) exceeded\n",
> + rlimit(RLIMIT_MEMLOCK));
> + ret = -ENOMEM;
> + } else {
> + current->mm->locked_vm += npages;
> + }
> + up_write(¤t->mm->mmap_sem);
> +
> + return ret;
> +}
> +
> static void release_spapr_tce_table(struct kvmppc_spapr_tce_table *stt)
> {
> struct kvm *kvm = stt->kvm;
> int i;
> + long npages = kvmppc_stt_npages(stt->window_size);
>
> mutex_lock(&kvm->lock);
> list_del(&stt->list);
> - for (i = 0; i < kvmppc_stt_npages(stt->window_size); i++)
> + for (i = 0; i < npages; i++)
> __free_page(stt->pages[i]);
> +
> kfree(stt);
> mutex_unlock(&kvm->lock);
>
> + kvmppc_account_memlimit(-(npages + 1));
> +
> kvm_put_kvm(kvm);
> }
>
> @@ -112,6 +142,9 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
> }
>
> npages = kvmppc_stt_npages(args->window_size);
> + ret = kvmppc_account_memlimit(npages + 1);
> + if (ret)
> + goto fail;
This is called for VFIO only or is it also called when creating TCE
tables for emulated devices ? Because in the latter case, you don't
want to account the pages as locked, do you ?
Also, you need to explain what +1
Finally, do I correctly deduce that creating 10 TCE tables of 2G
each will end up accounting 20G as locked even if the guest for
example only has 4G of RAM ?
> stt = kzalloc(sizeof(*stt) + npages * sizeof(struct page *),
> GFP_KERNEL);
Ben.
^ permalink raw reply
* Re: [PATCH v3 04/18] vfio: powerpc: Move locked_vm accounting to a helper
From: Benjamin Herrenschmidt @ 2014-07-28 0:46 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-5-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:47 +1000, Alexey Kardashevskiy wrote:
> Additional DMA windows support is coming and accounting will include them
> so let's move this code to a helper for reuse.
This code looks a LOT like the one you added in the previous patch
(ie. kvmppc_account_memlimit()), though in a different place. I
wonder if we should re-arrange things so that there is really
only one version of it..
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> drivers/vfio/vfio_iommu_spapr_tce.c | 54 ++++++++++++++++++++++++-------------
> 1 file changed, 36 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index a84788b..c8f7284 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -47,10 +47,40 @@ struct tce_container {
> bool enabled;
> };
>
> +/*
> + * Checks ulimit in order not to let the user space to pin all
> + * available memory for TCE tables.
> + */
> +static long tce_iommu_account_memlimit(struct iommu_table *tbl, bool inc)
> +{
> + unsigned long ret = 0, locked, lock_limit;
> + long npages;
> +
> + if (!current->mm)
> + return -ESRCH; /* process exited */
> +
> + npages = (tbl->it_size << IOMMU_PAGE_SHIFT_4K) >> PAGE_SHIFT;
> + if (!inc)
> + npages = -npages;
> +
> + down_write(¤t->mm->mmap_sem);
> + locked = current->mm->locked_vm + npages;
> + lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
> + if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
> + pr_warn("RLIMIT_MEMLOCK (%ld) exceeded\n",
> + rlimit(RLIMIT_MEMLOCK));
> + ret = -ENOMEM;
> + } else {
> + current->mm->locked_vm += npages;
> + }
> + up_write(¤t->mm->mmap_sem);
> +
> + return ret;
> +}
> +
> static int tce_iommu_enable(struct tce_container *container)
> {
> int ret = 0;
> - unsigned long locked, lock_limit, npages;
> struct iommu_table *tbl = container->tbl;
>
> if (!container->tbl)
> @@ -80,20 +110,11 @@ static int tce_iommu_enable(struct tce_container *container)
> * that would effectively kill the guest at random points, much better
> * enforcing the limit based on the max that the guest can map.
> */
> - down_write(¤t->mm->mmap_sem);
> - npages = (tbl->it_size << IOMMU_PAGE_SHIFT_4K) >> PAGE_SHIFT;
> - locked = current->mm->locked_vm + npages;
> - lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
> - if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
> - pr_warn("RLIMIT_MEMLOCK (%ld) exceeded\n",
> - rlimit(RLIMIT_MEMLOCK));
> - ret = -ENOMEM;
> - } else {
> + ret = tce_iommu_account_memlimit(tbl, true);
> + if (ret)
> + return ret;
>
> - current->mm->locked_vm += npages;
> - container->enabled = true;
> - }
> - up_write(¤t->mm->mmap_sem);
> + container->enabled = true;
>
> return ret;
> }
> @@ -108,10 +129,7 @@ static void tce_iommu_disable(struct tce_container *container)
> if (!container->tbl || !current->mm)
> return;
>
> - down_write(¤t->mm->mmap_sem);
> - current->mm->locked_vm -= (container->tbl->it_size <<
> - IOMMU_PAGE_SHIFT_4K) >> PAGE_SHIFT;
> - up_write(¤t->mm->mmap_sem);
> + tce_iommu_account_memlimit(container->tbl, false);
> }
>
> static void *tce_iommu_open(unsigned long arg)
^ permalink raw reply
* Re: [PATCH v3 13/18] powerpc/iommu: Extend ppc_md.tce_build(_rm) to return old TCE values
From: Benjamin Herrenschmidt @ 2014-07-28 1:09 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-14-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
> The tce_build/tce_build_rm callbacks are used to implement H_PUT_TCE/etc
> hypercalls. The PAPR spec does not allow to fail if the TCE is not empty.
> However we cannot just overwrite the existing TCE value with the new one
> as we still have to do page counting.
>
> This adds an optional @old_tces return parameter. If it is not NULL,
> it must point to an array of @npages size where the callbacks will
> store old TCE values. Since tce_build receives virtual addresses,
> the old_tces array will contain virtual addresses as well.
>
> As this patch is mechanical, no change in behaviour is expected.
You missed a few iommu's in the conversion ... pasemi, cell, ...
Ben.
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/machdep.h | 2 ++
> arch/powerpc/kernel/iommu.c | 8 +++++---
> arch/powerpc/platforms/powernv/pci.c | 13 ++++++++-----
> arch/powerpc/platforms/pseries/iommu.c | 7 +++++--
> arch/powerpc/sysdev/dart_iommu.c | 1 +
> 5 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index f92b0b5..f11596c 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -69,6 +69,7 @@ struct machdep_calls {
> long index,
> long npages,
> unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs);
> void (*tce_free)(struct iommu_table *tbl,
> @@ -83,6 +84,7 @@ struct machdep_calls {
> long index,
> long npages,
> unsigned long uaddr,
> + long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs);
> void (*tce_free_rm)(struct iommu_table *tbl,
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 5af2319..ccf7510 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -324,7 +324,8 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
> /* Put the TCEs in the HW table */
> build_fail = ppc_md.tce_build(tbl, entry, npages,
> (unsigned long)page &
> - IOMMU_PAGE_MASK(tbl), direction, attrs);
> + IOMMU_PAGE_MASK(tbl), NULL, direction,
> + attrs);
>
> /* ppc_md.tce_build() only returns non-zero for transient errors.
> * Clean up the table bitmap in this case and return
> @@ -497,7 +498,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
> /* Insert into HW table */
> build_fail = ppc_md.tce_build(tbl, entry, npages,
> vaddr & IOMMU_PAGE_MASK(tbl),
> - direction, attrs);
> + NULL, direction, attrs);
> if(unlikely(build_fail))
> goto failure;
>
> @@ -1059,7 +1060,8 @@ int iommu_tce_build(struct iommu_table *tbl, unsigned long entry,
> oldtce = ppc_md.tce_get(tbl, entry);
> /* Add new entry if it is not busy */
> if (!(oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)))
> - ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, direction, NULL);
> + ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, NULL,
> + direction, NULL);
>
> spin_unlock(&(pool->lock));
>
> diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
> index cc54e3b..4b764c2 100644
> --- a/arch/powerpc/platforms/powernv/pci.c
> +++ b/arch/powerpc/platforms/powernv/pci.c
> @@ -572,7 +572,8 @@ static void pnv_tce_invalidate(struct iommu_table *tbl, __be64 *startp,
> }
>
> static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
> - unsigned long uaddr, enum dma_data_direction direction,
> + unsigned long uaddr, unsigned long *old_tces,
> + enum dma_data_direction direction,
> struct dma_attrs *attrs, bool rm)
> {
> u64 proto_tce;
> @@ -597,12 +598,12 @@ static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
> }
>
> static int pnv_tce_build_vm(struct iommu_table *tbl, long index, long npages,
> - unsigned long uaddr,
> + unsigned long uaddr, unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs,
> - false);
> + return pnv_tce_build(tbl, index, npages, uaddr, old_tces, direction,
> + attrs, false);
> }
>
> static void pnv_tce_free(struct iommu_table *tbl, long index, long npages,
> @@ -630,10 +631,12 @@ static unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
>
> static int pnv_tce_build_rm(struct iommu_table *tbl, long index, long npages,
> unsigned long uaddr,
> + long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs, true);
> + return pnv_tce_build(tbl, index, npages, uaddr, old_tces, direction,
> + attrs, true);
> }
>
> static void pnv_tce_free_rm(struct iommu_table *tbl, long index, long npages)
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index a047754..6c70b7c 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -82,6 +82,7 @@ static void tce_invalidate_pSeries_sw(struct iommu_table *tbl,
>
> static int tce_build_pSeries(struct iommu_table *tbl, long index,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -138,6 +139,7 @@ static void tce_freemulti_pSeriesLP(struct iommu_table*, long, long);
>
> static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -181,6 +183,7 @@ static DEFINE_PER_CPU(__be64 *, tce_page);
>
> static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -195,7 +198,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
>
> if (npages == 1) {
> return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
> - direction, attrs);
> + old_tces, direction, attrs);
> }
>
> local_irq_save(flags); /* to protect tcep and the page behind it */
> @@ -211,7 +214,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
> if (!tcep) {
> local_irq_restore(flags);
> return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
> - direction, attrs);
> + old_tces, direction, attrs);
> }
> __get_cpu_var(tce_page) = tcep;
> }
> diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
> index 9e5353f..0d3cf7c 100644
> --- a/arch/powerpc/sysdev/dart_iommu.c
> +++ b/arch/powerpc/sysdev/dart_iommu.c
> @@ -162,6 +162,7 @@ static void dart_flush(struct iommu_table *tbl)
>
> static int dart_build(struct iommu_table *tbl, long index,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
^ permalink raw reply
* Re: [PATCH v3 13/18] powerpc/iommu: Extend ppc_md.tce_build(_rm) to return old TCE values
From: Benjamin Herrenschmidt @ 2014-07-28 1:16 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-14-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
> The tce_build/tce_build_rm callbacks are used to implement H_PUT_TCE/etc
> hypercalls. The PAPR spec does not allow to fail if the TCE is not empty.
> However we cannot just overwrite the existing TCE value with the new one
> as we still have to do page counting.
>
> This adds an optional @old_tces return parameter. If it is not NULL,
> it must point to an array of @npages size where the callbacks will
> store old TCE values. Since tce_build receives virtual addresses,
> the old_tces array will contain virtual addresses as well.
>
> As this patch is mechanical, no change in behaviour is expected.
Yeah well ... you added the new argument but you never actually populate
it. Don't do that, make that one single patch.
Also this is broken in many other ways. You don't implement it for all
iommu's which is not a reasonable interface. On the other hand,
implementing for all of them would have a significant cost since on
pseries It would mean another H-call.
So I'd suggest you actually create a separate callback, something like
tce_get_and_set() or something...
In fact, since you're going to touch each iommu interface like that you
should probably do what I suggested earlier and move those callbacks
to an iommu_ops structure per iommu.
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/machdep.h | 2 ++
> arch/powerpc/kernel/iommu.c | 8 +++++---
> arch/powerpc/platforms/powernv/pci.c | 13 ++++++++-----
> arch/powerpc/platforms/pseries/iommu.c | 7 +++++--
> arch/powerpc/sysdev/dart_iommu.c | 1 +
> 5 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
> index f92b0b5..f11596c 100644
> --- a/arch/powerpc/include/asm/machdep.h
> +++ b/arch/powerpc/include/asm/machdep.h
> @@ -69,6 +69,7 @@ struct machdep_calls {
> long index,
> long npages,
> unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs);
> void (*tce_free)(struct iommu_table *tbl,
> @@ -83,6 +84,7 @@ struct machdep_calls {
> long index,
> long npages,
> unsigned long uaddr,
> + long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs);
> void (*tce_free_rm)(struct iommu_table *tbl,
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 5af2319..ccf7510 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -324,7 +324,8 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
> /* Put the TCEs in the HW table */
> build_fail = ppc_md.tce_build(tbl, entry, npages,
> (unsigned long)page &
> - IOMMU_PAGE_MASK(tbl), direction, attrs);
> + IOMMU_PAGE_MASK(tbl), NULL, direction,
> + attrs);
>
> /* ppc_md.tce_build() only returns non-zero for transient errors.
> * Clean up the table bitmap in this case and return
> @@ -497,7 +498,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
> /* Insert into HW table */
> build_fail = ppc_md.tce_build(tbl, entry, npages,
> vaddr & IOMMU_PAGE_MASK(tbl),
> - direction, attrs);
> + NULL, direction, attrs);
> if(unlikely(build_fail))
> goto failure;
>
> @@ -1059,7 +1060,8 @@ int iommu_tce_build(struct iommu_table *tbl, unsigned long entry,
> oldtce = ppc_md.tce_get(tbl, entry);
> /* Add new entry if it is not busy */
> if (!(oldtce & (TCE_PCI_WRITE | TCE_PCI_READ)))
> - ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, direction, NULL);
> + ret = ppc_md.tce_build(tbl, entry, 1, hwaddr, NULL,
> + direction, NULL);
>
> spin_unlock(&(pool->lock));
>
> diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
> index cc54e3b..4b764c2 100644
> --- a/arch/powerpc/platforms/powernv/pci.c
> +++ b/arch/powerpc/platforms/powernv/pci.c
> @@ -572,7 +572,8 @@ static void pnv_tce_invalidate(struct iommu_table *tbl, __be64 *startp,
> }
>
> static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
> - unsigned long uaddr, enum dma_data_direction direction,
> + unsigned long uaddr, unsigned long *old_tces,
> + enum dma_data_direction direction,
> struct dma_attrs *attrs, bool rm)
> {
> u64 proto_tce;
> @@ -597,12 +598,12 @@ static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
> }
>
> static int pnv_tce_build_vm(struct iommu_table *tbl, long index, long npages,
> - unsigned long uaddr,
> + unsigned long uaddr, unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs,
> - false);
> + return pnv_tce_build(tbl, index, npages, uaddr, old_tces, direction,
> + attrs, false);
> }
>
> static void pnv_tce_free(struct iommu_table *tbl, long index, long npages,
> @@ -630,10 +631,12 @@ static unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
>
> static int pnv_tce_build_rm(struct iommu_table *tbl, long index, long npages,
> unsigned long uaddr,
> + long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> - return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs, true);
> + return pnv_tce_build(tbl, index, npages, uaddr, old_tces, direction,
> + attrs, true);
> }
>
> static void pnv_tce_free_rm(struct iommu_table *tbl, long index, long npages)
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index a047754..6c70b7c 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -82,6 +82,7 @@ static void tce_invalidate_pSeries_sw(struct iommu_table *tbl,
>
> static int tce_build_pSeries(struct iommu_table *tbl, long index,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -138,6 +139,7 @@ static void tce_freemulti_pSeriesLP(struct iommu_table*, long, long);
>
> static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -181,6 +183,7 @@ static DEFINE_PER_CPU(__be64 *, tce_page);
>
> static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
> @@ -195,7 +198,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
>
> if (npages == 1) {
> return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
> - direction, attrs);
> + old_tces, direction, attrs);
> }
>
> local_irq_save(flags); /* to protect tcep and the page behind it */
> @@ -211,7 +214,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
> if (!tcep) {
> local_irq_restore(flags);
> return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
> - direction, attrs);
> + old_tces, direction, attrs);
> }
> __get_cpu_var(tce_page) = tcep;
> }
> diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
> index 9e5353f..0d3cf7c 100644
> --- a/arch/powerpc/sysdev/dart_iommu.c
> +++ b/arch/powerpc/sysdev/dart_iommu.c
> @@ -162,6 +162,7 @@ static void dart_flush(struct iommu_table *tbl)
>
> static int dart_build(struct iommu_table *tbl, long index,
> long npages, unsigned long uaddr,
> + unsigned long *old_tces,
> enum dma_data_direction direction,
> struct dma_attrs *attrs)
> {
^ permalink raw reply
* Re: [PATCH v3 10/18] powerpc/powernv: Convert/move set_bypass() callback to take_ownership()
From: Benjamin Herrenschmidt @ 2014-07-28 1:18 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-11-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
> At the moment the iommu_table struct has a set_bypass() which enables/
> disables DMA bypass on IODA2 PHB. This is exposed to POWERPC IOMMU code
> which calls this callback when external IOMMU users such as VFIO are
> about to get over a PHB.
>
> Since the set_bypass() is not really an iommu_table function but PE's
> function, and we have an ops struct per IOMMU owner, let's move
> set_bypass() to the spapr_tce_iommu_ops struct.
>
> As arch/powerpc/kernel/iommu.c is more about POWERPC IOMMU tables and
> has very little to do with PEs, this moves take_ownership() calls to
> the VFIO SPAPR TCE driver.
>
> This renames set_bypass() to take_ownership() as it is not necessarily
> just enabling bypassing, it can be something else/more so let's give it
> a generic name. The bool parameter is inverted.
I disagree with the name change. take_ownership() is the right semantic
at the high level, but down to the actual table, it *is* about disabling
bypass.
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> arch/powerpc/include/asm/iommu.h | 1 -
> arch/powerpc/include/asm/tce.h | 2 ++
> arch/powerpc/kernel/iommu.c | 12 ------------
> arch/powerpc/platforms/powernv/pci-ioda.c | 18 +++++++++++-------
> drivers/vfio/vfio_iommu_spapr_tce.c | 16 ++++++++++++++++
> 5 files changed, 29 insertions(+), 20 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
> index 84ee339..2b0b01d 100644
> --- a/arch/powerpc/include/asm/iommu.h
> +++ b/arch/powerpc/include/asm/iommu.h
> @@ -77,7 +77,6 @@ struct iommu_table {
> #ifdef CONFIG_IOMMU_API
> struct iommu_group *it_group;
> #endif
> - void (*set_bypass)(struct iommu_table *tbl, bool enable);
> };
>
> /* Pure 2^n version of get_order */
> diff --git a/arch/powerpc/include/asm/tce.h b/arch/powerpc/include/asm/tce.h
> index 8bfe98f..5ee4987 100644
> --- a/arch/powerpc/include/asm/tce.h
> +++ b/arch/powerpc/include/asm/tce.h
> @@ -58,6 +58,8 @@ struct spapr_tce_iommu_ops {
> struct iommu_table *(*get_table)(
> struct spapr_tce_iommu_group *data,
> phys_addr_t addr);
> + void (*take_ownership)(struct spapr_tce_iommu_group *data,
> + bool enable);
> };
>
> struct spapr_tce_iommu_group {
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index e203314..06984d5 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -1116,14 +1116,6 @@ int iommu_take_ownership(struct iommu_table *tbl)
> memset(tbl->it_map, 0xff, sz);
> iommu_clear_tces_and_put_pages(tbl, tbl->it_offset, tbl->it_size);
>
> - /*
> - * Disable iommu bypass, otherwise the user can DMA to all of
> - * our physical memory via the bypass window instead of just
> - * the pages that has been explicitly mapped into the iommu
> - */
> - if (tbl->set_bypass)
> - tbl->set_bypass(tbl, false);
> -
> return 0;
> }
> EXPORT_SYMBOL_GPL(iommu_take_ownership);
> @@ -1138,10 +1130,6 @@ void iommu_release_ownership(struct iommu_table *tbl)
> /* Restore bit#0 set by iommu_init_table() */
> if (tbl->it_offset == 0)
> set_bit(0, tbl->it_map);
> -
> - /* The kernel owns the device now, we can restore the iommu bypass */
> - if (tbl->set_bypass)
> - tbl->set_bypass(tbl, true);
> }
> EXPORT_SYMBOL_GPL(iommu_release_ownership);
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 495137b..f828c57 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -709,10 +709,8 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
> __free_pages(tce_mem, get_order(TCE32_TABLE_SIZE * segs));
> }
>
> -static void pnv_pci_ioda2_set_bypass(struct iommu_table *tbl, bool enable)
> +static void pnv_pci_ioda2_set_bypass(struct pnv_ioda_pe *pe, bool enable)
> {
> - struct pnv_ioda_pe *pe = container_of(tbl, struct pnv_ioda_pe,
> - tce32.table);
> uint16_t window_id = (pe->pe_number << 1 ) + 1;
> int64_t rc;
>
> @@ -752,15 +750,21 @@ static void pnv_pci_ioda2_setup_bypass_pe(struct pnv_phb *phb,
> /* TVE #1 is selected by PCI address bit 59 */
> pe->tce_bypass_base = 1ull << 59;
>
> - /* Install set_bypass callback for VFIO */
> - pe->tce32.table.set_bypass = pnv_pci_ioda2_set_bypass;
> -
> /* Enable bypass by default */
> - pnv_pci_ioda2_set_bypass(&pe->tce32.table, true);
> + pnv_pci_ioda2_set_bypass(pe, true);
> +}
> +
> +static void pnv_ioda2_take_ownership(struct spapr_tce_iommu_group *data,
> + bool enable)
> +{
> + struct pnv_ioda_pe *pe = data->iommu_owner;
> +
> + pnv_pci_ioda2_set_bypass(pe, !enable);
> }
>
> static struct spapr_tce_iommu_ops pnv_pci_ioda2_ops = {
> .get_table = pnv_ioda1_iommu_get_table,
> + .take_ownership = pnv_ioda2_take_ownership,
> };
>
> static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 917c854..05b2f11 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -78,6 +78,13 @@ static long tce_iommu_account_memlimit(struct iommu_table *tbl, bool inc)
> return ret;
> }
>
> +static void tce_iommu_take_ownership_notify(struct spapr_tce_iommu_group *data,
> + bool enable)
> +{
> + if (data && data->ops && data->ops->take_ownership)
> + data->ops->take_ownership(data, enable);
> +}
> +
> static int tce_iommu_enable(struct tce_container *container)
> {
> int ret = 0;
> @@ -386,6 +393,12 @@ static int tce_iommu_attach_group(void *iommu_data,
> ret = iommu_take_ownership(tbl);
> if (!ret)
> container->grp = iommu_group;
> + /*
> + * Disable iommu bypass, otherwise the user can DMA to all of
> + * our physical memory via the bypass window instead of just
> + * the pages that has been explicitly mapped into the iommu
> + */
> + tce_iommu_take_ownership_notify(data, true);
> }
>
> mutex_unlock(&container->lock);
> @@ -423,6 +436,9 @@ static void tce_iommu_detach_group(void *iommu_data,
> BUG_ON(!tbl);
>
> iommu_release_ownership(tbl);
> +
> + /* Kernel owns the device now, we can restore bypass */
> + tce_iommu_take_ownership_notify(data, false);
> }
> mutex_unlock(&container->lock);
> }
^ permalink raw reply
* Re: [PATCH v3 12/18] powerpc/iommu: Fix missing permission bits in iommu_put_tce_user_mode()
From: Benjamin Herrenschmidt @ 2014-07-28 1:19 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406191691-31441-13-git-send-email-aik@ozlabs.ru>
On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
> This adds missing permission bits to the translated TCE.
Is this a bug fix for existing stuff ? If yes, submit it separately.
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> arch/powerpc/kernel/iommu.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 0cda2e8..5af2319 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -1088,6 +1088,7 @@ int iommu_put_tce_user_mode(struct iommu_table *tbl, unsigned long entry,
> return -EFAULT;
> }
> hwaddr = (unsigned long) page_address(page) + offset;
> + hwaddr |= tce & (TCE_PCI_READ | TCE_PCI_WRITE);
>
> ret = iommu_tce_build(tbl, entry, hwaddr, direction);
> if (ret)
^ permalink raw reply
* Re: [PATCH] powerpc: fixing endianness of flash_block_list in rtas_flash
From: Michael Ellerman @ 2014-07-28 3:35 UTC (permalink / raw)
To: Thomas Falcon; +Cc: linuxppc-dev
In-Reply-To: <1406310462-23005-1-git-send-email-tlfalcon@linux.vnet.ibm.com>
Hi Thomas,
On Fri, 2014-07-25 at 12:47 -0500, Thomas Falcon wrote:
> [PATCH] powerpc: fixing endianness of flash_block_list in rtas_flash
Minor nit, but the commit title should use the imperative mood, so eg:
[PATCH] powerpc: Fix endianness of flash_block_list in rtas_flash
> The function rtas_flash_firmware passes the address of a data structure,
> flash_block_list, when making the update-flash-64-and-reboot rtas call.
> While the endianness of the address is handled correctly, the endianness
> of the data is not. This patch ensures that the data in flash_block_list
> is big endian when passed to rtas on little endian hosts.
This looks good.
But you can do even better by changing the data types to be explicitly BE, so
eg. length should be __be64 I think.
Then if you build with "make C=2 CF=-D__CHECK_ENDIAN__" and have sparse
installed it will tell you when incorrectly assign from/to the BE types.
cheers
^ permalink raw reply
* [git pull] Please pull powerpc.git merge branch
From: Benjamin Herrenschmidt @ 2014-07-28 3:46 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linuxppc-dev, Linux Kernel list
Hi Linus !
Here are 3 more small powerpc fixes that should still go into .16.
One is a recent regression (MMCR2 business), the other is a trivial
endian fix without which FW updates won't work on LE in IBM machines,
and the 3rd one turns a BUG_ON into a WARN_ON which is definitely
a LOT more friendly especially when the whole thing is about retrieving
error logs ...
Cheers,
Ben.
The following changes since commit 6f5405bc2ee0102bb3856e2cdea64ff415db2e0c:
powerpc: use _GLOBAL_TOC for memmove (2014-07-22 15:56:04 +1000)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc.git merge
for you to fetch changes up to 396a34340cdf7373c00e3977db27d1a20ea65ebc:
powerpc: Fix endianness of flash_block_list in rtas_flash (2014-07-28 11:30:54 +1000)
----------------------------------------------------------------
Michael Ellerman (1):
powerpc/perf: Fix MMCR2 handling for EBB
Thomas Falcon (1):
powerpc: Fix endianness of flash_block_list in rtas_flash
Vasant Hegde (1):
powerpc/powernv: Change BUG_ON to WARN_ON in elog code
arch/powerpc/kernel/rtas_flash.c | 6 ++++--
arch/powerpc/perf/core-book3s.c | 6 +++---
arch/powerpc/platforms/powernv/opal-elog.c | 4 ++--
3 files changed, 9 insertions(+), 7 deletions(-)
^ permalink raw reply
* [PATCH] Add Michael Ellerman as powerpc co-maintainer
From: Benjamin Herrenschmidt @ 2014-07-28 3:54 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Linus Torvalds
Michael has been backing me up and helping will all aspects of
maintainership for a while now, let's make it official.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
--
Linus: I'll put this patch in powerpc-next, I'm just CC'ing
you so you are aware, in case I'm not available and Michael starts
sending you stuff directly.
diff --git a/MAINTAINERS b/MAINTAINERS
index c43ea88..815cd6f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5357,6 +5357,7 @@ F: arch/powerpc/boot/rs6000.h
LINUX FOR POWERPC (32-BIT AND 64-BIT)
M: Benjamin Herrenschmidt <benh@kernel.crashing.org>
M: Paul Mackerras <paulus@samba.org>
+M: Michael Ellerman <mpe@ellerman.id.au>
W: http://www.penguinppc.org/
L: linuxppc-dev@lists.ozlabs.org
Q: http://patchwork.ozlabs.org/project/linuxppc-dev/list/
^ permalink raw reply related
* Re: [PATCH v3 10/18] powerpc/powernv: Convert/move set_bypass() callback to take_ownership()
From: Alexey Kardashevskiy @ 2014-07-28 3:55 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras, Gavin Shan
In-Reply-To: <1406510335.4935.34.camel@pasglop>
On 07/28/2014 11:18 AM, Benjamin Herrenschmidt wrote:
> On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
>> At the moment the iommu_table struct has a set_bypass() which enables/
>> disables DMA bypass on IODA2 PHB. This is exposed to POWERPC IOMMU code
>> which calls this callback when external IOMMU users such as VFIO are
>> about to get over a PHB.
>>
>> Since the set_bypass() is not really an iommu_table function but PE's
>> function, and we have an ops struct per IOMMU owner, let's move
>> set_bypass() to the spapr_tce_iommu_ops struct.
>>
>> As arch/powerpc/kernel/iommu.c is more about POWERPC IOMMU tables and
>> has very little to do with PEs, this moves take_ownership() calls to
>> the VFIO SPAPR TCE driver.
>>
>> This renames set_bypass() to take_ownership() as it is not necessarily
>> just enabling bypassing, it can be something else/more so let's give it
>> a generic name. The bool parameter is inverted.
>
> I disagree with the name change. take_ownership() is the right semantic
> at the high level, but down to the actual table, it *is* about disabling
> bypass.
It is still pnv_pci_ioda2_set_bypass() :-/
take_ownership() is a callback of PNV IOMMU group.
s/take_ownership/set_bypass/ ?
>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>> ---
>> arch/powerpc/include/asm/iommu.h | 1 -
>> arch/powerpc/include/asm/tce.h | 2 ++
>> arch/powerpc/kernel/iommu.c | 12 ------------
>> arch/powerpc/platforms/powernv/pci-ioda.c | 18 +++++++++++-------
>> drivers/vfio/vfio_iommu_spapr_tce.c | 16 ++++++++++++++++
>> 5 files changed, 29 insertions(+), 20 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
>> index 84ee339..2b0b01d 100644
>> --- a/arch/powerpc/include/asm/iommu.h
>> +++ b/arch/powerpc/include/asm/iommu.h
>> @@ -77,7 +77,6 @@ struct iommu_table {
>> #ifdef CONFIG_IOMMU_API
>> struct iommu_group *it_group;
>> #endif
>> - void (*set_bypass)(struct iommu_table *tbl, bool enable);
>> };
>>
>> /* Pure 2^n version of get_order */
>> diff --git a/arch/powerpc/include/asm/tce.h b/arch/powerpc/include/asm/tce.h
>> index 8bfe98f..5ee4987 100644
>> --- a/arch/powerpc/include/asm/tce.h
>> +++ b/arch/powerpc/include/asm/tce.h
>> @@ -58,6 +58,8 @@ struct spapr_tce_iommu_ops {
>> struct iommu_table *(*get_table)(
>> struct spapr_tce_iommu_group *data,
>> phys_addr_t addr);
>> + void (*take_ownership)(struct spapr_tce_iommu_group *data,
>> + bool enable);
>> };
>>
>> struct spapr_tce_iommu_group {
>> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
>> index e203314..06984d5 100644
>> --- a/arch/powerpc/kernel/iommu.c
>> +++ b/arch/powerpc/kernel/iommu.c
>> @@ -1116,14 +1116,6 @@ int iommu_take_ownership(struct iommu_table *tbl)
>> memset(tbl->it_map, 0xff, sz);
>> iommu_clear_tces_and_put_pages(tbl, tbl->it_offset, tbl->it_size);
>>
>> - /*
>> - * Disable iommu bypass, otherwise the user can DMA to all of
>> - * our physical memory via the bypass window instead of just
>> - * the pages that has been explicitly mapped into the iommu
>> - */
>> - if (tbl->set_bypass)
>> - tbl->set_bypass(tbl, false);
>> -
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(iommu_take_ownership);
>> @@ -1138,10 +1130,6 @@ void iommu_release_ownership(struct iommu_table *tbl)
>> /* Restore bit#0 set by iommu_init_table() */
>> if (tbl->it_offset == 0)
>> set_bit(0, tbl->it_map);
>> -
>> - /* The kernel owns the device now, we can restore the iommu bypass */
>> - if (tbl->set_bypass)
>> - tbl->set_bypass(tbl, true);
>> }
>> EXPORT_SYMBOL_GPL(iommu_release_ownership);
>>
>> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
>> index 495137b..f828c57 100644
>> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
>> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
>> @@ -709,10 +709,8 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
>> __free_pages(tce_mem, get_order(TCE32_TABLE_SIZE * segs));
>> }
>>
>> -static void pnv_pci_ioda2_set_bypass(struct iommu_table *tbl, bool enable)
>> +static void pnv_pci_ioda2_set_bypass(struct pnv_ioda_pe *pe, bool enable)
>> {
>> - struct pnv_ioda_pe *pe = container_of(tbl, struct pnv_ioda_pe,
>> - tce32.table);
>> uint16_t window_id = (pe->pe_number << 1 ) + 1;
>> int64_t rc;
>>
>> @@ -752,15 +750,21 @@ static void pnv_pci_ioda2_setup_bypass_pe(struct pnv_phb *phb,
>> /* TVE #1 is selected by PCI address bit 59 */
>> pe->tce_bypass_base = 1ull << 59;
>>
>> - /* Install set_bypass callback for VFIO */
>> - pe->tce32.table.set_bypass = pnv_pci_ioda2_set_bypass;
>> -
>> /* Enable bypass by default */
>> - pnv_pci_ioda2_set_bypass(&pe->tce32.table, true);
>> + pnv_pci_ioda2_set_bypass(pe, true);
>> +}
>> +
>> +static void pnv_ioda2_take_ownership(struct spapr_tce_iommu_group *data,
>> + bool enable)
>> +{
>> + struct pnv_ioda_pe *pe = data->iommu_owner;
>> +
>> + pnv_pci_ioda2_set_bypass(pe, !enable);
>> }
>>
>> static struct spapr_tce_iommu_ops pnv_pci_ioda2_ops = {
>> .get_table = pnv_ioda1_iommu_get_table,
>> + .take_ownership = pnv_ioda2_take_ownership,
>> };
>>
>> static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
>> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
>> index 917c854..05b2f11 100644
>> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
>> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
>> @@ -78,6 +78,13 @@ static long tce_iommu_account_memlimit(struct iommu_table *tbl, bool inc)
>> return ret;
>> }
>>
>> +static void tce_iommu_take_ownership_notify(struct spapr_tce_iommu_group *data,
>> + bool enable)
>> +{
>> + if (data && data->ops && data->ops->take_ownership)
>> + data->ops->take_ownership(data, enable);
>> +}
>> +
>> static int tce_iommu_enable(struct tce_container *container)
>> {
>> int ret = 0;
>> @@ -386,6 +393,12 @@ static int tce_iommu_attach_group(void *iommu_data,
>> ret = iommu_take_ownership(tbl);
>> if (!ret)
>> container->grp = iommu_group;
>> + /*
>> + * Disable iommu bypass, otherwise the user can DMA to all of
>> + * our physical memory via the bypass window instead of just
>> + * the pages that has been explicitly mapped into the iommu
>> + */
>> + tce_iommu_take_ownership_notify(data, true);
>> }
>>
>> mutex_unlock(&container->lock);
>> @@ -423,6 +436,9 @@ static void tce_iommu_detach_group(void *iommu_data,
>> BUG_ON(!tbl);
>>
>> iommu_release_ownership(tbl);
>> +
>> + /* Kernel owns the device now, we can restore bypass */
>> + tce_iommu_take_ownership_notify(data, false);
>> }
>> mutex_unlock(&container->lock);
>> }
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
--
Alexey
^ permalink raw reply
* Re: [PATCH v3 02/18] KVM: PPC: Use RCU when adding to arch.spapr_tce_tables
From: Alexey Kardashevskiy @ 2014-07-28 4:11 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Paul Mackerras, linuxppc-dev, Gavin Shan
In-Reply-To: <1406508047.4935.21.camel@pasglop>
On 07/28/2014 10:40 AM, Benjamin Herrenschmidt wrote:
> On Thu, 2014-07-24 at 18:47 +1000, Alexey Kardashevskiy wrote:
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>
> You need a much better changeset here, explaining what you are
> protecting against and why just changing that one list_add is
> sufficient.
===
At the moment the spapr_tce_tables list is not protected against races
which may happen if the userspace issues the KVM_CREATE_SPAPR_TCE ioctl
to KVM from different threads.
This makes use of _rcu helpers for list_add()/list_del().
===
and it is missing this bit as well (was under impression that all tables
get freed at once at KVM exit but this might not be the case for malicious
guest):
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -211,7 +211,7 @@ static void release_spapr_tce_table(struct
kvmppc_spapr_tce_table *stt)
long npages = kvmppc_stt_npages(stt->size);
mutex_lock(&kvm->lock);
- list_del(&stt->list);
+ list_del_rcu(&stt->list);
Would this be sufficient?
>
> Cheers,
> Ben.
>
>> ---
>> arch/powerpc/kvm/book3s_64_vio.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
>> index 54cf9bc..516f2ee 100644
>> --- a/arch/powerpc/kvm/book3s_64_vio.c
>> +++ b/arch/powerpc/kvm/book3s_64_vio.c
>> @@ -131,7 +131,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
>> kvm_get_kvm(kvm);
>>
>> mutex_lock(&kvm->lock);
>> - list_add(&stt->list, &kvm->arch.spapr_tce_tables);
>> + list_add_rcu(&stt->list, &kvm->arch.spapr_tce_tables);
>>
>> mutex_unlock(&kvm->lock);
>>
>
>
--
Alexey
^ permalink raw reply
* Re: [PATCH v3 10/18] powerpc/powernv: Convert/move set_bypass() callback to take_ownership()
From: Benjamin Herrenschmidt @ 2014-07-28 4:19 UTC (permalink / raw)
To: Alexey Kardashevskiy; +Cc: linuxppc-dev, Paul Mackerras, Gavin Shan
In-Reply-To: <53D5C994.7050507@ozlabs.ru>
On Mon, 2014-07-28 at 13:55 +1000, Alexey Kardashevskiy wrote:
> On 07/28/2014 11:18 AM, Benjamin Herrenschmidt wrote:
> > On Thu, 2014-07-24 at 18:48 +1000, Alexey Kardashevskiy wrote:
> >> At the moment the iommu_table struct has a set_bypass() which enables/
> >> disables DMA bypass on IODA2 PHB. This is exposed to POWERPC IOMMU code
> >> which calls this callback when external IOMMU users such as VFIO are
> >> about to get over a PHB.
> >>
> >> Since the set_bypass() is not really an iommu_table function but PE's
> >> function, and we have an ops struct per IOMMU owner, let's move
> >> set_bypass() to the spapr_tce_iommu_ops struct.
> >>
> >> As arch/powerpc/kernel/iommu.c is more about POWERPC IOMMU tables and
> >> has very little to do with PEs, this moves take_ownership() calls to
> >> the VFIO SPAPR TCE driver.
> >>
> >> This renames set_bypass() to take_ownership() as it is not necessarily
> >> just enabling bypassing, it can be something else/more so let's give it
> >> a generic name. The bool parameter is inverted.
> >
> > I disagree with the name change. take_ownership() is the right semantic
> > at the high level, but down to the actual table, it *is* about disabling
> > bypass.
>
> It is still pnv_pci_ioda2_set_bypass() :-/
>
> take_ownership() is a callback of PNV IOMMU group.
>
> s/take_ownership/set_bypass/ ?
>
Hrm, ... ok. It's a bit messy but should do for now.
> >
> >> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> >> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> >> ---
> >> arch/powerpc/include/asm/iommu.h | 1 -
> >> arch/powerpc/include/asm/tce.h | 2 ++
> >> arch/powerpc/kernel/iommu.c | 12 ------------
> >> arch/powerpc/platforms/powernv/pci-ioda.c | 18 +++++++++++-------
> >> drivers/vfio/vfio_iommu_spapr_tce.c | 16 ++++++++++++++++
> >> 5 files changed, 29 insertions(+), 20 deletions(-)
> >>
> >> diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
> >> index 84ee339..2b0b01d 100644
> >> --- a/arch/powerpc/include/asm/iommu.h
> >> +++ b/arch/powerpc/include/asm/iommu.h
> >> @@ -77,7 +77,6 @@ struct iommu_table {
> >> #ifdef CONFIG_IOMMU_API
> >> struct iommu_group *it_group;
> >> #endif
> >> - void (*set_bypass)(struct iommu_table *tbl, bool enable);
> >> };
> >>
> >> /* Pure 2^n version of get_order */
> >> diff --git a/arch/powerpc/include/asm/tce.h b/arch/powerpc/include/asm/tce.h
> >> index 8bfe98f..5ee4987 100644
> >> --- a/arch/powerpc/include/asm/tce.h
> >> +++ b/arch/powerpc/include/asm/tce.h
> >> @@ -58,6 +58,8 @@ struct spapr_tce_iommu_ops {
> >> struct iommu_table *(*get_table)(
> >> struct spapr_tce_iommu_group *data,
> >> phys_addr_t addr);
> >> + void (*take_ownership)(struct spapr_tce_iommu_group *data,
> >> + bool enable);
> >> };
> >>
> >> struct spapr_tce_iommu_group {
> >> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> >> index e203314..06984d5 100644
> >> --- a/arch/powerpc/kernel/iommu.c
> >> +++ b/arch/powerpc/kernel/iommu.c
> >> @@ -1116,14 +1116,6 @@ int iommu_take_ownership(struct iommu_table *tbl)
> >> memset(tbl->it_map, 0xff, sz);
> >> iommu_clear_tces_and_put_pages(tbl, tbl->it_offset, tbl->it_size);
> >>
> >> - /*
> >> - * Disable iommu bypass, otherwise the user can DMA to all of
> >> - * our physical memory via the bypass window instead of just
> >> - * the pages that has been explicitly mapped into the iommu
> >> - */
> >> - if (tbl->set_bypass)
> >> - tbl->set_bypass(tbl, false);
> >> -
> >> return 0;
> >> }
> >> EXPORT_SYMBOL_GPL(iommu_take_ownership);
> >> @@ -1138,10 +1130,6 @@ void iommu_release_ownership(struct iommu_table *tbl)
> >> /* Restore bit#0 set by iommu_init_table() */
> >> if (tbl->it_offset == 0)
> >> set_bit(0, tbl->it_map);
> >> -
> >> - /* The kernel owns the device now, we can restore the iommu bypass */
> >> - if (tbl->set_bypass)
> >> - tbl->set_bypass(tbl, true);
> >> }
> >> EXPORT_SYMBOL_GPL(iommu_release_ownership);
> >>
> >> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> >> index 495137b..f828c57 100644
> >> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> >> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> >> @@ -709,10 +709,8 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
> >> __free_pages(tce_mem, get_order(TCE32_TABLE_SIZE * segs));
> >> }
> >>
> >> -static void pnv_pci_ioda2_set_bypass(struct iommu_table *tbl, bool enable)
> >> +static void pnv_pci_ioda2_set_bypass(struct pnv_ioda_pe *pe, bool enable)
> >> {
> >> - struct pnv_ioda_pe *pe = container_of(tbl, struct pnv_ioda_pe,
> >> - tce32.table);
> >> uint16_t window_id = (pe->pe_number << 1 ) + 1;
> >> int64_t rc;
> >>
> >> @@ -752,15 +750,21 @@ static void pnv_pci_ioda2_setup_bypass_pe(struct pnv_phb *phb,
> >> /* TVE #1 is selected by PCI address bit 59 */
> >> pe->tce_bypass_base = 1ull << 59;
> >>
> >> - /* Install set_bypass callback for VFIO */
> >> - pe->tce32.table.set_bypass = pnv_pci_ioda2_set_bypass;
> >> -
> >> /* Enable bypass by default */
> >> - pnv_pci_ioda2_set_bypass(&pe->tce32.table, true);
> >> + pnv_pci_ioda2_set_bypass(pe, true);
> >> +}
> >> +
> >> +static void pnv_ioda2_take_ownership(struct spapr_tce_iommu_group *data,
> >> + bool enable)
> >> +{
> >> + struct pnv_ioda_pe *pe = data->iommu_owner;
> >> +
> >> + pnv_pci_ioda2_set_bypass(pe, !enable);
> >> }
> >>
> >> static struct spapr_tce_iommu_ops pnv_pci_ioda2_ops = {
> >> .get_table = pnv_ioda1_iommu_get_table,
> >> + .take_ownership = pnv_ioda2_take_ownership,
> >> };
> >>
> >> static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
> >> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> index 917c854..05b2f11 100644
> >> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> >> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> >> @@ -78,6 +78,13 @@ static long tce_iommu_account_memlimit(struct iommu_table *tbl, bool inc)
> >> return ret;
> >> }
> >>
> >> +static void tce_iommu_take_ownership_notify(struct spapr_tce_iommu_group *data,
> >> + bool enable)
> >> +{
> >> + if (data && data->ops && data->ops->take_ownership)
> >> + data->ops->take_ownership(data, enable);
> >> +}
> >> +
> >> static int tce_iommu_enable(struct tce_container *container)
> >> {
> >> int ret = 0;
> >> @@ -386,6 +393,12 @@ static int tce_iommu_attach_group(void *iommu_data,
> >> ret = iommu_take_ownership(tbl);
> >> if (!ret)
> >> container->grp = iommu_group;
> >> + /*
> >> + * Disable iommu bypass, otherwise the user can DMA to all of
> >> + * our physical memory via the bypass window instead of just
> >> + * the pages that has been explicitly mapped into the iommu
> >> + */
> >> + tce_iommu_take_ownership_notify(data, true);
> >> }
> >>
> >> mutex_unlock(&container->lock);
> >> @@ -423,6 +436,9 @@ static void tce_iommu_detach_group(void *iommu_data,
> >> BUG_ON(!tbl);
> >>
> >> iommu_release_ownership(tbl);
> >> +
> >> + /* Kernel owns the device now, we can restore bypass */
> >> + tce_iommu_take_ownership_notify(data, false);
> >> }
> >> mutex_unlock(&container->lock);
> >> }
> >
> >
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/linuxppc-dev
> >
>
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox