[PATCH 4/5] KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs

2021-08-17 Thread Sean Christopherson
Add a test to verify an rseq's CPU ID is updated correctly if the task is migrated while the kernel is handling KVM_RUN. This is a regression test for a bug introduced by commit 72c3c0fe54a3 ("x86/kvm: Use generic xfer to guest work function"), where TIF_NOTIFY_RESUME would be cleared by KVM

[PATCH 5/5] KVM: selftests: Remove __NR_userfaultfd syscall fallback

2021-08-17 Thread Sean Christopherson
Revert the __NR_userfaultfd syscall fallback added for KVM selftests now that x86's unistd_{32,63}.h overrides are under uapi/ and thus not in KVM sefltests' search path, i.e. now that KVM gets x86 syscall numbers from the installed kernel headers. No functional change intended. Cc: Ben Gardon

[PATCH 3/5] tools: Move x86 syscall number fallbacks to .../uapi/

2021-08-17 Thread Sean Christopherson
Move unistd_{32,64}.h from x86/include/asm to x86/include/uapi/asm so that tools/selftests that install kernel headers, e.g. KVM selftests, can include non-uapi tools headers, e.g. to get 'struct list_head', without effectively overriding the installed non-tool uapi headers. Swapping KVM's search

[PATCH 2/5] entry: rseq: Call rseq_handle_notify_resume() in tracehook_notify_resume()

2021-08-17 Thread Sean Christopherson
Invoke rseq_handle_notify_resume() from tracehook_notify_resume() now that the two function are always called back-to-back by architectures that have rseq. The rseq helper is stubbed out for architectures that don't support rseq, i.e. this is a nop across the board. Note,

[PATCH 0/5] KVM: rseq: Fix and a test for a KVM+rseq bug

2021-08-17 Thread Sean Christopherson
Patch 1 fixes a KVM+rseq bug where KVM's handling of TIF_NOTIFY_RESUME, e.g. for task migration, clears the flag without informing rseq and leads to stale data in userspace's rseq struct. Patch 2 is a cleanup to try and make future bugs less likely. It's also a baby step towards moving and

[PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME on xfer to KVM guest

2021-08-17 Thread Sean Christopherson
Invoke rseq's NOTIFY_RESUME handler when processing the flag prior to transferring to a KVM guest, which is roughly equivalent to an exit to userspace and processes many of the same pending actions. While the task cannot be in an rseq critical section as the KVM path is reachable only via

Re: [PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread Xianting TIan
在 2021/8/18 上午11:17, Jiri Slaby 写道: Hi, On 17. 08. 21, 15:22, Xianting Tian wrote: As well known, hvc backend can register its opertions to hvc backend. the opertions contain put_chars(), get_chars() and so on. "operations". And there too: Some hvc backend may do dma in its opertions.

Re: [PATCH/RFC] powerpc/module_64: allow .init_array constructors to run

2021-08-17 Thread Daniel Axtens
Jan Stancek writes: > gcov and kasan rely on compiler generated constructor code. > For modules, gcc-8 with gcov enabled generates .init_array section, > but on ppc64le it doesn't get executed. find_module_sections() never > finds .init_array section, because module_frob_arch_sections() renames

Re: [PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread Jiri Slaby
Hi, On 17. 08. 21, 15:22, Xianting Tian wrote: As well known, hvc backend can register its opertions to hvc backend. the opertions contain put_chars(), get_chars() and so on. "operations". And there too: Some hvc backend may do dma in its opertions. eg, put_chars() of virtio-console. But in

Re: [PATCH] scsi: ibmvfc: Stop using scsi_cmnd.tag

2021-08-17 Thread Bart Van Assche
On 8/17/21 6:43 AM, John Garry wrote: > Use scsi_cmd_to_rq(scsi_cmnd)->tag in preference to scsi_cmnd.tag. Reviewed-by: Bart Van Assche

Re: [PATCH] scsi: ibmvfc: Stop using scsi_cmnd.tag

2021-08-17 Thread Martin K. Petersen
John, > Use scsi_cmd_to_rq(scsi_cmnd)->tag in preference to scsi_cmnd.tag. Applied to 5.15/scsi-staging and rebased for bisectability. Just to be picky it looks like there's another scsi_cmmd tag lurking in qla1280.c but it's sitting behind an #ifdef DEBUG_QLA1280. -- Martin K. Petersen

Re: [PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread Xianting TIan
在 2021/8/17 下午11:48, Greg KH 写道: On Tue, Aug 17, 2021 at 09:22:59PM +0800, Xianting Tian wrote: We tested the patch, it worked normally. Who is "we"? Signed-off-by: Xianting Tian Like I said before, I need another developer from your company to review and sign-off on this patch (and the

Re: [PATCH kernel] KVM: PPC: Book3S HV: Make unique debugfs nodename

2021-08-17 Thread Fabiano Rosas
Alexey Kardashevskiy writes: > On 07/07/2021 14:13, Alexey Kardashevskiy wrote: > alternatively move this debugfs stuff under the platform-independent > directory, how about that? That's a good idea. I only now realized we have two separate directories for the same guest: $ ls

Re: [PATCH v2 06/12] x86/sev: Replace occurrences of sev_active() with prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Tue, Aug 17, 2021 at 10:26:18AM -0500, Tom Lendacky wrote: > >>/* > >> - * If SME is active we need to be sure that kexec pages are > >> - * not encrypted because when we boot to the new kernel the > >> + * If host memory encryption is active we need to be sure that kexec > >> + *

Re: [PATCH v2 05/12] x86/sme: Replace occurrences of sme_active() with prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Tue, Aug 17, 2021 at 09:46:58AM -0500, Tom Lendacky wrote: > I'm ok with letting the TDX folks make changes to these calls to be SME or > SEV specific, if necessary, later. Yap, exactly. Let's add the specific stuff only when really needed. Thx. -- Regards/Gruss, Boris.

Re: [PATCH v2 03/12] x86/sev: Add an x86 version of prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Tue, Aug 17, 2021 at 10:22:52AM -0500, Tom Lendacky wrote: > I can change it to be an AMD/HYGON check... although, I'll have to check > to see if any (very) early use of the function will work with that. We can always change it later if really needed. It is just that I'm not a fan of such

Re: [PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread kernel test robot
Hi Xianting, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on tty/tty-testing] [also build test WARNING on char-misc/char-misc-testing soc/for-next v5.14-rc6 next-20210817] [If your patch is applied to the wrong git tree, kindly drop us a note. And when

Re: [PATCH] macintosh: no need to initilise statics to 0

2021-08-17 Thread Joe Perches
On Tue, 2021-08-17 at 13:59 +0200, Christophe Leroy wrote: > > Le 17/08/2021 à 13:51, Jason Wang a écrit : > > Global static variables dont need to be initialised to 0. Because > > the compiler will initilise them. > > It is not the compiler, it is the Kernel. It is done here: > >

Re: [PATCH] powerpc/32s: Fix random crashes by adding isync() after locking/unlocking KUEP

2021-08-17 Thread Segher Boessenkool
Hi! On Tue, Aug 17, 2021 at 07:13:44PM +0200, Christophe Leroy wrote: > Le 17/08/2021 à 18:22, Segher Boessenkool a écrit : > >On Tue, Aug 17, 2021 at 02:43:15PM +, Christophe Leroy wrote: > >>Commit b5efec00b671 ("powerpc/32s: Move KUEP locking/unlocking in C") > >>removed the 'isync'

Re: [PATCH] macintosh: no need to initilise statics to 0

2021-08-17 Thread Segher Boessenkool
On Tue, Aug 17, 2021 at 01:59:33PM +0200, Christophe Leroy wrote: > > > Le 17/08/2021 à 13:51, Jason Wang a écrit : > >Global static variables dont need to be initialised to 0. Because > >the compiler will initilise them. > > It is not the compiler, it is the Kernel. It is done here: > >

Re: [PATCH] powerpc/32s: Fix random crashes by adding isync() after locking/unlocking KUEP

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 18:22, Segher Boessenkool a écrit : On Tue, Aug 17, 2021 at 02:43:15PM +, Christophe Leroy wrote: Commit b5efec00b671 ("powerpc/32s: Move KUEP locking/unlocking in C") removed the 'isync' instruction after adding/removing NX bit in user segments. The reasoning behind this

Re: [PATCH] powerpc/32s: Fix random crashes by adding isync() after locking/unlocking KUEP

2021-08-17 Thread Segher Boessenkool
On Tue, Aug 17, 2021 at 02:43:15PM +, Christophe Leroy wrote: > Commit b5efec00b671 ("powerpc/32s: Move KUEP locking/unlocking in C") > removed the 'isync' instruction after adding/removing NX bit in user > segments. The reasoning behind this change was that when setting the > NX bit we don't

[PATCH] powerpc/ptrace: Make user_mode() common to PPC32 and PPC64

2021-08-17 Thread Christophe Leroy
Today we have: #ifdef __powerpc64__ #define user_mode(regs) regs)->msr) >> MSR_PR_LG) & 0x1) #else #define user_mode(regs) (((regs)->msr & MSR_PR) != 0) #endif With ppc64_defconfig, we get: if (!user_mode(regs)) 14b4: e9 3e 01 08

Re: [PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread Greg KH
On Tue, Aug 17, 2021 at 09:22:59PM +0800, Xianting Tian wrote: > We tested the patch, it worked normally. Who is "we"? > Signed-off-by: Xianting Tian Like I said before, I need another developer from your company to review and sign-off on this patch (and the other one), before I am willing to

Re: [PATCH v2 09/12] mm: Remove the now unused mem_encrypt_active() function

2021-08-17 Thread Tom Lendacky
On 8/17/21 5:24 AM, Borislav Petkov wrote: > On Tue, Aug 17, 2021 at 12:22:33PM +0200, Borislav Petkov wrote: >> This one wants to be part of the previous patch. > > ... and the three following patches too - the treewide patch does a > single atomic :) replacement and that's it. Ok, I'll squash

Re: [PATCH v2 06/12] x86/sev: Replace occurrences of sev_active() with prot_guest_has()

2021-08-17 Thread Tom Lendacky
On 8/17/21 5:02 AM, Borislav Petkov wrote: > On Fri, Aug 13, 2021 at 11:59:25AM -0500, Tom Lendacky wrote: >> diff --git a/arch/x86/kernel/machine_kexec_64.c >> b/arch/x86/kernel/machine_kexec_64.c >> index 8e7b517ad738..66ff788b79c9 100644 >> --- a/arch/x86/kernel/machine_kexec_64.c >> +++

Re: [PATCH v2 03/12] x86/sev: Add an x86 version of prot_guest_has()

2021-08-17 Thread Tom Lendacky
On 8/15/21 9:39 AM, Borislav Petkov wrote: > On Sun, Aug 15, 2021 at 08:53:31AM -0500, Tom Lendacky wrote: >> It's not a cross-vendor thing as opposed to a KVM or other hypervisor >> thing where the family doesn't have to be reported as AMD or HYGON. > > What would be the use case? A HV starts a

Re: [PATCH v2 05/12] x86/sme: Replace occurrences of sme_active() with prot_guest_has()

2021-08-17 Thread Tom Lendacky
On 8/17/21 4:00 AM, Borislav Petkov wrote: > On Fri, Aug 13, 2021 at 11:59:24AM -0500, Tom Lendacky wrote: >> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c >> index edc67ddf065d..5635ca9a1fbe 100644 >> --- a/arch/x86/mm/mem_encrypt.c >> +++ b/arch/x86/mm/mem_encrypt.c >> @@

[PATCH] powerpc/32s: Fix random crashes by adding isync() after locking/unlocking KUEP

2021-08-17 Thread Christophe Leroy
Commit b5efec00b671 ("powerpc/32s: Move KUEP locking/unlocking in C") removed the 'isync' instruction after adding/removing NX bit in user segments. The reasoning behind this change was that when setting the NX bit we don't mind it taking effect with delay as the kernel never executes text from

Re: [PATCH] powerpc/mm: Fix set_memory_*() against concurrent accesses

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 16:21, Fabiano Rosas a écrit : Michael Ellerman writes: Hi, I already mentioned these things in private, but I'll post here so everyone can see: Because pte_update() takes the set of PTE bits to set and clear we can't use our existing helpers, eg. pte_wrprotect() etc. and

Re: [PATCH] powerpc/mm: Fix set_memory_*() against concurrent accesses

2021-08-17 Thread Fabiano Rosas
Michael Ellerman writes: Hi, I already mentioned these things in private, but I'll post here so everyone can see: > Because pte_update() takes the set of PTE bits to set and clear we can't > use our existing helpers, eg. pte_wrprotect() etc. and instead have to > open code the set of flags. We

Re: [PATCH] powerpc/mm: Fix set_memory_*() against concurrent accesses

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 15:25, Michael Ellerman a écrit : Laurent reported that STRICT_MODULE_RWX was causing intermittent crashes on one of his systems: kernel tried to execute exec-protected page (c00804073278) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch

Re: [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc version of prot_guest_has()

2021-08-17 Thread Tom Lendacky
On 8/17/21 3:35 AM, Borislav Petkov wrote: > On Fri, Aug 13, 2021 at 11:59:23AM -0500, Tom Lendacky wrote: >> Introduce a powerpc version of the prot_guest_has() function. This will >> be used to replace the powerpc mem_encrypt_active() implementation, so >> the implementation will initially only

[PATCH] scsi: ibmvfc: Stop using scsi_cmnd.tag

2021-08-17 Thread John Garry
Use scsi_cmd_to_rq(scsi_cmnd)->tag in preference to scsi_cmnd.tag. Signed-off-by: John Garry --- This patch was missed in a series to remove scsi_cmnd.tag, which caused a build error on Martin's SCSI staging tree:

Re: [PATCH v1 2/4] powerpc/64s/perf: add power_pmu_running to query whether perf is being used

2021-08-17 Thread Michael Ellerman
Nicholas Piggin writes: > Interrupt handling code would like to know whether perf is enabled, to > know whether it should enable MSR[EE] to improve PMI coverage. > > Cc: Madhavan Srinivasan > Cc: Athira Rajeev > Signed-off-by: Nicholas Piggin > --- > arch/powerpc/include/asm/hw_irq.h | 2 ++

[PATCH] powerpc/mm: Fix set_memory_*() against concurrent accesses

2021-08-17 Thread Michael Ellerman
Laurent reported that STRICT_MODULE_RWX was causing intermittent crashes on one of his systems: kernel tried to execute exec-protected page (c00804073278) - exploit attempt? (uid: 0) BUG: Unable to handle kernel instruction fetch Faulting instruction address: 0xc00804073278 Oops:

[PATCH v7 2/2] virtio-console: remove unnecessary kmemdup()

2021-08-17 Thread Xianting Tian
hvc framework will never pass stack memory to the put_chars() function, So the calling of kmemdup() is unnecessary, we can remove it. This revert commit c4baad5029 ("virtio-console: avoid DMA from stack") Signed-off-by: Xianting Tian --- drivers/char/virtio_console.c | 12 ++-- 1 file

[PATCH v7 1/2] tty: hvc: pass DMA capable memory to put_chars()

2021-08-17 Thread Xianting Tian
As well known, hvc backend can register its opertions to hvc backend. the opertions contain put_chars(), get_chars() and so on. Some hvc backend may do dma in its opertions. eg, put_chars() of virtio-console. But in the code of hvc framework, it may pass DMA incapable memory to put_chars() under

[PATCH v7 0/2] make hvc pass dma capable memory to its backend

2021-08-17 Thread Xianting Tian
Dear all, This patch series make hvc framework pass DMA capable memory to put_chars() of hvc backend(eg, virtio-console), and revert commit c4baad5029 ("virtio-console: avoid DMA from stack”) V1 virtio-console: avoid DMA from vmalloc area https://lkml.org/lkml/2021/7/27/494 For v1 patch, Arnd

Re: [PATCH/RFC] powerpc/module_64: allow .init_array constructors to run

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 15:02, Jan Stancek a écrit : gcov and kasan rely on compiler generated constructor code. For modules, gcc-8 with gcov enabled generates .init_array section, but on ppc64le it doesn't get executed. find_module_sections() never finds .init_array section, because

Re: [PATCH v1 2/4] powerpc/64s/perf: add power_pmu_running to query whether perf is being used

2021-08-17 Thread Madhavan Srinivasan
On 8/16/21 12:59 PM, Nicholas Piggin wrote: Interrupt handling code would like to know whether perf is enabled, to know whether it should enable MSR[EE] to improve PMI coverage. Cc: Madhavan Srinivasan Cc: Athira Rajeev Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/hw_irq.h

[PATCH/RFC] powerpc/module_64: allow .init_array constructors to run

2021-08-17 Thread Jan Stancek
gcov and kasan rely on compiler generated constructor code. For modules, gcc-8 with gcov enabled generates .init_array section, but on ppc64le it doesn't get executed. find_module_sections() never finds .init_array section, because module_frob_arch_sections() renames it to _init_array. Avoid

[PATCH] powerpc/head_check: Fix shellcheck errors

2021-08-17 Thread Michael Ellerman
Replace "cat file | grep pattern" with "grep pattern file", and quote a few variables. Together that fixes all shellcheck errors. Signed-off-by: Michael Ellerman --- arch/powerpc/tools/head_check.sh | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git

Re: [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0

2021-08-17 Thread Michael Ellerman
Christophe Leroy writes: > Le 16/08/2021 à 08:44, kajoljain a écrit : >> On 8/14/21 6:14 PM, Michael Ellerman wrote: ... >>> >>> eg. >>> >>> if (use_siar && siar_valid(regs) && siar) >>> return siar + perf_ip_adjust(regs); >>> else if (use_siar) >>> return 0;

Re: [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc version of prot_guest_has()

2021-08-17 Thread Michael Ellerman
Tom Lendacky writes: > Introduce a powerpc version of the prot_guest_has() function. This will > be used to replace the powerpc mem_encrypt_active() implementation, so > the implementation will initially only support the PATTR_MEM_ENCRYPT > attribute. > > Cc: Michael Ellerman > Cc: Benjamin

Re: [PATCH] macintosh: no need to initilise statics to 0

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 13:51, Jason Wang a écrit : Global static variables dont need to be initialised to 0. Because the compiler will initilise them. It is not the compiler, it is the Kernel. It is done here: https://elixir.bootlin.com/linux/v5.14-rc6/source/arch/powerpc/kernel/early_32.c

[PATCH] macintosh: no need to initilise statics to 0

2021-08-17 Thread Jason Wang
Global static variables dont need to be initialised to 0. Because the compiler will initilise them. Signed-off-by: Jason Wang --- drivers/macintosh/mediabay.c | 10 ++--- drivers/macintosh/via-pmu.c | 78 ++-- 2 files changed, 44 insertions(+), 44 deletions(-)

Re: [PATCH v2 09/12] mm: Remove the now unused mem_encrypt_active() function

2021-08-17 Thread Borislav Petkov
On Tue, Aug 17, 2021 at 12:22:33PM +0200, Borislav Petkov wrote: > This one wants to be part of the previous patch. ... and the three following patches too - the treewide patch does a single atomic :) replacement and that's it. -- Regards/Gruss, Boris.

Re: [PATCH v2 09/12] mm: Remove the now unused mem_encrypt_active() function

2021-08-17 Thread Borislav Petkov
On Fri, Aug 13, 2021 at 11:59:28AM -0500, Tom Lendacky wrote: > The mem_encrypt_active() function has been replaced by prot_guest_has(), > so remove the implementation. > > Reviewed-by: Joerg Roedel > Signed-off-by: Tom Lendacky > --- > include/linux/mem_encrypt.h | 4 > 1 file changed, 4

Re: [PATCH v2 07/12] x86/sev: Replace occurrences of sev_es_active() with prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Fri, Aug 13, 2021 at 11:59:26AM -0500, Tom Lendacky wrote: > Replace occurrences of sev_es_active() with the more generic > prot_guest_has() using PATTR_GUEST_PROT_STATE, except for in > arch/x86/kernel/sev*.c and arch/x86/mm/mem_encrypt*.c where PATTR_SEV_ES > will be used. If future support

Re: [PATCH v2 06/12] x86/sev: Replace occurrences of sev_active() with prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Fri, Aug 13, 2021 at 11:59:25AM -0500, Tom Lendacky wrote: > diff --git a/arch/x86/kernel/machine_kexec_64.c > b/arch/x86/kernel/machine_kexec_64.c > index 8e7b517ad738..66ff788b79c9 100644 > --- a/arch/x86/kernel/machine_kexec_64.c > +++ b/arch/x86/kernel/machine_kexec_64.c > @@ -167,7 +167,7

Re: [PATCH 2/3] powerpc: Fix undefined static key

2021-08-17 Thread Christophe Leroy
Le 17/08/2021 à 04:44, Joel Stanley a écrit : On Mon, 16 Aug 2021 at 08:39, Christophe Leroy wrote: Le 16/08/2021 à 10:24, Joel Stanley a écrit : When CONFIG_PPC_BARRIER_NOSPEC=n, security.c is not built leading to a missing definition of uaccess_flush_key. LD vmlinux.o

Re: [PATCH v2 05/12] x86/sme: Replace occurrences of sme_active() with prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Fri, Aug 13, 2021 at 11:59:24AM -0500, Tom Lendacky wrote: > diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c > index edc67ddf065d..5635ca9a1fbe 100644 > --- a/arch/x86/mm/mem_encrypt.c > +++ b/arch/x86/mm/mem_encrypt.c > @@ -144,7 +144,7 @@ void __init sme_unmap_bootdata(char

Re: [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc version of prot_guest_has()

2021-08-17 Thread Borislav Petkov
On Fri, Aug 13, 2021 at 11:59:23AM -0500, Tom Lendacky wrote: > Introduce a powerpc version of the prot_guest_has() function. This will > be used to replace the powerpc mem_encrypt_active() implementation, so > the implementation will initially only support the PATTR_MEM_ENCRYPT > attribute. > >

Re: [PATCH v2 2/2] powerpc/perf: Return regs->nip as instruction pointer value when SIAR is 0

2021-08-17 Thread kajoljain
On 8/17/21 11:07 AM, Madhavan Srinivasan wrote: > > On 8/16/21 12:26 PM, Christophe Leroy wrote: >> >> >> Le 16/08/2021 à 08:44, kajoljain a écrit : >>> >>> >>> On 8/14/21 6:14 PM, Michael Ellerman wrote: Christophe Leroy writes: > Le 13/08/2021 à 10:24, Kajol Jain a écrit : >>

[PATCH v6 11/11] powerpc/pseries/iommu: Rename "direct window" to "dma window"

2021-08-17 Thread Leonardo Bras
A previous change introduced the usage of DDW as a bigger indirect DMA mapping when the DDW available size does not map the whole partition. As most of the code that manipulates direct mappings was reused for indirect mappings, it's necessary to rename all names and debug/info messages to reflect

[PATCH v6 10/11] powerpc/pseries/iommu: Make use of DDW for indirect mapping

2021-08-17 Thread Leonardo Bras
So far it's assumed possible to map the guest RAM 1:1 to the bus, which works with a small number of devices. SRIOV changes it as the user can configure hundreds VFs and since phyp preallocates TCEs and does not allow IOMMU pages bigger than 64K, it has to limit the number of TCEs per a PE to

[PATCH v6 09/11] powerpc/pseries/iommu: Find existing DDW with given property name

2021-08-17 Thread Leonardo Bras
At the moment pseries stores information about created directly mapped DDW window in DIRECT64_PROPNAME. With the objective of implementing indirect DMA mapping with DDW, it's necessary to have another propriety name to make sure kexec'ing into older kernels does not break, as it would if we reuse

[PATCH v6 08/11] powerpc/pseries/iommu: Update remove_dma_window() to accept property name

2021-08-17 Thread Leonardo Bras
Update remove_dma_window() so it can be used to remove DDW with a given property name. This enables the creation of new property names for DDW, so we can have different usage for it, like indirect mapping. Also, add return values to it so we can check if the property was found while removing the

[PATCH v6 07/11] powerpc/pseries/iommu: Reorganize iommu_table_setparms*() with new helper

2021-08-17 Thread Leonardo Bras
Add a new helper _iommu_table_setparms(), and use it in iommu_table_setparms() and iommu_table_setparms_lpar() to avoid duplicated code. Also, setting tbl->it_ops was happening outsite iommu_table_setparms*(), so move it to the new helper. Since we need the iommu_table_ops to be declared before

[PATCH v6 06/11] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2021-08-17 Thread Leonardo Bras
Code used to create a ddw property that was previously scattered in enable_ddw() is now gathered in ddw_property_create(), which deals with allocation and filling the property, letting it ready for of_property_add(), which now occurs in sequence. This created an opportunity to reorganize the

[PATCH v6 05/11] powerpc/pseries/iommu: Allow DDW windows starting at 0x00

2021-08-17 Thread Leonardo Bras
enable_ddw() currently returns the address of the DMA window, which is considered invalid if has the value 0x00. Also, it only considers valid an address returned from find_existing_ddw if it's not 0x00. Changing this behavior makes sense, given the users of enable_ddw() only need to know if

[PATCH v6 04/11] powerpc/pseries/iommu: Add ddw_list_new_entry() helper

2021-08-17 Thread Leonardo Bras
There are two functions creating direct_window_list entries in a similar way, so create a ddw_list_new_entry() to avoid duplicity and simplify those functions. Signed-off-by: Leonardo Bras Reviewed-by: Alexey Kardashevskiy Reviewed-by: Frederic Barrat ---

[PATCH v6 03/11] powerpc/pseries/iommu: Add iommu_pseries_alloc_table() helper

2021-08-17 Thread Leonardo Bras
Creates a helper to allow allocating a new iommu_table without the need to reallocate the iommu_group. This will be helpful for replacing the iommu_table for the new DMA window, after we remove the old one with iommu_tce_table_put(). Signed-off-by: Leonardo Bras Reviewed-by: Alexey

[PATCH v6 02/11] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2021-08-17 Thread Leonardo Bras
Having a function to check if the iommu table has any allocation helps deciding if a tbl can be reset for using a new DMA window. It should be enough to replace all instances of !bitmap_empty(tbl...). iommu_table_in_use() skips reserved memory, so we don't need to worry about releasing it before

[PATCH v6 01/11] powerpc/pseries/iommu: Replace hard-coded page shift

2021-08-17 Thread Leonardo Bras
Some functions assume IOMMU page size can only be 4K (pageshift == 12). Update them to accept any page size passed, so we can use 64K pages. In the process, some defines like TCE_SHIFT were made obsolete, and then removed. IODA3 Revision 3.0_prd1 (OpenPowerFoundation), Figures 3.4 and 3.5 show a

[PATCH v6 00/11] DDW + Indirect Mapping

2021-08-17 Thread Leonardo Bras
So far it's assumed possible to map the guest RAM 1:1 to the bus, which works with a small number of devices. SRIOV changes it as the user can configure hundreds VFs and since phyp preallocates TCEs and does not allow IOMMU pages bigger than 64K, it has to limit the number of TCEs per a PE to

Re: [PATCH v5 08/11] powerpc/pseries/iommu: Update remove_dma_window() to accept property name

2021-08-17 Thread Leonardo Brás
On Tue, 2021-08-17 at 02:59 -0300, Leonardo Brás wrote: > Hello Fred, thanks for the feedback! > > On Tue, 2021-07-20 at 19:51 +0200, Frederic Barrat wrote: > > > > > > On 16/07/2021 10:27, Leonardo Bras wrote: > > > Update remove_dma_window() so it can be used to remove DDW with a > > > given

Re: [PATCH v5 10/11] powerpc/pseries/iommu: Make use of DDW for indirect mapping

2021-08-17 Thread Leonardo Brás
Alexey, Fred: On Fri, 2021-07-23 at 15:34 +1000, Alexey Kardashevskiy wrote: > > > On 22/07/2021 01:04, Frederic Barrat wrote: > > > > > > On 21/07/2021 05:32, Alexey Kardashevskiy wrote: > > > > > +    struct iommu_table *newtbl; > > > > > +    int i; > > > > > + > > > > > +   

Re: [PATCH v5 08/11] powerpc/pseries/iommu: Update remove_dma_window() to accept property name

2021-08-17 Thread Leonardo Brás
Hello Fred, thanks for the feedback! On Tue, 2021-07-20 at 19:51 +0200, Frederic Barrat wrote: > > > On 16/07/2021 10:27, Leonardo Bras wrote: > > Update remove_dma_window() so it can be used to remove DDW with a > > given > > property name. > > > > This enables the creation of new property

Re: [PATCH v5 10/11] powerpc/pseries/iommu: Make use of DDW for indirect mapping

2021-08-17 Thread Leonardo Brás
Hello Alexey, Fred. Thanks for reviewing! On Wed, 2021-07-21 at 13:32 +1000, Alexey Kardashevskiy wrote: > > >     spin_lock(_window_list_lock); > > > > > > > > > > Somewhere around here, we have: > > > > out_remove_win: > >  remove_ddw(pdn, true, DIRECT64_PROPNAME); > > > > We should