Re: [PATCH 04/21] mm: free_area_init: use maximal zone PFNs rather than zone sizes

2020-06-14 Thread Greg Ungerer

Hi Mike,

From: Mike Rapoport 

Currently, architectures that use free_area_init() to initialize memory map
and node and zone structures need to calculate zone and hole sizes. We can
use free_area_init_nodes() instead and let it detect the zone boundaries
while the architectures will only have to supply the possible limits for
the zones.

Signed-off-by: Mike Rapoport 


This is causing some new warnings for me on boot on at least one non-MMU m68k 
target:

...
NET: Registered protocol family 17
BUG: Bad page state in process swapper  pfn:20165
page:41fe0ca0 refcount:0 mapcount:1 mapping: index:0x0
flags: 0x0()
raw:  0100 0122     
page dumped because: nonzero mapcount
CPU: 0 PID: 1 Comm: swapper Not tainted 5.8.0-rc1-1-g3a38f8a60c65-dirty #1
Stack from 404c9ebc:
404c9ebc 4029ab28 4029ab28 40088470 41fe0ca0 40299e21 40299df1 404ba2a4
00020165  41fd2c10 402c7ba0 41fd2c04 40088504 41fe0ca0 40299e21
 40088a12 41fe0ca0 41fe0ca4 020a  0001 402ca000
 41fe0ca0 41fd2c10 41fd2c10   402b2388 0001
400a0934 40091056 404c9f44 404c9f44 40088db4 402c7ba0 0001 41fd2c04
41fe0ca0 41fd2000 41fe0ca0 40089e02 4026ecf4 40089e4e 41fe0ca0 
Call Trace:
[<40088470>] 0x40088470
 [<40088504>] 0x40088504
 [<40088a12>] 0x40088a12
 [<402ca000>] 0x402ca000
 [<400a0934>] 0x400a0934

[<40091056>] 0x40091056
 [<40088db4>] 0x40088db4
 [<40089e02>] 0x40089e02
 [<4026ecf4>] 0x4026ecf4
 [<40089e4e>] 0x40089e4e

[<4008ca26>] 0x4008ca26
 [<4004adf8>] 0x4004adf8
 [<402701ec>] 0x402701ec
 [<4008f25e>] 0x4008f25e
 [<400516f4>] 0x400516f4

[<4026eec0>] 0x4026eec0
 [<400224f0>] 0x400224f0
 [<402ca000>] 0x402ca000
 [<4026eeda>] 0x4026eeda
 [<40020b00>] 0x40020b00
...

Lots more of them.

...
BUG: Bad page state in process swapper  pfn:201a0
page:41fe1400 refcount:0 mapcount:1 mapping: index:0x0
flags: 0x0()
raw:  0100 0122     
page dumped because: nonzero mapcount
CPU: 0 PID: 1 Comm: swapper Tainted: GB 
5.8.0-rc1-1-g3a38f8a60c65-dirty #1
Stack from 404c9ebc:
404c9ebc 4029ab28 4029ab28 40088470 41fe1400 40299e21 40299df1 404ba2a4
000201a0  41fd2c10 402c7ba0 41fd2c04 40088504 41fe1400 40299e21
 40088a12 41fe1400 41fe1404 020a 003b 0001 4034
 41fe1400 41fd2c10 41fd2c10   41fe13e0 40022826
0044 404c9f44 404c9f44 404c9f44 40088db4 402c7ba0 0001 41fd2c04
41fe1400 41fd2000 41fe1400 40089e02 4026ecf4 40089e4e 41fe1400 
Call Trace:
[<40088470>] 0x40088470
 [<40088504>] 0x40088504
 [<40088a12>] 0x40088a12
 [<40022826>] 0x40022826
 [<40088db4>] 0x40088db4

[<40089e02>] 0x40089e02
 [<4026ecf4>] 0x4026ecf4
 [<40089e4e>] 0x40089e4e
 [<4008ca26>] 0x4008ca26
 [<4004adf8>] 0x4004adf8

[<402701ec>] 0x402701ec
 [<4008f25e>] 0x4008f25e
 [<400516f4>] 0x400516f4
 [<4026eec0>] 0x4026eec0
 [<400224f0>] 0x400224f0

[<402ca000>] 0x402ca000
 [<4026eeda>] 0x4026eeda
 [<40020b00>] 0x40020b00
Freeing unused kernel memory: 648K
This architecture does not have kernel memory protection.
Run /init as init process
...

System boots pretty much as normal through user space after this.
Seems to be fully operational despite all those BUGONs.

Specifically this is a M5208EVB target (arch/m68k/configs/m5208evb).


[snip]

diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index b88d510d4fe3..6d3147662ff2 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -84,7 +84,7 @@ void __init paging_init(void)
 * page_alloc get different views of the world.
 */
unsigned long end_mem = memory_end & PAGE_MASK;
-   unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+   unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
 
 	high_memory = (void *) end_mem;
 
@@ -98,8 +98,8 @@ void __init paging_init(void)

 */
set_fs (USER_DS);
 
-	zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;

-   free_area_init(zones_size);
+   max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
+   free_area_init(max_zone_pfn);


This worries me a little. On this target PAGE_OFFSET will be non-0.

Thoughts?

Regards
Greg





[PATCH V3 4/4] Documentation/mm: Add descriptions for arch page table helpers

2020-06-14 Thread Anshuman Khandual
This adds a specific description file for all arch page table helpers which
is in sync with the semantics being tested via CONFIG_DEBUG_VM_PGTABLE. All
future changes either to these descriptions here or the debug test should
always remain in sync.

Cc: Jonathan Corbet 
Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: Vineet Gupta 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: Christian Borntraeger 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Kirill A. Shutemov 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux-a...@vger.kernel.org
Cc: linux...@kvack.org
Cc: linux-...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Suggested-by: Mike Rapoport 
Signed-off-by: Anshuman Khandual 
---
 Documentation/vm/arch_pgtable_helpers.rst | 258 ++
 mm/debug_vm_pgtable.c |   6 +
 2 files changed, 264 insertions(+)
 create mode 100644 Documentation/vm/arch_pgtable_helpers.rst

diff --git a/Documentation/vm/arch_pgtable_helpers.rst 
b/Documentation/vm/arch_pgtable_helpers.rst
new file mode 100644
index ..cd7609b05446
--- /dev/null
+++ b/Documentation/vm/arch_pgtable_helpers.rst
@@ -0,0 +1,258 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. _arch_page_table_helpers:
+
+===
+Architecture Page Table Helpers
+===
+
+Generic MM expects architectures (with MMU) to provide helpers to create, 
access
+and modify page table entries at various level for different memory functions.
+These page table helpers need to conform to a common semantics across 
platforms.
+Following tables describe the expected semantics which can also be tested 
during
+boot via CONFIG_DEBUG_VM_PGTABLE option. All future changes in here or the 
debug
+test need to be in sync.
+
+==
+PTE Page Table Helpers
+==
+
+
+| pte_same  | Tests whether both PTE entries are the same  
|
+
+| pte_bad   | Tests a non-table mapped PTE 
|
+
+| pte_present   | Tests a valid mapped PTE 
|
+
+| pte_young | Tests a young PTE
|
+
+| pte_dirty | Tests a dirty PTE
|
+
+| pte_write | Tests a writable PTE 
|
+
+| pte_special   | Tests a special PTE  
|
+
+| pte_protnone  | Tests a PROT_NONE PTE
|
+
+| pte_devmap| Tests a ZONE_DEVICE mapped PTE   
|
+
+| pte_soft_dirty| Tests a soft dirty PTE   
|
+
+| pte_swp_soft_dirty| Tests a soft dirty swapped PTE   
|
+
+| pte_mkyoung   | Creates a young PTE  
|
+
+| pte_mkold | Creates an old PTE   
|
+
+| pte_mkdirty   | Creates a dirty PTE  
|
+
+| pte_mkclean   | Creates a clean PTE  
|
+
+| pte_mkwrite   | Creates a writable PTE   
|
+
+| pte_mkwrprotect   | Creates a write protected PTE
|

[PATCH V3 3/4] mm/debug_vm_pgtable: Add debug prints for individual tests

2020-06-14 Thread Anshuman Khandual
This adds debug print information that enlists all tests getting executed
on a given platform. With dynamic debug enabled, the following information
will be splashed during boot. For compactness purpose, dropped both time
stamp and prefix (i.e debug_vm_pgtable) from this sample output.

[debug_vm_pgtable  ]: Validating architecture page table helpers
[pte_basic_tests   ]: Validating PTE basic
[pmd_basic_tests   ]: Validating PMD basic
[p4d_basic_tests   ]: Validating P4D basic
[pgd_basic_tests   ]: Validating PGD basic
[pte_clear_tests   ]: Validating PTE clear
[pmd_clear_tests   ]: Validating PMD clear
[pte_advanced_tests]: Validating PTE advanced
[pmd_advanced_tests]: Validating PMD advanced
[hugetlb_advanced_tests]: Validating HugeTLB advanced
[pmd_leaf_tests]: Validating PMD leaf
[pmd_huge_tests]: Validating PMD huge
[pte_savedwrite_tests  ]: Validating PTE saved write
[pmd_savedwrite_tests  ]: Validating PMD saved write
[pmd_populate_tests]: Validating PMD populate
[pte_special_tests ]: Validating PTE special
[pte_protnone_tests]: Validating PTE protnone
[pmd_protnone_tests]: Validating PMD protnone
[pte_devmap_tests  ]: Validating PTE devmap
[pmd_devmap_tests  ]: Validating PMD devmap
[pte_swap_tests]: Validating PTE swap
[swap_migration_tests  ]: Validating swap migration
[hugetlb_basic_tests   ]: Validating HugeTLB basic
[pmd_thp_tests ]: Validating PMD based THP

Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: Vineet Gupta 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: Christian Borntraeger 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Kirill A. Shutemov 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux...@kvack.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Anshuman Khandual 
---
 mm/debug_vm_pgtable.c | 46 ++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index e3f9f8317a98..536f3b1b3ad6 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -8,7 +8,7 @@
  *
  * Author: Anshuman Khandual 
  */
-#define pr_fmt(fmt) "debug_vm_pgtable: %s: " fmt, __func__
+#define pr_fmt(fmt) "debug_vm_pgtable: [%-25s]: " fmt, __func__
 
 #include 
 #include 
@@ -48,6 +48,7 @@ static void __init pte_basic_tests(unsigned long pfn, 
pgprot_t prot)
 {
pte_t pte = pfn_pte(pfn, prot);
 
+   pr_debug("Validating PTE basic\n");
WARN_ON(!pte_same(pte, pte));
WARN_ON(!pte_young(pte_mkyoung(pte_mkold(pte;
WARN_ON(!pte_dirty(pte_mkdirty(pte_mkclean(pte;
@@ -63,6 +64,7 @@ static void __init pte_advanced_tests(struct mm_struct *mm,
 {
pte_t pte = pfn_pte(pfn, prot);
 
+   pr_debug("Validating PTE advanced\n");
pte = pfn_pte(pfn, prot);
set_pte_at(mm, vaddr, ptep, pte);
ptep_set_wrprotect(mm, vaddr, ptep);
@@ -102,6 +104,7 @@ static void __init pte_savedwrite_tests(unsigned long pfn, 
pgprot_t prot)
 {
pte_t pte = pfn_pte(pfn, prot);
 
+   pr_debug("Validating PTE saved write\n");
WARN_ON(!pte_savedwrite(pte_mk_savedwrite(pte_clear_savedwrite(pte;
WARN_ON(pte_savedwrite(pte_clear_savedwrite(pte_mk_savedwrite(pte;
 }
@@ -113,6 +116,7 @@ static void __init pmd_basic_tests(unsigned long pfn, 
pgprot_t prot)
if (!has_transparent_hugepage())
return;
 
+   pr_debug("Validating PMD basic\n");
WARN_ON(!pmd_same(pmd, pmd));
WARN_ON(!pmd_young(pmd_mkyoung(pmd_mkold(pmd;
WARN_ON(!pmd_dirty(pmd_mkdirty(pmd_mkclean(pmd;
@@ -136,6 +140,7 @@ static void __init pmd_advanced_tests(struct mm_struct *mm,
if (!has_transparent_hugepage())
return;
 
+   pr_debug("Validating PMD advanced\n");
/* Align the address wrt HPAGE_PMD_SIZE */
vaddr = (vaddr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE;
 
@@ -178,6 +183,7 @@ static void __init pmd_leaf_tests(unsigned long pfn, 
pgprot_t prot)
 {
pmd_t pmd = pfn_pmd(pfn, prot);
 
+   pr_debug("Validating PMD leaf\n");
/*
 * PMD based THP is a leaf entry.
 */
@@ -191,6 +197,8 @@ static void __init pmd_huge_tests(pmd_t *pmdp, unsigned 
long pfn, pgprot_t prot)
 
if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
return;
+
+   pr_debug("Validating PMD huge\n");
/*
 * X86 defined pmd_set_huge() verifies that the given
 * PMD is not a populated non-leaf entry.
@@ -206,6 +214,7 @@ static void __init pmd_savedwrite_tests(unsigned long pfn, 
pgprot_t prot)
 {
  

[PATCH V3 2/4] mm/debug_vm_pgtable: Add tests validating advanced arch page table helpers

2020-06-14 Thread Anshuman Khandual
This adds new tests validating for these following arch advanced page table
helpers. These tests create and test specific mapping types at various page
table levels.

1. pxxp_set_wrprotect()
2. pxxp_get_and_clear()
3. pxxp_set_access_flags()
4. pxxp_get_and_clear_full()
5. pxxp_test_and_clear_young()
6. pxx_leaf()
7. pxx_set_huge()
8. pxx_(clear|mk)_savedwrite()
9. huge_pxxp_xxx()

Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: Vineet Gupta 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: Christian Borntraeger 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Kirill A. Shutemov 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux...@kvack.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Suggested-by: Catalin Marinas 
Signed-off-by: Anshuman Khandual 
---
 mm/debug_vm_pgtable.c | 306 ++
 1 file changed, 306 insertions(+)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index ffa163d4c63c..e3f9f8317a98 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define VMFLAGS(VM_READ|VM_WRITE|VM_EXEC)
 
@@ -55,6 +57,54 @@ static void __init pte_basic_tests(unsigned long pfn, 
pgprot_t prot)
WARN_ON(pte_write(pte_wrprotect(pte_mkwrite(pte;
 }
 
+static void __init pte_advanced_tests(struct mm_struct *mm,
+   struct vm_area_struct *vma, pte_t *ptep,
+   unsigned long pfn, unsigned long vaddr, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   pte = pfn_pte(pfn, prot);
+   set_pte_at(mm, vaddr, ptep, pte);
+   ptep_set_wrprotect(mm, vaddr, ptep);
+   pte = READ_ONCE(*ptep);
+   WARN_ON(pte_write(pte));
+
+   pte = pfn_pte(pfn, prot);
+   set_pte_at(mm, vaddr, ptep, pte);
+   ptep_get_and_clear(mm, vaddr, ptep);
+   pte = READ_ONCE(*ptep);
+   WARN_ON(!pte_none(pte));
+
+   pte = pfn_pte(pfn, prot);
+   pte = pte_wrprotect(pte);
+   pte = pte_mkclean(pte);
+   set_pte_at(mm, vaddr, ptep, pte);
+   pte = pte_mkwrite(pte);
+   pte = pte_mkdirty(pte);
+   ptep_set_access_flags(vma, vaddr, ptep, pte, 1);
+   pte = READ_ONCE(*ptep);
+   WARN_ON(!(pte_write(pte) && pte_dirty(pte)));
+
+   pte = pfn_pte(pfn, prot);
+   set_pte_at(mm, vaddr, ptep, pte);
+   ptep_get_and_clear_full(mm, vaddr, ptep, 1);
+   pte = READ_ONCE(*ptep);
+   WARN_ON(!pte_none(pte));
+
+   pte = pte_mkyoung(pte);
+   set_pte_at(mm, vaddr, ptep, pte);
+   ptep_test_and_clear_young(vma, vaddr, ptep);
+   pte = READ_ONCE(*ptep);
+   WARN_ON(pte_young(pte));
+}
+
+static void __init pte_savedwrite_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   WARN_ON(!pte_savedwrite(pte_mk_savedwrite(pte_clear_savedwrite(pte;
+   WARN_ON(pte_savedwrite(pte_clear_savedwrite(pte_mk_savedwrite(pte;
+}
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 static void __init pmd_basic_tests(unsigned long pfn, pgprot_t prot)
 {
@@ -77,6 +127,89 @@ static void __init pmd_basic_tests(unsigned long pfn, 
pgprot_t prot)
WARN_ON(!pmd_bad(pmd_mkhuge(pmd)));
 }
 
+static void __init pmd_advanced_tests(struct mm_struct *mm,
+   struct vm_area_struct *vma, pmd_t *pmdp,
+   unsigned long pfn, unsigned long vaddr, pgprot_t prot)
+{
+   pmd_t pmd = pfn_pmd(pfn, prot);
+
+   if (!has_transparent_hugepage())
+   return;
+
+   /* Align the address wrt HPAGE_PMD_SIZE */
+   vaddr = (vaddr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE;
+
+   pmd = pfn_pmd(pfn, prot);
+   set_pmd_at(mm, vaddr, pmdp, pmd);
+   pmdp_set_wrprotect(mm, vaddr, pmdp);
+   pmd = READ_ONCE(*pmdp);
+   WARN_ON(pmd_write(pmd));
+
+   pmd = pfn_pmd(pfn, prot);
+   set_pmd_at(mm, vaddr, pmdp, pmd);
+   pmdp_huge_get_and_clear(mm, vaddr, pmdp);
+   pmd = READ_ONCE(*pmdp);
+   WARN_ON(!pmd_none(pmd));
+
+   pmd = pfn_pmd(pfn, prot);
+   pmd = pmd_wrprotect(pmd);
+   pmd = pmd_mkclean(pmd);
+   set_pmd_at(mm, vaddr, pmdp, pmd);
+   pmd = pmd_mkwrite(pmd);
+   pmd = pmd_mkdirty(pmd);
+   pmdp_set_access_flags(vma, vaddr, pmdp, pmd, 1);
+   pmd = READ_ONCE(*pmdp);
+   WARN_ON(!(pmd_write(pmd) && pmd_dirty(pmd)));
+
+   pmd = pmd_mkhuge(pfn_pmd(pfn, prot));
+   set_pmd_at(mm, vaddr, pmdp, pmd);
+   pmdp_huge_get_and_clear_full(vma, vaddr, pmdp, 1);
+   pmd = READ_ONCE(*pmdp);
+   

[PATCH V3 1/4] mm/debug_vm_pgtable: Add tests validating arch helpers for core MM features

2020-06-14 Thread Anshuman Khandual
This adds new tests validating arch page table helpers for these following
core memory features. These tests create and test specific mapping types at
various page table levels.

1. SPECIAL mapping
2. PROTNONE mapping
3. DEVMAP mapping
4. SOFTDIRTY mapping
5. SWAP mapping
6. MIGRATION mapping
7. HUGETLB mapping
8. THP mapping

Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: Vineet Gupta 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: Christian Borntraeger 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Kirill A. Shutemov 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux...@kvack.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org
Reviewed-by: Zi Yan 
Suggested-by: Catalin Marinas 
Signed-off-by: Anshuman Khandual 
---
 mm/debug_vm_pgtable.c | 302 +-
 1 file changed, 301 insertions(+), 1 deletion(-)

diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index e45623016aea..ffa163d4c63c 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -282,6 +282,278 @@ static void __init pmd_populate_tests(struct mm_struct 
*mm, pmd_t *pmdp,
WARN_ON(pmd_bad(pmd));
 }
 
+static void __init pte_special_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL))
+   return;
+
+   WARN_ON(!pte_special(pte_mkspecial(pte)));
+}
+
+static void __init pte_protnone_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_NUMA_BALANCING))
+   return;
+
+   WARN_ON(!pte_protnone(pte));
+   WARN_ON(!pte_present(pte));
+}
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+static void __init pmd_protnone_tests(unsigned long pfn, pgprot_t prot)
+{
+   pmd_t pmd = pmd_mkhuge(pfn_pmd(pfn, prot));
+
+   if (!IS_ENABLED(CONFIG_NUMA_BALANCING))
+   return;
+
+   WARN_ON(!pmd_protnone(pmd));
+   WARN_ON(!pmd_present(pmd));
+}
+#else  /* !CONFIG_TRANSPARENT_HUGEPAGE */
+static void __init pmd_protnone_tests(unsigned long pfn, pgprot_t prot) { }
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+
+#ifdef CONFIG_ARCH_HAS_PTE_DEVMAP
+static void __init pte_devmap_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   WARN_ON(!pte_devmap(pte_mkdevmap(pte)));
+}
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+static void __init pmd_devmap_tests(unsigned long pfn, pgprot_t prot)
+{
+   pmd_t pmd = pfn_pmd(pfn, prot);
+
+   WARN_ON(!pmd_devmap(pmd_mkdevmap(pmd)));
+}
+
+#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
+static void __init pud_devmap_tests(unsigned long pfn, pgprot_t prot)
+{
+   pud_t pud = pfn_pud(pfn, prot);
+
+   WARN_ON(!pud_devmap(pud_mkdevmap(pud)));
+}
+#else  /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
+static void __init pud_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+#endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */
+#else  /* CONFIG_TRANSPARENT_HUGEPAGE */
+static void __init pmd_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+static void __init pud_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
+#else
+static void __init pte_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+static void __init pmd_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+static void __init pud_devmap_tests(unsigned long pfn, pgprot_t prot) { }
+#endif /* CONFIG_ARCH_HAS_PTE_DEVMAP */
+
+static void __init pte_soft_dirty_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY))
+   return;
+
+   WARN_ON(!pte_soft_dirty(pte_mksoft_dirty(pte)));
+   WARN_ON(pte_soft_dirty(pte_clear_soft_dirty(pte)));
+}
+
+static void __init pte_swap_soft_dirty_tests(unsigned long pfn, pgprot_t prot)
+{
+   pte_t pte = pfn_pte(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY))
+   return;
+
+   WARN_ON(!pte_swp_soft_dirty(pte_swp_mksoft_dirty(pte)));
+   WARN_ON(pte_swp_soft_dirty(pte_swp_clear_soft_dirty(pte)));
+}
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+static void __init pmd_soft_dirty_tests(unsigned long pfn, pgprot_t prot)
+{
+   pmd_t pmd = pfn_pmd(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY))
+   return;
+
+   WARN_ON(!pmd_soft_dirty(pmd_mksoft_dirty(pmd)));
+   WARN_ON(pmd_soft_dirty(pmd_clear_soft_dirty(pmd)));
+}
+
+static void __init pmd_swap_soft_dirty_tests(unsigned long pfn, pgprot_t prot)
+{
+   pmd_t pmd = pfn_pmd(pfn, prot);
+
+   if (!IS_ENABLED(CONFIG_MEM_SOFT_DIRTY) 

[PATCH V3 0/4] mm/debug_vm_pgtable: Add some more tests

2020-06-14 Thread Anshuman Khandual
This series adds some more arch page table helper validation tests which
are related to core and advanced memory functions. This also creates a
documentation, enlisting expected semantics for all page table helpers as
suggested by Mike Rapoport previously (https://lkml.org/lkml/2020/1/30/40).

There are many TRANSPARENT_HUGEPAGE and ARCH_HAS_TRANSPARENT_HUGEPAGE_PUD
ifdefs scattered across the test. But consolidating all the fallback stubs
is not very straight forward because ARCH_HAS_TRANSPARENT_HUGEPAGE_PUD is
not explicitly dependent on ARCH_HAS_TRANSPARENT_HUGEPAGE.

Tested on arm64, x86 platforms but only build tested on all other enabled
platforms through ARCH_HAS_DEBUG_VM_PGTABLE i.e powerpc, arc, s390. The
following failure on arm64 still exists which was mentioned previously. It
will be fixed with the upcoming THP migration on arm64 enablement series.

WARNING  mm/debug_vm_pgtable.c:860 debug_vm_pgtable+0x940/0xa54
WARN_ON(!pmd_present(pmd_mkinvalid(pmd_mkhuge(pmd

This series is based on v5.8-rc1.

Changes in V3:

- Replaced HAVE_ARCH_SOFT_DIRTY with MEM_SOFT_DIRTY
- Added HAVE_ARCH_HUGE_VMAP checks in pxx_huge_tests() per Gerald
- Updated documentation for pmd_thp_tests() per Zi Yan
- Replaced READ_ONCE() with huge_ptep_get() per Gerald
- Added pte_mkhuge() and masking with PMD_MASK per Gerald
- Replaced pte_same() with holding pfn check in pxx_swap_tests()
- Added documentation for all (#ifdef #else #endif) per Gerald
- Updated pmd_protnone_tests() per Gerald
- Updated HugeTLB PTE creation in hugetlb_advanced_tests() per Gerald
- Replaced [pmd|pud]_mknotpresent() with [pmd|pud]_mkinvalid()
- Added has_transparent_hugepage() check for PMD and PUD tests
- Added a patch which debug prints all individual tests being executed
- Updated documentation for renamed [pmd|pud]_mkinvalid() helpers

Changes in V2: 
(https://patchwork.kernel.org/project/linux-mm/list/?series=260573)

- Dropped CONFIG_ARCH_HAS_PTE_SPECIAL per Christophe
- Dropped CONFIG_NUMA_BALANCING per Christophe
- Dropped CONFIG_HAVE_ARCH_SOFT_DIRTY per Christophe
- Dropped CONFIG_MIGRATION per Christophe
- Replaced CONFIG_S390 with __HAVE_ARCH_PMDP_INVALIDATE
- Moved page allocation & free inside swap_migration_tests() per Christophe
- Added CONFIG_TRANSPARENT_HUGEPAGE to protect pfn_pmd()
- Added CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD to protect pfn_pud()
- Added a patch for other arch advanced page table helper tests
- Added a patch creating a documentation for page table helper semantics

Changes in V1: (https://patchwork.kernel.org/patch/11408253/)

Cc: Jonathan Corbet 
Cc: Andrew Morton 
Cc: Mike Rapoport 
Cc: Vineet Gupta 
Cc: Catalin Marinas 
Cc: Will Deacon 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Heiko Carstens 
Cc: Vasily Gorbik 
Cc: Christian Borntraeger 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Cc: Borislav Petkov 
Cc: "H. Peter Anvin" 
Cc: Kirill A. Shutemov 
Cc: Paul Walmsley 
Cc: Palmer Dabbelt 
Cc: linux-snps-...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s...@vger.kernel.org
Cc: linux-ri...@lists.infradead.org
Cc: x...@kernel.org
Cc: linux...@kvack.org
Cc: linux-...@vger.kernel.org
Cc: linux-a...@vger.kernel.org
Cc: linux-ker...@vger.kernel.org

Anshuman Khandual (4):
  mm/debug_vm_pgtable: Add tests validating arch helpers for core MM features
  mm/debug_vm_pgtable: Add tests validating advanced arch page table helpers
  mm/debug_vm_pgtable: Add debug prints for individual tests
  Documentation/mm: Add descriptions for arch page table helpers

 Documentation/vm/arch_pgtable_helpers.rst | 258 +
 mm/debug_vm_pgtable.c | 660 +-
 2 files changed, 916 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/vm/arch_pgtable_helpers.rst

-- 
2.20.1



[PATCH v2] powerpc/powernv/pci: use ifdef to avoid dead code

2020-06-14 Thread Greg Thelen
Commit dc3d8f85bb57 ("powerpc/powernv/pci: Re-work bus PE
configuration") removed a couple pnv_ioda_setup_bus_dma() calls.  The
only remaining calls are behind CONFIG_IOMMU_API.  Thus builds without
CONFIG_IOMMU_API see:
  arch/powerpc/platforms/powernv/pci-ioda.c:1888:13: error: 
'pnv_ioda_setup_bus_dma' defined but not used

Move pnv_ioda_setup_bus_dma() under CONFIG_IOMMU_API to avoid dead code.

Fixes: dc3d8f85bb57 ("powerpc/powernv/pci: Re-work bus PE configuration")
Signed-off-by: Greg Thelen 
---
 arch/powerpc/platforms/powernv/pci-ioda.c | 26 +++
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 73a63efcf855..743d840712da 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1885,19 +1885,6 @@ static bool pnv_pci_ioda_iommu_bypass_supported(struct 
pci_dev *pdev,
return false;
 }
 
-static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus)
-{
-   struct pci_dev *dev;
-
-   list_for_each_entry(dev, >devices, bus_list) {
-   set_iommu_table_base(>dev, pe->table_group.tables[0]);
-   dev->dev.archdata.dma_offset = pe->tce_bypass_base;
-
-   if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate)
-   pnv_ioda_setup_bus_dma(pe, dev->subordinate);
-   }
-}
-
 static inline __be64 __iomem *pnv_ioda_get_inval_reg(struct pnv_phb *phb,
 bool real_mode)
 {
@@ -2501,6 +2488,19 @@ static long pnv_pci_ioda2_unset_window(struct 
iommu_table_group *table_group,
 #endif
 
 #ifdef CONFIG_IOMMU_API
+static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus)
+{
+   struct pci_dev *dev;
+
+   list_for_each_entry(dev, >devices, bus_list) {
+   set_iommu_table_base(>dev, pe->table_group.tables[0]);
+   dev->dev.archdata.dma_offset = pe->tce_bypass_base;
+
+   if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate)
+   pnv_ioda_setup_bus_dma(pe, dev->subordinate);
+   }
+}
+
 unsigned long pnv_pci_ioda2_get_table_size(__u32 page_shift,
__u64 window_size, __u32 levels)
 {
-- 
2.27.0.290.gba653c62da-goog



Re: [PATCH v2 11/12] x86/mmu: Allocate/free PASID

2020-06-14 Thread Lu Baolu

Hi Fenghua,

On 6/13/20 8:41 AM, Fenghua Yu wrote:

A PASID is allocated for an "mm" the first time any thread attaches
to an SVM capable device. Later device attachments (whether to the same
device or another SVM device) will re-use the same PASID.

The PASID is freed when the process exits (so no need to keep
reference counts on how many SVM devices are sharing the PASID).

Signed-off-by: Fenghua Yu 
Reviewed-by: Tony Luck 
---
v2:
- Define a helper free_bind() to simplify error exit code in bind_mm()
   (Thomas)
- Fix a ret error code in bind_mm() (Thomas)
- Change pasid's type from "int" to "unsigned int" to have consistent
   pasid type in iommu (Thomas)
- Simplify alloc_pasid() a bit.

  arch/x86/include/asm/iommu.h   |   2 +
  arch/x86/include/asm/mmu_context.h |  14 
  drivers/iommu/intel/svm.c  | 101 +
  3 files changed, 105 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index bf1ed2ddc74b..ed41259fe7ac 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -26,4 +26,6 @@ arch_rmrr_sanity_check(struct acpi_dmar_reserved_memory *rmrr)
return -EINVAL;
  }
  
+void __free_pasid(struct mm_struct *mm);

+
  #endif /* _ASM_X86_IOMMU_H */
diff --git a/arch/x86/include/asm/mmu_context.h 
b/arch/x86/include/asm/mmu_context.h
index 47562147e70b..f8c91ce8c451 100644
--- a/arch/x86/include/asm/mmu_context.h
+++ b/arch/x86/include/asm/mmu_context.h
@@ -13,6 +13,7 @@
  #include 
  #include 
  #include 
+#include 
  
  extern atomic64_t last_mm_ctx_id;
  
@@ -117,9 +118,22 @@ static inline int init_new_context(struct task_struct *tsk,

init_new_context_ldt(mm);
return 0;
  }
+
+static inline void free_pasid(struct mm_struct *mm)
+{
+   if (!IS_ENABLED(CONFIG_INTEL_IOMMU_SVM))
+   return;
+
+   if (!cpu_feature_enabled(X86_FEATURE_ENQCMD))
+   return;
+
+   __free_pasid(mm);
+}
+
  static inline void destroy_context(struct mm_struct *mm)
  {
destroy_context_ldt(mm);
+   free_pasid(mm);
  }
  
  extern void switch_mm(struct mm_struct *prev, struct mm_struct *next,

diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index 4e775e12ae52..27dc866b8461 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -425,6 +425,53 @@ int intel_svm_unbind_gpasid(struct device *dev, unsigned 
int pasid)
return ret;
  }
  
+static void free_bind(struct intel_svm *svm, struct intel_svm_dev *sdev,

+ bool new_pasid)
+{
+   if (new_pasid)
+   ioasid_free(svm->pasid);
+   kfree(svm);
+   kfree(sdev);
+}
+
+/*
+ * If this mm already has a PASID, use it. Otherwise allocate a new one.
+ * Let the caller know if a new PASID is allocated via 'new_pasid'.
+ */
+static int alloc_pasid(struct intel_svm *svm, struct mm_struct *mm,
+  unsigned int pasid_max, bool *new_pasid,
+  unsigned int flags)
+{
+   unsigned int pasid;
+
+   *new_pasid = false;
+
+   /*
+* Reuse the PASID if the mm already has a PASID and not a private
+* PASID is requested.
+*/
+   if (mm && mm->pasid && !(flags & SVM_FLAG_PRIVATE_PASID)) {
+   /*
+* Once a PASID is allocated for this mm, the PASID
+* stays with the mm until the mm is dropped. Reuse
+* the PASID which has been already allocated for the
+* mm instead of allocating a new one.
+*/
+   ioasid_set_data(mm->pasid, svm);


How about adding some sanity checks here? For example,

void *p = ioasid_find(NULL, mm->pasid, NULL);

if (!p)
ioasid_set_data(mm->pasid, svm);
else if (IS_ERR(p) || p != svm)
return INVALID_IOSASID;

Best regards,
baolu


Re: [PATCH v2] powerpc/powernv/pci: use ifdef to avoid dead code

2020-06-14 Thread Oliver O'Halloran
On Mon, Jun 15, 2020 at 9:33 AM Greg Thelen  wrote:
>
> Commit dc3d8f85bb57 ("powerpc/powernv/pci: Re-work bus PE
> configuration") removed a couple pnv_ioda_setup_bus_dma() calls.  The
> only remaining calls are behind CONFIG_IOMMU_API.  Thus builds without
> CONFIG_IOMMU_API see:
>   arch/powerpc/platforms/powernv/pci-ioda.c:1888:13: error: 
> 'pnv_ioda_setup_bus_dma' defined but not used
>
> Move pnv_ioda_setup_bus_dma() under CONFIG_IOMMU_API to avoid dead code.

Doh! Thanks for the fix.

Reviewed-by: Oliver O'Halloran 


Re: [PATCH] powerpc/fsl_booke/32: fix build with CONFIG_RANDOMIZE_BASE

2020-06-14 Thread Jason Yan



在 2020/6/14 0:28, Arseny Solokha 写道:

Building the current 5.8 kernel for a e500 machine with
CONFIG_RANDOMIZE_BASE set yields the following failure:

   arch/powerpc/mm/nohash/kaslr_booke.c: In function 'kaslr_early_init':
   arch/powerpc/mm/nohash/kaslr_booke.c:387:2: error: implicit declaration
of function 'flush_icache_range'; did you mean 'flush_tlb_range'?
[-Werror=implicit-function-declaration]

Indeed, including asm/cacheflush.h into kaslr_booke.c fixes the build.

The issue dates back to the introduction of that file and probably went
unnoticed because there's no in-tree defconfig with CONFIG_RANDOMIZE_BASE
set.

Fixes: 2b0e86cc5de6 ("powerpc/fsl_booke/32: implement KASLR infrastructure")
Cc: sta...@vger.kernel.org
Signed-off-by: Arseny Solokha 
---
  arch/powerpc/mm/nohash/kaslr_booke.c | 1 +
  1 file changed, 1 insertion(+)



Reviewed-by: Jason Yan 



Re: PowerPC KVM-PR issue

2020-06-14 Thread Christian Zigotzky

On 14 June 2020 at 04:52 pm, Christian Zigotzky wrote:

On 14 June 2020 at 02:53 pm, Nicholas Piggin wrote:

Excerpts from Christian Zigotzky's message of June 12, 2020 11:01 pm:

On 11 June 2020 at 04:47 pm, Christian Zigotzky wrote:

On 10 June 2020 at 01:23 pm, Christian Zigotzky wrote:

On 10 June 2020 at 11:06 am, Christian Zigotzky wrote:

On 10 June 2020 at 00:18 am, Christian Zigotzky wrote:

Hello,

KVM-PR doesn't work anymore on my Nemo board [1]. I figured out
that the Git kernels and the kernel 5.7 are affected.

Error message: Fienix kernel: kvmppc_exit_pr_progint: emulation at
700 failed ()

I can boot virtual QEMU PowerPC machines with KVM-PR with the
kernel 5.6 without any problems on my Nemo board.

I tested it with QEMU 2.5.0 and QEMU 5.0.0 today.

Could you please check KVM-PR on your PowerPC machine?

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

I figured out that the PowerPC updates 5.7-1 [1] are responsible for
the KVM-PR issue. Please test KVM-PR on your PowerPC machines and
check the PowerPC updates 5.7-1 [1].

Thanks

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969 





I tested the latest Git kernel with Mac-on-Linux/KVM-PR today.
Unfortunately I can't use KVM-PR with MoL anymore because of this
issue (see screenshots [1]). Please check the PowerPC updates 5.7-1.

Thanks

[1]
-
https://i.pinimg.com/originals/0c/b3/64/0cb364a40241fa2b7f297d4272bbb8b7.png 


-
https://i.pinimg.com/originals/9a/61/d1/9a61d170b1c9f514f7a78a3014ffd18f.png 




Hi All,

I bisected today because of the KVM-PR issue.

Result:

9600f261acaaabd476d7833cec2dd20f2919f1a0 is the first bad commit
commit 9600f261acaaabd476d7833cec2dd20f2919f1a0
Author: Nicholas Piggin 
Date:   Wed Feb 26 03:35:21 2020 +1000

 powerpc/64s/exception: Move KVM test to common code

 This allows more code to be moved out of unrelocated regions. The
 system call KVMTEST is changed to be open-coded and remain in the
 tramp area to avoid having to move it to entry_64.S. The custom
nature
 of the system call entry code means the hcall case can be made 
more

 streamlined than regular interrupt handlers.

 mpe: Incorporate fix from Nick:

 Moving KVM test to the common entry code missed the case of 
HMI and
 MCE, which do not do __GEN_COMMON_ENTRY (because they don't 
want to

 switch to virt mode).

 This means a MCE or HMI exception that is taken while KVM is
running a
 guest context will not be switched out of that context, and 
KVM won't
 be notified. Found by running sigfuz in guest with patched 
host on
 POWER9 DD2.3, which causes some TM related HMI interrupts 
(which are

 expected and supposed to be handled by KVM).

 This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers 
to add
 the KVM test. This makes them look a little more like other 
handlers

 that all use __GEN_COMMON_ENTRY.

 Signed-off-by: Nicholas Piggin 
 Signed-off-by: Michael Ellerman 
 Link:
https://lore.kernel.org/r/20200225173541.1549955-13-npig...@gmail.com

:04 04 ec21cec22d165f8696d69532734cb2985d532cb0
87dd49a9cd7202ec79350e8ca26cea01f1dbd93d M    arch

-

The following commit is the problem: powerpc/64s/exception: Move KVM
test to common code [1]

These changes were included in the PowerPC updates 5.7-1. [2]

Another test:

git checkout d38c07afc356ddebaa3ed8ecb3f553340e05c969 (PowerPC updates
5.7-1 [2] ) -> KVM-PR doesn't work.

After that: git revert d38c07afc356ddebaa3ed8ecb3f553340e05c969 -m 1
-> KVM-PR works.

Could you please check the first bad commit? [1]

Thanks,
Christian


[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9600f261acaaabd476d7833cec2dd20f2919f1a0 


[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969 


Hi All,

I tried to revert the __GEN_REALMODE_COMMON_ENTRY fix for the latest 
Git

kernel and for the stable kernel 5.7.2 but without any success. There
was lot of restructuring work during the kernel 5.7 development time in
the PowerPC area so it isn't possible reactivate the old code. That
means we have lost the whole KVM-PR support. I also reported this issue
to Alexander Graf two days ago. He wrote: "Howdy :). It looks pretty
broken. Have you ever made a bisect to see where the problem comes 
from?"


Please check the KVM-PR code.

Does this patch fix it for you?

The CTR register reload in the KVM interrupt path used the wrong save
area for SLB (and NMI) interrupts.

Fixes: 9600f261acaaa ("powerpc/64s/exception: Move KVM test to common 
code")

Reported-by: Christian Zigotzky 
Signed-off-by: Nicholas Piggin 
---
  arch/powerpc/kernel/exceptions-64s.S | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S

index 

Re: [PATCH] scsi: target/sbp: remove firewire SBP target driver

2020-06-14 Thread Finn Thain
On Sun, 14 Jun 2020, Chris Boot wrote:

> I expect that if someone finds this useful it can stick around (but 
> that's not my call).

Who's call is that? If the patch had said "From: Martin K. Petersen" and 
"This driver is being removed because it has the following defects..." 
that would be some indication of a good-faith willingness to accept users 
as developers in the spirit of the GPL, which is what you seem to be 
alluding to (?).

> I just don't have the time or inclination or hardware to be able to 
> maintain it anymore, so someone else would have to pick it up.
> 

Which is why most drivers get orphaned, right?


Re: [PATCH] SUNRPC: Add missing asm/cacheflush.h

2020-06-14 Thread Chuck Lever
Hi Christophe -

> On Jun 14, 2020, at 1:07 PM, Christophe Leroy  
> wrote:
> 
> Even if that's only a warning, not including asm/cacheflush.h
> leads to svc_flush_bvec() being empty allthough powerpc defines
> ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE.
> 
>  CC  net/sunrpc/svcsock.o
> net/sunrpc/svcsock.c:227:5: warning: "ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE" is 
> not defined [-Wundef]
> #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
> ^
> 
> Fixes: ca07eda33e01 ("SUNRPC: Refactor svc_recvfrom()")
> Signed-off-by: Christophe Leroy 
> ---
> I detected this on linux-next on June 4th and warned Chuck. Seems like it 
> went into mainline anyway.

Thanks for your patch. I've searched my mailbox. It appears I never
received your June 4th e-mail.

Does your patch also address:

   https://marc.info/?l=linux-kernel=159194369128024=2 ?

If so, then

   Reported-by: kernel test robot 

should be added to the patch description.

Ideally, compilation on x86_64 should have thrown the same warning,
but it didn't. Why would the x86_64 build behave differently than
ppc64 or i386?


> net/sunrpc/svcsock.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
> index 5c4ec9386f81..d9e99cb09aab 100644
> --- a/net/sunrpc/svcsock.c
> +++ b/net/sunrpc/svcsock.c
> @@ -45,6 +45,7 @@
> #include 
> #include 
> #include 
> +#include 

Nit: Let's include  in net/sunrpc/svcsock.h instead
of  directly.


> #include 
> #include 
> -- 
> 2.25.0
> 

--
Chuck Lever





[PATCH] SUNRPC: Add missing asm/cacheflush.h

2020-06-14 Thread Christophe Leroy
Even if that's only a warning, not including asm/cacheflush.h
leads to svc_flush_bvec() being empty allthough powerpc defines
ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE.

  CC  net/sunrpc/svcsock.o
net/sunrpc/svcsock.c:227:5: warning: "ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE" is not 
defined [-Wundef]
 #if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
 ^

Fixes: ca07eda33e01 ("SUNRPC: Refactor svc_recvfrom()")
Signed-off-by: Christophe Leroy 
---
 I detected this on linux-next on June 4th and warned Chuck. Seems like it went 
into mainline anyway.

 net/sunrpc/svcsock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 5c4ec9386f81..d9e99cb09aab 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
-- 
2.25.0



Re: PowerPC KVM-PR issue

2020-06-14 Thread Christian Zigotzky

On 14 June 2020 at 02:53 pm, Nicholas Piggin wrote:

Excerpts from Christian Zigotzky's message of June 12, 2020 11:01 pm:

On 11 June 2020 at 04:47 pm, Christian Zigotzky wrote:

On 10 June 2020 at 01:23 pm, Christian Zigotzky wrote:

On 10 June 2020 at 11:06 am, Christian Zigotzky wrote:

On 10 June 2020 at 00:18 am, Christian Zigotzky wrote:

Hello,

KVM-PR doesn't work anymore on my Nemo board [1]. I figured out
that the Git kernels and the kernel 5.7 are affected.

Error message: Fienix kernel: kvmppc_exit_pr_progint: emulation at
700 failed ()

I can boot virtual QEMU PowerPC machines with KVM-PR with the
kernel 5.6 without any problems on my Nemo board.

I tested it with QEMU 2.5.0 and QEMU 5.0.0 today.

Could you please check KVM-PR on your PowerPC machine?

Thanks,
Christian

[1] https://en.wikipedia.org/wiki/AmigaOne_X1000

I figured out that the PowerPC updates 5.7-1 [1] are responsible for
the KVM-PR issue. Please test KVM-PR on your PowerPC machines and
check the PowerPC updates 5.7-1 [1].

Thanks

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969



I tested the latest Git kernel with Mac-on-Linux/KVM-PR today.
Unfortunately I can't use KVM-PR with MoL anymore because of this
issue (see screenshots [1]). Please check the PowerPC updates 5.7-1.

Thanks

[1]
-
https://i.pinimg.com/originals/0c/b3/64/0cb364a40241fa2b7f297d4272bbb8b7.png
-
https://i.pinimg.com/originals/9a/61/d1/9a61d170b1c9f514f7a78a3014ffd18f.png


Hi All,

I bisected today because of the KVM-PR issue.

Result:

9600f261acaaabd476d7833cec2dd20f2919f1a0 is the first bad commit
commit 9600f261acaaabd476d7833cec2dd20f2919f1a0
Author: Nicholas Piggin 
Date:   Wed Feb 26 03:35:21 2020 +1000

     powerpc/64s/exception: Move KVM test to common code

     This allows more code to be moved out of unrelocated regions. The
     system call KVMTEST is changed to be open-coded and remain in the
     tramp area to avoid having to move it to entry_64.S. The custom
nature
     of the system call entry code means the hcall case can be made more
     streamlined than regular interrupt handlers.

     mpe: Incorporate fix from Nick:

     Moving KVM test to the common entry code missed the case of HMI and
     MCE, which do not do __GEN_COMMON_ENTRY (because they don't want to
     switch to virt mode).

     This means a MCE or HMI exception that is taken while KVM is
running a
     guest context will not be switched out of that context, and KVM won't
     be notified. Found by running sigfuz in guest with patched host on
     POWER9 DD2.3, which causes some TM related HMI interrupts (which are
     expected and supposed to be handled by KVM).

     This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers to add
     the KVM test. This makes them look a little more like other handlers
     that all use __GEN_COMMON_ENTRY.

     Signed-off-by: Nicholas Piggin 
     Signed-off-by: Michael Ellerman 
     Link:
https://lore.kernel.org/r/20200225173541.1549955-13-npig...@gmail.com

:04 04 ec21cec22d165f8696d69532734cb2985d532cb0
87dd49a9cd7202ec79350e8ca26cea01f1dbd93d M    arch

-

The following commit is the problem: powerpc/64s/exception: Move KVM
test to common code [1]

These changes were included in the PowerPC updates 5.7-1. [2]

Another test:

git checkout d38c07afc356ddebaa3ed8ecb3f553340e05c969 (PowerPC updates
5.7-1 [2] ) -> KVM-PR doesn't work.

After that: git revert d38c07afc356ddebaa3ed8ecb3f553340e05c969 -m 1
-> KVM-PR works.

Could you please check the first bad commit? [1]

Thanks,
Christian


[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9600f261acaaabd476d7833cec2dd20f2919f1a0
[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969

Hi All,

I tried to revert the __GEN_REALMODE_COMMON_ENTRY fix for the latest Git
kernel and for the stable kernel 5.7.2 but without any success. There
was lot of restructuring work during the kernel 5.7 development time in
the PowerPC area so it isn't possible reactivate the old code. That
means we have lost the whole KVM-PR support. I also reported this issue
to Alexander Graf two days ago. He wrote: "Howdy :). It looks pretty
broken. Have you ever made a bisect to see where the problem comes from?"

Please check the KVM-PR code.

Does this patch fix it for you?

The CTR register reload in the KVM interrupt path used the wrong save
area for SLB (and NMI) interrupts.

Fixes: 9600f261acaaa ("powerpc/64s/exception: Move KVM test to common code")
Reported-by: Christian Zigotzky 
Signed-off-by: Nicholas Piggin 
---
  arch/powerpc/kernel/exceptions-64s.S | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index e70ebb5c318c..fa080694e581 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ 

Re: PowerPC KVM-PR issue

2020-06-14 Thread Nicholas Piggin
Excerpts from Christian Zigotzky's message of June 12, 2020 11:01 pm:
> On 11 June 2020 at 04:47 pm, Christian Zigotzky wrote:
>> On 10 June 2020 at 01:23 pm, Christian Zigotzky wrote:
>>> On 10 June 2020 at 11:06 am, Christian Zigotzky wrote:
 On 10 June 2020 at 00:18 am, Christian Zigotzky wrote:
> Hello,
>
> KVM-PR doesn't work anymore on my Nemo board [1]. I figured out 
> that the Git kernels and the kernel 5.7 are affected.
>
> Error message: Fienix kernel: kvmppc_exit_pr_progint: emulation at 
> 700 failed ()
>
> I can boot virtual QEMU PowerPC machines with KVM-PR with the 
> kernel 5.6 without any problems on my Nemo board.
>
> I tested it with QEMU 2.5.0 and QEMU 5.0.0 today.
>
> Could you please check KVM-PR on your PowerPC machine?
>
> Thanks,
> Christian
>
> [1] https://en.wikipedia.org/wiki/AmigaOne_X1000

 I figured out that the PowerPC updates 5.7-1 [1] are responsible for 
 the KVM-PR issue. Please test KVM-PR on your PowerPC machines and 
 check the PowerPC updates 5.7-1 [1].

 Thanks

 [1] 
 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969


>>> I tested the latest Git kernel with Mac-on-Linux/KVM-PR today. 
>>> Unfortunately I can't use KVM-PR with MoL anymore because of this 
>>> issue (see screenshots [1]). Please check the PowerPC updates 5.7-1.
>>>
>>> Thanks
>>>
>>> [1]
>>> - 
>>> https://i.pinimg.com/originals/0c/b3/64/0cb364a40241fa2b7f297d4272bbb8b7.png
>>> - 
>>> https://i.pinimg.com/originals/9a/61/d1/9a61d170b1c9f514f7a78a3014ffd18f.png
>>>
>> Hi All,
>>
>> I bisected today because of the KVM-PR issue.
>>
>> Result:
>>
>> 9600f261acaaabd476d7833cec2dd20f2919f1a0 is the first bad commit
>> commit 9600f261acaaabd476d7833cec2dd20f2919f1a0
>> Author: Nicholas Piggin 
>> Date:   Wed Feb 26 03:35:21 2020 +1000
>>
>>     powerpc/64s/exception: Move KVM test to common code
>>
>>     This allows more code to be moved out of unrelocated regions. The
>>     system call KVMTEST is changed to be open-coded and remain in the
>>     tramp area to avoid having to move it to entry_64.S. The custom 
>> nature
>>     of the system call entry code means the hcall case can be made more
>>     streamlined than regular interrupt handlers.
>>
>>     mpe: Incorporate fix from Nick:
>>
>>     Moving KVM test to the common entry code missed the case of HMI and
>>     MCE, which do not do __GEN_COMMON_ENTRY (because they don't want to
>>     switch to virt mode).
>>
>>     This means a MCE or HMI exception that is taken while KVM is 
>> running a
>>     guest context will not be switched out of that context, and KVM won't
>>     be notified. Found by running sigfuz in guest with patched host on
>>     POWER9 DD2.3, which causes some TM related HMI interrupts (which are
>>     expected and supposed to be handled by KVM).
>>
>>     This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers to add
>>     the KVM test. This makes them look a little more like other handlers
>>     that all use __GEN_COMMON_ENTRY.
>>
>>     Signed-off-by: Nicholas Piggin 
>>     Signed-off-by: Michael Ellerman 
>>     Link: 
>> https://lore.kernel.org/r/20200225173541.1549955-13-npig...@gmail.com
>>
>> :04 04 ec21cec22d165f8696d69532734cb2985d532cb0 
>> 87dd49a9cd7202ec79350e8ca26cea01f1dbd93d M    arch
>>
>> -
>>
>> The following commit is the problem: powerpc/64s/exception: Move KVM 
>> test to common code [1]
>>
>> These changes were included in the PowerPC updates 5.7-1. [2]
>>
>> Another test:
>>
>> git checkout d38c07afc356ddebaa3ed8ecb3f553340e05c969 (PowerPC updates 
>> 5.7-1 [2] ) -> KVM-PR doesn't work.
>>
>> After that: git revert d38c07afc356ddebaa3ed8ecb3f553340e05c969 -m 1 
>> -> KVM-PR works.
>>
>> Could you please check the first bad commit? [1]
>>
>> Thanks,
>> Christian
>>
>>
>> [1] 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9600f261acaaabd476d7833cec2dd20f2919f1a0
>> [2] 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969
> 
> Hi All,
> 
> I tried to revert the __GEN_REALMODE_COMMON_ENTRY fix for the latest Git 
> kernel and for the stable kernel 5.7.2 but without any success. There 
> was lot of restructuring work during the kernel 5.7 development time in 
> the PowerPC area so it isn't possible reactivate the old code. That 
> means we have lost the whole KVM-PR support. I also reported this issue 
> to Alexander Graf two days ago. He wrote: "Howdy :). It looks pretty 
> broken. Have you ever made a bisect to see where the problem comes from?"
> 
> Please check the KVM-PR code.

Does this patch fix it for you?

The CTR register reload in the KVM interrupt path used the wrong save
area for SLB (and NMI) interrupts.

Fixes: 9600f261acaaa ("powerpc/64s/exception: Move KVM test to 

Re: [PATCH] scsi: target/sbp: remove firewire SBP target driver

2020-06-14 Thread Chris Boot
On 14/06/2020 01:03, Finn Thain wrote:
> On Sat, 13 Jun 2020, Chris Boot wrote:
> 
>> I no longer have the time to maintain this subsystem nor the hardware to
>> test patches with. 
> 
> Then why not patch MAINTAINERS, and orphan it, as per usual practice?
> 
> $ git log --oneline MAINTAINERS | grep -i orphan

My patch to remove it was in response to:

https://lore.kernel.org/lkml/yq1img99d4k@ca-mkp.ca.oracle.com/

>> It also doesn't appear to have any active users so I doubt anyone will 
>> miss it.
>>
> 
> It's not unusual that any Linux driver written more than 5 years ago 
> "doesn't appear to have any active users".
> 
> If a driver has been orphaned and broken in the past, and no-one stepped 
> up to fix it within a reasonable period, removal would make sense. But 
> that's not the case here.
> 
> I haven't used this driver for a long time, but I still own PowerMacs with 
> firewire, and I know I'm not the only one.

I expect that if someone finds this useful it can stick around (but
that's not my call). I just don't have the time or inclination or
hardware to be able to maintain it anymore, so someone else would have
to pick it up.

Cheers,
Chris

-- 
Chris Boot
bo...@boo.tc


Re: [PATCH v2 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR

2020-06-14 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of June 10, 2020 10:41 pm:
> Hi Nick
> 
> Le 03/04/2020 à 11:35, Nicholas Piggin a écrit :
>> There is no need to allow user accesses when probing kernel addresses.
> 
> You should have a look at 
> https://github.com/torvalds/linux/commit/fa94111d94354de76c47fea6e1187d1ee91e23a7
> 
> At seems to implement a generic way of achieving what you are trying to 
> do here.

Yep thanks for that, I'll rebase this series on upstream now.

Thanks,
Nick


Re: Linux powerpc new system call instruction and ABI

2020-06-14 Thread Nicholas Piggin
Excerpts from Segher Boessenkool's message of June 12, 2020 7:02 am:
> Hi!
> 
> On Thu, Jun 11, 2020 at 06:12:01PM +1000, Nicholas Piggin wrote:
>> Calling convention
>> --
>> The proposal is for scv 0 to provide the standard Linux system call ABI 
>> with the following differences from sc convention[1]:
>> 
>> - lr is to be volatile across scv calls. This is necessary because the 
>>   scv instruction clobbers lr. From previous discussion, this should be 
>>   possible to deal with in GCC clobbers and CFI.
>> 
>> - cr1 and cr5-cr7 are volatile. This matches the C ABI and would allow the
>>   kernel system call exit to avoid restoring the volatile cr registers
>>   (although we probably still would anyway to avoid information leaks).
>> 
>> - Error handling: The consensus among kernel, glibc, and musl is to move to
>>   using negative return values in r3 rather than CR0[SO]=1 to indicate error,
>>   which matches most other architectures, and is closer to a function call.
> 
> What about cr0 then?  Will it be volatile as well (exactly like for
> function calls)?

Yes, same as for sc (except for SO bit). Which is a bit unclear in this
section.

>> Notes
>> -
>> - r0,r4-r8 are documented as volatile in the ABI, but the kernel patch as
>>   submitted currently preserves them. This is to leave room for deciding
>>   which way to go with these.
> 
> The kernel has to set it to *something* that doesn't leak information ;-)

For "sc" system calls these were defined as volatile (and used to just 
leak information), so now we just zero them.

Thanks,
Nick


Re: [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread

2020-06-14 Thread Nicholas Piggin
Excerpts from Christophe Leroy's message of June 11, 2020 10:26 pm:
> 
> 
> Le 11/06/2020 à 14:11, Nicholas Piggin a écrit :
>> blrl is not recommended to use as an indirect function call, as it may
>> corrupt the link stack predictor.
>> 
>> This is not a performance critical path but this should be fixed for
>> consistency.
> 
> There's exactly the same in entry_32.S
> Should it be changed there too ... for consistency :) ?
> 
> ppc32 also uses blrl for calling syscall handler, should it be changed 
> as well ?

Yes I would say so. I don't know much about 32-bit implementations but
MPC7450 at least has a link stack predictor.

Thanks,
Nick


Re: PowerPC KVM-PR issue

2020-06-14 Thread Nicholas Piggin
Excerpts from Christian Zigotzky's message of June 12, 2020 11:01 pm:
> On 11 June 2020 at 04:47 pm, Christian Zigotzky wrote:
>> On 10 June 2020 at 01:23 pm, Christian Zigotzky wrote:
>>> On 10 June 2020 at 11:06 am, Christian Zigotzky wrote:
 On 10 June 2020 at 00:18 am, Christian Zigotzky wrote:
> Hello,
>
> KVM-PR doesn't work anymore on my Nemo board [1]. I figured out 
> that the Git kernels and the kernel 5.7 are affected.
>
> Error message: Fienix kernel: kvmppc_exit_pr_progint: emulation at 
> 700 failed ()
>
> I can boot virtual QEMU PowerPC machines with KVM-PR with the 
> kernel 5.6 without any problems on my Nemo board.
>
> I tested it with QEMU 2.5.0 and QEMU 5.0.0 today.
>
> Could you please check KVM-PR on your PowerPC machine?
>
> Thanks,
> Christian
>
> [1] https://en.wikipedia.org/wiki/AmigaOne_X1000

 I figured out that the PowerPC updates 5.7-1 [1] are responsible for 
 the KVM-PR issue. Please test KVM-PR on your PowerPC machines and 
 check the PowerPC updates 5.7-1 [1].

 Thanks

 [1] 
 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969


>>> I tested the latest Git kernel with Mac-on-Linux/KVM-PR today. 
>>> Unfortunately I can't use KVM-PR with MoL anymore because of this 
>>> issue (see screenshots [1]). Please check the PowerPC updates 5.7-1.
>>>
>>> Thanks
>>>
>>> [1]
>>> - 
>>> https://i.pinimg.com/originals/0c/b3/64/0cb364a40241fa2b7f297d4272bbb8b7.png
>>> - 
>>> https://i.pinimg.com/originals/9a/61/d1/9a61d170b1c9f514f7a78a3014ffd18f.png
>>>
>> Hi All,
>>
>> I bisected today because of the KVM-PR issue.
>>
>> Result:
>>
>> 9600f261acaaabd476d7833cec2dd20f2919f1a0 is the first bad commit
>> commit 9600f261acaaabd476d7833cec2dd20f2919f1a0
>> Author: Nicholas Piggin 
>> Date:   Wed Feb 26 03:35:21 2020 +1000
>>
>>     powerpc/64s/exception: Move KVM test to common code
>>
>>     This allows more code to be moved out of unrelocated regions. The
>>     system call KVMTEST is changed to be open-coded and remain in the
>>     tramp area to avoid having to move it to entry_64.S. The custom 
>> nature
>>     of the system call entry code means the hcall case can be made more
>>     streamlined than regular interrupt handlers.
>>
>>     mpe: Incorporate fix from Nick:
>>
>>     Moving KVM test to the common entry code missed the case of HMI and
>>     MCE, which do not do __GEN_COMMON_ENTRY (because they don't want to
>>     switch to virt mode).
>>
>>     This means a MCE or HMI exception that is taken while KVM is 
>> running a
>>     guest context will not be switched out of that context, and KVM won't
>>     be notified. Found by running sigfuz in guest with patched host on
>>     POWER9 DD2.3, which causes some TM related HMI interrupts (which are
>>     expected and supposed to be handled by KVM).
>>
>>     This fix adds a __GEN_REALMODE_COMMON_ENTRY for those handlers to add
>>     the KVM test. This makes them look a little more like other handlers
>>     that all use __GEN_COMMON_ENTRY.
>>
>>     Signed-off-by: Nicholas Piggin 
>>     Signed-off-by: Michael Ellerman 
>>     Link: 
>> https://lore.kernel.org/r/20200225173541.1549955-13-npig...@gmail.com
>>
>> :04 04 ec21cec22d165f8696d69532734cb2985d532cb0 
>> 87dd49a9cd7202ec79350e8ca26cea01f1dbd93d M    arch
>>
>> -
>>
>> The following commit is the problem: powerpc/64s/exception: Move KVM 
>> test to common code [1]
>>
>> These changes were included in the PowerPC updates 5.7-1. [2]
>>
>> Another test:
>>
>> git checkout d38c07afc356ddebaa3ed8ecb3f553340e05c969 (PowerPC updates 
>> 5.7-1 [2] ) -> KVM-PR doesn't work.
>>
>> After that: git revert d38c07afc356ddebaa3ed8ecb3f553340e05c969 -m 1 
>> -> KVM-PR works.
>>
>> Could you please check the first bad commit? [1]
>>
>> Thanks,
>> Christian
>>
>>
>> [1] 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9600f261acaaabd476d7833cec2dd20f2919f1a0
>> [2] 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d38c07afc356ddebaa3ed8ecb3f553340e05c969
> 
> Hi All,
> 
> I tried to revert the __GEN_REALMODE_COMMON_ENTRY fix for the latest Git 
> kernel and for the stable kernel 5.7.2 but without any success. There 
> was lot of restructuring work during the kernel 5.7 development time in 
> the PowerPC area so it isn't possible reactivate the old code. That 
> means we have lost the whole KVM-PR support. I also reported this issue 
> to Alexander Graf two days ago. He wrote: "Howdy :). It looks pretty 
> broken. Have you ever made a bisect to see where the problem comes from?"
> 
> Please check the KVM-PR code.

Hey, thanks for debugging it and reporting. I'm looking into it, will 
try to get a fix soon.

Thanks,
Nick


[PATCH] powerpc/perf: fix missing is_sier_aviable() during build

2020-06-14 Thread Madhavan Srinivasan
Compilation error:

arch/powerpc/perf/perf_regs.c:80:undefined reference to `.is_sier_available'

Currently is_sier_available() is part of core-book3s.c.
But then, core-book3s.c is added to build based on
CONFIG_PPC_PERF_CTRS. A config with CONFIG_PERF_EVENTS
and without CONFIG_PPC_PERF_CTRS will have a build break
because of missing is_sier_available(). Patch adds
is_sier_available() in asm/perf_event.h to fix the build
break for configs missing CONFIG_PPC_PERF_CTRS.

Fixes: 333804dc3b7a9 ('powerpc/perf: Update perf_regs structure to include 
SIER")
Reported-by: Aneesh Kumar K.V 
Signed-off-by: Madhavan Srinivasan 
---
 arch/powerpc/include/asm/perf_event.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/include/asm/perf_event.h 
b/arch/powerpc/include/asm/perf_event.h
index eed3954082fa..1e8b2e1ec1db 100644
--- a/arch/powerpc/include/asm/perf_event.h
+++ b/arch/powerpc/include/asm/perf_event.h
@@ -12,6 +12,8 @@
 
 #ifdef CONFIG_PPC_PERF_CTRS
 #include 
+#else
+static inline bool is_sier_available(void) { return false; }
 #endif
 
 #ifdef CONFIG_FSL_EMB_PERF_EVENT
-- 
2.26.2



Re: [PATCH] powerpc/powernv/pci: add ifdef to avoid dead code

2020-06-14 Thread Christophe Leroy

Hi,

Le 14/06/2020 à 07:54, Greg Thelen a écrit :

Commit dc3d8f85bb57 ("powerpc/powernv/pci: Re-work bus PE
configuration") removed a couple pnv_ioda_setup_bus_dma() calls.  The
only remaining calls are behind CONFIG_IOMMU_API.  Thus builds without
CONFIG_IOMMU_API see:
   arch/powerpc/platforms/powernv/pci-ioda.c:1888:13: error: 
'pnv_ioda_setup_bus_dma' defined but not used

Add CONFIG_IOMMU_API ifdef guard to avoid dead code.


I think you should move the function down into the same ifdef as the 
callers instead of adding a new ifdef.


Christophe



Fixes: dc3d8f85bb57 ("powerpc/powernv/pci: Re-work bus PE configuration")
Signed-off-by: Greg Thelen 
---
  arch/powerpc/platforms/powernv/pci-ioda.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c 
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 73a63efcf855..f7762052b7c4 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1885,6 +1885,7 @@ static bool pnv_pci_ioda_iommu_bypass_supported(struct 
pci_dev *pdev,
return false;
  }
  
+#ifdef CONFIG_IOMMU_API

  static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus 
*bus)
  {
struct pci_dev *dev;
@@ -1897,6 +1898,7 @@ static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe 
*pe, struct pci_bus *bus)
pnv_ioda_setup_bus_dma(pe, dev->subordinate);
}
  }
+#endif
  
  static inline __be64 __iomem *pnv_ioda_get_inval_reg(struct pnv_phb *phb,

 bool real_mode)