[powerpc:merge] BUILD SUCCESS f855455dee0b970f3a9d930ec9b3a2a7138c0f5e

2021-11-05 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
merge
branch HEAD: f855455dee0b970f3a9d930ec9b3a2a7138c0f5e  Automatic merge of 
'next' into merge (2021-11-05 22:19)

elapsed time: 797m

configs tested: 53
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nds32 allnoconfig
nds32   defconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
xtensa   allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc   allyesconfig
s390defconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386  debian-10.3
i386 allyesconfig
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc   allnoconfig
powerpc  allmodconfig
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
um   x86_64_defconfig
um i386_defconfig
x86_64   allyesconfig
x86_64rhel-8.3-kselftests
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-func
x86_64  kexec

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


[powerpc:fixes-test] BUILD SUCCESS 11c41994b1c3a7cb08c87883cc19d469258882b6

2021-11-05 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
fixes-test
branch HEAD: 11c41994b1c3a7cb08c87883cc19d469258882b6  KVM: PPC: Book3S HV: Use 
GLOBAL_TOC for kvmppc_h_set_dabr/xdabr()

elapsed time: 740m

configs tested: 32
configs skipped: 53

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
nios2   defconfig
nds32 allnoconfig
arc  allyesconfig
nds32   defconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
nios2allyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
parisc   allyesconfig
s390defconfig
powerpc  allyesconfig
powerpc   allnoconfig
powerpc  allmodconfig
riscvnommu_k210_defconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
um   x86_64_defconfig
um i386_defconfig

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


[powerpc:topic/ppc-kvm] BUILD SUCCESS 235cee162459d96153d63651ce7ff51752528c96

2021-11-05 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
topic/ppc-kvm
branch HEAD: 235cee162459d96153d63651ce7ff51752528c96  KVM: PPC: Tick 
accounting should defer vtime accounting 'til after IRQ handling

elapsed time: 5687m

configs tested: 193
configs skipped: 93

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
i386 randconfig-c001-20211101
powerpc  randconfig-c003-20211101
powerpc  allyesconfig
powerpc powernv_defconfig
armshmobile_defconfig
mipsar7_defconfig
powerpc   currituck_defconfig
sh  landisk_defconfig
mips  malta_defconfig
powerpc tqm8555_defconfig
armcerfcube_defconfig
mipsbcm63xx_defconfig
powerpc  bamboo_defconfig
powerpc  katmai_defconfig
mips decstation_r4k_defconfig
powerpcicon_defconfig
arcnsimosci_defconfig
shecovec24-romimage_defconfig
powerpc kmeter1_defconfig
m68km5307c3_defconfig
mips   mtx1_defconfig
mipsmalta_qemu_32r6_defconfig
powerpc ep8248e_defconfig
sh  sh7785lcr_32bit_defconfig
h8300   h8s-sim_defconfig
powerpc mpc8540_ads_defconfig
powerpc mpc837x_mds_defconfig
arm   spear13xx_defconfig
armmvebu_v7_defconfig
mips  loongson3_defconfig
mips  maltasmvp_defconfig
m68kstmark2_defconfig
arc  axs103_defconfig
arm  pxa3xx_defconfig
sh sh03_defconfig
powerpc taishan_defconfig
ia64  gensparse_defconfig
arm  jornada720_defconfig
mips   sb1250_swarm_defconfig
powerpc   bluestone_defconfig
arm  moxart_defconfig
s390 allmodconfig
riscv allnoconfig
powerpcsam440ep_defconfig
m68k  atari_defconfig
armmmp2_defconfig
mipsjmr3927_defconfig
arm ezx_defconfig
arcvdk_hs38_defconfig
powerpc mpc8272_ads_defconfig
mips   xway_defconfig
shapsh4ad0a_defconfig
xtensa  audio_kc705_defconfig
powerpc  pcm030_defconfig
arm   versatile_defconfig
arm   tegra_defconfig
riscv   defconfig
mips   gcw0_defconfig
arm   corgi_defconfig
shshmin_defconfig
arm s3c2410_defconfig
powerpc  ppc6xx_defconfig
powerpc  acadia_defconfig
armoxnas_v6_defconfig
powerpc  tqm8xx_defconfig
m68k  hp300_defconfig
pariscgeneric-64bit_defconfig
arm  colibri_pxa270_defconfig
xtensa   alldefconfig
armspear6xx_defconfig
mips allmodconfig
powerpc wii_defconfig
mipsvocore2_defconfig
sh magicpanelr2_defconfig
s390  debug_defconfig
powerpc mpc834x_itx_defconfig
arm   h5000_defconfig
arc  alldefconfig
shhp6xx_defconfig
m68kq40_defconfig
arm   aspeed_g5_defconfig
shtitan_defconfig
mips   capcella_defconfig
powerpc tqm8548_defconfig
arm cm_x300_defconfig
powerpc linkstation_defconfig
sh   se7712_defconfig
mips  ath79_defconfig
mips  maltaaprp_defconfig
sh  lboxre2_defconfig
sh   se7206_defconfig
powerpc mpc8313_rdb_defconfig
s390 alldefconfig
ia64zx1_defconfig
powerpc  ep8

[powerpc:next] BUILD SUCCESS c12ab8dbc492b992e1ea717db933cee568780c47

2021-11-05 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
next
branch HEAD: c12ab8dbc492b992e1ea717db933cee568780c47  powerpc/8xx: Fix Oops 
with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST

elapsed time: 5687m

configs tested: 197
configs skipped: 4

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
i386 randconfig-c001-20211101
mips randconfig-c004-20211101
powerpc  randconfig-c003-20211101
powerpc powernv_defconfig
armshmobile_defconfig
mipsar7_defconfig
powerpc   currituck_defconfig
sh  landisk_defconfig
mips  malta_defconfig
powerpc tqm8555_defconfig
armcerfcube_defconfig
mipsbcm63xx_defconfig
powerpc  bamboo_defconfig
powerpc  katmai_defconfig
mips decstation_r4k_defconfig
powerpcicon_defconfig
arcnsimosci_defconfig
shecovec24-romimage_defconfig
powerpc kmeter1_defconfig
m68km5307c3_defconfig
mips   mtx1_defconfig
mipsmalta_qemu_32r6_defconfig
powerpc ep8248e_defconfig
sh  sh7785lcr_32bit_defconfig
h8300   h8s-sim_defconfig
powerpc mpc8540_ads_defconfig
powerpc mpc837x_mds_defconfig
arm   spear13xx_defconfig
armmvebu_v7_defconfig
mips  loongson3_defconfig
mips  maltasmvp_defconfig
m68kstmark2_defconfig
arc  axs103_defconfig
arm  pxa3xx_defconfig
sh sh03_defconfig
powerpc taishan_defconfig
ia64  gensparse_defconfig
arm  jornada720_defconfig
mips   sb1250_swarm_defconfig
powerpc   bluestone_defconfig
arm  moxart_defconfig
riscv allnoconfig
powerpcsam440ep_defconfig
m68k  atari_defconfig
armmmp2_defconfig
mipsjmr3927_defconfig
arm ezx_defconfig
arcvdk_hs38_defconfig
powerpc mpc8272_ads_defconfig
mips   xway_defconfig
shapsh4ad0a_defconfig
xtensa  audio_kc705_defconfig
powerpc  pcm030_defconfig
arm   versatile_defconfig
arm   tegra_defconfig
riscv   defconfig
mips   gcw0_defconfig
arm   corgi_defconfig
shshmin_defconfig
arm s3c2410_defconfig
powerpc  ppc6xx_defconfig
powerpc  acadia_defconfig
armoxnas_v6_defconfig
powerpc  tqm8xx_defconfig
m68k  hp300_defconfig
pariscgeneric-64bit_defconfig
arm  colibri_pxa270_defconfig
xtensa   alldefconfig
armspear6xx_defconfig
mips allmodconfig
powerpc wii_defconfig
mipsvocore2_defconfig
sh magicpanelr2_defconfig
s390  debug_defconfig
powerpc mpc834x_itx_defconfig
arm   h5000_defconfig
arc  alldefconfig
shhp6xx_defconfig
arm cm_x300_defconfig
powerpc linkstation_defconfig
sh   se7712_defconfig
mips  ath79_defconfig
mips  maltaaprp_defconfig
sh  lboxre2_defconfig
sh   se7206_defconfig
powerpc mpc8313_rdb_defconfig
s390 alldefconfig
ia64zx1_defconfig
powerpc  ep88xc_defconfig
arm   spitz_defconfig
ia64generic_defconfig
arm   omap1_defconfig
sh   sh2007_defconfig
shsh7785lcr_defconfig
m68k  multi_defconfig
sh   

[PATCH 5/5] KVM: Convert the kvm->vcpus array to a xarray

2021-11-05 Thread Marc Zyngier
At least on arm64 and x86, the vcpus array is pretty huge (512 entries),
and is mostly empty in most cases (running 512 vcpu VMs is not that
common). This mean that we end-up with a 4kB block of unused memory
in the middle of the kvm structure.

Instead of wasting away this memory, let's use an xarray instead,
which gives us almost the same flexibility as a normal array, but
with a reduced memory usage with smaller VMs.

Signed-off-by: Marc Zyngier 
---
 include/linux/kvm_host.h |  5 +++--
 virt/kvm/kvm_main.c  | 15 +--
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 36967291b8c6..3933d825e28b 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -552,7 +553,7 @@ struct kvm {
struct mutex slots_arch_lock;
struct mm_struct *mm; /* userspace tied to this vm */
struct kvm_memslots __rcu *memslots[KVM_ADDRESS_SPACE_NUM];
-   struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
+   struct xarray vcpu_array;
 
/* Used to wait for completion of MMU notifiers.  */
spinlock_t mn_invalidate_lock;
@@ -693,7 +694,7 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm 
*kvm, int i)
 
/* Pairs with smp_wmb() in kvm_vm_ioctl_create_vcpu.  */
smp_rmb();
-   return kvm->vcpus[i];
+   return xa_load(&kvm->vcpu_array, i);
 }
 
 #define kvm_for_each_vcpu(idx, vcpup, kvm) \
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index d83553eeea21..4c18d7911fa5 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -461,7 +461,7 @@ void kvm_destroy_vcpus(struct kvm *kvm)
 
mutex_lock(&kvm->lock);
for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
-   kvm->vcpus[i] = NULL;
+   xa_erase(&kvm->vcpu_array, i);
 
atomic_set(&kvm->online_vcpus, 0);
mutex_unlock(&kvm->lock);
@@ -1066,6 +1066,7 @@ static struct kvm *kvm_create_vm(unsigned long type)
mutex_init(&kvm->slots_arch_lock);
spin_lock_init(&kvm->mn_invalidate_lock);
rcuwait_init(&kvm->mn_memslots_update_rcuwait);
+   xa_init(&kvm->vcpu_array);
 
INIT_LIST_HEAD(&kvm->devices);
 
@@ -3661,7 +3662,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 
id)
}
 
vcpu->vcpu_idx = atomic_read(&kvm->online_vcpus);
-   BUG_ON(kvm->vcpus[vcpu->vcpu_idx]);
+   r = xa_insert(&kvm->vcpu_array, vcpu->vcpu_idx, vcpu, 
GFP_KERNEL_ACCOUNT);
+   BUG_ON(r == -EBUSY);
+   if (r)
+   goto unlock_vcpu_destroy;
 
/* Fill the stats id string for the vcpu */
snprintf(vcpu->stats_id, sizeof(vcpu->stats_id), "kvm-%d/vcpu-%d",
@@ -3671,15 +3675,14 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, 
u32 id)
kvm_get_kvm(kvm);
r = create_vcpu_fd(vcpu);
if (r < 0) {
+   xa_erase(&kvm->vcpu_array, vcpu->vcpu_idx);
kvm_put_kvm_no_destroy(kvm);
goto unlock_vcpu_destroy;
}
 
-   kvm->vcpus[vcpu->vcpu_idx] = vcpu;
-
/*
-* Pairs with smp_rmb() in kvm_get_vcpu.  Write kvm->vcpus
-* before kvm->online_vcpu's incremented value.
+* Pairs with smp_rmb() in kvm_get_vcpu.  Store the vcpu
+* pointer before kvm->online_vcpu's incremented value.
 */
smp_wmb();
atomic_inc(&kvm->online_vcpus);
-- 
2.30.2



[PATCH 1/5] KVM: Move wiping of the kvm->vcpus array to common code

2021-11-05 Thread Marc Zyngier
All architectures have similar loops iterating over the vcpus,
freeing one vcpu at a time, and eventually wiping the reference
off the vcpus array. They are also inconsistently taking
the kvm->lock mutex when wiping the references from the array.

Make this code common, which will simplify further changes.

Signed-off-by: Marc Zyngier 
---
 arch/arm64/kvm/arm.c   | 10 +-
 arch/mips/kvm/mips.c   | 21 +
 arch/powerpc/kvm/powerpc.c | 10 +-
 arch/riscv/kvm/vm.c| 10 +-
 arch/s390/kvm/kvm-s390.c   | 18 +-
 arch/x86/kvm/x86.c |  9 +
 include/linux/kvm_host.h   |  2 +-
 virt/kvm/kvm_main.c| 20 ++--
 8 files changed, 25 insertions(+), 75 deletions(-)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index f5490afe1ebf..75bb7215da03 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -175,19 +175,11 @@ vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, 
struct vm_fault *vmf)
  */
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
-   int i;
-
bitmap_free(kvm->arch.pmu_filter);
 
kvm_vgic_destroy(kvm);
 
-   for (i = 0; i < KVM_MAX_VCPUS; ++i) {
-   if (kvm->vcpus[i]) {
-   kvm_vcpu_destroy(kvm->vcpus[i]);
-   kvm->vcpus[i] = NULL;
-   }
-   }
-   atomic_set(&kvm->online_vcpus, 0);
+   kvm_destroy_vcpus(kvm);
 }
 
 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 562aa878b266..ceacca74f808 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -171,25 +171,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
return 0;
 }
 
-void kvm_mips_free_vcpus(struct kvm *kvm)
-{
-   unsigned int i;
-   struct kvm_vcpu *vcpu;
-
-   kvm_for_each_vcpu(i, vcpu, kvm) {
-   kvm_vcpu_destroy(vcpu);
-   }
-
-   mutex_lock(&kvm->lock);
-
-   for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
-   kvm->vcpus[i] = NULL;
-
-   atomic_set(&kvm->online_vcpus, 0);
-
-   mutex_unlock(&kvm->lock);
-}
-
 static void kvm_mips_free_gpa_pt(struct kvm *kvm)
 {
/* It should always be safe to remove after flushing the whole range */
@@ -199,7 +180,7 @@ static void kvm_mips_free_gpa_pt(struct kvm *kvm)
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
-   kvm_mips_free_vcpus(kvm);
+   kvm_destroy_vcpus(kvm);
kvm_mips_free_gpa_pt(kvm);
 }
 
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 35e9cccdeef9..492e4a4121cb 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -463,9 +463,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
-   unsigned int i;
-   struct kvm_vcpu *vcpu;
-
 #ifdef CONFIG_KVM_XICS
/*
 * We call kick_all_cpus_sync() to ensure that all
@@ -476,14 +473,9 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
kick_all_cpus_sync();
 #endif
 
-   kvm_for_each_vcpu(i, vcpu, kvm)
-   kvm_vcpu_destroy(vcpu);
+   kvm_destroy_vcpus(kvm);
 
mutex_lock(&kvm->lock);
-   for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
-   kvm->vcpus[i] = NULL;
-
-   atomic_set(&kvm->online_vcpus, 0);
 
kvmppc_core_destroy_vm(kvm);
 
diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c
index 26399df15b63..6af6cde295eb 100644
--- a/arch/riscv/kvm/vm.c
+++ b/arch/riscv/kvm/vm.c
@@ -46,15 +46,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
-   int i;
-
-   for (i = 0; i < KVM_MAX_VCPUS; ++i) {
-   if (kvm->vcpus[i]) {
-   kvm_vcpu_destroy(kvm->vcpus[i]);
-   kvm->vcpus[i] = NULL;
-   }
-   }
-   atomic_set(&kvm->online_vcpus, 0);
+   kvm_destroy_vcpus(kvm);
 }
 
 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c6257f625929..7af53b8788fa 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -2819,27 +2819,11 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
free_page((unsigned long)(vcpu->arch.sie_block));
 }
 
-static void kvm_free_vcpus(struct kvm *kvm)
-{
-   unsigned int i;
-   struct kvm_vcpu *vcpu;
-
-   kvm_for_each_vcpu(i, vcpu, kvm)
-   kvm_vcpu_destroy(vcpu);
-
-   mutex_lock(&kvm->lock);
-   for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
-   kvm->vcpus[i] = NULL;
-
-   atomic_set(&kvm->online_vcpus, 0);
-   mutex_unlock(&kvm->lock);
-}
-
 void kvm_arch_destroy_vm(struct kvm *kvm)
 {
u16 rc, rrc;
 
-   kvm_free_vcpus(kvm);
+   kvm_destroy_vcpus(kvm);
sca_dispose(kvm);
kvm_s390_gisa_destroy(kvm);
/*
diff

[PATCH 4/5] KVM: x86: Use kvm_get_vcpu() instead of open-coded access

2021-11-05 Thread Marc Zyngier
As we are about to change the way vcpus are allocated, mandate
the use of kvm_get_vcpu() instead of open-coding the access.

Signed-off-by: Marc Zyngier 
---
 arch/x86/kvm/vmx/posted_intr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/posted_intr.c b/arch/x86/kvm/vmx/posted_intr.c
index 5f81ef092bd4..82a49720727d 100644
--- a/arch/x86/kvm/vmx/posted_intr.c
+++ b/arch/x86/kvm/vmx/posted_intr.c
@@ -272,7 +272,7 @@ int pi_update_irte(struct kvm *kvm, unsigned int host_irq, 
uint32_t guest_irq,
 
if (!kvm_arch_has_assigned_device(kvm) ||
!irq_remapping_cap(IRQ_POSTING_CAP) ||
-   !kvm_vcpu_apicv_active(kvm->vcpus[0]))
+   !kvm_vcpu_apicv_active(kvm_get_vcpu(kvm, 0)))
return 0;
 
idx = srcu_read_lock(&kvm->irq_srcu);
-- 
2.30.2



[PATCH 3/5] KVM: s390: Use kvm_get_vcpu() instead of open-coded access

2021-11-05 Thread Marc Zyngier
As we are about to change the way vcpus are allocated, mandate
the use of kvm_get_vcpu() instead of open-coding the access.

Signed-off-by: Marc Zyngier 
---
 arch/s390/kvm/kvm-s390.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 7af53b8788fa..4a0f62b03964 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -4572,7 +4572,7 @@ int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu)
}
 
for (i = 0; i < online_vcpus; i++) {
-   if (!is_vcpu_stopped(vcpu->kvm->vcpus[i]))
+   if (!is_vcpu_stopped(kvm_get_vcpu(vcpu->kvm, i)))
started_vcpus++;
}
 
@@ -4634,9 +4634,11 @@ int kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu)
__disable_ibs_on_vcpu(vcpu);
 
for (i = 0; i < online_vcpus; i++) {
-   if (!is_vcpu_stopped(vcpu->kvm->vcpus[i])) {
+   struct kvm_vcpu *tmp = kvm_get_vcpu(vcpu->kvm, i);
+
+   if (!is_vcpu_stopped(tmp)) {
started_vcpus++;
-   started_vcpu = vcpu->kvm->vcpus[i];
+   started_vcpu = tmp;
}
}
 
-- 
2.30.2



[PATCH 0/5] KVM: Turn the vcpu array into an xarray

2021-11-05 Thread Marc Zyngier
The kvm structure is pretty large. A large portion of it is the vcpu
array, which is 4kB on x86_64 and arm64 as they deal with 512 vcpu
VMs. Of course, hardly anyone runs VMs this big, so this is often a
net waste of memory and cache locality.

A possible approach is to turn the fixed-size array into an xarray,
which results in a net code deletion after a bit of cleanup.

This series is on top of the current linux/master as it touches the
RISC-V implementation. Only tested on arm64.

Marc Zyngier (5):
  KVM: Move wiping of the kvm->vcpus array to common code
  KVM: mips: Use kvm_get_vcpu() instead of open-coded access
  KVM: s390: Use kvm_get_vcpu() instead of open-coded access
  KVM: x86: Use kvm_get_vcpu() instead of open-coded access
  KVM: Convert the kvm->vcpus array to a xarray

 arch/arm64/kvm/arm.c   | 10 +-
 arch/mips/kvm/loongson_ipi.c   |  4 ++--
 arch/mips/kvm/mips.c   | 23 ++-
 arch/powerpc/kvm/powerpc.c | 10 +-
 arch/riscv/kvm/vm.c| 10 +-
 arch/s390/kvm/kvm-s390.c   | 26 ++
 arch/x86/kvm/vmx/posted_intr.c |  2 +-
 arch/x86/kvm/x86.c |  9 +
 include/linux/kvm_host.h   |  7 ---
 virt/kvm/kvm_main.c| 33 ++---
 10 files changed, 45 insertions(+), 89 deletions(-)

-- 
2.30.2



[PATCH 2/5] KVM: mips: Use kvm_get_vcpu() instead of open-coded access

2021-11-05 Thread Marc Zyngier
As we are about to change the way vcpus are allocated, mandate
the use of kvm_get_vcpu() instead of open-coding the access.

Signed-off-by: Marc Zyngier 
---
 arch/mips/kvm/loongson_ipi.c | 4 ++--
 arch/mips/kvm/mips.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kvm/loongson_ipi.c b/arch/mips/kvm/loongson_ipi.c
index 3681fc8fba38..5d53f32d837c 100644
--- a/arch/mips/kvm/loongson_ipi.c
+++ b/arch/mips/kvm/loongson_ipi.c
@@ -120,7 +120,7 @@ static int loongson_vipi_write(struct loongson_kvm_ipi *ipi,
s->status |= data;
irq.cpu = id;
irq.irq = 6;
-   kvm_vcpu_ioctl_interrupt(kvm->vcpus[id], &irq);
+   kvm_vcpu_ioctl_interrupt(kvm_get_vcpu(kvm, id), &irq);
break;
 
case CORE0_CLEAR_OFF:
@@ -128,7 +128,7 @@ static int loongson_vipi_write(struct loongson_kvm_ipi *ipi,
if (!s->status) {
irq.cpu = id;
irq.irq = -6;
-   kvm_vcpu_ioctl_interrupt(kvm->vcpus[id], &irq);
+   kvm_vcpu_ioctl_interrupt(kvm_get_vcpu(kvm, id), &irq);
}
break;
 
diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index ceacca74f808..6228bf396d63 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -479,7 +479,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
if (irq->cpu == -1)
dvcpu = vcpu;
else
-   dvcpu = vcpu->kvm->vcpus[irq->cpu];
+   dvcpu = kvm_get_vcpu(vcpu->kvm, irq->cpu);
 
if (intr == 2 || intr == 3 || intr == 4 || intr == 6) {
kvm_mips_callbacks->queue_io_int(dvcpu, irq);
-- 
2.30.2



Re: [PATCH] drm/virtio: Fix NULL dereference error in virtio_gpu_poll

2021-11-05 Thread Christian Zigotzky

On 04 November 2021 at 10:42 pm, Vivek Kasireddy wrote:

> When virgl is not enabled, vfpriv pointer would not be allocated.
> Therefore, check for a valid value before dereferencing.
>
> Reported-by: Christian Zigotzky 
> Cc: Gurchetan Singh 
> Cc: Gerd Hoffmann 
> Signed-off-by: Vivek Kasireddy 
> ---
>  drivers/gpu/drm/virtio/virtgpu_drv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c 
b/drivers/gpu/drm/virtio/virtgpu_drv.c

> index 749db18dcfa2..d86e1ad4a972 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> @@ -163,10 +163,11 @@ static __poll_t virtio_gpu_poll(struct file *filp,
>  struct drm_file *drm_file = filp->private_data;
>  struct virtio_gpu_fpriv *vfpriv = drm_file->driver_priv;
>  struct drm_device *dev = drm_file->minor->dev;
> +    struct virtio_gpu_device *vgdev = dev->dev_private;
>  struct drm_pending_event *e = NULL;
>  __poll_t mask = 0;
>
> -    if (!vfpriv->ring_idx_mask)
> +    if (!vgdev->has_virgl_3d || !vfpriv || !vfpriv->ring_idx_mask)
>      return drm_poll(filp, wait);
>
>  poll_wait(filp, &drm_file->event_wait, wait);

Tested-by: Christian Zigotzky  [1]

[1] https://i.ibb.co/N1vL5Kd/Kernel-5-16-alpha3-Power-PC.png


Re: Fwd: Fwd: X stopped working with 5.14 on iBook

2021-11-05 Thread Segher Boessenkool
On Fri, Nov 05, 2021 at 10:36:18AM +1100, Finn Thain wrote:
> There is no __get_user_asm2_goto in this tree, and __get_user_asm2 already
> has the "=&r" constraint:
> 
> #define __get_user_asm2(x, addr, err)   \
> __asm__ __volatile__(   \
> "1: lwz%X2 %1, %2\n"\
> "2: lwz%X2 %L1, %L2\n"  \
> "3:\n"  \
> ".section .fixup,\"ax\"\n"  \
> "4: li %0,%3\n" \
> "   li %1,0\n"  \
> "   li %1+1,0\n"\
> "   b 3b\n" \
> ".previous\n"   \
> EX_TABLE(1b, 4b)\
> EX_TABLE(2b, 4b)\
> : "=r" (err), "=&r" (x) \
> : "m" (*addr), "i" (-EFAULT), "0" (err)) 

operand 0 needs an earlyclobber as well, in principle.  But there is
nothing left it can be tied to, so this won't change generated code.

What is operand 4 about?  It isn't used?

The "%1+1" can be written %L1 btw (it means exactly the same thing, but
work on more configs).


Segher


Re: Fwd: Fwd: X stopped working with 5.14 on iBook

2021-11-05 Thread Christophe Leroy




Le 05/11/2021 à 00:36, Finn Thain a écrit :

On Thu, 4 Nov 2021, Christophe Leroy wrote:


Le 02/11/2021 à 03:20, Finn Thain a écrit :

Hi Christopher,

After many builds and tests, Stan and I were able to determine that this
regression only affects builds with CONFIG_USER_NS=y. That is,

d3ccc9781560  + CONFIG_USER_NS=y  -->  fail
d3ccc9781560  + CONFIG_USER_NS=n  -->  okay
d3ccc9781560~ + CONFIG_USER_NS=y  -->  okay
d3ccc9781560~ + CONFIG_USER_NS=n  -->  okay

Stan also tested a PowerMac G3 system and found that the regression is not
present there. Thus far, only PowerMac G4 systems are known to be affected
(Stan's Cube and Riccardo's PowerBook).

I asked Stan to try v5.15-rc after reverting commit d3ccc9781560.
Unexpectedly, this build had the same issue. So, it appears there are
multiple bad commits that produce this Xorg failure, of which d3ccc9781560
is just the first.

But there's no easy way to identify the other bad commits using bisection.
So I've addressed this message to you. Can you help fix this regression?



I'm wondering if this commit is really the cause of the problem.

Are you using GCC 11 ?

If yes, I think it could be a false positive, fixed by
https://github.com/linuxppc/linux/commit/7315e457d6bc

Can you try with GCC 10 or older ?



AFAIK, all of Stan's builds were made with gcc 10.


Can you cherry pick 7315e457d6bc ("powerpc/uaccess: Fix __get_user() with
CONFIG_CC_HAS_ASM_GOTO_OUTPUT") on top of d3ccc9781560 and see what happens ?



$ git checkout d3ccc9781560
$ git cherry-pick 7315e457d6bc
Auto-merging arch/powerpc/include/asm/uaccess.h
CONFLICT (content): Merge conflict in arch/powerpc/include/asm/uaccess.h
error: could not apply 7315e457d6bc... powerpc/uaccess: Fix __get_user() with 
CONFIG_CC_HAS_ASM_GOTO_OUTPUT

There is no __get_user_asm2_goto in this tree, and __get_user_asm2 already
has the "=&r" constraint:

#define __get_user_asm2(x, addr, err)   \
 __asm__ __volatile__(   \
 "1: lwz%X2 %1, %2\n"\
 "2: lwz%X2 %L1, %L2\n"  \
 "3:\n"  \
 ".section .fixup,\"ax\"\n"  \
 "4: li %0,%3\n" \
 "   li %1,0\n"  \
 "   li %1+1,0\n"\
 "   b 3b\n" \
 ".previous\n"   \
 EX_TABLE(1b, 4b)\
 EX_TABLE(2b, 4b)\
 : "=r" (err), "=&r" (x) \
 : "m" (*addr), "i" (-EFAULT), "0" (err))



You are right, __get_user_asm2_goto() was added later.

I think I found the issue.

__get_user_sigset() is wrong for 32 bits.

Could you change its content  to return __get_user(*(u64*)&dst->sig[0], 
(u64 __user *)&src->sig[0]);


If it works, for the mainline also change unsafe_get_user_sigset()

Christophe


Re: [PATCH v3 2/4] mm: Make generic arch_is_kernel_initmem_freed() do what it says

2021-11-05 Thread Christophe Leroy




Le 04/11/2021 à 22:44, Andrew Morton a écrit :

On Fri, 01 Oct 2021 17:14:41 +1000 Daniel Axtens  wrote:


  #ifdef __KERNEL__
+/*
+ * Check if an address is part of freed initmem. After initmem is freed,
+ * memory can be allocated from it, and such allocations would then have
+ * addresses within the range [_stext, _end].
+ */
+#ifndef arch_is_kernel_initmem_freed
+static int arch_is_kernel_initmem_freed(unsigned long addr)
+{
+   if (system_state < SYSTEM_FREEING_INITMEM)
+   return 0;
+
+   return init_section_contains((void *)addr, 1);


Is init_section_contains sufficient here?

include/asm-generic/sections.h says:
  * [__init_begin, __init_end]: contains .init.* sections, but .init.text.*
  *   may be out of this range on some architectures.
  * [_sinittext, _einittext]: contains .init.text.* sections

init_section_contains only checks __init_*:
static inline bool init_section_contains(void *virt, size_t size)
{
return memory_contains(__init_begin, __init_end, virt, size);
}

Do we need to check against _sinittext and _einittext?

Your proposed generic code will work for powerpc and s390 because those
archs only test against __init_* anyway. I don't know if any platform
actually does place .init.text outside of __init_begin=>__init_end, but
the comment seems to suggest that they could.



Christophe?



Sorry for answering late.

I've been thorugh free_initmem() in each architecture. The only sections 
involved in the freeing actions are [__init_begin, __init_end], so I 
think checking against __init_being, __init_end is enough.


If some architecture has init text outside of this section, then it is 
not freed hence not necessary to check.


Christophe


Re: [PATCH 4/7] arch: Remove leftovers from mandatory file locking

2021-11-05 Thread Jeff Layton
On Fri, 2021-11-05 at 16:43 +0100, Alexandre Ghiti wrote:
> This config was removed so remove all references to it.
> 
> Fixes: f7e33bdbd6d1 ("fs: remove mandatory file locking support")
> Signed-off-by: Alexandre Ghiti 
> ---
>  arch/mips/configs/decstation_64_defconfig  | 1 -
>  arch/mips/configs/decstation_defconfig | 1 -
>  arch/mips/configs/decstation_r4k_defconfig | 1 -
>  3 files changed, 3 deletions(-)
> 
> diff --git a/arch/mips/configs/decstation_64_defconfig 
> b/arch/mips/configs/decstation_64_defconfig
> index 85f1955b4b00..e2ed105f8c97 100644
> --- a/arch/mips/configs/decstation_64_defconfig
> +++ b/arch/mips/configs/decstation_64_defconfig
> @@ -144,7 +144,6 @@ CONFIG_EXT2_FS_SECURITY=y
>  CONFIG_EXT3_FS=y
>  CONFIG_EXT3_FS_POSIX_ACL=y
>  CONFIG_EXT3_FS_SECURITY=y
> -# CONFIG_MANDATORY_FILE_LOCKING is not set
>  CONFIG_ISO9660_FS=y
>  CONFIG_JOLIET=y
>  CONFIG_PROC_KCORE=y
> diff --git a/arch/mips/configs/decstation_defconfig 
> b/arch/mips/configs/decstation_defconfig
> index 30a6eafdb1d0..7e987d6f5e34 100644
> --- a/arch/mips/configs/decstation_defconfig
> +++ b/arch/mips/configs/decstation_defconfig
> @@ -140,7 +140,6 @@ CONFIG_EXT2_FS_SECURITY=y
>  CONFIG_EXT3_FS=y
>  CONFIG_EXT3_FS_POSIX_ACL=y
>  CONFIG_EXT3_FS_SECURITY=y
> -# CONFIG_MANDATORY_FILE_LOCKING is not set
>  CONFIG_ISO9660_FS=y
>  CONFIG_JOLIET=y
>  CONFIG_PROC_KCORE=y
> diff --git a/arch/mips/configs/decstation_r4k_defconfig 
> b/arch/mips/configs/decstation_r4k_defconfig
> index e2b58dbf4aa9..6df5f6f2ac8e 100644
> --- a/arch/mips/configs/decstation_r4k_defconfig
> +++ b/arch/mips/configs/decstation_r4k_defconfig
> @@ -140,7 +140,6 @@ CONFIG_EXT2_FS_SECURITY=y
>  CONFIG_EXT3_FS=y
>  CONFIG_EXT3_FS_POSIX_ACL=y
>  CONFIG_EXT3_FS_SECURITY=y
> -# CONFIG_MANDATORY_FILE_LOCKING is not set
>  CONFIG_ISO9660_FS=y
>  CONFIG_JOLIET=y
>  CONFIG_PROC_KCORE=y

Reviewed-by: Jeff Layton 


Re: [PATCH v2 2/5] powerpc/watchdog: Tighten non-atomic read-modify-write access

2021-11-05 Thread Laurent Dufour

Le 04/11/2021 à 17:10, Nicholas Piggin a écrit :

Most updates to wd_smp_cpus_pending are under lock except the watchdog
interrupt bit clear.

This can race with non-atomic RMW updates to the mask under lock, which
can happen in two instances:

Firstly, if another CPU detects this one is stuck, removes it from the
mask, mask becomes empty and is re-filled with non-atomic stores. This
is okay because it would re-fill the mask with this CPU's bit clear
anyway (because this CPU is now stuck), so it doesn't matter that the
bit clear update got "lost". Add a comment for this.

Secondly, if another CPU detects a different CPU is stuck and removes it
from the pending mask with a non-atomic store to bytes which also
include the bit of this CPU. This case can result in the bit clear being
lost and the end result being the bit is set. This should be so rare it
hardly matters, but to make things simpler to reason about just avoid
the non-atomic access for that case.

Signed-off-by: Nicholas Piggin 


Reviewed-by: Laurent Dufour 


---
  arch/powerpc/kernel/watchdog.c | 36 --
  1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index be80071336a4..1d2623230297 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -131,10 +131,10 @@ static void wd_lockup_ipi(struct pt_regs *regs)
/* Do not panic from here because that can recurse into NMI IPI layer */
  }
  
-static void set_cpumask_stuck(const struct cpumask *cpumask, u64 tb)

+static bool set_cpu_stuck(int cpu, u64 tb)
  {
-   cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask);
-   cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask);
+   cpumask_set_cpu(cpu, &wd_smp_cpus_stuck);
+   cpumask_clear_cpu(cpu, &wd_smp_cpus_pending);
/*
 * See wd_smp_clear_cpu_pending()
 */
@@ -144,11 +144,9 @@ static void set_cpumask_stuck(const struct cpumask 
*cpumask, u64 tb)
cpumask_andnot(&wd_smp_cpus_pending,
&wd_cpus_enabled,
&wd_smp_cpus_stuck);
+   return true;
}
-}
-static void set_cpu_stuck(int cpu, u64 tb)
-{
-   set_cpumask_stuck(cpumask_of(cpu), tb);
+   return false;
  }
  
  static void watchdog_smp_panic(int cpu, u64 tb)

@@ -177,15 +175,17 @@ static void watchdog_smp_panic(int cpu, u64 tb)
 * get a backtrace on all of them anyway.
 */
for_each_cpu(c, &wd_smp_cpus_pending) {
+   bool empty;
if (c == cpu)
continue;
+   /* Take the stuck CPUs out of the watch group */
+   empty = set_cpu_stuck(c, tb);
smp_send_nmi_ipi(c, wd_lockup_ipi, 100);
+   if (empty)
+   break;
}
}
  
-	/* Take the stuck CPUs out of the watch group */

-   set_cpumask_stuck(&wd_smp_cpus_pending, tb);
-
wd_smp_unlock(&flags);
  
  	if (sysctl_hardlockup_all_cpu_backtrace)

@@ -232,6 +232,22 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
return;
}
  
+	/*

+* All other updates to wd_smp_cpus_pending are performed under
+* wd_smp_lock. All of them are atomic except the case where the
+* mask becomes empty and is reset. This will not happen here because
+* cpu was tested to be in the bitmap (above), and a CPU only clears
+* its own bit. _Except_ in the case where another CPU has detected a
+* hard lockup on our CPU and takes us out of the pending mask. So in
+* normal operation there will be no race here, no problem.
+*
+* In the lockup case, this atomic clear-bit vs a store that refills
+* other bits in the accessed word wll not be a problem. The bit clear
+* is atomic so it will not cause the store to get lost, and the store
+* will never set this bit so it will not overwrite the bit clear. The
+* only way for a stuck CPU to return to the pending bitmap is to
+* become unstuck itself.
+*/
cpumask_clear_cpu(cpu, &wd_smp_cpus_pending);
  
  	/*






Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.16-1 tag

2021-11-05 Thread pr-tracker-bot
The pull request you sent on Sat, 06 Nov 2021 00:02:09 +1100:

> https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
> tags/powerpc-5.16-1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5c0b0c676ac2d84f69568715af91e45b610fe17a

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html


Re: [PATCH] powerpc/pseries: Fix numa FORM2 parsing fallback code

2021-11-05 Thread Aneesh Kumar K.V
Nicholas Piggin  writes:

> In case the FORM2 distance table from firmware is not the expected size,
> there is fallback code that just populates the lookup table as local vs
> remote.
>
> However it then continues on to use the distance table. Fix.
>

Reviewed-by: Aneesh Kumar K.V 

> Cc: Aneesh Kumar K.V 
> Fixes: 1c6b5a7e7405 ("powerpc/pseries: Add support for FORM2 associativity")
> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/mm/numa.c | 29 +
>  1 file changed, 13 insertions(+), 16 deletions(-)
>
> diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
> index 6f14c8fb6359..0789cde7f658 100644
> --- a/arch/powerpc/mm/numa.c
> +++ b/arch/powerpc/mm/numa.c
> @@ -380,6 +380,7 @@ static void 
> initialize_form2_numa_distance_lookup_table(void)
>   const __be32 *numa_lookup_index;
>   int numa_dist_table_length;
>   int max_numa_index, distance_index;
> + bool good = true;
>  
>   if (firmware_has_feature(FW_FEATURE_OPAL))
>   root = of_find_node_by_path("/ibm,opal");
> @@ -407,30 +408,26 @@ static void 
> initialize_form2_numa_distance_lookup_table(void)
>  
>   if (numa_dist_table_length != max_numa_index * max_numa_index) {
>   WARN(1, "Wrong NUMA distance information\n");
> - /* consider everybody else just remote. */
> - for (i = 0;  i < max_numa_index; i++) {
> - for (j = 0; j < max_numa_index; j++) {
> - int nodeA = numa_id_index_table[i];
> - int nodeB = numa_id_index_table[j];
> -
> - if (nodeA == nodeB)
> - numa_distance_table[nodeA][nodeB] = 
> LOCAL_DISTANCE;
> - else
> - numa_distance_table[nodeA][nodeB] = 
> REMOTE_DISTANCE;
> - }
> - }
> + good = false;
>   }
> -
>   distance_index = 0;
>   for (i = 0;  i < max_numa_index; i++) {
>   for (j = 0; j < max_numa_index; j++) {
>   int nodeA = numa_id_index_table[i];
>   int nodeB = numa_id_index_table[j];
> -
> - numa_distance_table[nodeA][nodeB] = 
> numa_dist_table[distance_index++];
> - pr_debug("dist[%d][%d]=%d ", nodeA, nodeB, 
> numa_distance_table[nodeA][nodeB]);
> + int dist;
> +
> + if (good)
> + dist = numa_dist_table[distance_index++];
> + else if (nodeA == nodeB)
> + dist = LOCAL_DISTANCE;
> + else
> + dist = REMOTE_DISTANCE;
> + numa_distance_table[nodeA][nodeB] = dist;
> + pr_debug("dist[%d][%d]=%d ", nodeA, nodeB, dist);
>   }
>   }
> +
>   of_node_put(root);
>  }
>  
> -- 
> 2.23.0


Re: [PATCH 0/7] Cleanup after removal of configs

2021-11-05 Thread Arnd Bergmann
On Fri, Nov 5, 2021 at 4:43 PM Alexandre Ghiti
 wrote:
>
> While bumping from 5.13 to 5.15, I found that a few deleted configs had
> left some pieces here and there: this patchset cleans that.
>
> Alexandre Ghiti (7):
>   Documentation, arch: Remove leftovers from fscache/cachefiles
> histograms
>   Documentation, arch: Remove leftovers from raw device
>   Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH
>   arch: Remove leftovers from mandatory file locking
>   Documentation, arch, fs: Remove leftovers from fscache object list
>   include: mfd: Remove leftovers from bd70528 watchdog
>   arch: Remove leftovers from prism54 wireless driver

Looks all good to me, thanks a lot for the cleanup!

For arch/arm/configs:

Acked-by: Arnd Bergmann 

assuming this goes through someone else's tree. Let me know if you need me
to pick up the patches in the asm-generic tree for cross-architecture work.

 Arnd


[PATCH 7/7] arch: Remove leftovers from prism54 wireless driver

2021-11-05 Thread Alexandre Ghiti
This driver was removed so remove all references to it.

Fixes: d249ff28b1d8 ("intersil: remove obsolete prism54 wireless driver")
Signed-off-by: Alexandre Ghiti 
---
 arch/mips/configs/ip27_defconfig| 1 -
 arch/mips/configs/malta_defconfig   | 1 -
 arch/mips/configs/malta_kvm_defconfig   | 1 -
 arch/mips/configs/maltaup_xpa_defconfig | 1 -
 arch/powerpc/configs/pmac32_defconfig   | 1 -
 5 files changed, 5 deletions(-)

diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index 638d7cf5ef01..821630ac1be7 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -223,7 +223,6 @@ CONFIG_TMD_HERMES=m
 CONFIG_NORTEL_HERMES=m
 CONFIG_P54_COMMON=m
 CONFIG_P54_PCI=m
-CONFIG_PRISM54=m
 CONFIG_LIBERTAS=m
 CONFIG_LIBERTAS_THINFIRM=m
 CONFIG_MWL8K=m
diff --git a/arch/mips/configs/malta_defconfig 
b/arch/mips/configs/malta_defconfig
index 9cb2cf2595e0..3321bb576944 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -302,7 +302,6 @@ CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
 CONFIG_HOSTAP_PLX=m
 CONFIG_HOSTAP_PCI=m
-CONFIG_PRISM54=m
 CONFIG_LIBERTAS=m
 CONFIG_INPUT_MOUSEDEV=y
 CONFIG_MOUSE_PS2_ELANTECH=y
diff --git a/arch/mips/configs/malta_kvm_defconfig 
b/arch/mips/configs/malta_kvm_defconfig
index 5924e48fd3ec..009b30372226 100644
--- a/arch/mips/configs/malta_kvm_defconfig
+++ b/arch/mips/configs/malta_kvm_defconfig
@@ -310,7 +310,6 @@ CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
 CONFIG_HOSTAP_PLX=m
 CONFIG_HOSTAP_PCI=m
-CONFIG_PRISM54=m
 CONFIG_LIBERTAS=m
 CONFIG_INPUT_MOUSEDEV=y
 CONFIG_SERIAL_8250=y
diff --git a/arch/mips/configs/maltaup_xpa_defconfig 
b/arch/mips/configs/maltaup_xpa_defconfig
index c0d3156ef640..e214e136101c 100644
--- a/arch/mips/configs/maltaup_xpa_defconfig
+++ b/arch/mips/configs/maltaup_xpa_defconfig
@@ -309,7 +309,6 @@ CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
 CONFIG_HOSTAP_PLX=m
 CONFIG_HOSTAP_PCI=m
-CONFIG_PRISM54=m
 CONFIG_LIBERTAS=m
 CONFIG_INPUT_MOUSEDEV=y
 CONFIG_MOUSE_PS2_ELANTECH=y
diff --git a/arch/powerpc/configs/pmac32_defconfig 
b/arch/powerpc/configs/pmac32_defconfig
index 7aefac5afab0..13885ec563d1 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -169,7 +169,6 @@ CONFIG_USB_USBNET=m
 CONFIG_B43=m
 CONFIG_B43LEGACY=m
 CONFIG_P54_COMMON=m
-CONFIG_PRISM54=m
 CONFIG_INPUT_EVDEV=y
 # CONFIG_KEYBOARD_ATKBD is not set
 # CONFIG_MOUSE_PS2 is not set
-- 
2.32.0



[PATCH 6/7] include: mfd: Remove leftovers from bd70528 watchdog

2021-11-05 Thread Alexandre Ghiti
This driver was removed so remove all references to it.

Fixes: 52a5502507bc ("watchdog: bd70528 drop bd70528 support")
Signed-off-by: Alexandre Ghiti 
---
 include/linux/mfd/rohm-bd70528.h | 24 
 1 file changed, 24 deletions(-)

diff --git a/include/linux/mfd/rohm-bd70528.h b/include/linux/mfd/rohm-bd70528.h
index 4a5966475a35..297a4a84fff5 100644
--- a/include/linux/mfd/rohm-bd70528.h
+++ b/include/linux/mfd/rohm-bd70528.h
@@ -362,28 +362,4 @@ enum {
 #define BD70528_MASK_BUCK_RAMP 0x10
 #define BD70528_SIFT_BUCK_RAMP 4
 
-#if IS_ENABLED(CONFIG_BD70528_WATCHDOG)
-
-int bd70528_wdt_set(struct rohm_regmap_dev *data, int enable, int *old_state);
-void bd70528_wdt_lock(struct rohm_regmap_dev *data);
-void bd70528_wdt_unlock(struct rohm_regmap_dev *data);
-
-#else /* CONFIG_BD70528_WATCHDOG */
-
-static inline int bd70528_wdt_set(struct rohm_regmap_dev *data, int enable,
- int *old_state)
-{
-   return 0;
-}
-
-static inline void bd70528_wdt_lock(struct rohm_regmap_dev *data)
-{
-}
-
-static inline void bd70528_wdt_unlock(struct rohm_regmap_dev *data)
-{
-}
-
-#endif /* CONFIG_BD70528_WATCHDOG */
-
 #endif /* __LINUX_MFD_BD70528_H__ */
-- 
2.32.0



[PATCH 5/7] Documentation, arch, fs: Remove leftovers from fscache object list

2021-11-05 Thread Alexandre Ghiti
A few references to the fscache object list were left in the
Documentation, some arch defconfigs and in fs: remove them since this
config does not exists anymore.

Fixes: 58f386a73f16 ("fscache: Remove the object list procfile")
Signed-off-by: Alexandre Ghiti 
---
 Documentation/filesystems/caching/fscache.rst | 89 ---
 arch/arm/configs/axm55xx_defconfig|  1 -
 fs/fscache/object.c   |  3 -
 fs/fscache/proc.c | 12 ---
 4 files changed, 105 deletions(-)

diff --git a/Documentation/filesystems/caching/fscache.rst 
b/Documentation/filesystems/caching/fscache.rst
index 66e31a6d1070..7cedab444947 100644
--- a/Documentation/filesystems/caching/fscache.rst
+++ b/Documentation/filesystems/caching/fscache.rst
@@ -411,95 +411,6 @@ proc file.
 
+--+---+---+
 
 
-
-Object List
-===
-
-If CONFIG_FSCACHE_OBJECT_LIST is enabled, the FS-Cache facility will maintain a
-list of all the objects currently allocated and allow them to be viewed
-through::
-
-   /proc/fs/fscache/objects
-
-This will look something like::
-
-   [root@andromeda ~]# head /proc/fs/fscache/objects
-   OBJECT   PARENT   STAT CHLDN OPS OOP IPR EX READS EM EV F S | 
NETFS_COOKIE_DEF TY FL NETFS_DATA   OBJECT_KEY, AUX_DATA
-      = === === === == = == == = = | 
 == ==  
-  17e4b2 ACTV 0   0   0   0  0 0 7b  4 0 0 | NFS.fh
   DT  0 88001dd82820 
010006017edcf8bbc93b43298fdfbe71e50b57b13a172c0117f38472, 
e567634763f2404ac90363f2404a
-  1693a2 ACTV 0   0   0   0  0 0 7b  4 0 0 | NFS.fh
   DT  0 88002db23380 
010006017edcf8bbc93b43298fdfbe71e50b57b1e0162c01a2df0ea6, 
420ebc4a420ebc4a0e180100420ebc4a
-
-where the first set of columns before the '|' describe the object:
-
-   === ===
-   COLUMN  DESCRIPTION
-   === ===
-   OBJECT  Object debugging ID (appears as OBJ%x in some debug messages)
-   PARENT  Debugging ID of parent object
-   STATObject state
-   CHLDN   Number of child objects of this object
-   OPS Number of outstanding operations on this object
-   OOP Number of outstanding child object management operations
-   IPR
-   EX  Number of outstanding exclusive operations
-   READS   Number of outstanding read operations
-   EM  Object's event mask
-   EV  Events raised on this object
-   F   Object flags
-   S   Object work item busy state mask (1:pending 2:running)
-   === ===
-
-and the second set of columns describe the object's cookie, if present:
-
-    ==
-   COLUMN   DESCRIPTION
-    ==
-   NETFS_COOKIE_DEF Name of netfs cookie definition
-   TY   Cookie type (IX - index, DT - data, hex - special)
-   FL   Cookie flags
-   NETFS_DATA   Netfs private data stored in the cookie
-   OBJECT_KEY   Object key } 1 column, with separating comma
-   AUX_DATA Object aux data } presence may be configured
-    ==
-
-The data shown may be filtered by attaching the a key to an appropriate keyring
-before viewing the file.  Something like::
-
-   keyctl add user fscache:objlist  @s
-
-where  are a selection of the following letters:
-
-   ==  =
-   K   Show hexdump of object key (don't show if not given)
-   A   Show hexdump of object aux data (don't show if not given)
-   ==  =
-
-and the following paired letters:
-
-   ==  =
-   C   Show objects that have a cookie
-   c   Show objects that don't have a cookie
-   B   Show objects that are busy
-   b   Show objects that aren't busy
-   W   Show objects that have pending writes
-   w   Show objects that don't have pending writes
-   R   Show objects that have outstanding reads
-   r   Show objects that don't have outstanding reads
-   S   Show objects that have work queued
-   s   Show objects that don't have work queued
-   ==  =
-
-

[PATCH 4/7] arch: Remove leftovers from mandatory file locking

2021-11-05 Thread Alexandre Ghiti
This config was removed so remove all references to it.

Fixes: f7e33bdbd6d1 ("fs: remove mandatory file locking support")
Signed-off-by: Alexandre Ghiti 
---
 arch/mips/configs/decstation_64_defconfig  | 1 -
 arch/mips/configs/decstation_defconfig | 1 -
 arch/mips/configs/decstation_r4k_defconfig | 1 -
 3 files changed, 3 deletions(-)

diff --git a/arch/mips/configs/decstation_64_defconfig 
b/arch/mips/configs/decstation_64_defconfig
index 85f1955b4b00..e2ed105f8c97 100644
--- a/arch/mips/configs/decstation_64_defconfig
+++ b/arch/mips/configs/decstation_64_defconfig
@@ -144,7 +144,6 @@ CONFIG_EXT2_FS_SECURITY=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
-# CONFIG_MANDATORY_FILE_LOCKING is not set
 CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
 CONFIG_PROC_KCORE=y
diff --git a/arch/mips/configs/decstation_defconfig 
b/arch/mips/configs/decstation_defconfig
index 30a6eafdb1d0..7e987d6f5e34 100644
--- a/arch/mips/configs/decstation_defconfig
+++ b/arch/mips/configs/decstation_defconfig
@@ -140,7 +140,6 @@ CONFIG_EXT2_FS_SECURITY=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
-# CONFIG_MANDATORY_FILE_LOCKING is not set
 CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
 CONFIG_PROC_KCORE=y
diff --git a/arch/mips/configs/decstation_r4k_defconfig 
b/arch/mips/configs/decstation_r4k_defconfig
index e2b58dbf4aa9..6df5f6f2ac8e 100644
--- a/arch/mips/configs/decstation_r4k_defconfig
+++ b/arch/mips/configs/decstation_r4k_defconfig
@@ -140,7 +140,6 @@ CONFIG_EXT2_FS_SECURITY=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
-# CONFIG_MANDATORY_FILE_LOCKING is not set
 CONFIG_ISO9660_FS=y
 CONFIG_JOLIET=y
 CONFIG_PROC_KCORE=y
-- 
2.32.0



[PATCH 3/7] Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH

2021-11-05 Thread Alexandre Ghiti
This config was removed so remove all references to it.

Fixes: 76a3c92ec9e0 ("cifs: remove support for NTLM and weaker authentication 
algorithms")
Signed-off-by: Alexandre Ghiti 
---
 Documentation/admin-guide/cifs/usage.rst| 7 +++
 arch/arm/configs/cm_x300_defconfig  | 1 -
 arch/arm/configs/ezx_defconfig  | 1 -
 arch/arm/configs/imote2_defconfig   | 1 -
 arch/arm/configs/nhk8815_defconfig  | 1 -
 arch/arm/configs/pxa_defconfig  | 1 -
 arch/mips/configs/fuloong2e_defconfig   | 1 -
 arch/mips/configs/malta_qemu_32r6_defconfig | 1 -
 arch/mips/configs/maltaaprp_defconfig   | 1 -
 arch/mips/configs/maltasmvp_defconfig   | 1 -
 arch/mips/configs/maltasmvp_eva_defconfig   | 1 -
 arch/mips/configs/maltaup_defconfig | 1 -
 arch/mips/configs/nlm_xlp_defconfig | 1 -
 arch/mips/configs/nlm_xlr_defconfig | 1 -
 arch/powerpc/configs/ppc6xx_defconfig   | 1 -
 arch/sh/configs/titan_defconfig | 1 -
 16 files changed, 3 insertions(+), 19 deletions(-)

diff --git a/Documentation/admin-guide/cifs/usage.rst 
b/Documentation/admin-guide/cifs/usage.rst
index f170d8820258..3766bf8a1c20 100644
--- a/Documentation/admin-guide/cifs/usage.rst
+++ b/Documentation/admin-guide/cifs/usage.rst
@@ -734,10 +734,9 @@ SecurityFlags  Flags which control security 
negotiation and
using weaker password hashes is 0x37037 (lanman,
plaintext, ntlm, ntlmv2, signing allowed).  Some
SecurityFlags require the corresponding menuconfig
-   options to be enabled (lanman and plaintext require
-   CONFIG_CIFS_WEAK_PW_HASH for example).  Enabling
-   plaintext authentication currently requires also
-   enabling lanman authentication in the security flags
+   options to be enabled.  Enabling plaintext
+   authentication currently requires also enabling
+   lanman authentication in the security flags
because the cifs module only supports sending
laintext passwords using the older lanman dialect
form of the session setup SMB.  (e.g. for authentication
diff --git a/arch/arm/configs/cm_x300_defconfig 
b/arch/arm/configs/cm_x300_defconfig
index 502a9d870ca4..45769d0ddd4e 100644
--- a/arch/arm/configs/cm_x300_defconfig
+++ b/arch/arm/configs/cm_x300_defconfig
@@ -146,7 +146,6 @@ CONFIG_NFS_V3_ACL=y
 CONFIG_NFS_V4=y
 CONFIG_ROOT_NFS=y
 CONFIG_CIFS=m
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_PARTITION_ADVANCED=y
 CONFIG_NLS_CODEPAGE_437=m
 CONFIG_NLS_ISO8859_1=m
diff --git a/arch/arm/configs/ezx_defconfig b/arch/arm/configs/ezx_defconfig
index a49e699e52de..ec84d80096b1 100644
--- a/arch/arm/configs/ezx_defconfig
+++ b/arch/arm/configs/ezx_defconfig
@@ -314,7 +314,6 @@ CONFIG_NFSD_V3_ACL=y
 CONFIG_SMB_FS=m
 CONFIG_CIFS=m
 CONFIG_CIFS_STATS=y
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 CONFIG_NLS_CODEPAGE_437=m
diff --git a/arch/arm/configs/imote2_defconfig 
b/arch/arm/configs/imote2_defconfig
index 118c4c927f26..6db871d4e077 100644
--- a/arch/arm/configs/imote2_defconfig
+++ b/arch/arm/configs/imote2_defconfig
@@ -288,7 +288,6 @@ CONFIG_NFSD_V3_ACL=y
 CONFIG_SMB_FS=m
 CONFIG_CIFS=m
 CONFIG_CIFS_STATS=y
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 CONFIG_NLS_CODEPAGE_437=m
diff --git a/arch/arm/configs/nhk8815_defconfig 
b/arch/arm/configs/nhk8815_defconfig
index 23595fc5a29a..907d6512821a 100644
--- a/arch/arm/configs/nhk8815_defconfig
+++ b/arch/arm/configs/nhk8815_defconfig
@@ -127,7 +127,6 @@ CONFIG_NFS_FS=y
 CONFIG_NFS_V3_ACL=y
 CONFIG_ROOT_NFS=y
 CONFIG_CIFS=m
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ASCII=y
 CONFIG_NLS_ISO8859_1=y
diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig
index 58f4834289e6..dedaaae3d0d8 100644
--- a/arch/arm/configs/pxa_defconfig
+++ b/arch/arm/configs/pxa_defconfig
@@ -699,7 +699,6 @@ CONFIG_NFSD_V3_ACL=y
 CONFIG_NFSD_V4=y
 CONFIG_CIFS=m
 CONFIG_CIFS_STATS=y
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 CONFIG_NLS_DEFAULT="utf8"
diff --git a/arch/mips/configs/fuloong2e_defconfig 
b/arch/mips/configs/fuloong2e_defconfig
index 5c24ac7fdf56..ba47c5e929b7 100644
--- a/arch/mips/configs/fuloong2e_defconfig
+++ b/arch/mips/configs/fuloong2e_defconfig
@@ -206,7 +206,6 @@ CONFIG_NFSD_V3_ACL=y
 CONFIG_NFSD_V4=y
 CONFIG_CIFS=m
 CONFIG_CIFS_STATS2=y
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 CONFIG_CIFS_DEBUG2=y
diff --git a/arch/mips/configs/malta_qemu_32r6_defconfig 
b/arch/mips/configs/malta_qemu_32r6_defconfig
index 614af02d83e6..6fb9bc29f4a0 100644
--- a/arch/mips/configs/malta_qemu_32r6_defconfig
+++ b/arch/mips/configs/malta_qemu_32r6_defconfig
@@ -165,7 +165,6 @@ CONFIG_TMPFS=y
 CONFIG_N

[PATCH 2/7] Documentation, arch: Remove leftovers from raw device

2021-11-05 Thread Alexandre Ghiti
Raw device interface was removed so remove all references to configs
related to it.

Fixes: 603e4922f1c8 ("remove the raw driver")
Signed-off-by: Alexandre Ghiti 
---
 Documentation/admin-guide/devices.txt  | 8 +---
 arch/arm/configs/spear13xx_defconfig   | 1 -
 arch/arm/configs/spear3xx_defconfig| 1 -
 arch/arm/configs/spear6xx_defconfig| 1 -
 arch/powerpc/configs/pseries_defconfig | 1 -
 5 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/Documentation/admin-guide/devices.txt 
b/Documentation/admin-guide/devices.txt
index 922c23bb4372..c07dc0ee860e 100644
--- a/Documentation/admin-guide/devices.txt
+++ b/Documentation/admin-guide/devices.txt
@@ -2339,13 +2339,7 @@
disks (see major number 3) except that the limit on
partitions is 31.
 
- 162 char  Raw block device interface
- 0 = /dev/rawctl   Raw I/O control device
- 1 = /dev/raw/raw1 First raw I/O device
- 2 = /dev/raw/raw2 Second raw I/O device
-   ...
-max minor number of raw device is set by kernel config
-MAX_RAW_DEVS or raw module parameter 'max_raw_devs'
+ 162 char  Used for (now removed) raw block device interface
 
  163 char
 
diff --git a/arch/arm/configs/spear13xx_defconfig 
b/arch/arm/configs/spear13xx_defconfig
index 3b206a31902f..065553326b39 100644
--- a/arch/arm/configs/spear13xx_defconfig
+++ b/arch/arm/configs/spear13xx_defconfig
@@ -61,7 +61,6 @@ CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 CONFIG_RAW_DRIVER=y
-CONFIG_MAX_RAW_DEVS=8192
 CONFIG_I2C=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 CONFIG_SPI=y
diff --git a/arch/arm/configs/spear3xx_defconfig 
b/arch/arm/configs/spear3xx_defconfig
index fc5f71c765ed..afca722d6605 100644
--- a/arch/arm/configs/spear3xx_defconfig
+++ b/arch/arm/configs/spear3xx_defconfig
@@ -41,7 +41,6 @@ CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 CONFIG_RAW_DRIVER=y
-CONFIG_MAX_RAW_DEVS=8192
 CONFIG_I2C=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 CONFIG_SPI=y
diff --git a/arch/arm/configs/spear6xx_defconfig 
b/arch/arm/configs/spear6xx_defconfig
index 52a56b8ce6a7..bc32c02cb86b 100644
--- a/arch/arm/configs/spear6xx_defconfig
+++ b/arch/arm/configs/spear6xx_defconfig
@@ -36,7 +36,6 @@ CONFIG_INPUT_FF_MEMLESS=y
 CONFIG_SERIAL_AMBA_PL011=y
 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
 CONFIG_RAW_DRIVER=y
-CONFIG_MAX_RAW_DEVS=8192
 CONFIG_I2C=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 CONFIG_SPI=y
diff --git a/arch/powerpc/configs/pseries_defconfig 
b/arch/powerpc/configs/pseries_defconfig
index b183629f1bcf..d0494fbb4961 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -190,7 +190,6 @@ CONFIG_HVCS=m
 CONFIG_VIRTIO_CONSOLE=m
 CONFIG_IBM_BSR=m
 CONFIG_RAW_DRIVER=y
-CONFIG_MAX_RAW_DEVS=1024
 CONFIG_I2C_CHARDEV=y
 CONFIG_FB=y
 CONFIG_FIRMWARE_EDID=y
-- 
2.32.0



[PATCH 1/7] Documentation, arch: Remove leftovers from fscache/cachefiles histograms

2021-11-05 Thread Alexandre Ghiti
A few references to the fscache and cachefiles histograms were left in
the Documentation and some arch defconfigs: remove them since those
configs do not exist anymore.

Fixes: 6ae9bd8bb037("fscache, cachefiles: Remove the histogram stuff")
Signed-off-by: Alexandre Ghiti 
---
 .../filesystems/caching/cachefiles.rst| 34 ---
 Documentation/filesystems/caching/fscache.rst | 34 ++-
 arch/arm/configs/axm55xx_defconfig|  2 --
 arch/mips/configs/nlm_xlp_defconfig   |  1 -
 arch/mips/configs/nlm_xlr_defconfig   |  1 -
 5 files changed, 2 insertions(+), 70 deletions(-)

diff --git a/Documentation/filesystems/caching/cachefiles.rst 
b/Documentation/filesystems/caching/cachefiles.rst
index e58bc1fd312a..e59861458029 100644
--- a/Documentation/filesystems/caching/cachefiles.rst
+++ b/Documentation/filesystems/caching/cachefiles.rst
@@ -424,40 +424,6 @@ for CacheFiles to run in a context of a specific security 
label, or to create
 files and directories with another security label.
 
 
-Statistical Information
-===
-
-If FS-Cache is compiled with the following option enabled::
-
-   CONFIG_CACHEFILES_HISTOGRAM=y
-
-then it will gather certain statistics and display them through a proc file.
-
- /proc/fs/cachefiles/histogram
-
- ::
-
-   cat /proc/fs/cachefiles/histogram
-   JIFS  SECS  LOOKUPS   MKDIRSCREATES
-   = = = = =
-
- This shows the breakdown of the number of times each amount of time
- between 0 jiffies and HZ-1 jiffies a variety of tasks took to run.  The
- columns are as follows:
-
-   === ===
-   COLUMN  TIME MEASUREMENT
-   === ===
-   LOOKUPS Length of time to perform a lookup on the backing fs
-   MKDIRS  Length of time to perform a mkdir on the backing fs
-   CREATES Length of time to perform a create on the backing fs
-   === ===
-
- Each row shows the number of events that took a particular range of times.
- Each step is 1 jiffy in size.  The JIFS column indicates the particular
- jiffy range covered, and the SECS field the equivalent number of seconds.
-
-
 Debugging
 =
 
diff --git a/Documentation/filesystems/caching/fscache.rst 
b/Documentation/filesystems/caching/fscache.rst
index 70de86922b6a..66e31a6d1070 100644
--- a/Documentation/filesystems/caching/fscache.rst
+++ b/Documentation/filesystems/caching/fscache.rst
@@ -201,10 +201,9 @@ Statistical Information
 If FS-Cache is compiled with the following options enabled::
 
CONFIG_FSCACHE_STATS=y
-   CONFIG_FSCACHE_HISTOGRAM=y
 
-then it will gather certain statistics and display them through a number of
-proc files.
+then it will gather certain statistics and display them through the following
+proc file.
 
 /proc/fs/fscache/stats
 --
@@ -413,35 +412,6 @@ proc files.
 
 
 
-/proc/fs/fscache/histogram
---
-
- ::
-
-   cat /proc/fs/fscache/histogram
-   JIFS  SECS  OBJ INST  OP RUNS   OBJ RUNS  RETRV DLY RETRIEVLS
-   = = = = = = =
-
- This shows the breakdown of the number of times each amount of time
- between 0 jiffies and HZ-1 jiffies a variety of tasks took to run.  The
- columns are as follows:
-
-   =   ===
-   COLUMN  TIME MEASUREMENT
-   =   ===
-   OBJ INSTLength of time to instantiate an object
-   OP RUNS Length of time a call to process an operation took
-   OBJ RUNSLength of time a call to process an object event took
-   RETRV DLY   Time between an requesting a read and lookup completing
-   RETRIEVLS   Time between beginning and end of a retrieval
-   =   ===
-
- Each row shows the number of events that took a particular range of times.
- Each step is 1 jiffy in size.  The JIFS column indicates the particular
- jiffy range covered, and the SECS field the equivalent number of seconds.
-
-
-
 Object List
 ===
 
diff --git a/arch/arm/configs/axm55xx_defconfig 
b/arch/arm/configs/axm55xx_defconfig
index 46075216ee6d..b36e0b347d1f 100644
--- a/arch/arm/configs/axm55xx_defconfig
+++ b/arch/arm/configs/axm55xx_defconfig
@@ -204,11 +204,9 @@ CONFIG_FUSE_FS=y
 CONFIG_CUSE=y
 CONFIG_FSCACHE=y
 CONFIG_FSCACHE_STATS=y
-CONFIG_FSCACHE_HISTOGRAM=y
 CONFIG_FSCACHE_DEBUG=y
 CONFIG_FSCACHE_OBJECT_LIST=y
 CONFIG_CACHEFILES=y
-CONFIG_CACHEFILES_HISTOGRAM=y
 CONFIG_ISO9660_FS=y
 CONFIG_UDF_FS=y
 CONFIG_MSDOS_FS=y
diff --

[PATCH 0/7] Cleanup after removal of configs

2021-11-05 Thread Alexandre Ghiti
While bumping from 5.13 to 5.15, I found that a few deleted configs had
left some pieces here and there: this patchset cleans that.

Alexandre Ghiti (7):
  Documentation, arch: Remove leftovers from fscache/cachefiles
histograms
  Documentation, arch: Remove leftovers from raw device
  Documentation, arch: Remove leftovers from CIFS_WEAK_PW_HASH
  arch: Remove leftovers from mandatory file locking
  Documentation, arch, fs: Remove leftovers from fscache object list
  include: mfd: Remove leftovers from bd70528 watchdog
  arch: Remove leftovers from prism54 wireless driver

 Documentation/admin-guide/cifs/usage.rst  |   7 +-
 Documentation/admin-guide/devices.txt |   8 +-
 .../filesystems/caching/cachefiles.rst|  34 -
 Documentation/filesystems/caching/fscache.rst | 123 +-
 arch/arm/configs/axm55xx_defconfig|   3 -
 arch/arm/configs/cm_x300_defconfig|   1 -
 arch/arm/configs/ezx_defconfig|   1 -
 arch/arm/configs/imote2_defconfig |   1 -
 arch/arm/configs/nhk8815_defconfig|   1 -
 arch/arm/configs/pxa_defconfig|   1 -
 arch/arm/configs/spear13xx_defconfig  |   1 -
 arch/arm/configs/spear3xx_defconfig   |   1 -
 arch/arm/configs/spear6xx_defconfig   |   1 -
 arch/mips/configs/decstation_64_defconfig |   1 -
 arch/mips/configs/decstation_defconfig|   1 -
 arch/mips/configs/decstation_r4k_defconfig|   1 -
 arch/mips/configs/fuloong2e_defconfig |   1 -
 arch/mips/configs/ip27_defconfig  |   1 -
 arch/mips/configs/malta_defconfig |   1 -
 arch/mips/configs/malta_kvm_defconfig |   1 -
 arch/mips/configs/malta_qemu_32r6_defconfig   |   1 -
 arch/mips/configs/maltaaprp_defconfig |   1 -
 arch/mips/configs/maltasmvp_defconfig |   1 -
 arch/mips/configs/maltasmvp_eva_defconfig |   1 -
 arch/mips/configs/maltaup_defconfig   |   1 -
 arch/mips/configs/maltaup_xpa_defconfig   |   1 -
 arch/mips/configs/nlm_xlp_defconfig   |   2 -
 arch/mips/configs/nlm_xlr_defconfig   |   2 -
 arch/powerpc/configs/pmac32_defconfig |   1 -
 arch/powerpc/configs/ppc6xx_defconfig |   1 -
 arch/powerpc/configs/pseries_defconfig|   1 -
 arch/sh/configs/titan_defconfig   |   1 -
 fs/fscache/object.c   |   3 -
 fs/fscache/proc.c |  12 --
 include/linux/mfd/rohm-bd70528.h  |  24 
 35 files changed, 6 insertions(+), 237 deletions(-)

-- 
2.32.0



Re: [PATCH] powerpc/64s: introduce CONFIG_MAXSMP to test very large SMP

2021-11-05 Thread kernel test robot
Hi Nicholas,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.15 next-20211105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Nicholas-Piggin/powerpc-64s-introduce-CONFIG_MAXSMP-to-test-very-large-SMP/20211105-121250
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/0day-ci/linux/commit/9ca640e0639b6bdab803c15ba0ea3321a846c466
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Nicholas-Piggin/powerpc-64s-introduce-CONFIG_MAXSMP-to-test-very-large-SMP/20211105-121250
git checkout 9ca640e0639b6bdab803c15ba0ea3321a846c466
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross 
ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   drivers/cpufreq/cpufreq_ondemand.c: In function 'od_set_powersave_bias':
>> drivers/cpufreq/cpufreq_ondemand.c:446:1: error: the frame size of 2064 
>> bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
 446 | }
 | ^
   cc1: all warnings being treated as errors
--
   kernel/trace/preemptirq_delay_test.c: In function 'preemptirq_delay_run':
>> kernel/trace/preemptirq_delay_test.c:145:1: error: the frame size of 2064 
>> bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
 145 | }
 | ^
   cc1: all warnings being treated as errors
--
   drivers/powercap/dtpm_cpu.c: In function 'set_pd_power_limit':
>> drivers/powercap/dtpm_cpu.c:104:1: error: the frame size of 2064 bytes is 
>> larger than 2048 bytes [-Werror=frame-larger-than=]
 104 | }
 | ^
   drivers/powercap/dtpm_cpu.c: In function 'get_pd_power_uw':
   drivers/powercap/dtpm_cpu.c:129:1: error: the frame size of 2064 bytes is 
larger than 2048 bytes [-Werror=frame-larger-than=]
 129 | }
 | ^
   cc1: all warnings being treated as errors
--
   In file included from :
   drivers/leds/trigger/ledtrig-cpu.c: In function 'ledtrig_cpu_init':
>> include/linux/compiler_types.h:322:45: error: call to 
>> '__compiletime_assert_175' declared with attribute error: BUILD_BUG_ON 
>> failed: CONFIG_NR_CPUS > 
 322 | _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
 | ^
   include/linux/compiler_types.h:303:25: note: in definition of macro 
'__compiletime_assert'
 303 | prefix ## suffix();  
   \
 | ^~
   include/linux/compiler_types.h:322:9: note: in expansion of macro 
'_compiletime_assert'
 322 | _compiletime_assert(condition, msg, __compiletime_assert_, 
__COUNTER__)
 | ^~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 
'compiletime_assert'
  39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
 | ^~
   include/linux/build_bug.h:50:9: note: in expansion of macro 
'BUILD_BUG_ON_MSG'
  50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " 
#condition)
 | ^~~~
   drivers/leds/trigger/ledtrig-cpu.c:137:9: note: in expansion of macro 
'BUILD_BUG_ON'
 137 | BUILD_BUG_ON(CONFIG_NR_CPUS > );
 | ^~~~
--
   drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c: In function 
'update_xps.isra':
>> drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:2495:1: error: the frame 
>> size of 2064 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
2495 | }
 | ^
   cc1: all warnings being treated as errors
--
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 
'stmmac_request_irq_multi_msi':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3554:1: error: the frame 
>> size of 2064 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
3554 | }
 | ^
   cc1: all warnings being treated as errors


vim +446 drivers/cpufreq/cpufreq_ondemand.c

af926185231a6e3 Rafael J. Wysocki 2016-02-05  412  
f

Re: [PATCH] powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST

2021-11-05 Thread Michael Ellerman
On Fri, 29 Oct 2021 17:10:45 +0200, Christophe Leroy wrote:
> Until now, all tests involving CONFIG_STRICT_KERNEL_RWX were done with
> DEBUG_RODATA_TEST to check the result. But now that
> CONFIG_STRICT_KERNEL_RWX is selected by default, it came without
> CONFIG_DEBUG_RODATA_TEST and led to the following Oops
> 
> [6.830908] Freeing unused kernel image (initmem) memory: 352K
> [6.840077] BUG: Unable to handle kernel data access on write at 0xc1285200
> [6.846836] Faulting instruction address: 0xc0004b6c
> [6.851745] Oops: Kernel access of bad area, sig: 11 [#1]
> [6.857075] BE PAGE_SIZE=16K PREEMPT CMPC885
> [6.861348] SAF3000 DIE NOTIFICATION
> [6.864830] CPU: 0 PID: 1 Comm: swapper Not tainted 
> 5.15.0-rc5-s3k-dev-02255-g2747d7b7916f #451
> [6.873429] NIP:  c0004b6c LR: c0004b60 CTR: 
> [6.878419] REGS: c902be60 TRAP: 0300   Not tainted  
> (5.15.0-rc5-s3k-dev-02255-g2747d7b7916f)
> [6.886852] MSR:  9032   CR: 53000335  XER: 8000ff40
> [6.893564] DAR: c1285200 DSISR: 8200
> [6.893564] GPR00: 0c00 c902bf20 c20f4000 0800 0001 04001f00 
> c180 0035
> [6.893564] GPR08: ff0001ff c128 0002 c0004b60 1000  
> c0004b1c 
> [6.893564] GPR16:       
>  
> [6.893564] GPR24:       
>  c106
> [6.932034] NIP [c0004b6c] kernel_init+0x50/0x138
> [6.936682] LR [c0004b60] kernel_init+0x44/0x138
> [6.941245] Call Trace:
> [6.943653] [c902bf20] [c0004b60] kernel_init+0x44/0x138 (unreliable)
> [6.950022] [c902bf30] [c001122c] ret_from_kernel_thread+0x5c/0x64
> [6.956135] Instruction dump:
> [6.959060] 48ffc521 48045469 4800d8cd 3d20c086 89295fa0 2c09 41820058 
> 480796c9
> [6.966890] 4800e48d 3d20c128 3942 3fe0c106 <91495200> 3bff8000 
> 4806fa1d 481f7d75
> [6.974902] ---[ end trace 1e397bacba4aa610 ]---
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST
  https://git.kernel.org/powerpc/c/c12ab8dbc492b992e1ea717db933cee568780c47

cheers


Re: [PATCH v2 4/5] powerpc/watchdog: Read TB close to where it is used

2021-11-05 Thread Laurent Dufour

Le 04/11/2021 à 17:10, Nicholas Piggin a écrit :

When taking watchdog actions, printing messages, comparing and
re-setting wd_smp_last_reset_tb, etc., read TB close to the point of use
and under wd_smp_lock or printing lock (if applicable).

This should keep timebase mostly monotonic with kernel log messages, and
could prevent (in theory) a laggy CPU updating wd_smp_last_reset_tb to
something a long way in the past, and causing other CPUs to appear to be
stuck.

These additional TB reads are all slowpath (lockup has been detected),
so performance does not matter.

Signed-off-by: Nicholas Piggin 
---
  arch/powerpc/kernel/watchdog.c | 30 ++
  1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index 0265d27340f1..2444cd10b61a 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -94,6 +94,10 @@ static u64 wd_smp_last_reset_tb;
   * Try to take the exclusive watchdog action / NMI IPI / printing lock.
   * wd_smp_lock must be held. If this fails, we should return and wait
   * for the watchdog to kick in again (or another CPU to trigger it).
+ *
+ * Importantly, if hardlockup_panic is set, wd_try_report failure should
+ * not delay the panic, because whichever other CPU is reporting will
+ * call panic.
   */


I guess this comment should be part of the previous commit in this series.

Despite that, please consider

Reviewed-by: Laurent Dufour 


  static bool wd_try_report(void)
  {
@@ -153,7 +157,7 @@ static void wd_lockup_ipi(struct pt_regs *regs)
/* Do not panic from here because that can recurse into NMI IPI layer */
  }
  
-static bool set_cpu_stuck(int cpu, u64 tb)

+static bool set_cpu_stuck(int cpu)
  {
cpumask_set_cpu(cpu, &wd_smp_cpus_stuck);
cpumask_clear_cpu(cpu, &wd_smp_cpus_pending);
@@ -162,7 +166,7 @@ static bool set_cpu_stuck(int cpu, u64 tb)
 */
smp_mb();
if (cpumask_empty(&wd_smp_cpus_pending)) {
-   wd_smp_last_reset_tb = tb;
+   wd_smp_last_reset_tb = get_tb();
cpumask_andnot(&wd_smp_cpus_pending,
&wd_cpus_enabled,
&wd_smp_cpus_stuck);
@@ -171,14 +175,16 @@ static bool set_cpu_stuck(int cpu, u64 tb)
return false;
  }
  
-static void watchdog_smp_panic(int cpu, u64 tb)

+static void watchdog_smp_panic(int cpu)
  {
static cpumask_t wd_smp_cpus_ipi; // protected by reporting
unsigned long flags;
+   u64 tb;
int c;
  
  	wd_smp_lock(&flags);

/* Double check some things under lock */
+   tb = get_tb();
if ((s64)(tb - wd_smp_last_reset_tb) < (s64)wd_smp_panic_timeout_tb)
goto out;
if (cpumask_test_cpu(cpu, &wd_smp_cpus_pending))
@@ -192,7 +198,7 @@ static void watchdog_smp_panic(int cpu, u64 tb)
continue; // should not happen
  
  		__cpumask_set_cpu(c, &wd_smp_cpus_ipi);

-   if (set_cpu_stuck(c, tb))
+   if (set_cpu_stuck(c))
break;
}
if (cpumask_empty(&wd_smp_cpus_ipi)) {
@@ -232,7 +238,7 @@ static void watchdog_smp_panic(int cpu, u64 tb)
wd_smp_unlock(&flags);
  }
  
-static void wd_smp_clear_cpu_pending(int cpu, u64 tb)

+static void wd_smp_clear_cpu_pending(int cpu)
  {
if (!cpumask_test_cpu(cpu, &wd_smp_cpus_pending)) {
if (unlikely(cpumask_test_cpu(cpu, &wd_smp_cpus_stuck))) {
@@ -240,7 +246,7 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
unsigned long flags;
  
  			pr_emerg("CPU %d became unstuck TB:%lld\n",

-cpu, tb);
+cpu, get_tb());
print_irqtrace_events(current);
if (regs)
show_regs(regs);
@@ -301,7 +307,7 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
 */
wd_smp_lock(&flags);
if (cpumask_empty(&wd_smp_cpus_pending)) {
-   wd_smp_last_reset_tb = tb;
+   wd_smp_last_reset_tb = get_tb();
cpumask_andnot(&wd_smp_cpus_pending,
&wd_cpus_enabled,
&wd_smp_cpus_stuck);
@@ -316,10 +322,10 @@ static void watchdog_timer_interrupt(int cpu)
  
  	per_cpu(wd_timer_tb, cpu) = tb;
  
-	wd_smp_clear_cpu_pending(cpu, tb);

+   wd_smp_clear_cpu_pending(cpu);
  
  	if ((s64)(tb - wd_smp_last_reset_tb) >= (s64)wd_smp_panic_timeout_tb)

-   watchdog_smp_panic(cpu, tb);
+   watchdog_smp_panic(cpu);
  }
  
  DEFINE_INTERRUPT_HANDLER_NMI(soft_nmi_interrupt)

@@ -356,7 +362,7 @@ DEFINE_INTERRUPT_HANDLER_NMI(soft_nmi_interrupt)
return 0;
}
  
-		set_cpu_stuck(cpu, tb);

+   

[PATCH] powerpc/pseries: use slab context cpumask allocation in CPU hotplug init

2021-11-05 Thread Nicholas Piggin
Slab is up at this point, using the bootmem allocator triggers a
warning. Switch to using the regular cpumask allocator.

Signed-off-by: Nicholas Piggin 
---

This only matters when CONFIG_CPUMASK_OFFNODE=y, which has not been
possible before on powerpc.

Thanks,
Nick

 arch/powerpc/platforms/pseries/hotplug-cpu.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c 
b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index d646c22e94ab..78a70ba60d24 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -1016,12 +1016,13 @@ static int __init pseries_cpu_hotplug_init(void)
/* Processors can be added/removed only on LPAR */
if (firmware_has_feature(FW_FEATURE_LPAR)) {
for_each_node(node) {
-   alloc_bootmem_cpumask_var(&node_recorded_ids_map[node]);
+   if 
(!alloc_cpumask_var_node(&node_recorded_ids_map[node],
+   GFP_KERNEL, node))
+   return -ENOMEM;
 
/* Record ids of CPU added at boot time */
-   cpumask_or(node_recorded_ids_map[node],
-  node_recorded_ids_map[node],
-  cpumask_of_node(node));
+   cpumask_copy(node_recorded_ids_map[node],
+cpumask_of_node(node));
}
 
of_reconfig_notifier_register(&pseries_smp_nb);
-- 
2.23.0



[PATCH] powerpc/pseries: Fix numa FORM2 parsing fallback code

2021-11-05 Thread Nicholas Piggin
In case the FORM2 distance table from firmware is not the expected size,
there is fallback code that just populates the lookup table as local vs
remote.

However it then continues on to use the distance table. Fix.

Cc: Aneesh Kumar K.V 
Fixes: 1c6b5a7e7405 ("powerpc/pseries: Add support for FORM2 associativity")
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/mm/numa.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 6f14c8fb6359..0789cde7f658 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -380,6 +380,7 @@ static void 
initialize_form2_numa_distance_lookup_table(void)
const __be32 *numa_lookup_index;
int numa_dist_table_length;
int max_numa_index, distance_index;
+   bool good = true;
 
if (firmware_has_feature(FW_FEATURE_OPAL))
root = of_find_node_by_path("/ibm,opal");
@@ -407,30 +408,26 @@ static void 
initialize_form2_numa_distance_lookup_table(void)
 
if (numa_dist_table_length != max_numa_index * max_numa_index) {
WARN(1, "Wrong NUMA distance information\n");
-   /* consider everybody else just remote. */
-   for (i = 0;  i < max_numa_index; i++) {
-   for (j = 0; j < max_numa_index; j++) {
-   int nodeA = numa_id_index_table[i];
-   int nodeB = numa_id_index_table[j];
-
-   if (nodeA == nodeB)
-   numa_distance_table[nodeA][nodeB] = 
LOCAL_DISTANCE;
-   else
-   numa_distance_table[nodeA][nodeB] = 
REMOTE_DISTANCE;
-   }
-   }
+   good = false;
}
-
distance_index = 0;
for (i = 0;  i < max_numa_index; i++) {
for (j = 0; j < max_numa_index; j++) {
int nodeA = numa_id_index_table[i];
int nodeB = numa_id_index_table[j];
-
-   numa_distance_table[nodeA][nodeB] = 
numa_dist_table[distance_index++];
-   pr_debug("dist[%d][%d]=%d ", nodeA, nodeB, 
numa_distance_table[nodeA][nodeB]);
+   int dist;
+
+   if (good)
+   dist = numa_dist_table[distance_index++];
+   else if (nodeA == nodeB)
+   dist = LOCAL_DISTANCE;
+   else
+   dist = REMOTE_DISTANCE;
+   numa_distance_table[nodeA][nodeB] = dist;
+   pr_debug("dist[%d][%d]=%d ", nodeA, nodeB, dist);
}
}
+
of_node_put(root);
 }
 
-- 
2.23.0



Re: [PATCH 0/3] KEXEC_SIG with appended signature

2021-11-05 Thread Michal Suchánek
On Fri, Nov 05, 2021 at 09:55:52PM +1100, Daniel Axtens wrote:
> Michal Suchanek  writes:
> 
> > S390 uses appended signature for kernel but implements the check
> > separately from module loader.
> >
> > Support for secure boot on powerpc with appended signature is planned -
> > grub patches submitted upstream but not yet merged.
> 
> Power Non-Virtualised / OpenPower already supports secure boot via kexec
> with signature verification via IMA. I think you have now sent a
> follow-up series that merges some of the IMA implementation, I just
> wanted to make sure it was clear that we actually already have support

So is IMA_KEXEC and KEXEC_SIG redundant?

I see some architectures have both. I also see there is a lot of overlap
between the IMA framework and the KEXEC_SIG and MODULE_SIg.

Thanks

Michal


Re: [PATCH 1/2] powerpc: remove cpu_online_cores_map function

2021-11-05 Thread Sachin Sant



> On 05-Nov-2021, at 9:20 AM, Nicholas Piggin  wrote:
> 
> This function builds the cores online map with on-stack cpumasks which
> can cause high stack usage with large NR_CPUS.
> 
> It is not used in any performance sensitive paths, so instead just check
> for first thread sibling.
> 
> Signed-off-by: Nicholas Piggin 
> ---

Tested-by: Sachin Sant 

Thanks
- Sachin

> arch/powerpc/include/asm/cputhreads.h | 33 ---
> arch/powerpc/platforms/powernv/idle.c | 10 +++
> arch/powerpc/platforms/powernv/opal-imc.c |  6 ++---
> 3 files changed, 8 insertions(+), 41 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/cputhreads.h 
> b/arch/powerpc/include/asm/cputhreads.h
> index b167186aaee4..f26c430f3982 100644
> --- a/arch/powerpc/include/asm/cputhreads.h
> +++ b/arch/powerpc/include/asm/cputhreads.h
> @@ -32,44 +32,11 @@ extern cpumask_t threads_core_mask;
> #define threads_core_mask (*get_cpu_mask(0))
> #endif
> 
> -/* cpu_thread_mask_to_cores - Return a cpumask of one per cores
> - *hit by the argument
> - *
> - * @threads: a cpumask of online threads
> - *
> - * This function returns a cpumask which will have one online cpu's
> - * bit set for each core that has at least one thread set in the argument.
> - *
> - * This can typically be used for things like IPI for tlb invalidations
> - * since those need to be done only once per core/TLB
> - */
> -static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask 
> *threads)
> -{
> - cpumask_t   tmp, res;
> - int i, cpu;
> -
> - cpumask_clear(&res);
> - for (i = 0; i < NR_CPUS; i += threads_per_core) {
> - cpumask_shift_left(&tmp, &threads_core_mask, i);
> - if (cpumask_intersects(threads, &tmp)) {
> - cpu = cpumask_next_and(-1, &tmp, cpu_online_mask);
> - if (cpu < nr_cpu_ids)
> - cpumask_set_cpu(cpu, &res);
> - }
> - }
> - return res;
> -}
> -
> static inline int cpu_nr_cores(void)
> {
>   return nr_cpu_ids >> threads_shift;
> }
> 
> -static inline cpumask_t cpu_online_cores_map(void)
> -{
> - return cpu_thread_mask_to_cores(cpu_online_mask);
> -}
> -
> #ifdef CONFIG_SMP
> int cpu_core_index_of_thread(int cpu);
> int cpu_first_thread_of_core(int core);
> diff --git a/arch/powerpc/platforms/powernv/idle.c 
> b/arch/powerpc/platforms/powernv/idle.c
> index e3ffdc8e8567..70da314fd2d7 100644
> --- a/arch/powerpc/platforms/powernv/idle.c
> +++ b/arch/powerpc/platforms/powernv/idle.c
> @@ -146,9 +146,13 @@ EXPORT_SYMBOL_GPL(pnv_get_supported_cpuidle_states);
> static void pnv_fastsleep_workaround_apply(void *info)
> 
> {
> + int cpu = smp_processor_id();
>   int rc;
>   int *err = info;
> 
> + if (cpu_first_thread_sibling(cpu) != cpu)
> + return;
> +
>   rc = opal_config_cpu_idle_state(OPAL_CONFIG_IDLE_FASTSLEEP,
>   OPAL_CONFIG_IDLE_APPLY);
>   if (rc)
> @@ -175,7 +179,6 @@ static ssize_t 
> store_fastsleep_workaround_applyonce(struct device *dev,
>   struct device_attribute *attr, const char *buf,
>   size_t count)
> {
> - cpumask_t primary_thread_mask;
>   int err;
>   u8 val;
> 
> @@ -200,10 +203,7 @@ static ssize_t 
> store_fastsleep_workaround_applyonce(struct device *dev,
>   power7_fastsleep_workaround_exit = false;
> 
>   cpus_read_lock();
> - primary_thread_mask = cpu_online_cores_map();
> - on_each_cpu_mask(&primary_thread_mask,
> - pnv_fastsleep_workaround_apply,
> - &err, 1);
> + on_each_cpu(pnv_fastsleep_workaround_apply, &err, 1);
>   cpus_read_unlock();
>   if (err) {
>   pr_err("fastsleep_workaround_applyonce change failed while 
> running pnv_fastsleep_workaround_apply");
> diff --git a/arch/powerpc/platforms/powernv/opal-imc.c 
> b/arch/powerpc/platforms/powernv/opal-imc.c
> index 05d3832019b9..3fea5da6d1b3 100644
> --- a/arch/powerpc/platforms/powernv/opal-imc.c
> +++ b/arch/powerpc/platforms/powernv/opal-imc.c
> @@ -200,13 +200,13 @@ static void disable_nest_pmu_counters(void)
> 
> static void disable_core_pmu_counters(void)
> {
> - cpumask_t cores_map;
>   int cpu, rc;
> 
>   cpus_read_lock();
>   /* Disable the IMC Core functions */
> - cores_map = cpu_online_cores_map();
> - for_each_cpu(cpu, &cores_map) {
> + for_each_online_cpu(cpu) {
> + if (cpu_first_thread_sibling(cpu) != cpu)
> + continue;
>   rc = opal_imc_counters_stop(OPAL_IMC_COUNTERS_CORE,
>   get_hard_smp_processor_id(cpu));
>   if (rc)
> -- 
> 2.23.0
> 



[GIT PULL] Please pull powerpc/linux.git powerpc-5.16-1 tag

2021-11-05 Thread Michael Ellerman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi Linus,

Please pull a small batch of powerpc updates for 5.16:

The following changes since commit e4e737bb5c170df6135a127739a9e6148ee3da82:

  Linux 5.15-rc2 (2021-09-19 17:28:22 -0700)

are available in the git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 
tags/powerpc-5.16-1

for you to fetch changes up to c12ab8dbc492b992e1ea717db933cee568780c47:

  powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST 
(2021-11-01 21:39:03 +1100)

- --
powerpc updates for 5.16

 - Enable STRICT_KERNEL_RWX for Freescale 85xx platforms.

 - Activate CONFIG_STRICT_KERNEL_RWX by default, while still allowing it to be 
disabled.

 - Add support for out-of-line static calls on 32-bit.

 - Fix oopses doing bpf-to-bpf calls when STRICT_KERNEL_RWX is enabled.

 - Fix boot hangs on e5500 due to stale value in ESR passed to do_page_fault().

 - Fix several bugs on pseries in handling of device tree cache information for 
hotplugged
   CPUs, and/or during partition migration.

 - Various other small features and fixes.

Thanks to: Alexey Kardashevskiy, Alistair Popple, Anatolij Gustschin, Andrew 
Donnellan,
Athira Rajeev, Bixuan Cui, Bjorn Helgaas, Cédric Le Goater, Christophe Leroy, 
Daniel
Axtens, Daniel Henrique Barboza, Denis Kirjanov, Fabiano Rosas, Frederic 
Barrat, Gustavo
A. R. Silva, Hari Bathini, Jacques de Laval, Joel Stanley, Kai Song, Kajol 
Jain, Laurent
Vivier, Leonardo Bras, Madhavan Srinivasan, Nathan Chancellor, Nathan Lynch, 
Naveen N.
Rao, Nicholas Piggin, Nick Desaulniers, Niklas Schnelle, Oliver O'Halloran, Rob 
Herring,
Russell Currey, Srikar Dronamraju, Stan Johnson, Tyrel Datwyler, Uwe 
Kleine-König, Vasant
Hegde, Wan Jiabing, Xiaoming Ni,

- --
Alexey Kardashevskiy (1):
  powerps/pseries/dma: Add support for 2M IOMMU page size

Anatolij Gustschin (3):
  powerpc/5200: dts: add missing pci ranges
  powerpc/5200: dts: fix pci ranges warnings
  powerpc/5200: dts: fix memory node unit name

Athira Rajeev (3):
  powerpc/perf: Refactor the code definition of perf reg extended mask
  powerpc/perf: Expose instruction and data address registers as part of 
extended regs
  powerpc/perf: Fix cycles/instructions as PM_CYC/PM_INST_CMPL in power10

Bixuan Cui (1):
  powerpc/44x/fsp2: add missing of_node_put

Christophe Leroy (31):
  powerpc/476: Fix sparse report
  powerpc/powermac: Remove stale declaration of pmac_md
  powerpc/mem: Fix arch/powerpc/mm/mem.c:53:12: error: no previous 
prototype for 'create_section_mapping'
  video: fbdev: chipsfb: use memset_io() instead of memset()
  powerpc: Set max_mapnr correctly
  powerpc: Mark .opd section read-only
  powerpc/booke: Disable STRICT_KERNEL_RWX, DEBUG_PAGEALLOC and KFENCE
  powerpc/fsl_booke: Rename fsl_booke.c to fsl_book3e.c
  powerpc/fsl_booke: Take exec flag into account when setting TLBCAMs
  powerpc/fsl_booke: Enable reloading of TLBCAM without switching to AS1
  powerpc/fsl_booke: Tell map_mem_in_cams() if init is done
  powerpc/fsl_booke: Allocate separate TLBCAMs for readonly memory
  powerpc/fsl_booke: Update of TLBCAMs after init
  powerpc/fsl_booke: Enable STRICT_KERNEL_RWX
  powerpc/32: Don't use lmw/stmw for saving/restoring non volatile regs
  powerpc/audit: Convert powerpc to AUDIT_ARCH_COMPAT_GENERIC
  powerpc/time: Remove generic_suspend_{dis/en}able_irqs()
  powerpc/machdep: Remove stale functions from ppc_md structure
  powerpc/32: Add support for out-of-line static calls
  powerpc: warn on emulation of dcbz instruction in kernel mode
  powerpc/lib/sstep: Don't use __{get/put}_user() on kernel addresses
  powerpc/8xx: Simplify TLB handling
  powerpc: Activate CONFIG_STRICT_KERNEL_RWX by default
  powerpc/breakpoint: Cleanup
  powerpc/32: Don't use a struct based type for pte_t
  powerpc/boot: Set LC_ALL=C in wrapper script
  powerpc/nohash: Fix __ptep_set_access_flags() and ptep_set_wrprotect()
  powerpc/book3e: Fix set_memory_x() and set_memory_nx()
  powerpc/fsl_booke: Fix setting of exec flag when setting TLBCAMs
  powerpc: Don't provide __kernel_map_pages() without 
ARCH_SUPPORTS_DEBUG_PAGEALLOC
  powerpc/8xx: Fix Oops with STRICT_KERNEL_RWX without DEBUG_RODATA_TEST

Cédric Le Goater (1):
  powerpc/boot: Use CONFIG_PPC_POWERNV to compile OPAL support

Daniel Axtens (1):
  powerpc: Remove unused prototype for of_show_percpuinfo

Denis Kirjanov (1):
  powerpc/xmon: fix task state output

Gustavo A. R. Silva (1):
  powerpc/vas: Fix potential NULL pointer dereference

Hari Bathini (1):
  powerpc/bpf: Fix write protecting JIT code

Joel Stanley (2):
  powerpc/s64: Clarify that radix lacks DEBUG_PAGEALLOC
  powerpc/64s: Default to 64K 

Re: [PATCH v2 1/5] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race

2021-11-05 Thread Laurent Dufour

Le 05/11/2021 à 12:46, Nicholas Piggin a écrit :

Excerpts from Laurent Dufour's message of November 5, 2021 7:20 pm:

Le 04/11/2021 à 17:10, Nicholas Piggin a écrit :

It is possible for all CPUs to miss the pending cpumask becoming clear,
and then nobody resetting it, which will cause the lockup detector to
stop working. It will eventually expire, but watchdog_smp_panic will
avoid doing anything if the pending mask is clear and it will never be
reset.

Order the cpumask clear vs the subsequent test to close this race.

Add an extra check for an empty pending mask when the watchdog fires and
finds its bit still clear, to try to catch any other possible races or
bugs here and keep the watchdog working. The extra test in
arch_touch_nmi_watchdog is required to prevent the new warning from
firing off.

Debugged-by: Laurent Dufour 
Signed-off-by: Nicholas Piggin 
---
   arch/powerpc/kernel/watchdog.c | 36 +-
   1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index f9ea0e5357f9..be80071336a4 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -135,6 +135,10 @@ static void set_cpumask_stuck(const struct cpumask 
*cpumask, u64 tb)
   {
cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask);
cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask);
+   /*
+* See wd_smp_clear_cpu_pending()
+*/
+   smp_mb();
if (cpumask_empty(&wd_smp_cpus_pending)) {
wd_smp_last_reset_tb = tb;
cpumask_andnot(&wd_smp_cpus_pending,
@@ -215,13 +219,39 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
   
   			cpumask_clear_cpu(cpu, &wd_smp_cpus_stuck);

wd_smp_unlock(&flags);
+   } else {
+   /*
+* The last CPU to clear pending should have reset the
+* watchdog, yet we find it empty here. This should not
+* happen but we can try to recover and avoid a false
+* positive if it does.
+*/
+   if (WARN_ON_ONCE(cpumask_empty(&wd_smp_cpus_pending)))
+   goto none_pending;


I run a stress on my victim node on top of this patch and hit that warning:

[  C475] [ cut here ]
[  C475] WARNING: CPU: 475 PID: 0 at
/home/laurent/src/linux-ppc/arch/powerpc/kernel/watchdog.c:260
wd_smp_clear_cpu_pending+0x320/0x4b0
[  C475] Modules linked in: rpadlpar_io rpaphp xt_tcpudp iptable_filter
ip_tables x_tables xfs pseries_rng rng_core vmx_crypto gf128mul be2net fuse
btrfs blake2b_generic libcrc32c xor zstd_compress lzo_compress raid6_pq
dm_service_time crc32c_vpmsum lpfc crc_t10dif crct10dif_generic crct10dif_common
dm_mirror dm_region_hash dm_log dm_multipath scsi_dh_rdac scsi_dh_alua autofs4
[  C475] CPU: 475 PID: 0 Comm: swapper/475 Kdump: loaded Not tainted
5.15.0-rc2-ppc-bz192129+ #72
[  C475] NIP:  c003d710 LR: c003d478 CTR: c003e2e0
[  C475] REGS: c6b16026f420 TRAP: 0700   Not tainted  
(5.15.0-rc2-ppc-bz192129+)
[  C475] MSR:  80029033   CR: 22000222  XER: 
2000
[  C475] CFAR: c003d480 IRQMASK: 3
[  C475] GPR00: c003e3bc c6b16026f6c0 c1b28700 
0800
[  C475] GPR04:  0800 0800 

[  C475] GPR08:   00f8 
00013f06986272e7
[  C475] GPR12: c003e2e0 c7d3df00  
1f043b60
[  C475] GPR16: c6b1601b7b00  c003e2e0 
0001
[  C475] GPR20: 347411d4cf28 c7adbdb0a898 0001 

[  C475] GPR24:  0003 c1b6d7d0 
00013f0698627d84
[  C475] GPR28: c1bd05c8 c1bd05b8 c1bd06c8 
01db
[  C475] NIP [c003d710] wd_smp_clear_cpu_pending+0x320/0x4b0
[  C475] LR [c003d478] wd_smp_clear_cpu_pending+0x88/0x4b0
[  C475] Call Trace:
[  C475] [c6b16026f6c0] [0001] 0x1 (unreliable)
[  C475] [c6b16026f770] [c003e3bc] watchdog_timer_fn+0xdc/0x5a0
[  C475] [c6b16026f840] [c0245a4c] __hrtimer_run_queues+0x49c/0x700
[  C475] [c6b16026f8f0] [c0246c20] hrtimer_interrupt+0x110/0x310
[  C475] [c6b16026f9a0] [c00292f8] timer_interrupt+0x1e8/0x5a0
[  C475] [c6b16026fa00] [c0009a00] 
decrementer_common_virt+0x210/0x220
[  C475] --- interrupt: 900 at plpar_hcall_norets_notrace+0x18/0x2c
[  C475] NIP:  c00e5dd0 LR: c0c18f04 CTR: 
[  C475] REGS: c6b16026fa70 TRAP: 0900   Not tainted  
(5.15.0-rc2-ppc-bz192129+)
[  C475] MSR:  80009033   CR: 22000824  XER: 
2000
[  C475] CFAR: 0c00 IRQMASK: 0
[  C475] GPR00: 0

[Bug 214913] [xfstests generic/051] BUG: Kernel NULL pointer dereference on read at 0x00000108 NIP [c0000000000372e4] tm_cgpr_active+0x14/0x40

2021-11-05 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=214913

--- Comment #4 from Zorro Lang (zl...@redhat.com) ---
(In reply to Michal Suchanek from comment #3)
> What CPU is this?
> 
> Does it go away if you boot with ppc_tm=off

(In reply to Michael Ellerman from comment #2)
> Thanks for the report, I agree this looks like a powerpc bug not an XFS bug.
> 
> I won't have time to look at this until next week probably, unless someone
> beats me to it.

Thanks for you reply. (Un)fortunately, due to linux keeps updating, I can't
reproduce this panic on latest mainline linux master branch now. The HEAD
commit is 7ddb58cb0eca. From 8bb7eca972ad (v5.15) to 7ddb58cb0eca (v5.15+),
there're many changes, I can't sure which commit fixes this bug, or hide it? Do
you know if there was a known issue about this has been fixed?

Thanks,
Zorro

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.

Re: [PATCH v2 1/5] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race

2021-11-05 Thread Nicholas Piggin
Excerpts from Laurent Dufour's message of November 5, 2021 7:20 pm:
> Le 04/11/2021 à 17:10, Nicholas Piggin a écrit :
>> It is possible for all CPUs to miss the pending cpumask becoming clear,
>> and then nobody resetting it, which will cause the lockup detector to
>> stop working. It will eventually expire, but watchdog_smp_panic will
>> avoid doing anything if the pending mask is clear and it will never be
>> reset.
>> 
>> Order the cpumask clear vs the subsequent test to close this race.
>> 
>> Add an extra check for an empty pending mask when the watchdog fires and
>> finds its bit still clear, to try to catch any other possible races or
>> bugs here and keep the watchdog working. The extra test in
>> arch_touch_nmi_watchdog is required to prevent the new warning from
>> firing off.
>> 
>> Debugged-by: Laurent Dufour 
>> Signed-off-by: Nicholas Piggin 
>> ---
>>   arch/powerpc/kernel/watchdog.c | 36 +-
>>   1 file changed, 35 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
>> index f9ea0e5357f9..be80071336a4 100644
>> --- a/arch/powerpc/kernel/watchdog.c
>> +++ b/arch/powerpc/kernel/watchdog.c
>> @@ -135,6 +135,10 @@ static void set_cpumask_stuck(const struct cpumask 
>> *cpumask, u64 tb)
>>   {
>>  cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask);
>>  cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask);
>> +/*
>> + * See wd_smp_clear_cpu_pending()
>> + */
>> +smp_mb();
>>  if (cpumask_empty(&wd_smp_cpus_pending)) {
>>  wd_smp_last_reset_tb = tb;
>>  cpumask_andnot(&wd_smp_cpus_pending,
>> @@ -215,13 +219,39 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
>>   
>>  cpumask_clear_cpu(cpu, &wd_smp_cpus_stuck);
>>  wd_smp_unlock(&flags);
>> +} else {
>> +/*
>> + * The last CPU to clear pending should have reset the
>> + * watchdog, yet we find it empty here. This should not
>> + * happen but we can try to recover and avoid a false
>> + * positive if it does.
>> + */
>> +if (WARN_ON_ONCE(cpumask_empty(&wd_smp_cpus_pending)))
>> +goto none_pending;
> 
> I run a stress on my victim node on top of this patch and hit that warning:
> 
> [  C475] [ cut here ]
> [  C475] WARNING: CPU: 475 PID: 0 at 
> /home/laurent/src/linux-ppc/arch/powerpc/kernel/watchdog.c:260 
> wd_smp_clear_cpu_pending+0x320/0x4b0
> [  C475] Modules linked in: rpadlpar_io rpaphp xt_tcpudp iptable_filter 
> ip_tables x_tables xfs pseries_rng rng_core vmx_crypto gf128mul be2net fuse 
> btrfs blake2b_generic libcrc32c xor zstd_compress lzo_compress raid6_pq 
> dm_service_time crc32c_vpmsum lpfc crc_t10dif crct10dif_generic 
> crct10dif_common 
> dm_mirror dm_region_hash dm_log dm_multipath scsi_dh_rdac scsi_dh_alua autofs4
> [  C475] CPU: 475 PID: 0 Comm: swapper/475 Kdump: loaded Not tainted 
> 5.15.0-rc2-ppc-bz192129+ #72
> [  C475] NIP:  c003d710 LR: c003d478 CTR: c003e2e0
> [  C475] REGS: c6b16026f420 TRAP: 0700   Not tainted  
> (5.15.0-rc2-ppc-bz192129+)
> [  C475] MSR:  80029033   CR: 22000222  XER: 
> 2000
> [  C475] CFAR: c003d480 IRQMASK: 3
> [  C475] GPR00: c003e3bc c6b16026f6c0 c1b28700 
> 0800
> [  C475] GPR04:  0800 0800 
> 
> [  C475] GPR08:   00f8 
> 00013f06986272e7
> [  C475] GPR12: c003e2e0 c7d3df00  
> 1f043b60
> [  C475] GPR16: c6b1601b7b00  c003e2e0 
> 0001
> [  C475] GPR20: 347411d4cf28 c7adbdb0a898 0001 
> 
> [  C475] GPR24:  0003 c1b6d7d0 
> 00013f0698627d84
> [  C475] GPR28: c1bd05c8 c1bd05b8 c1bd06c8 
> 01db
> [  C475] NIP [c003d710] wd_smp_clear_cpu_pending+0x320/0x4b0
> [  C475] LR [c003d478] wd_smp_clear_cpu_pending+0x88/0x4b0
> [  C475] Call Trace:
> [  C475] [c6b16026f6c0] [0001] 0x1 (unreliable)
> [  C475] [c6b16026f770] [c003e3bc] watchdog_timer_fn+0xdc/0x5a0
> [  C475] [c6b16026f840] [c0245a4c] 
> __hrtimer_run_queues+0x49c/0x700
> [  C475] [c6b16026f8f0] [c0246c20] hrtimer_interrupt+0x110/0x310
> [  C475] [c6b16026f9a0] [c00292f8] timer_interrupt+0x1e8/0x5a0
> [  C475] [c6b16026fa00] [c0009a00] 
> decrementer_common_virt+0x210/0x220
> [  C475] --- interrupt: 900 at plpar_hcall_norets_notrace+0x18/0x2c
> [  C475] NIP:  c00e5dd0 LR: c0c18f04 CTR: 
> [  C475] REGS: c6b16026fa70 TRAP: 0900   Not tainted  

Re: [PATCH 0/3] KEXEC_SIG with appended signature

2021-11-05 Thread Daniel Axtens
Michal Suchanek  writes:

> S390 uses appended signature for kernel but implements the check
> separately from module loader.
>
> Support for secure boot on powerpc with appended signature is planned -
> grub patches submitted upstream but not yet merged.

Power Non-Virtualised / OpenPower already supports secure boot via kexec
with signature verification via IMA. I think you have now sent a
follow-up series that merges some of the IMA implementation, I just
wanted to make sure it was clear that we actually already have support
for this in the kernel, it's just grub that is getting new support.

> This is an attempt at unified appended signature verification.

I am always in favour of fewer reimplementations of the same feature in
the kernel :)

Regards,
Daniel

>
> Thanks
>
> Michal
>
> Michal Suchanek (3):
>   s390/kexec_file: Don't opencode appended signature verification.
>   module: strip the signature marker in the verification function.
>   powerpc/kexec_file: Add KEXEC_SIG support.
>
>  arch/powerpc/Kconfig  | 11 +++
>  arch/powerpc/kexec/elf_64.c   | 14 +
>  arch/s390/kernel/machine_kexec_file.c | 42 +++
>  include/linux/verification.h  |  3 ++
>  kernel/module-internal.h  |  2 --
>  kernel/module.c   | 11 +++
>  kernel/module_signing.c   | 32 ++--
>  7 files changed, 59 insertions(+), 56 deletions(-)
>
> -- 
> 2.31.1


[PATCH 07/11] powerpc/xive: Add a debugfs file to dump EQs

2021-11-05 Thread Cédric Le Goater
The XIVE driver under Linux uses a single interrupt priority and only
one event queue is configured per CPU. Expose the contents under
a 'xive/eqs/cpuX' debugfs file.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 37 +++
 1 file changed, 37 insertions(+)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index c5167f284da5..75c683ffae7e 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1775,9 +1775,40 @@ static int xive_ipi_debug_show(struct seq_file *m, void 
*private)
 }
 DEFINE_SHOW_ATTRIBUTE(xive_ipi_debug);
 
+static void xive_eq_debug_show_one(struct seq_file *m, struct xive_q *q, u8 
prio)
+{
+   int i;
+
+   seq_printf(m, "EQ%d idx=%d T=%d\n", prio, q->idx, q->toggle);
+   if (q->qpage) {
+   for (i = 0; i < q->msk + 1; i++) {
+   if (!(i % 8))
+   seq_printf(m, "%05d ", i);
+   seq_printf(m, "%08x%s", be32_to_cpup(q->qpage + i),
+  (i + 1) % 8 ? " " : "\n");
+   }
+   }
+   seq_puts(m, "\n");
+}
+
+static int xive_eq_debug_show(struct seq_file *m, void *private)
+{
+   int cpu = (long)m->private;
+   struct xive_cpu *xc = per_cpu(xive_cpu, cpu);
+
+   if (xc)
+   xive_eq_debug_show_one(m, &xc->queue[xive_irq_priority],
+  xive_irq_priority);
+   return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(xive_eq_debug);
+
 static void xive_core_debugfs_create(void)
 {
struct dentry *xive_dir;
+   struct dentry *xive_eq_dir;
+   long cpu;
+   char name[16];
 
xive_dir = debugfs_create_dir("xive", arch_debugfs_dir);
if (IS_ERR(xive_dir))
@@ -1787,6 +1818,12 @@ static void xive_core_debugfs_create(void)
NULL, &xive_ipi_debug_fops);
debugfs_create_file("interrupts", 0400, xive_dir,
NULL, &xive_irq_debug_fops);
+   xive_eq_dir = debugfs_create_dir("eqs", xive_dir);
+   for_each_possible_cpu(cpu) {
+   snprintf(name, sizeof(name), "cpu%ld", cpu);
+   debugfs_create_file(name, 0400, xive_eq_dir, (void *)cpu,
+   &xive_eq_debug_fops);
+   }
 }
 
 #endif /* CONFIG_DEBUG_FS */
-- 
2.31.1



[PATCH 05/11] powerpc/xive: Change the debugfs file 'xive' into a directory

2021-11-05 Thread Cédric Le Goater
Use a 'cpus' file to dump CPU states and 'interrupts' to dump IRQ states.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 36 +--
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index b71cc1020296..0b34ad5748ee 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1760,17 +1760,10 @@ static void xive_debug_show_irq(struct seq_file *m, 
struct irq_data *d)
seq_puts(m, "\n");
 }
 
-static int xive_core_debug_show(struct seq_file *m, void *private)
+static int xive_irq_debug_show(struct seq_file *m, void *private)
 {
unsigned int i;
struct irq_desc *desc;
-   int cpu;
-
-   if (xive_ops->debug_show)
-   xive_ops->debug_show(m, private);
-
-   for_each_possible_cpu(cpu)
-   xive_debug_show_cpu(m, cpu);
 
for_each_irq_desc(i, desc) {
struct irq_data *d = irq_domain_get_irq_data(xive_irq_domain, 
i);
@@ -1780,12 +1773,33 @@ static int xive_core_debug_show(struct seq_file *m, 
void *private)
}
return 0;
 }
-DEFINE_SHOW_ATTRIBUTE(xive_core_debug);
+DEFINE_SHOW_ATTRIBUTE(xive_irq_debug);
+
+static int xive_cpu_debug_show(struct seq_file *m, void *private)
+{
+   int cpu;
+
+   if (xive_ops->debug_show)
+   xive_ops->debug_show(m, private);
+
+   for_each_possible_cpu(cpu)
+   xive_debug_show_cpu(m, cpu);
+   return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(xive_cpu_debug);
 
 static void xive_core_debugfs_create(void)
 {
-   debugfs_create_file("xive", 0400, arch_debugfs_dir,
-   NULL, &xive_core_debug_fops);
+   struct dentry *xive_dir;
+
+   xive_dir = debugfs_create_dir("xive", arch_debugfs_dir);
+   if (IS_ERR(xive_dir))
+   return;
+
+   debugfs_create_file("cpus", 0400, xive_dir,
+   NULL, &xive_cpu_debug_fops);
+   debugfs_create_file("interrupts", 0400, xive_dir,
+   NULL, &xive_irq_debug_fops);
 }
 
 #endif /* CONFIG_DEBUG_FS */
-- 
2.31.1



[PATCH 11/11] powerpc/smp: Add a doorbell=off kernel parameter

2021-11-05 Thread Cédric Le Goater
On processors with a XIVE interrupt controller (POWER9 and above), the
kernel can use either doorbells or XIVE to generate CPU IPIs. Sending
doorbell is generally preferred to using the XIVE IC because it is
faster. There are cases where we want to avoid doorbells and use XIVE
only, for debug or performance. Only useful on POWER9 and above.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/include/asm/dbell.h|  1 +
 arch/powerpc/kernel/dbell.c | 17 +
 arch/powerpc/platforms/powernv/smp.c|  7 +--
 arch/powerpc/platforms/pseries/smp.c|  3 +++
 Documentation/admin-guide/kernel-parameters.txt | 10 ++
 5 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h
index 3e9da22a2779..07775aa3e81b 100644
--- a/arch/powerpc/include/asm/dbell.h
+++ b/arch/powerpc/include/asm/dbell.h
@@ -90,6 +90,7 @@ static inline void ppc_msgsync(void)
 #endif /* CONFIG_PPC_BOOK3S */
 
 extern void doorbell_exception(struct pt_regs *regs);
+extern bool doorbell_disabled;
 
 static inline void ppc_msgsnd(enum ppc_dbell type, u32 flags, u32 tag)
 {
diff --git a/arch/powerpc/kernel/dbell.c b/arch/powerpc/kernel/dbell.c
index 5545c9cd17c1..681ee4775629 100644
--- a/arch/powerpc/kernel/dbell.c
+++ b/arch/powerpc/kernel/dbell.c
@@ -38,6 +38,23 @@ DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
 
set_irq_regs(old_regs);
 }
+
+bool doorbell_disabled;
+
+static int __init doorbell_cmdline(char *arg)
+{
+   if (!arg)
+   return -EINVAL;
+
+   if (strncmp(arg, "off", 3) == 0) {
+   pr_info("Doorbell disabled on kernel command line\n");
+   doorbell_disabled = true;
+   }
+
+   return 0;
+}
+__setup("doorbell=", doorbell_cmdline);
+
 #else /* CONFIG_SMP */
 DEFINE_INTERRUPT_HANDLER_ASYNC(doorbell_exception)
 {
diff --git a/arch/powerpc/platforms/powernv/smp.c 
b/arch/powerpc/platforms/powernv/smp.c
index cbb67813cd5d..1311bda9446a 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -338,10 +338,13 @@ static void __init pnv_smp_probe(void)
ic_cause_ipi = smp_ops->cause_ipi;
WARN_ON(!ic_cause_ipi);
 
-   if (cpu_has_feature(CPU_FTR_ARCH_300))
+   if (cpu_has_feature(CPU_FTR_ARCH_300)) {
+   if (doorbell_disabled)
+   return;
smp_ops->cause_ipi = doorbell_global_ipi;
-   else
+   } else {
smp_ops->cause_ipi = pnv_cause_ipi;
+   }
}
 }
 
diff --git a/arch/powerpc/platforms/pseries/smp.c 
b/arch/powerpc/platforms/pseries/smp.c
index f47429323eee..3bc9e6aaf645 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -229,6 +229,9 @@ static __init void pSeries_smp_probe(void)
return;
}
 
+   if (doorbell_disabled)
+   return;
+
/*
 * Under PowerVM, FSCR[MSGP] is enabled as guest vCPU siblings are
 * gang scheduled on the same physical core, so doorbells are always
diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 10fa093251e8..2e1284febe39 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1041,6 +1041,16 @@
The filter can be disabled or changed to another
driver later using sysfs.
 
+   doorbell=off[PPC]
+   On processors with a XIVE interrupt controller
+   (POWER9 and above), the kernel can use either
+   doorbells or XIVE to generate CPU IPIs. Sending
+   doorbell is generally preferred to using the XIVE
+   IC because it is faster. There are cases where
+   we want to avoid doorbells and use XIVE only,
+   for debug or performance. Only useful on
+   POWER9 and above.
+
driver_async_probe=  [KNL]
List of driver names to be probed asynchronously.
Format: ,...
-- 
2.31.1



[PATCH 06/11] powerpc/xive: Rename the 'cpus' debugfs file to 'ipis'

2021-11-05 Thread Cédric Le Goater
and remove the EQ entries output which is not very useful since only
the next two events of the queue are taken into account. We will
improve the dump of the EQ in the next patches.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 27 +++
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 0b34ad5748ee..c5167f284da5 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1704,11 +1704,11 @@ static int __init xive_off(char *arg)
 __setup("xive=off", xive_off);
 
 #ifdef CONFIG_DEBUG_FS
-static void xive_debug_show_cpu(struct seq_file *m, int cpu)
+static void xive_debug_show_ipi(struct seq_file *m, int cpu)
 {
struct xive_cpu *xc = per_cpu(xive_cpu, cpu);
 
-   seq_printf(m, "CPU %d:", cpu);
+   seq_printf(m, "CPU %d: ", cpu);
if (xc) {
seq_printf(m, "pp=%02x CPPR=%02x ", xc->pending_prio, xc->cppr);
 
@@ -1720,19 +1720,6 @@ static void xive_debug_show_cpu(struct seq_file *m, int 
cpu)
seq_printf(m, "IPI=0x%08x %s", xc->hw_ipi, buffer);
}
 #endif
-   {
-   struct xive_q *q = &xc->queue[xive_irq_priority];
-   u32 i0, i1, idx;
-
-   if (q->qpage) {
-   idx = q->idx;
-   i0 = be32_to_cpup(q->qpage + idx);
-   idx = (idx + 1) & q->msk;
-   i1 = be32_to_cpup(q->qpage + idx);
-   seq_printf(m, "EQ idx=%d T=%d %08x %08x ...",
-  q->idx, q->toggle, i0, i1);
-   }
-   }
}
seq_puts(m, "\n");
 }
@@ -1775,7 +1762,7 @@ static int xive_irq_debug_show(struct seq_file *m, void 
*private)
 }
 DEFINE_SHOW_ATTRIBUTE(xive_irq_debug);
 
-static int xive_cpu_debug_show(struct seq_file *m, void *private)
+static int xive_ipi_debug_show(struct seq_file *m, void *private)
 {
int cpu;
 
@@ -1783,10 +1770,10 @@ static int xive_cpu_debug_show(struct seq_file *m, void 
*private)
xive_ops->debug_show(m, private);
 
for_each_possible_cpu(cpu)
-   xive_debug_show_cpu(m, cpu);
+   xive_debug_show_ipi(m, cpu);
return 0;
 }
-DEFINE_SHOW_ATTRIBUTE(xive_cpu_debug);
+DEFINE_SHOW_ATTRIBUTE(xive_ipi_debug);
 
 static void xive_core_debugfs_create(void)
 {
@@ -1796,8 +1783,8 @@ static void xive_core_debugfs_create(void)
if (IS_ERR(xive_dir))
return;
 
-   debugfs_create_file("cpus", 0400, xive_dir,
-   NULL, &xive_cpu_debug_fops);
+   debugfs_create_file("ipis", 0400, xive_dir,
+   NULL, &xive_ipi_debug_fops);
debugfs_create_file("interrupts", 0400, xive_dir,
NULL, &xive_irq_debug_fops);
 }
-- 
2.31.1



[PATCH 08/11] powerpc/xive: Add a debugfs toggle for StoreEOI

2021-11-05 Thread Cédric Le Goater
It can be used to deactivate temporarily StoreEOI for tests or
performance on platforms supporting the feature (POWER10)

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 75c683ffae7e..11e2aaa13965 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -84,6 +84,16 @@ static DEFINE_PER_CPU(struct xive_cpu *, xive_cpu);
 /* An invalid CPU target */
 #define XIVE_INVALID_TARGET(-1)
 
+/*
+ * Global toggle to switch on/off StoreEOI
+ */
+static bool xive_store_eoi = true;
+
+static bool xive_is_store_eoi(struct xive_irq_data *xd)
+{
+   return xd->flags & XIVE_IRQ_FLAG_STORE_EOI && xive_store_eoi;
+}
+
 /*
  * Read the next entry in a queue, return its content if it's valid
  * or 0 if there is no new entry.
@@ -208,7 +218,7 @@ static notrace u8 xive_esb_read(struct xive_irq_data *xd, 
u32 offset)
 {
u64 val;
 
-   if (offset == XIVE_ESB_SET_PQ_10 && xd->flags & XIVE_IRQ_FLAG_STORE_EOI)
+   if (offset == XIVE_ESB_SET_PQ_10 && xive_is_store_eoi(xd))
offset |= XIVE_ESB_LD_ST_MO;
 
if ((xd->flags & XIVE_IRQ_FLAG_H_INT_ESB) && xive_ops->esb_rw)
@@ -233,7 +243,7 @@ static void xive_irq_data_dump(struct xive_irq_data *xd, 
char *buffer, size_t si
u64 val = xive_esb_read(xd, XIVE_ESB_GET);
 
snprintf(buffer, size, "flags=%c%c%c PQ=%c%c 0x%016llx 0x%016llx",
-xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
+xive_is_store_eoi(xd) ? 'S' : ' ',
 xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
 xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
 val & XIVE_ESB_VAL_P ? 'P' : '-',
@@ -395,7 +405,7 @@ static void xive_do_source_eoi(struct xive_irq_data *xd)
xd->stale_p = false;
 
/* If the XIVE supports the new "store EOI facility, use it */
-   if (xd->flags & XIVE_IRQ_FLAG_STORE_EOI) {
+   if (xive_is_store_eoi(xd)) {
xive_esb_write(xd, XIVE_ESB_STORE_EOI, 0);
return;
}
@@ -1824,6 +1834,7 @@ static void xive_core_debugfs_create(void)
debugfs_create_file(name, 0400, xive_eq_dir, (void *)cpu,
&xive_eq_debug_fops);
}
+   debugfs_create_bool("store-eoi", 0600, xive_dir, &xive_store_eoi);
 }
 
 #endif /* CONFIG_DEBUG_FS */
-- 
2.31.1



[PATCH 00/11] powerpc/xive: Improve diagnostic and activate StoreEOI on P10 PowerNV

2021-11-05 Thread Cédric Le Goater
Hello,

This series tries to improve diagnostic support in the XIVE driver. It
adds pr_debug() primitives that can be activated at run-time and changes
the debugfs xive entry to expose more information :

  /sys/kernel/debug/powerpc/xive/
├── eqs/
│   ├── cpu0
│   ├── cpu1
│   ├── cpu2
.   .
│   └── cpu99
├── interrupts
├── ipis
├── save-restore
└── store-eoi

It also introduces 2 new kernel parameters :

xive.store-eoi=off   to deactivate StoreEOI at boot but it still be
 reactivated through sysfs.
 
doorbell=off to deactivate doorbells for CPU IPIs
 and XIVE instead

The first is a workaround in case of a FW advertising the wrong
feature. It can be used to check performance also. The second is for
PowerVM development and tests when the LP-per-thread mode is
activated. Doorbells cannot be used in that case.

Finally, it activates StoreEOI support for the PowerNV platform. OPAL
for P10 has been released and we are free to use this extension.

Thanks,

C.


Cédric Le Goater (11):
  powerpc/xive: Replace pr_devel() by pr_debug() to ease debug
  powerpc/xive: Introduce an helper to print out interrupt
characteristics
  powerpc/xive: Activate StoreEOI on P10
  powerpc/xive: Introduce xive_core_debugfs_create()
  powerpc/xive: Change the debugfs file 'xive' into a directory
  powerpc/xive: Rename the 'cpus' debugfs file to 'ipis'
  powerpc/xive: Add a debugfs file to dump EQs
  powerpc/xive: Add a debugfs toggle for StoreEOI
  powerpc/xive: Add a kernel parameter for StoreEOI
  powerpc/xive: Add a debugfs toggle for save-restore
  powerpc/smp: Add a doorbell=off kernel parameter

 arch/powerpc/include/asm/dbell.h  |   1 +
 arch/powerpc/include/asm/opal-api.h   |   1 +
 arch/powerpc/sysdev/xive/xive-internal.h  |   1 +
 arch/powerpc/kernel/dbell.c   |  17 ++
 arch/powerpc/platforms/powernv/smp.c  |   7 +-
 arch/powerpc/platforms/pseries/smp.c  |   3 +
 arch/powerpc/sysdev/xive/common.c | 211 --
 arch/powerpc/sysdev/xive/native.c |   4 +-
 arch/powerpc/sysdev/xive/spapr.c  |  38 ++--
 .../admin-guide/kernel-parameters.txt |  16 ++
 10 files changed, 209 insertions(+), 90 deletions(-)

-- 
2.31.1



[PATCH 01/11] powerpc/xive: Replace pr_devel() by pr_debug() to ease debug

2021-11-05 Thread Cédric Le Goater
These routines are not on hot code paths and pr_debug() is easier to
activate. Also add a '0x' prefix to hex printed values (HW IRQ number).

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 29 +++
 arch/powerpc/sysdev/xive/spapr.c  | 38 +++
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index c5d75c02ad8b..7280ff3fef2d 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -451,6 +451,8 @@ static void xive_do_source_set_mask(struct xive_irq_data 
*xd,
 {
u64 val;
 
+   pr_debug("%s: HW 0x%x %smask\n", __func__, xd->hw_irq, mask ? "" : 
"un");
+
/*
 * If the interrupt had P set, it may be in a queue.
 *
@@ -612,8 +614,8 @@ static unsigned int xive_irq_startup(struct irq_data *d)
 
xd->saved_p = false;
xd->stale_p = false;
-   pr_devel("xive_irq_startup: irq %d [0x%x] data @%p\n",
-d->irq, hw_irq, d);
+
+   pr_debug("%s: irq %d [0x%x] data @%p\n", __func__, d->irq, hw_irq, d);
 
/* Pick a target */
target = xive_pick_irq_target(d, irq_data_get_affinity_mask(d));
@@ -654,8 +656,7 @@ static void xive_irq_shutdown(struct irq_data *d)
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
 
-   pr_devel("xive_irq_shutdown: irq %d [0x%x] data @%p\n",
-d->irq, hw_irq, d);
+   pr_debug("%s: irq %d [0x%x] data @%p\n", __func__, d->irq, hw_irq, d);
 
if (WARN_ON(xd->target == XIVE_INVALID_TARGET))
return;
@@ -679,7 +680,7 @@ static void xive_irq_unmask(struct irq_data *d)
 {
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
 
-   pr_devel("xive_irq_unmask: irq %d data @%p\n", d->irq, xd);
+   pr_debug("%s: irq %d data @%p\n", __func__, d->irq, xd);
 
xive_do_source_set_mask(xd, false);
 }
@@ -688,7 +689,7 @@ static void xive_irq_mask(struct irq_data *d)
 {
struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
 
-   pr_devel("xive_irq_mask: irq %d data @%p\n", d->irq, xd);
+   pr_debug("%s: irq %d data @%p\n", __func__, d->irq, xd);
 
xive_do_source_set_mask(xd, true);
 }
@@ -702,7 +703,7 @@ static int xive_irq_set_affinity(struct irq_data *d,
u32 target, old_target;
int rc = 0;
 
-   pr_debug("%s: irq %d/%x\n", __func__, d->irq, hw_irq);
+   pr_debug("%s: irq %d/0x%x\n", __func__, d->irq, hw_irq);
 
/* Is this valid ? */
if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids)
@@ -975,7 +976,7 @@ EXPORT_SYMBOL_GPL(is_xive_irq);
 
 void xive_cleanup_irq_data(struct xive_irq_data *xd)
 {
-   pr_debug("%s for HW %x\n", __func__, xd->hw_irq);
+   pr_debug("%s for HW 0x%x\n", __func__, xd->hw_irq);
 
if (xd->eoi_mmio) {
iounmap(xd->eoi_mmio);
@@ -1211,8 +1212,8 @@ static int xive_setup_cpu_ipi(unsigned int cpu)
pr_err("Failed to map IPI CPU %d\n", cpu);
return -EIO;
}
-   pr_devel("CPU %d HW IPI %x, virq %d, trig_mmio=%p\n", cpu,
-   xc->hw_ipi, xive_ipi_irq, xc->ipi_data.trig_mmio);
+   pr_debug("CPU %d HW IPI 0x%x, virq %d, trig_mmio=%p\n", cpu,
+xc->hw_ipi, xive_ipi_irq, xc->ipi_data.trig_mmio);
 
/* Unmask it */
xive_do_source_set_mask(&xc->ipi_data, false);
@@ -1390,7 +1391,7 @@ static int xive_irq_domain_alloc(struct irq_domain 
*domain, unsigned int virq,
if (rc)
return rc;
 
-   pr_debug("%s %d/%lx #%d\n", __func__, virq, hwirq, nr_irqs);
+   pr_debug("%s %d/0x%lx #%d\n", __func__, virq, hwirq, nr_irqs);
 
for (i = 0; i < nr_irqs; i++) {
/* TODO: call xive_irq_domain_map() */
@@ -1505,7 +1506,7 @@ static void xive_setup_cpu(void)
 #ifdef CONFIG_SMP
 void xive_smp_setup_cpu(void)
 {
-   pr_devel("SMP setup CPU %d\n", smp_processor_id());
+   pr_debug("SMP setup CPU %d\n", smp_processor_id());
 
/* This will have already been done on the boot CPU */
if (smp_processor_id() != boot_cpuid)
@@ -1651,10 +1652,10 @@ bool __init xive_core_init(struct device_node *np, 
const struct xive_ops *ops,
ppc_md.get_irq = xive_get_irq;
__xive_enabled = true;
 
-   pr_devel("Initializing host..\n");
+   pr_debug("Initializing host..\n");
xive_init_host(np);
 
-   pr_devel("Initializing boot CPU..\n");
+   pr_debug("Initializing boot CPU..\n");
 
/* Allocate per-CPU data and queues */
xive_prepare_cpu(smp_processor_id());
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index f143b6f111ac..77943dc70860 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -173,7 +173,7 @@ static long plpar_int_get_source

[PATCH 02/11] powerpc/xive: Introduce an helper to print out interrupt characteristics

2021-11-05 Thread Cédric Le Goater
and extend output of debugfs and xmon with addresses of the ESB
management and trigger pages.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 54 +++
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 7280ff3fef2d..3d558cad1f19 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -227,6 +227,19 @@ static void xive_esb_write(struct xive_irq_data *xd, u32 
offset, u64 data)
out_be64(xd->eoi_mmio + offset, data);
 }
 
+static void xive_irq_data_dump(struct xive_irq_data *xd, char *buffer, size_t 
size)
+{
+   u64 val = xive_esb_read(xd, XIVE_ESB_GET);
+
+   snprintf(buffer, size, "flags=%c%c%c PQ=%c%c 0x%016llx 0x%016llx",
+xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
+xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
+xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
+val & XIVE_ESB_VAL_P ? 'P' : '-',
+val & XIVE_ESB_VAL_Q ? 'Q' : '-',
+xd->trig_page, xd->eoi_page);
+}
+
 #ifdef CONFIG_XMON
 static notrace void xive_dump_eq(const char *name, struct xive_q *q)
 {
@@ -252,11 +265,10 @@ notrace void xmon_xive_do_dump(int cpu)
 
 #ifdef CONFIG_SMP
{
-   u64 val = xive_esb_read(&xc->ipi_data, XIVE_ESB_GET);
+   char buffer[128];
 
-   xmon_printf("IPI=0x%08x PQ=%c%c ", xc->hw_ipi,
-   val & XIVE_ESB_VAL_P ? 'P' : '-',
-   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
+   xive_irq_data_dump(&xc->ipi_data, buffer, 
sizeof(buffer));
+   xmon_printf("IPI=0x%08x %s", xc->hw_ipi, buffer);
}
 #endif
xive_dump_eq("EQ", &xc->queue[xive_irq_priority]);
@@ -291,15 +303,11 @@ int xmon_xive_get_irq_config(u32 hw_irq, struct irq_data 
*d)
d = xive_get_irq_data(hw_irq);
 
if (d) {
-   struct xive_irq_data *xd = irq_data_get_irq_handler_data(d);
-   u64 val = xive_esb_read(xd, XIVE_ESB_GET);
-
-   xmon_printf("flags=%c%c%c PQ=%c%c",
-   xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
-   xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
-   xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
-   val & XIVE_ESB_VAL_P ? 'P' : '-',
-   val & XIVE_ESB_VAL_Q ? 'Q' : '-');
+   char buffer[128];
+
+   xive_irq_data_dump(irq_data_get_irq_handler_data(d),
+  buffer, sizeof(buffer));
+   xmon_printf("%s", buffer);
}
 
xmon_printf("\n");
@@ -1703,11 +1711,10 @@ static void xive_debug_show_cpu(struct seq_file *m, int 
cpu)
 
 #ifdef CONFIG_SMP
{
-   u64 val = xive_esb_read(&xc->ipi_data, XIVE_ESB_GET);
+   char buffer[128];
 
-   seq_printf(m, "IPI=0x%08x PQ=%c%c ", xc->hw_ipi,
-  val & XIVE_ESB_VAL_P ? 'P' : '-',
-  val & XIVE_ESB_VAL_Q ? 'Q' : '-');
+   xive_irq_data_dump(&xc->ipi_data, buffer, 
sizeof(buffer));
+   seq_printf(m, "IPI=0x%08x %s", xc->hw_ipi, buffer);
}
 #endif
{
@@ -1734,8 +1741,7 @@ static void xive_debug_show_irq(struct seq_file *m, 
struct irq_data *d)
u32 target;
u8 prio;
u32 lirq;
-   struct xive_irq_data *xd;
-   u64 val;
+   char buffer[128];
 
rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq);
if (rc) {
@@ -1746,14 +1752,8 @@ static void xive_debug_show_irq(struct seq_file *m, 
struct irq_data *d)
seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ",
   hw_irq, target, prio, lirq);
 
-   xd = irq_data_get_irq_handler_data(d);
-   val = xive_esb_read(xd, XIVE_ESB_GET);
-   seq_printf(m, "flags=%c%c%c PQ=%c%c",
-  xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ',
-  xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ',
-  xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ',
-  val & XIVE_ESB_VAL_P ? 'P' : '-',
-  val & XIVE_ESB_VAL_Q ? 'Q' : '-');
+   xive_irq_data_dump(irq_data_get_irq_handler_data(d), buffer, 
sizeof(buffer));
+   seq_puts(m, buffer);
seq_puts(m, "\n");
 }
 
-- 
2.31.1



[PATCH 09/11] powerpc/xive: Add a kernel parameter for StoreEOI

2021-11-05 Thread Cédric Le Goater
StoreEOI is activated by default on platforms supporting the feature
(POWER10) and will be used as soon as firmware advertises its
availability. The kernel parameter provides a way to deactivate its
use. It can be still be reactivated through debugfs.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c   | 13 +
 Documentation/admin-guide/kernel-parameters.txt |  6 ++
 2 files changed, 19 insertions(+)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 11e2aaa13965..67fd3a306369 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1713,6 +1713,19 @@ static int __init xive_off(char *arg)
 }
 __setup("xive=off", xive_off);
 
+static int __init xive_store_eoi_cmdline(char *arg)
+{
+   if (!arg)
+   return -EINVAL;
+
+   if (strncmp(arg, "off", 3) == 0) {
+   pr_info("StoreEOI disabled on kernel command line\n");
+   xive_store_eoi = false;
+   }
+   return 0;
+}
+__setup("xive.store-eoi=", xive_store_eoi_cmdline);
+
 #ifdef CONFIG_DEBUG_FS
 static void xive_debug_show_ipi(struct seq_file *m, int cpu)
 {
diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 43dc35fe5bc0..10fa093251e8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -6387,6 +6387,12 @@
  controller on both pseries and powernv
  platforms. Only useful on POWER9 and above.
 
+   xive.store-eoi=off  [PPC]
+   By default on POWER10 and above, the kernel will use
+   stores for EOI handling when the XIVE interrupt mode
+   is active. This option allows the XIVE driver to use
+   loads instead, as on POWER9.
+
xhci-hcd.quirks [USB,KNL]
A hex value specifying bitmask with supplemental xhci
host controller quirks. Meaning of each bit can be
-- 
2.31.1



[PATCH 10/11] powerpc/xive: Add a debugfs toggle for save-restore

2021-11-05 Thread Cédric Le Goater
On POWER10, the automatic "save & restore" of interrupt context is
always available. Provide a way to deactivate it for tests or
performance.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/xive-internal.h | 1 +
 arch/powerpc/sysdev/xive/common.c| 1 +
 arch/powerpc/sysdev/xive/native.c| 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/xive/xive-internal.h 
b/arch/powerpc/sysdev/xive/xive-internal.h
index 504e7edce358..e0941bc64430 100644
--- a/arch/powerpc/sysdev/xive/xive-internal.h
+++ b/arch/powerpc/sysdev/xive/xive-internal.h
@@ -72,5 +72,6 @@ static inline u32 xive_alloc_order(u32 queue_shift)
 }
 
 extern bool xive_cmdline_disabled;
+extern bool xive_has_save_restore;
 
 #endif /*  __XIVE_INTERNAL_H */
diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 67fd3a306369..39142df828a0 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1848,6 +1848,7 @@ static void xive_core_debugfs_create(void)
&xive_eq_debug_fops);
}
debugfs_create_bool("store-eoi", 0600, xive_dir, &xive_store_eoi);
+   debugfs_create_bool("save-restore", 0600, xive_dir, 
&xive_has_save_restore);
 }
 
 #endif /* CONFIG_DEBUG_FS */
diff --git a/arch/powerpc/sysdev/xive/native.c 
b/arch/powerpc/sysdev/xive/native.c
index 7ec8911dad57..d6a091dc1bce 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -41,7 +41,7 @@ static u32 xive_queue_shift;
 static u32 xive_pool_vps = XIVE_INVALID_VP;
 static struct kmem_cache *xive_provision_cache;
 static bool xive_has_single_esc;
-static bool xive_has_save_restore;
+bool xive_has_save_restore;
 
 int xive_native_populate_irq_data(u32 hw_irq, struct xive_irq_data *data)
 {
-- 
2.31.1



[PATCH 03/11] powerpc/xive: Activate StoreEOI on P10

2021-11-05 Thread Cédric Le Goater
StoreEOI (the capability to EOI with a store) requires load-after-store
ordering in some cases to be reliable. P10 introduced a new offset for
load operations to enforce correct ordering and the XIVE driver has
the required support since kernel 5.8, commit b1f9be9392f0
("powerpc/xive: Enforce load-after-store ordering when StoreEOI is active")

Since skiboot v7, StoreEOI support is advertised on P10 with a new flag
on the PowerNV platform. See skiboot commit 4bd7d84afe46 ("xive/p10:
Introduce a new OPAL_XIVE_IRQ_STORE_EOI2 flag"). When detected,
activate the feature.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/include/asm/opal-api.h | 1 +
 arch/powerpc/sysdev/xive/native.c   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/powerpc/include/asm/opal-api.h 
b/arch/powerpc/include/asm/opal-api.h
index 0b63ba7d5917..a2bc4b95e703 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -1094,6 +1094,7 @@ enum {
OPAL_XIVE_IRQ_SHIFT_BUG = 0x0008, /* P9 DD1.0 workaround */
OPAL_XIVE_IRQ_MASK_VIA_FW   = 0x0010, /* P9 DD1.0 workaround */
OPAL_XIVE_IRQ_EOI_VIA_FW= 0x0020, /* P9 DD1.0 workaround */
+   OPAL_XIVE_IRQ_STORE_EOI2= 0x0040,
 };
 
 /* Flags for OPAL_XIVE_GET/SET_QUEUE_INFO */
diff --git a/arch/powerpc/sysdev/xive/native.c 
b/arch/powerpc/sysdev/xive/native.c
index 1aec282cd650..7ec8911dad57 100644
--- a/arch/powerpc/sysdev/xive/native.c
+++ b/arch/powerpc/sysdev/xive/native.c
@@ -63,6 +63,8 @@ int xive_native_populate_irq_data(u32 hw_irq, struct 
xive_irq_data *data)
opal_flags = be64_to_cpu(flags);
if (opal_flags & OPAL_XIVE_IRQ_STORE_EOI)
data->flags |= XIVE_IRQ_FLAG_STORE_EOI;
+   if (opal_flags & OPAL_XIVE_IRQ_STORE_EOI2)
+   data->flags |= XIVE_IRQ_FLAG_STORE_EOI;
if (opal_flags & OPAL_XIVE_IRQ_LSI)
data->flags |= XIVE_IRQ_FLAG_LSI;
data->eoi_page = be64_to_cpu(eoi_page);
-- 
2.31.1



[PATCH 04/11] powerpc/xive: Introduce xive_core_debugfs_create()

2021-11-05 Thread Cédric Le Goater
and fix some compile issues when !CONFIG_DEBUG_FS.

Signed-off-by: Cédric Le Goater 
---
 arch/powerpc/sysdev/xive/common.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/xive/common.c 
b/arch/powerpc/sysdev/xive/common.c
index 3d558cad1f19..b71cc1020296 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -227,6 +227,7 @@ static void xive_esb_write(struct xive_irq_data *xd, u32 
offset, u64 data)
out_be64(xd->eoi_mmio + offset, data);
 }
 
+#if defined(CONFIG_XMON) || defined(CONFIG_DEBUG_FS)
 static void xive_irq_data_dump(struct xive_irq_data *xd, char *buffer, size_t 
size)
 {
u64 val = xive_esb_read(xd, XIVE_ESB_GET);
@@ -239,6 +240,7 @@ static void xive_irq_data_dump(struct xive_irq_data *xd, 
char *buffer, size_t si
 val & XIVE_ESB_VAL_Q ? 'Q' : '-',
 xd->trig_page, xd->eoi_page);
 }
+#endif
 
 #ifdef CONFIG_XMON
 static notrace void xive_dump_eq(const char *name, struct xive_q *q)
@@ -1701,6 +1703,7 @@ static int __init xive_off(char *arg)
 }
 __setup("xive=off", xive_off);
 
+#ifdef CONFIG_DEBUG_FS
 static void xive_debug_show_cpu(struct seq_file *m, int cpu)
 {
struct xive_cpu *xc = per_cpu(xive_cpu, cpu);
@@ -1779,10 +1782,18 @@ static int xive_core_debug_show(struct seq_file *m, 
void *private)
 }
 DEFINE_SHOW_ATTRIBUTE(xive_core_debug);
 
+static void xive_core_debugfs_create(void)
+{
+   debugfs_create_file("xive", 0400, arch_debugfs_dir,
+   NULL, &xive_core_debug_fops);
+}
+
+#endif /* CONFIG_DEBUG_FS */
+
 int xive_core_debug_init(void)
 {
-   if (xive_enabled())
-   debugfs_create_file("xive", 0400, arch_debugfs_dir,
-   NULL, &xive_core_debug_fops);
+   if (xive_enabled() && IS_ENABLED(CONFIG_DEBUG_FS))
+   xive_core_debugfs_create();
+
return 0;
 }
-- 
2.31.1



[PATCH 2/2] module: Move duplicate mod_check_sig users code to mod_parse_sig

2021-11-05 Thread Michal Suchanek
Multiple users of mod_check_sig check for the marker, then call
mod_check_sig, extract signature length, and remove the signature.

Put this code in one place together with mod_check_sig.

Signed-off-by: Michal Suchanek 
---
 include/linux/module_signature.h|  1 +
 kernel/module_signature.c   | 56 -
 kernel/module_signing.c | 26 +++---
 security/integrity/ima/ima_modsig.c | 22 ++--
 4 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/include/linux/module_signature.h b/include/linux/module_signature.h
index 7eb4b00381ac..1343879b72b3 100644
--- a/include/linux/module_signature.h
+++ b/include/linux/module_signature.h
@@ -42,5 +42,6 @@ struct module_signature {
 
 int mod_check_sig(const struct module_signature *ms, size_t file_len,
  const char *name);
+int mod_parse_sig(const void *data, size_t *len, size_t *sig_len, const char 
*name);
 
 #endif /* _LINUX_MODULE_SIGNATURE_H */
diff --git a/kernel/module_signature.c b/kernel/module_signature.c
index 00132d12487c..784b40575ee4 100644
--- a/kernel/module_signature.c
+++ b/kernel/module_signature.c
@@ -8,14 +8,36 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+/**
+ * mod_check_sig_marker - check that the given data has signature marker at 
the end
+ *
+ * @data:  Data with appended signature
+ * @len:   Length of data. Signature marker length is subtracted on 
success.
+ */
+static inline int mod_check_sig_marker(const void *data, size_t *len)
+{
+   const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
+
+   if (markerlen > *len)
+   return -ENODATA;
+
+   if (memcmp(data + *len - markerlen, MODULE_SIG_STRING,
+  markerlen))
+   return -ENODATA;
+
+   *len -= markerlen;
+   return 0;
+}
+
 /**
  * mod_check_sig - check that the given signature is sane
  *
  * @ms:Signature to check.
- * @file_len:  Size of the file to which @ms is appended.
+ * @file_len:  Size of the file to which @ms is appended (without the marker).
  * @name:  What is being checked. Used for error messages.
  */
 int mod_check_sig(const struct module_signature *ms, size_t file_len,
@@ -44,3 +66,35 @@ int mod_check_sig(const struct module_signature *ms, size_t 
file_len,
 
return 0;
 }
+
+/**
+ * mod_parse_sig - check that the given signature is sane and determine 
signature length
+ *
+ * @data:  Data with appended signature.
+ * @len:   Length of data. Signature and marker length is subtracted on 
success.
+ * @sig_len:   Length of signature. Filled on success.
+ * @name:  What is being checked. Used for error messages.
+ */
+int mod_parse_sig(const void *data, size_t *len, size_t *sig_len, const char 
*name)
+{
+   const struct module_signature *sig;
+   int rc;
+
+   rc = mod_check_sig_marker(data, len);
+   if (rc)
+   return rc;
+
+   if (*len < sizeof(*sig))
+   return -ENODATA;
+
+   sig = (const struct module_signature *)(data + (*len - sizeof(*sig)));
+
+   rc = mod_check_sig(sig, *len, name);
+   if (rc)
+   return rc;
+
+   *sig_len = be32_to_cpu(sig->sig_len);
+   *len -= *sig_len + sizeof(*sig);
+
+   return 0;
+}
diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index cef72a6f6b5d..02bbca90f467 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -25,35 +25,17 @@ int verify_appended_signature(const void *data, size_t *len,
  struct key *trusted_keys,
  enum key_being_used_for purpose)
 {
-   const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
struct module_signature ms;
-   size_t sig_len, modlen = *len;
+   size_t sig_len;
int ret;
 
-   pr_devel("==>%s %s(,%zu)\n", __func__, key_being_used_for[purpose], 
modlen);
+   pr_devel("==>%s %s(,%zu)\n", __func__, key_being_used_for[purpose], 
*len);
 
-   if (markerlen > modlen)
-   return -ENODATA;
-
-   if (memcmp(data + modlen - markerlen, MODULE_SIG_STRING,
-  markerlen))
-   return -ENODATA;
-   modlen -= markerlen;
-
-   if (modlen <= sizeof(ms))
-   return -EBADMSG;
-
-   memcpy(&ms, data + (modlen - sizeof(ms)), sizeof(ms));
-
-   ret = mod_check_sig(&ms, modlen, key_being_used_for[purpose]);
+   ret = mod_parse_sig(data, len, &sig_len, key_being_used_for[purpose]);
if (ret)
return ret;
 
-   sig_len = be32_to_cpu(ms.sig_len);
-   modlen -= sig_len + sizeof(ms);
-   *len = modlen;
-
-   return verify_pkcs7_signature(data, modlen, data + modlen, sig_len,
+   return verify_pkcs7_signature(data, *len, data + *len, sig_len,
  trusted_keys,
  purpose,
  NULL, NULL)

[PATCH 0/2] Additional appended signature cleanup

2021-11-05 Thread Michal Suchanek
There is one more copy of the code checking appended signarutes.

Merge the common code to module_signature.c

Thanks

Michal

Michal Suchanek (2):
  module: Use key_being_used_for for log messages in
verify_appended_signature
  module: Move duplicate mod_check_sig users code to mod_parse_sig

 arch/powerpc/kexec/elf_64.c  |  2 +-
 arch/s390/kernel/machine_kexec_file.c|  2 +-
 crypto/asymmetric_keys/asymmetric_type.c |  1 +
 include/linux/module_signature.h |  1 +
 include/linux/verification.h |  3 +-
 kernel/module.c  |  3 +-
 kernel/module_signature.c| 56 +++-
 kernel/module_signing.c  | 33 --
 security/integrity/ima/ima_modsig.c  | 22 ++
 9 files changed, 74 insertions(+), 49 deletions(-)

-- 
2.31.1



[PATCH 1/2] module: Use key_being_used_for for log messages in verify_appended_signature

2021-11-05 Thread Michal Suchanek
Add value for kexec appended signature and pass in key_being_used_for
enum rather than a string to verify_appended_signature to produce log
messages about the signature.

Signed-off-by: Michal Suchanek 
---
 arch/powerpc/kexec/elf_64.c  |  2 +-
 arch/s390/kernel/machine_kexec_file.c|  2 +-
 crypto/asymmetric_keys/asymmetric_type.c |  1 +
 include/linux/verification.h |  3 ++-
 kernel/module.c  |  3 ++-
 kernel/module_signing.c  | 11 ++-
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c
index e8dff6b23ac5..3aa5269f6e0f 100644
--- a/arch/powerpc/kexec/elf_64.c
+++ b/arch/powerpc/kexec/elf_64.c
@@ -158,7 +158,7 @@ int elf64_verify_sig(const char *kernel, unsigned long 
length)
size_t kernel_len = length;
 
return verify_appended_signature(kernel, &kernel_len, 
VERIFY_USE_PLATFORM_KEYRING,
-"kexec_file");
+VERIFYING_KEXEC_APPENDED_SIGNATURE);
 }
 #endif /* CONFIG_KEXEC_SIG */
 
diff --git a/arch/s390/kernel/machine_kexec_file.c 
b/arch/s390/kernel/machine_kexec_file.c
index 82260bb61060..37fcbb149368 100644
--- a/arch/s390/kernel/machine_kexec_file.c
+++ b/arch/s390/kernel/machine_kexec_file.c
@@ -32,7 +32,7 @@ int s390_verify_sig(const char *kernel, unsigned long length)
return 0;
 
return verify_appended_signature(kernel, &kernel_len, 
VERIFY_USE_PLATFORM_KEYRING,
-   "kexec_file");
+   VERIFYING_KEXEC_APPENDED_SIGNATURE);
 }
 #endif /* CONFIG_KEXEC_SIG */
 
diff --git a/crypto/asymmetric_keys/asymmetric_type.c 
b/crypto/asymmetric_keys/asymmetric_type.c
index ad8af3d70ac0..6fd20eec3882 100644
--- a/crypto/asymmetric_keys/asymmetric_type.c
+++ b/crypto/asymmetric_keys/asymmetric_type.c
@@ -25,6 +25,7 @@ const char *const key_being_used_for[NR__KEY_BEING_USED_FOR] 
= {
[VERIFYING_KEXEC_PE_SIGNATURE]  = "kexec PE sig",
[VERIFYING_KEY_SIGNATURE]   = "key sig",
[VERIFYING_KEY_SELF_SIGNATURE]  = "key self sig",
+   [VERIFYING_KEXEC_APPENDED_SIGNATURE]= "kexec appended sig",
[VERIFYING_UNSPECIFIED_SIGNATURE]   = "unspec sig",
 };
 EXPORT_SYMBOL_GPL(key_being_used_for);
diff --git a/include/linux/verification.h b/include/linux/verification.h
index c1cf0582012a..23748feb9e03 100644
--- a/include/linux/verification.h
+++ b/include/linux/verification.h
@@ -26,6 +26,7 @@ enum key_being_used_for {
VERIFYING_KEXEC_PE_SIGNATURE,
VERIFYING_KEY_SIGNATURE,
VERIFYING_KEY_SELF_SIGNATURE,
+   VERIFYING_KEXEC_APPENDED_SIGNATURE,
VERIFYING_UNSPECIFIED_SIGNATURE,
NR__KEY_BEING_USED_FOR
 };
@@ -61,7 +62,7 @@ extern int verify_pefile_signature(const void *pebuf, 
unsigned pelen,
 #endif
 
 int verify_appended_signature(const void *data, size_t *len, struct key 
*trusted_keys,
- const char *what);
+ enum key_being_used_for purpose);
 
 #endif /* CONFIG_SYSTEM_DATA_VERIFICATION */
 #endif /* _LINUX_VERIFY_PEFILE_H */
diff --git a/kernel/module.c b/kernel/module.c
index 1c421b0442e3..5f1cf989e1cf 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2891,7 +2891,8 @@ static int module_sig_check(struct load_info *info, int 
flags)
 */
if (flags == 0) {
err = verify_appended_signature(mod, &info->len,
-   VERIFY_USE_SECONDARY_KEYRING, 
"module");
+   VERIFY_USE_SECONDARY_KEYRING,
+   VERIFYING_MODULE_SIGNATURE);
if (!err) {
info->sig_ok = true;
return 0;
diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index 4c28cb55275f..cef72a6f6b5d 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -19,17 +19,18 @@
  * @data: The data to be verified
  * @len: Size of @data.
  * @trusted_keys: Keyring to use for verification
- * @what: Informational string for log messages
+ * @purpose: The use to which the key is being put
  */
 int verify_appended_signature(const void *data, size_t *len,
- struct key *trusted_keys, const char *what)
+ struct key *trusted_keys,
+ enum key_being_used_for purpose)
 {
const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
struct module_signature ms;
size_t sig_len, modlen = *len;
int ret;
 
-   pr_devel("==>%s(,%zu)\n", __func__, modlen);
+   pr_devel("==>%s %s(,%zu)\n", __func__, key_being_used_for[purpose], 
modlen);
 
if (markerlen > modlen)
return -ENODATA;
@@ -44,7 +45,7 @@ int verify_appended_signature

Re: [PATCH v2 1/5] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race

2021-11-05 Thread Laurent Dufour

Le 04/11/2021 à 17:10, Nicholas Piggin a écrit :

It is possible for all CPUs to miss the pending cpumask becoming clear,
and then nobody resetting it, which will cause the lockup detector to
stop working. It will eventually expire, but watchdog_smp_panic will
avoid doing anything if the pending mask is clear and it will never be
reset.

Order the cpumask clear vs the subsequent test to close this race.

Add an extra check for an empty pending mask when the watchdog fires and
finds its bit still clear, to try to catch any other possible races or
bugs here and keep the watchdog working. The extra test in
arch_touch_nmi_watchdog is required to prevent the new warning from
firing off.

Debugged-by: Laurent Dufour 
Signed-off-by: Nicholas Piggin 
---
  arch/powerpc/kernel/watchdog.c | 36 +-
  1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c
index f9ea0e5357f9..be80071336a4 100644
--- a/arch/powerpc/kernel/watchdog.c
+++ b/arch/powerpc/kernel/watchdog.c
@@ -135,6 +135,10 @@ static void set_cpumask_stuck(const struct cpumask 
*cpumask, u64 tb)
  {
cpumask_or(&wd_smp_cpus_stuck, &wd_smp_cpus_stuck, cpumask);
cpumask_andnot(&wd_smp_cpus_pending, &wd_smp_cpus_pending, cpumask);
+   /*
+* See wd_smp_clear_cpu_pending()
+*/
+   smp_mb();
if (cpumask_empty(&wd_smp_cpus_pending)) {
wd_smp_last_reset_tb = tb;
cpumask_andnot(&wd_smp_cpus_pending,
@@ -215,13 +219,39 @@ static void wd_smp_clear_cpu_pending(int cpu, u64 tb)
  
  			cpumask_clear_cpu(cpu, &wd_smp_cpus_stuck);

wd_smp_unlock(&flags);
+   } else {
+   /*
+* The last CPU to clear pending should have reset the
+* watchdog, yet we find it empty here. This should not
+* happen but we can try to recover and avoid a false
+* positive if it does.
+*/
+   if (WARN_ON_ONCE(cpumask_empty(&wd_smp_cpus_pending)))
+   goto none_pending;


I run a stress on my victim node on top of this patch and hit that warning:

[  C475] [ cut here ]
[  C475] WARNING: CPU: 475 PID: 0 at 
/home/laurent/src/linux-ppc/arch/powerpc/kernel/watchdog.c:260 
wd_smp_clear_cpu_pending+0x320/0x4b0
[  C475] Modules linked in: rpadlpar_io rpaphp xt_tcpudp iptable_filter 
ip_tables x_tables xfs pseries_rng rng_core vmx_crypto gf128mul be2net fuse 
btrfs blake2b_generic libcrc32c xor zstd_compress lzo_compress raid6_pq 
dm_service_time crc32c_vpmsum lpfc crc_t10dif crct10dif_generic crct10dif_common 
dm_mirror dm_region_hash dm_log dm_multipath scsi_dh_rdac scsi_dh_alua autofs4
[  C475] CPU: 475 PID: 0 Comm: swapper/475 Kdump: loaded Not tainted 
5.15.0-rc2-ppc-bz192129+ #72

[  C475] NIP:  c003d710 LR: c003d478 CTR: c003e2e0
[  C475] REGS: c6b16026f420 TRAP: 0700   Not tainted  
(5.15.0-rc2-ppc-bz192129+)
[  C475] MSR:  80029033   CR: 22000222  XER: 
2000
[  C475] CFAR: c003d480 IRQMASK: 3
[  C475] GPR00: c003e3bc c6b16026f6c0 c1b28700 
0800
[  C475] GPR04:  0800 0800 

[  C475] GPR08:   00f8 
00013f06986272e7
[  C475] GPR12: c003e2e0 c7d3df00  
1f043b60
[  C475] GPR16: c6b1601b7b00  c003e2e0 
0001
[  C475] GPR20: 347411d4cf28 c7adbdb0a898 0001 

[  C475] GPR24:  0003 c1b6d7d0 
00013f0698627d84
[  C475] GPR28: c1bd05c8 c1bd05b8 c1bd06c8 
01db
[  C475] NIP [c003d710] wd_smp_clear_cpu_pending+0x320/0x4b0
[  C475] LR [c003d478] wd_smp_clear_cpu_pending+0x88/0x4b0
[  C475] Call Trace:
[  C475] [c6b16026f6c0] [0001] 0x1 (unreliable)
[  C475] [c6b16026f770] [c003e3bc] watchdog_timer_fn+0xdc/0x5a0
[  C475] [c6b16026f840] [c0245a4c] __hrtimer_run_queues+0x49c/0x700
[  C475] [c6b16026f8f0] [c0246c20] hrtimer_interrupt+0x110/0x310
[  C475] [c6b16026f9a0] [c00292f8] timer_interrupt+0x1e8/0x5a0
[  C475] [c6b16026fa00] [c0009a00] 
decrementer_common_virt+0x210/0x220
[  C475] --- interrupt: 900 at plpar_hcall_norets_notrace+0x18/0x2c
[  C475] NIP:  c00e5dd0 LR: c0c18f04 CTR: 
[  C475] REGS: c6b16026fa70 TRAP: 0900   Not tainted  
(5.15.0-rc2-ppc-bz192129+)
[  C475] MSR:  80009033   CR: 22000824  XER: 
2000
[  C475] CFAR: 0c00 IRQMASK: 0
[  C475] GPR00:  c6b16026fd10 c1b28700 

[  C475] GPR04:   00