[PATCH] Documentation: devices.txt: reconcile serial/ucc_uart minor numers
Reconcile devices.txt with serial/ucc_uart.c regarding device number assignments. ucc_uart.c supports 4 ports and uses minor devnums 46-49, so update devices.txt with that info. Then update ucc_uart.c's reference to the location of the devices.txt list in the kernel source tree. Fixes: d7584ed2b994 ("[POWERPC] qe-uart: add support for Freescale QUICCEngine UART") Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Randy Dunlap Cc: Timur Tabi Cc: Kumar Gala Cc: linuxppc-dev@lists.ozlabs.org Cc: Greg Kroah-Hartman Cc: Jiri Slaby Cc: linux-ser...@vger.kernel.org Cc: Jonathan Corbet Cc: linux-...@vger.kernel.org --- Documentation/admin-guide/devices.txt |2 +- drivers/tty/serial/ucc_uart.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff -- a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c @@ -59,7 +59,7 @@ static int firmware_loaded; /* #define LOOPBACK */ /* The major and minor device numbers are defined in - * http://www.lanana.org/docs/device-list/devices-2.6+.txt. For the QE + * Documentation/admin-guide/devices.txt. For the QE * UART, we have major number 204 and minor numbers 46 - 49, which are the * same as for the CPM2. This decision was made because no Freescale part * has both a CPM and a QE. diff -- a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt --- a/Documentation/admin-guide/devices.txt +++ b/Documentation/admin-guide/devices.txt @@ -2691,7 +2691,7 @@ 45 = /dev/ttyMM1 Marvell MPSC - port 1 (obsolete unused) 46 = /dev/ttyCPM0 PPC CPM (SCC or SMC) - port 0 ... -47 = /dev/ttyCPM5 PPC CPM (SCC or SMC) - port 5 +49 = /dev/ttyCPM5 PPC CPM (SCC or SMC) - port 3 50 = /dev/ttyIOC0 Altix serial card ... 81 = /dev/ttyIOC31 Altix serial card
Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes
On 2023-07-18 at 16:44:51 -0700, Sean Christopherson wrote: > From: Chao Peng > > In confidential computing usages, whether a page is private or shared is > necessary information for KVM to perform operations like page fault > handling, page zapping etc. There are other potential use cases for > per-page memory attributes, e.g. to make memory read-only (or no-exec, > or exec-only, etc.) without having to modify memslots. > > Introduce two ioctls (advertised by KVM_CAP_MEMORY_ATTRIBUTES) to allow > userspace to operate on the per-page memory attributes. > - KVM_SET_MEMORY_ATTRIBUTES to set the per-page memory attributes to > a guest memory range. > - KVM_GET_SUPPORTED_MEMORY_ATTRIBUTES to return the KVM supported > memory attributes. > > Use an xarray to store the per-page attributes internally, with a naive, > not fully optimized implementation, i.e. prioritize correctness over > performance for the initial implementation. > > Because setting memory attributes is roughly analogous to mprotect() on > memory that is mapped into the guest, zap existing mappings prior to > updating the memory attributes. Opportunistically provide an arch hook > for the post-set path (needed to complete invalidation anyways) in > anticipation of x86 needing the hook to update metadata related to > determining whether or not a given gfn can be backed with various sizes > of hugepages. > > It's possible that future usages may not require an invalidation, e.g. > if KVM ends up supporting RWX protections and userspace grants _more_ > protections, but again opt for simplicity and punt optimizations to > if/when they are needed. > > Suggested-by: Sean Christopherson > Link: https://lore.kernel.org/all/y2wb48kd0j4vg...@google.com > Cc: Fuad Tabba > Signed-off-by: Chao Peng > Co-developed-by: Sean Christopherson > Signed-off-by: Sean Christopherson > --- > Documentation/virt/kvm/api.rst | 60 > include/linux/kvm_host.h | 14 +++ > include/uapi/linux/kvm.h | 14 +++ > virt/kvm/Kconfig | 4 + > virt/kvm/kvm_main.c| 170 + > 5 files changed, 262 insertions(+) > Only some trivial concerns below. [...] > @@ -1175,6 +1176,9 @@ static struct kvm *kvm_create_vm(unsigned long type, > const char *fdname) > spin_lock_init(&kvm->mn_invalidate_lock); > rcuwait_init(&kvm->mn_memslots_update_rcuwait); > xa_init(&kvm->vcpu_array); > +#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES > + xa_init(&kvm->mem_attr_array); > +#endif > > INIT_LIST_HEAD(&kvm->gpc_list); > spin_lock_init(&kvm->gpc_lock); > @@ -1346,6 +1350,9 @@ static void kvm_destroy_vm(struct kvm *kvm) > kvm_free_memslots(kvm, &kvm->__memslots[i][0]); > kvm_free_memslots(kvm, &kvm->__memslots[i][1]); > } > +#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES > + xa_destroy(&kvm->mem_attr_array); > +#endif Is it better to make the destruction in reverse order from the creation? To put xa_destroy(&kvm->mem_attr_array) after cleanup_srcu_struct(&kvm->srcu), or put xa_init(&kvm->mem_attr_array) after init_srcu_struct(&kvm->irq_srcu). > cleanup_srcu_struct(&kvm->irq_srcu); > cleanup_srcu_struct(&kvm->srcu); > kvm_arch_free_vm(kvm); > @@ -2346,6 +2353,145 @@ static int kvm_vm_ioctl_clear_dirty_log(struct kvm > *kvm, > } > #endif /* CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT */ [...] > +static int kvm_vm_ioctl_set_mem_attributes(struct kvm *kvm, > +struct kvm_memory_attributes *attrs) > +{ > + gfn_t start, end; > + > + /* flags is currently not used. */ > + if (attrs->flags) > + return -EINVAL; > + if (attrs->attributes & ~kvm_supported_mem_attributes(kvm)) > + return -EINVAL; > + if (attrs->size == 0 || attrs->address + attrs->size < attrs->address) > + return -EINVAL; > + if (!PAGE_ALIGNED(attrs->address) || !PAGE_ALIGNED(attrs->size)) > + return -EINVAL; > + > + start = attrs->address >> PAGE_SHIFT; > + end = (attrs->address + attrs->size - 1 + PAGE_SIZE) >> PAGE_SHIFT; As the attrs->address/size are both garanteed to be non-zero, non-wrap and page aligned in prevous check. Is it OK to simplify the calculation, like: end = (attrs->address + attrs->size) >> PAGE_SHIFT; > + > + if (WARN_ON_ONCE(start == end)) > + return -EINVAL; Also, is this check possible to be hit? Maybe remove it? Thanks, Yilun > + > + /* > + * xarray tracks data using "unsigned long", and as a result so does > + * KVM. For simplicity, supports generic attributes only on 64-bit > + * architectures. > + */ > + BUILD_BUG_ON(sizeof(attrs->attributes) != sizeof(unsigned long)); > + > + return kvm_vm_set_mem_attributes(kvm, attrs->attributes, start, end); > +} > +#endif /* CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES */
[PATCH v3 11/13 fix] mm/khugepaged: delete khugepaged_collapse_pte_mapped_thps(): fix
Though not yet detected by syzbot, this commit was making the same mistake with mmap_locked as the previous commit: fix that. Signed-off-by: Hugh Dickins --- mm/khugepaged.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 1c773db26e88..41913730db4c 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2380,19 +2380,17 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, int *result, mmap_locked = false; *result = hpage_collapse_scan_file(mm, khugepaged_scan.address, file, pgoff, cc); + fput(file); if (*result == SCAN_PTE_MAPPED_HUGEPAGE) { mmap_read_lock(mm); - mmap_locked = true; - if (hpage_collapse_test_exit(mm)) { - fput(file); + if (hpage_collapse_test_exit(mm)) goto breakouterloop; - } *result = collapse_pte_mapped_thp(mm, khugepaged_scan.address, false); if (*result == SCAN_PMD_MAPPED) *result = SCAN_SUCCEED; + mmap_read_unlock(mm); } - fput(file); } else { *result = hpage_collapse_scan_pmd(mm, vma, khugepaged_scan.address, &mmap_locked, cc); -- 2.35.3
[PATCH v3 10/13 fix] mm/khugepaged: collapse_pte_mapped_thp() with mmap_read_lock(): fix
madvise_collapse() setting "mmap_locked = true" after calling collapse_pte_mapped_thp() looked good but was wrong. If the loop then moves on to the next extent, mmap_locked assures it that "vma" has been revalidated under mmap_lock, which was not the case: and led to UAFs, crashes in __fput() or task_work_run(), even collapse_file()'s VM_BUG_ON(start & (HPAGE_PMD_NR - 1)) - all detected by syzbot. (collapse_pte_mapped_thp() does validate the vma that it works on: but it's not passed in as an argument, collapse_pte_mapped_thp() finds the vma for mm and addr by itself - which may by this time have changed from the vma saved in madvise_collapse().) Reported-by: syzbot+fe7b1487405295d29...@syzkaller.appspotmail.com Closes: https://lore.kernel.org/lkml/f9de430600ae0...@google.com/ Reported-by: syzbot+173cc8cfdfbbef6dd...@syzkaller.appspotmail.com Closes: https://lore.kernel.org/linux-mm/e4b0f0060123c...@google.com/ Signed-off-by: Hugh Dickins --- mm/khugepaged.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 6bad69c0e4bd..1c773db26e88 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2747,7 +2747,7 @@ int madvise_collapse(struct vm_area_struct *vma, struct vm_area_struct **prev, BUG_ON(*prev); mmap_read_lock(mm); result = collapse_pte_mapped_thp(mm, addr, true); - mmap_locked = true; + mmap_read_unlock(mm); goto handle_result; /* Whitelisted set of results where continuing OK */ case SCAN_PMD_NULL: -- 2.35.3
[PATCH v3 07/13 fix] s390: add pte_free_defer() for pgtables sharing page: fix
Claudio finds warning on mm_has_pgste() more useful than on mm_alloc_pgste(). Signed-off-by: Hugh Dickins --- arch/s390/mm/pgalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c index 760b4ace475e..d7374add7820 100644 --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -459,7 +459,7 @@ void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable) * page_table_free() does not do the pgste gmap_unlink() which * page_table_free_rcu() does: warn us if pgste ever reaches here. */ - WARN_ON_ONCE(mm_alloc_pgste(mm)); + WARN_ON_ONCE(mm_has_pgste(mm)); } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -- 2.35.3
[PATCH v3 04/13 fix] powerpc: assert_pte_locked() use pte_offset_map_nolock(): fix
Aneesh points out that assert_pte_locked() still needs the pmd_none() check, to stop crashing in khugepaged: restore that comment and check. Andrew, when merging with original commit, please edit its 1st para to: Instead of pte_lockptr(), use the recently added pte_offset_map_nolock() in assert_pte_locked(). BUG if pte_offset_map_nolock() fails. Signed-off-by: Hugh Dickins --- arch/powerpc/mm/pgtable.c | 8 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index 16b061af86d7..a3dcdb2d5b4b 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -323,6 +323,14 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr) pud = pud_offset(p4d, addr); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, addr); + /* +* khugepaged to collapse normal pages to hugepage, first set +* pmd to none to force page fault/gup to take mmap_lock. After +* pmd is set to none, we do a pte_clear which does this assertion +* so if we find pmd none, return. +*/ + if (pmd_none(*pmd)) + return; pte = pte_offset_map_nolock(mm, pmd, addr, &ptl); BUG_ON(!pte); assert_spin_locked(ptl); -- 2.35.3
[powerpc:next-test] BUILD SUCCESS 6391d2478e2f6fc8db2c78f62b13085fd5dfb10e
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next-test branch HEAD: 6391d2478e2f6fc8db2c78f62b13085fd5dfb10e powerpc/64s/radix: combine final TLB flush and lazy tlb mm shootdown IPIs elapsed time: 722m configs tested: 5 configs skipped: 141 The following configs have been built successfully. More configs may be tested in the coming days. tested configs: powerpc allmodconfig gcc powerpc allnoconfig gcc powerpc randconfig-r022-20230723 gcc powerpc randconfig-r032-20230723 clang powerpc randconfig-r034-20230723 clang -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
[powerpc:merge] BUILD SUCCESS 78d5db798c25671640510aaa4b46a3dbee24a63f
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge branch HEAD: 78d5db798c25671640510aaa4b46a3dbee24a63f Automatic merge of 'master' into merge (2023-07-23 11:27) elapsed time: 722m configs tested: 143 configs skipped: 5 The following configs have been built successfully. More configs may be tested in the coming days. tested configs: alphaallyesconfig gcc alpha defconfig gcc alpharandconfig-r015-20230723 gcc alpharandconfig-r021-20230723 gcc arc allyesconfig gcc arc defconfig gcc arc randconfig-r001-20230723 gcc arc randconfig-r011-20230723 gcc arc randconfig-r033-20230723 gcc arc randconfig-r043-20230723 gcc arm allmodconfig gcc arm allyesconfig gcc arm aspeed_g4_defconfig clang arm davinci_all_defconfig clang arm defconfig gcc arm ixp4xx_defconfig clang arm jornada720_defconfig gcc arm randconfig-r003-20230723 gcc arm randconfig-r016-20230723 clang arm randconfig-r034-20230723 gcc arm randconfig-r046-20230723 clang armspear6xx_defconfig gcc arm64allyesconfig gcc arm64 defconfig gcc arm64randconfig-r036-20230723 clang cskydefconfig gcc csky randconfig-r024-20230723 gcc csky randconfig-r026-20230723 gcc hexagon randconfig-r002-20230723 clang hexagon randconfig-r012-20230723 clang hexagon randconfig-r041-20230723 clang hexagon randconfig-r045-20230723 clang i386 allyesconfig gcc i386 buildonly-randconfig-r004-20230723 clang i386 buildonly-randconfig-r005-20230723 clang i386 buildonly-randconfig-r006-20230723 clang i386 debian-10.3 gcc i386defconfig gcc i386 randconfig-i001-20230723 clang i386 randconfig-i002-20230723 clang i386 randconfig-i003-20230723 clang i386 randconfig-i004-20230723 clang i386 randconfig-i005-20230723 clang i386 randconfig-i006-20230723 clang i386 randconfig-i011-20230723 gcc i386 randconfig-i012-20230723 gcc i386 randconfig-i013-20230723 gcc i386 randconfig-i014-20230723 gcc i386 randconfig-i015-20230723 gcc i386 randconfig-i016-20230723 gcc i386 randconfig-r021-20230723 gcc i386 randconfig-r025-20230723 gcc loongarchallmodconfig gcc loongarch allnoconfig gcc loongarch defconfig gcc loongarchrandconfig-r003-20230723 gcc loongarchrandconfig-r011-20230723 gcc loongarchrandconfig-r026-20230723 gcc loongarchrandconfig-r031-20230723 gcc m68k allmodconfig gcc m68k allyesconfig gcc m68kdefconfig gcc microblaze mmu_defconfig gcc microblaze randconfig-r004-20230723 gcc microblaze randconfig-r014-20230723 gcc mips allmodconfig gcc mips allyesconfig gcc mips decstation_64_defconfig gcc mips gcw0_defconfig gcc mips ip28_defconfig clang mips randconfig-r036-20230723 gcc nios2 defconfig gcc nios2randconfig-r031-20230723 gcc openrisc randconfig-r013-20230723 gcc openrisc randconfig-r023-20230723 gcc openrisc randconfig-r032-20230723 gcc parisc allyesconfig gcc parisc defconfig gcc parisc randconfig-r034-20230723 gcc parisc64defconfig gcc powerpc akebono_defconfig clang powerpc allmodconfig gcc powerpc allnoconfig gcc powerpc bamboo_defconfig gcc riscvallmodconfig g