Re: [PATCH 20/23] powerpc/64s: Clear/restore caller gprs in syscall interrupt/return

2022-09-20 Thread Rohan McLure
> On 20 Sep 2022, at 2:54 pm, Rohan McLure wrote: > >> On 20 Sep 2022, at 12:03 pm, Nicholas Piggin wrote: >> >> On Fri Sep 16, 2022 at 3:32 PM AEST, Rohan McLure wrote: >>> Clear user state in gprs (assign to zero) to reduce the influence of user >>> registers on speculation within kernel

Re: [PATCH] powerpc: Save AMR/IAMR when switching tasks

2022-09-20 Thread Christophe Leroy
Le 21/09/2022 à 05:33, Samuel Holland a écrit : > On 9/19/22 07:37, Michael Ellerman wrote: >> Christophe Leroy writes: >>> Le 16/09/2022 à 07:05, Samuel Holland a écrit : With CONFIG_PREEMPT=y (involuntary preemption enabled), it is possible to switch away from a task inside

Re: [PATCH v1 1/3] coding-style.rst: document BUG() and WARN() rules ("do not crash the kernel")

2022-09-20 Thread Kalle Valo
David Hildenbrand writes: > Linus notes [1] that the introduction of new code that uses VM_BUG_ON() > is just as bad as BUG_ON(), because it will crash the kernel on > distributions that enable CONFIG_DEBUG_VM (like Fedora): > > VM_BUG_ON() has the exact same semantics as BUG_ON. It is

Re: [PATCH 19/23] powerpc: Provide syscall wrapper

2022-09-20 Thread Rohan McLure
> On 20 Sep 2022, at 11:59 am, Nicholas Piggin wrote: > > On Fri Sep 16, 2022 at 3:32 PM AEST, Rohan McLure wrote: >> Implement syscall wrapper as per s390, x86, arm64. When enabled >> cause handlers to accept parameters from a stack frame rather than >> from user scratch register state. This

Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation

2022-09-20 Thread Anshuman Khandual
On 9/21/22 07:21, Barry Song wrote: > On Wed, Sep 21, 2022 at 1:50 PM Barry Song <21cn...@gmail.com> wrote: >> >> On Tue, Sep 20, 2022 at 8:45 PM Anshuman Khandual >> wrote: >>> >>> >>> >>> On 9/20/22 09:09, Barry Song wrote: On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual wrote:

Re: [PATCH] powerpc: Save AMR/IAMR when switching tasks

2022-09-20 Thread Samuel Holland
On 9/19/22 07:37, Michael Ellerman wrote: > Christophe Leroy writes: >> Le 16/09/2022 à 07:05, Samuel Holland a écrit : >>> With CONFIG_PREEMPT=y (involuntary preemption enabled), it is possible >>> to switch away from a task inside copy_{from,to}_user. This left the CPU >>> with userspace access

Re: [PATCH v2 1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

2022-09-20 Thread Michael Ellerman
Nicholas Miehlbradt writes: > There is support for DEBUG_PAGEALLOC on hash but not on radix. > Add support on radix. > > Signed-off-by: Nicholas Miehlbradt > --- > v2: Revert change to radix_memory_block_size, instead set the size > in radix_init_pgtable and radix__create_section_mapping

Re: [RFC] Objtool toolchain proposal: -fannotate-{jump-table,noreturn}

2022-09-20 Thread Chen Zhongjin
Hi, On 2022/9/21 0:49, Ard Biesheuvel wrote: On Thu, 15 Sept 2022 at 10:47, Peter Zijlstra wrote: On Thu, Sep 15, 2022 at 10:56:58AM +0800, Chen Zhongjin wrote: We have found some anonymous information on x86 in .rodata. Well yes, but that's still a bunch of heuristics on our side. I'm

[PATCH v2 3/4] powerpc/64s: Allow double call of kernel_[un]map_linear_page()

2022-09-20 Thread Nicholas Miehlbradt
From: Christophe Leroy If the page is already mapped resp. already unmapped, bail out. Signed-off-by: Christophe Leroy Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/mm/book3s64/hash_utils.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git

[PATCH v2 4/4] powerpc/64s: Enable KFENCE on book3s64

2022-09-20 Thread Nicholas Miehlbradt
KFENCE support was added for ppc32 in commit 90cbac0e995d ("powerpc: Enable KFENCE for PPC32"). Enable KFENCE on ppc64 architecture with hash and radix MMUs. It uses the same mechanism as debug pagealloc to protect/unprotect pages. All KFENCE kunit tests pass on both MMUs. KFENCE memory is

[PATCH v2 2/4] powerpc/64s: Remove unneeded #ifdef CONFIG_DEBUG_PAGEALLOC in hash_utils

2022-09-20 Thread Nicholas Miehlbradt
From: Christophe Leroy debug_pagealloc_enabled() is always defined and constant folds to 'false' when CONFIG_DEBUG_PAGEALLOC is not enabled. Remove the #ifdefs, the code and associated static variables will be optimised out by the compiler when CONFIG_DEBUG_PAGEALLOC is not defined.

[PATCH v2 1/4] powerpc/64s: Add DEBUG_PAGEALLOC for radix

2022-09-20 Thread Nicholas Miehlbradt
There is support for DEBUG_PAGEALLOC on hash but not on radix. Add support on radix. Signed-off-by: Nicholas Miehlbradt --- v2: Revert change to radix_memory_block_size, instead set the size in radix_init_pgtable and radix__create_section_mapping directly. ---

Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation

2022-09-20 Thread Barry Song
On Wed, Sep 21, 2022 at 1:50 PM Barry Song <21cn...@gmail.com> wrote: > > On Tue, Sep 20, 2022 at 8:45 PM Anshuman Khandual > wrote: > > > > > > > > On 9/20/22 09:09, Barry Song wrote: > > > On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual > > > wrote: > > >> > > >> > > >> On 8/22/22 13:51,

Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation

2022-09-20 Thread Barry Song
On Tue, Sep 20, 2022 at 8:45 PM Anshuman Khandual wrote: > > > > On 9/20/22 09:09, Barry Song wrote: > > On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual > > wrote: > >> > >> > >> On 8/22/22 13:51, Yicong Yang wrote: > >>> +static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) >

[PATCH 2/2] powerpc/64s: update cpu selection options

2022-09-20 Thread Nicholas Piggin
Update the 64s GENERIC_CPU option. POWER4 support has been dropped, so make that clear in the option name. The POWER5_CPU option is dropped because it's uncommon, and GENERIC_CPU covers it. -mtune= before power8 is dropped because the minimum gcc version supports power8, and tuning is made

[PATCH 1/2] powerpc/64s: Fix GENERIC_CPU build flags for PPC970 / G5

2022-09-20 Thread Nicholas Piggin
Big-endian GENERIC_CPU supports 970, but builds with -mcpu=power5. POWER5 is ISA v2.02 whereas 970 is v2.01 plus Altivec. 2.02 added the popcntb instruction which a compiler might use. Use -mcpu=power4. Fixes: 471d7ff8b51b ("powerpc/64s: Remove POWER4 support") Signed-off-by: Nicholas Piggin

Re: [RFC PATCH 5/7] powerpc/64s: update generic cpu option name and compiler flags

2022-09-20 Thread Nicholas Piggin
On Wed Sep 21, 2022 at 8:16 AM AEST, Segher Boessenkool wrote: > Hi! > > On Tue, Sep 20, 2022 at 12:01:47AM +1000, Nicholas Piggin wrote: > > Update the 64s GENERIC_CPU option. POWER4 support has been dropped, so > > make that clear in the option name. > > AFAIR the minimum now is POWER4+ (ISA

[PATCH v4 12/12] KVM: remove KVM_REQ_UNHALT

2022-09-20 Thread Sean Christopherson
From: Paolo Bonzini KVM_REQ_UNHALT is now unnecessary because it is replaced by the return value of kvm_vcpu_block/kvm_vcpu_halt. Remove it. No functional change intended. Signed-off-by: Paolo Bonzini Signed-off-by: Sean Christopherson --- Documentation/virt/kvm/vcpu-requests.rst | 28

[PATCH v4 11/12] KVM: mips, x86: do not rely on KVM_REQ_UNHALT

2022-09-20 Thread Sean Christopherson
From: Paolo Bonzini KVM_REQ_UNHALT is a weird request that simply reports the value of kvm_arch_vcpu_runnable() on exit from kvm_vcpu_halt(). Only MIPS and x86 are looking at it, the others just clear it. Check the state of the vCPU directly so that the request is handled as a nop on all

[PATCH v4 10/12] KVM: x86: never write to memory from kvm_vcpu_check_block()

2022-09-20 Thread Sean Christopherson
From: Paolo Bonzini kvm_vcpu_check_block() is called while not in TASK_RUNNING, and therefore it cannot sleep. Writing to guest memory is therefore forbidden, but it can happen on AMD processors if kvm_check_nested_events() causes a vmexit. Fortunately, all events that are caught by

[PATCH v4 09/12] KVM: x86: Don't snapshot pending INIT/SIPI prior to checking nested events

2022-09-20 Thread Sean Christopherson
Don't snapshot pending INIT/SIPI events prior to checking nested events, architecturally there's nothing wrong with KVM processing (dropping) a SIPI that is received immediately after synthesizing a VM-Exit. Taking and consuming the snapshot makes the flow way more subtle than it needs to be,

[PATCH v4 08/12] KVM: nVMX: Make event request on VMXOFF iff INIT/SIPI is pending

2022-09-20 Thread Sean Christopherson
Explicitly check for a pending INIT/SIPI event when emulating VMXOFF instead of blindly making an event request. There's obviously no need to evaluate events if none are pending. Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/nested.c | 4 ++-- 1 file changed, 2 insertions(+), 2

[PATCH v4 07/12] KVM: nVMX: Make an event request if INIT or SIPI is pending on VM-Enter

2022-09-20 Thread Sean Christopherson
Evaluate interrupts, i.e. set KVM_REQ_EVENT, if INIT or SIPI is pending when emulating nested VM-Enter. INIT is blocked while the CPU is in VMX root mode, but not in VMX non-root, i.e. becomes unblocked on VM-Enter. This bug has been masked by KVM calling ->check_nested_events() in the core run

[PATCH v4 06/12] KVM: SVM: Make an event request if INIT or SIPI is pending when GIF is set

2022-09-20 Thread Sean Christopherson
Set KVM_REQ_EVENT if INIT or SIPI is pending when the guest enables GIF. INIT in particular is blocked when GIF=0 and needs to be processed when GIF is toggled to '1'. This bug has been masked by (a) KVM calling ->check_nested_events() in the core run loop and (b) hypervisors toggling GIF from

[PATCH v4 05/12] KVM: x86: lapic does not have to process INIT if it is blocked

2022-09-20 Thread Sean Christopherson
From: Paolo Bonzini Do not return true from kvm_vcpu_has_events() if the vCPU isn' going to immediately process a pending INIT/SIPI. INIT/SIPI shouldn't be treated as wake events if they are blocked. Signed-off-by: Paolo Bonzini [sean: rebase onto refactored INIT/SIPI helpers, massage

[PATCH v4 04/12] KVM: x86: Rename kvm_apic_has_events() to make it INIT/SIPI specific

2022-09-20 Thread Sean Christopherson
Rename kvm_apic_has_events() to kvm_apic_has_pending_init_or_sipi() so that it's more obvious that "events" really just means "INIT or SIPI". Opportunistically clean up a weirdly worded comment that referenced kvm_apic_has_events() instead of kvm_apic_accept_events(). No functional change

[PATCH v4 03/12] KVM: x86: Rename and expose helper to detect if INIT/SIPI are allowed

2022-09-20 Thread Sean Christopherson
Rename and invert kvm_vcpu_latch_init() to kvm_apic_init_sipi_allowed() so as to match the behavior of {interrupt,nmi,smi}_allowed(), and expose the helper so that it can be used by kvm_vcpu_has_events() to determine whether or not an INIT or SIPI is pending _and_ can be taken immediately.

[PATCH v4 02/12] KVM: nVMX: Make an event request when pending an MTF nested VM-Exit

2022-09-20 Thread Sean Christopherson
Set KVM_REQ_EVENT when MTF becomes pending to ensure that KVM will run through inject_pending_event() and thus vmx_check_nested_events() prior to re-entering the guest. MTF currently works by virtue of KVM's hack that calls kvm_check_nested_events() from kvm_vcpu_running(), but that hack will be

[PATCH v4 01/12] KVM: x86: make vendor code check for all nested events

2022-09-20 Thread Sean Christopherson
From: Paolo Bonzini Interrupts, NMIs etc. sent while in guest mode are already handled properly by the *_interrupt_allowed callbacks, but other events can cause a vCPU to be runnable that are specific to guest mode. In the case of VMX there are two, the preemption timer and the monitor trap.

[PATCH v4 00/12] KVM: x86: never write to memory from kvm_vcpu_check_block

2022-09-20 Thread Sean Christopherson
Non-x86 folks, there's nothing interesting to see here, y'all got pulled in because removing KVM_REQ_UNHALT requires deleting kvm_clear_request() from arch code. Note, this based on: https://github.com/sean-jc/linux.git tags/kvm-x86-6.1-1 to pre-resolve conflicts with the

[PATCH v2] powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined

2022-09-20 Thread Yury Norov
generic_secondary_common_init() calls LOAD_REG_ADDR(r7, nr_cpu_ids) conditionally on CONFIG_SMP. However, if NR_CPUS == 1, kernel doesn't use the nr_cpu_ids, and in C code, it's just: #if NR_CPUS == 1 #define nr_cpu_ids ... The [1] makes declaration of nr_cpu_ids conditional on NR_CPUS ==

Re: [PATCH v2 00/44] cpuidle,rcu: Clean up the mess

2022-09-20 Thread Peter Zijlstra
Because Nadav asked about tracing/kprobing idle, I had another go around and noticed not all functions calling ct_cpuidle_enter are __cpuidle. Basically all cpuidle_driver::enter functions should be __cpuidle; i'll do that audit shortly. For now this is ct_cpuidle_enter / CPU_IDLE_ENTER users.

Re: [PATCH v2 00/44] cpuidle,rcu: Clean up the mess

2022-09-20 Thread Frederic Weisbecker
On Mon, Sep 19, 2022 at 11:59:39AM +0200, Peter Zijlstra wrote: > Hi All! > > At long last, a respin of the cpuidle vs rcu cleanup patches. > > v1: https://lkml.kernel.org/r/20220608142723.103523...@infradead.org > > These here patches clean up the mess that is cpuidle vs rcuidle. > > At the

Re: [PATCH] powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined

2022-09-20 Thread Yury Norov
On Wed, Sep 21, 2022 at 08:20:06AM +1000, Stephen Rothwell wrote: > Hi Yury, > > On Tue, 20 Sep 2022 08:29:35 -0700 Yury Norov wrote: > > > > > diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S > > index cf2c08902c05..7cb97881635e 100644 > > ---

Re: [PATCH] powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined

2022-09-20 Thread Stephen Rothwell
Hi Yury, On Tue, 20 Sep 2022 08:29:35 -0700 Yury Norov wrote: > > diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S > index cf2c08902c05..7cb97881635e 100644 > --- a/arch/powerpc/kernel/head_64.S > +++ b/arch/powerpc/kernel/head_64.S > @@ -400,7 +400,11 @@

Re: [RFC PATCH 5/7] powerpc/64s: update generic cpu option name and compiler flags

2022-09-20 Thread Segher Boessenkool
Hi! On Tue, Sep 20, 2022 at 12:01:47AM +1000, Nicholas Piggin wrote: > Update the 64s GENERIC_CPU option. POWER4 support has been dropped, so > make that clear in the option name. AFAIR the minimum now is POWER4+ (ISA 2.01), not POWER5 (ISA 2.02). > -mtune= before power8 is dropped because the

[PATCH v6 8/8] [WIP] arm64: dts: ls1088ardb: Add serdes bindings

2022-09-20 Thread Sean Anderson
This is a first stab at adding serdes support on the LS1088A. Linux hangs around when the serdes is initialized if the si5341 is enabled, so it's commented out. The MC firmware needs to be fairly new (it must support DPAA2_MAC_FEATURE_PROTOCOL_CHANGE), and the DPC needs to set the macs to

[PATCH v6 1/8] dt-bindings: phy: Add 2500BASE-X and 10GBASE-R

2022-09-20 Thread Sean Anderson
This adds some modes necessary for Lynx 10G support. 2500BASE-X, also known as 2.5G SGMII, is 1000BASE-X/SGMII overclocked to 3.125 GHz, with autonegotiation disabled. 10GBASE-R, also known as XFI, is the protocol spoken between the PMA and PMD ethernet layers for 10GBASE-T and 10GBASE-S/L/E. It

[PATCH v6 7/8] arm64: dts: ls1046ardb: Add serdes bindings

2022-09-20 Thread Sean Anderson
This adds appropriate bindings for the macs which use the SerDes. The 156.25MHz fixed clock is a crystal. The 100MHz clocks (there are actually 3) come from a Renesas 6V49205B at address 69 on i2c0. There is no driver for this device (and as far as I know all you can do with the 100MHz clocks is

[PATCH v6 6/8] arm64: dts: ls1088a: Add serdes bindings

2022-09-20 Thread Sean Anderson
This adds bindings for the SerDes devices. They are disabled by default to prevent any breakage on existing boards. Signed-off-by: Sean Anderson --- (no changes since v4) Changes in v4: - Convert to new bindings Changes in v3: - New arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 18

[PATCH v6 5/8] arm64: dts: ls1046a: Add serdes bindings

2022-09-20 Thread Sean Anderson
This adds bindings for the SerDes devices. They are disabled by default to prevent any breakage on existing boards. Signed-off-by: Sean Anderson --- (no changes since v4) Changes in v4: - Convert to new bindings Changes in v3: - Describe modes in device tree Changes in v2: - Use one phy cell

[PATCH v6 4/8] phy: fsl: Add Lynx 10G SerDes driver

2022-09-20 Thread Sean Anderson
This adds support for the Lynx 10G "SerDes" devices found on various NXP QorIQ SoCs. There may be up to four SerDes devices on each SoC, each supporting up to eight lanes. Protocol support for each SerDes is highly heterogeneous, with each SoC typically having a totally different selection of

[PATCH v6 3/8] dt-bindings: clock: Add ids for Lynx 10g PLLs

2022-09-20 Thread Sean Anderson
This adds ids for the Lynx 10g SerDes's internal PLLs. These may be used with assigned-clock* to specify a particular frequency to use. For example, to set the second PLL (at offset 0x20)'s frequency, use LYNX10G_PLLa(1). These are for use only in the device tree, and are not otherwise used by the

[PATCH v6 2/8] dt-bindings: phy: Add Lynx 10G phy binding

2022-09-20 Thread Sean Anderson
This adds a binding for the SerDes module found on QorIQ processors. Each phy is a subnode of the top-level device, possibly supporting multiple lanes and protocols. This "thick" #phy-cells is used due to allow for better organization of parameters. Note that the particular parameters necessary to

[PATCH v6 0/8] phy: Add support for Lynx 10G SerDes

2022-09-20 Thread Sean Anderson
This adds support for the Lynx 10G SerDes found on the QorIQ T-series and Layerscape series. Due to limited time and hardware, only support for the LS1046ARDB is added in this initial series. There is a sketch for LS1088ARDB support, but it is incomplete. Dynamic reconfiguration does not work.

Re: [PATCH] powerpc/highmem: Properly handle fragmented memory

2022-09-20 Thread Pali Rohár
On Tuesday 20 September 2022 19:36:42 Christophe Leroy wrote: > In addition to checking whether a page is reserved before allocating > it to highmem, verify that it is valid memory. > > Otherwise the kernel Oopses as below: > > [0.00] mem auto-init: stack:off, heap alloc:off, heap

[PATCH] powerpc/highmem: Properly handle fragmented memory

2022-09-20 Thread Christophe Leroy
In addition to checking whether a page is reserved before allocating it to highmem, verify that it is valid memory. Otherwise the kernel Oopses as below: [0.00] mem auto-init: stack:off, heap alloc:off, heap free:off [0.00] Kernel attempted to read user page (7df58) - exploit

Re: [RFC] Objtool toolchain proposal: -fannotate-{jump-table,noreturn}

2022-09-20 Thread Ard Biesheuvel
On Thu, 15 Sept 2022 at 10:47, Peter Zijlstra wrote: > > On Thu, Sep 15, 2022 at 10:56:58AM +0800, Chen Zhongjin wrote: > > > We have found some anonymous information on x86 in .rodata. > > Well yes, but that's still a bunch of heuristics on our side. > > > I'm not sure if those are *all* of Josh

[PATCH] powerpc/hv-gpci: Fix hv_gpci event list

2022-09-20 Thread Kajol Jain
Based on getPerfCountInfo v1.018 documentation, some of the hv_gpci events got deprecated for platforms firmware that supports counter_info_version 0x8 or above. Patch fixes the hv_gpci event list by adding a new attribute group called "hv_gpci_event_attrs_v6" and a "EVENT_ENABLE" macro to enable

[PATCH] powerpc/64: don't refer nr_cpu_ids in asm code when it's undefined

2022-09-20 Thread Yury Norov
generic_secondary_common_init() calls LOAD_REG_ADDR(r7, nr_cpu_ids) conditionally on CONFIG_SMP. However, if NR_CPUS == 1, kernel doesn't use the nr_cpu_ids, and in C code, it's just: #if NR_CPUS == 1 #define nr_cpu_ids ... The [1] makes declaration of nr_cpu_ids conditional on NR_CPUS ==

Re: [PATCH kernel v2 3/3] powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains

2022-09-20 Thread Jason Gunthorpe
On Tue, Sep 20, 2022 at 11:04:57PM +1000, Alexey Kardashevskiy wrote: > Up until now PPC64 managed to avoid using iommu_ops. The VFIO driver > uses a SPAPR TCE sub-driver and all iommu_ops uses were kept in > the Type1 VFIO driver. Recent development added 2 uses of iommu_ops to > the generic VFIO

[PATCH kernel v2 3/3] powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains

2022-09-20 Thread Alexey Kardashevskiy
Up until now PPC64 managed to avoid using iommu_ops. The VFIO driver uses a SPAPR TCE sub-driver and all iommu_ops uses were kept in the Type1 VFIO driver. Recent development added 2 uses of iommu_ops to the generic VFIO which broke POWER: - a coherency capability check; - blocking IOMMU domain -

[PATCH kernel v2 0/3] powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains

2022-09-20 Thread Alexey Kardashevskiy
Here is another take on iommu_ops on POWER to make VFIO work again on POWERPC64. Tested on PPC, kudos to Fred! The tree with all prerequisites is here: https://github.com/aik/linux/tree/kvm-fixes-wip The previous discussion is here:

[PATCH] powerpc/64: Remove unused prom_init_toc symbols

2022-09-20 Thread Michael Ellerman
Commit 24d33ac5b8ff ("powerpc/64s: Make prom_init require RELOCATABLE") made prom_init depend on CONFIG_RELOCATABLE. But it missed cleaning up a case in the linker script for RELOCATABLE=n, and associated symbols. Remove them now. Fixes: 24d33ac5b8ff ("powerpc/64s: Make prom_init require

[PATCH kernel v2 1/3] powerpc/iommu: Add "borrowing" iommu_table_group_ops

2022-09-20 Thread Alexey Kardashevskiy
PPC64 IOMMU API defines iommu_table_group_ops which handles DMA windows for PEs: control the ownership, create/set/unset a table the hardware for dynamic DMA windows (DDW). VFIO uses the API to implement support on POWER. So far only PowerNV IODA2 (POWER8 and newer machines) implemented this and

[PATCH kernel v2 2/3] powerpc/pci_64: Init pcibios subsys a bit later

2022-09-20 Thread Alexey Kardashevskiy
The following patches are going to add dependency/use of iommu_ops which is initialized in subsys_initcall as well. This moves pciobios_init() to the next initcall level. This should not cause behavioral change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kernel/pci_64.c | 2 +- 1

[PATCH v1 3/3] checkpatch: warn on usage of VM_BUG_ON() and other BUG variants

2022-09-20 Thread David Hildenbrand
checkpatch does not point out that VM_BUG_ON() and friends should be avoided, however, Linus notes: VM_BUG_ON() has the exact same semantics as BUG_ON. It is literally no different, the only difference is "we can make the code smaller because these are less important". [1] So let's

[PATCH v1 2/3] powerpc/prom_init: drop PROM_BUG()

2022-09-20 Thread David Hildenbrand
Unused, let's drop it. Signed-off-by: David Hildenbrand --- arch/powerpc/kernel/prom_init.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index a6669c40c1db..d464ba412084 100644 --- a/arch/powerpc/kernel/prom_init.c

[PATCH v1 1/3] coding-style.rst: document BUG() and WARN() rules ("do not crash the kernel")

2022-09-20 Thread David Hildenbrand
Linus notes [1] that the introduction of new code that uses VM_BUG_ON() is just as bad as BUG_ON(), because it will crash the kernel on distributions that enable CONFIG_DEBUG_VM (like Fedora): VM_BUG_ON() has the exact same semantics as BUG_ON. It is literally no different, the only

[PATCH v1 0/3] coding-style.rst: document BUG() and WARN() rules

2022-09-20 Thread David Hildenbrand
As it seems to be rather unclear if/when to use BUG(), BUG_ON(), VM_BUG_ON(), WARN_ON_ONCE(), ... let's try to document the result of a recent discussion. Details can be found in patch #1. RFC -> v1: * "coding-style.rst: document BUG() and WARN() rules ("do not crash the kernel")" ->

[PATCH v4 2/2] powerpc/64s: Make POWER10 and later use pause_short in cpu_relax loops

2022-09-20 Thread Nicholas Piggin
We want to move away from using SMT priority updates for cpu_relax, and use a 'wait' instruction which is similar to x86. As well as being a much better fit for what everybody else uses and tests with, priority nops are stateful which is nasty (interrupts have to consider they might be taken at a

[PATCH v4 1/2] powerpc: add ISA v3.0 / v3.1 wait opcode macro

2022-09-20 Thread Nicholas Piggin
The wait instruction encoding changed between ISA v2.07 and ISA v3.0. In v3.1 the instruction gained a new field. Update the PPC_WAIT macro to the current encoding. Rename the older incompatible one with a _v203 suffix as it was introduced in v2.03 (the WC field was introduced in v2.07 but the

Re: [PATCH v2 11/44] cpuidle,omap4: Push RCU-idle into driver

2022-09-20 Thread Frederic Weisbecker
On Mon, Sep 19, 2022 at 11:59:50AM +0200, Peter Zijlstra wrote: > Doing RCU-idle outside the driver, only to then temporarily enable it > again, some *four* times, before going idle is daft. > > Signed-off-by: Peter Zijlstra (Intel) > Reviewed-by: Tony Lindgren > Tested-by: Tony Lindgren

Re: [PATCH v2 03/44] cpuidle/poll: Ensure IRQ state is invariant

2022-09-20 Thread Frederic Weisbecker
On Tue, Sep 20, 2022 at 10:57:00AM +0200, Peter Zijlstra wrote: > On Mon, Sep 19, 2022 at 03:19:27PM +0200, Frederic Weisbecker wrote: > > On Mon, Sep 19, 2022 at 11:59:42AM +0200, Peter Zijlstra wrote: > > > cpuidle_state::enter() methods should be IRQ invariant > > > > Got a bit confused with

Re: [PATCH v2 08/44] cpuidle,imx6: Push RCU-idle into driver

2022-09-20 Thread Frederic Weisbecker
On Tue, Sep 20, 2022 at 10:58:59AM +0200, Peter Zijlstra wrote: > On Mon, Sep 19, 2022 at 04:21:23PM +0200, Frederic Weisbecker wrote: > > On Mon, Sep 19, 2022 at 11:59:47AM +0200, Peter Zijlstra wrote: > > > Doing RCU-idle outside the driver, only to then temporarily enable it > > > again, at

Re: [PATCH v2 08/44] cpuidle,imx6: Push RCU-idle into driver

2022-09-20 Thread Peter Zijlstra
On Mon, Sep 19, 2022 at 04:21:23PM +0200, Frederic Weisbecker wrote: > On Mon, Sep 19, 2022 at 11:59:47AM +0200, Peter Zijlstra wrote: > > Doing RCU-idle outside the driver, only to then temporarily enable it > > again, at least twice, before going idle is daft. > > Hmm, what ends up calling

Re: [PATCH v2 03/44] cpuidle/poll: Ensure IRQ state is invariant

2022-09-20 Thread Peter Zijlstra
On Mon, Sep 19, 2022 at 03:19:27PM +0200, Frederic Weisbecker wrote: > On Mon, Sep 19, 2022 at 11:59:42AM +0200, Peter Zijlstra wrote: > > cpuidle_state::enter() methods should be IRQ invariant > > Got a bit confused with the invariant thing since the first chunck I > see in this patch is a

Re: [PATCH v2 09/44] cpuidle,omap3: Push RCU-idle into driver

2022-09-20 Thread Frederic Weisbecker
On Mon, Sep 19, 2022 at 05:19:05PM +0200, Peter Zijlstra wrote: > On Mon, Sep 19, 2022 at 04:31:42PM +0200, Frederic Weisbecker wrote: > > On Mon, Sep 19, 2022 at 11:59:48AM +0200, Peter Zijlstra wrote: > > > Doing RCU-idle outside the driver, only to then teporarily enable it > > > again before

Re: [PATCH v2 21/44] arch/idle: Change arch_cpu_idle() IRQ behaviour

2022-09-20 Thread Guo Ren
On Mon, Sep 19, 2022 at 6:18 PM Peter Zijlstra wrote: > > Current arch_cpu_idle() is called with IRQs disabled, but will return > with IRQs enabled. > > However, the very first thing the generic code does after calling > arch_cpu_idle() is raw_local_irq_disable(). This means that > architectures

Re: [PATCH 20/23] powerpc/64s: Clear/restore caller gprs in syscall interrupt/return

2022-09-20 Thread Rohan McLure
> On 20 Sep 2022, at 12:03 pm, Nicholas Piggin wrote: > > On Fri Sep 16, 2022 at 3:32 PM AEST, Rohan McLure wrote: >> Clear user state in gprs (assign to zero) to reduce the influence of user >> registers on speculation within kernel syscall handlers. Clears occur >> at the very beginning of

Re: [PATCH v2 3/7] powerpc/build: move got, toc, plt, branch_lt sections to read-only

2022-09-20 Thread Nicholas Piggin
On Mon Sep 19, 2022 at 3:39 PM AEST, Michael Ellerman wrote: > kernel test robot writes: > > Hi Nicholas, > > > > I love your patch! Yet something to improve: > > > > [auto build test ERROR on powerpc/next] > > [also build test ERROR on linus/master v6.0-rc5 next-20220916] > > [If your patch is

Re: [PATCH v2 06/19] powerpc/cputable: Split cpu_specs[] out of cputable.h

2022-09-20 Thread Nicholas Piggin
On Tue Sep 20, 2022 at 3:01 AM AEST, Christophe Leroy wrote: > cpu_specs[] is full of #ifdefs depending on the different > types of CPU. > > CPUs are mutually exclusive, it is therefore possible to split > cpu_specs[] into smaller more readable pieces. > > Create cpu_specs_XXX.h that will each be

Re: [PATCH v3 4/4] arm64: support batched/deferred tlb shootdown during page reclamation

2022-09-20 Thread Anshuman Khandual
On 9/20/22 09:09, Barry Song wrote: > On Tue, Sep 20, 2022 at 3:00 PM Anshuman Khandual > wrote: >> >> >> On 8/22/22 13:51, Yicong Yang wrote: >>> +static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) >>> +{ >>> + return true; >>> +} >> >> This needs to be conditional on

Re: [PATCH v2 2/2] powerpc/kvm: Remove unused references for MMCR3/SIER2/SIER3 registers

2022-09-20 Thread Nicholas Piggin
On Fri Sep 16, 2022 at 8:57 PM AEST, Disha Goel wrote: > From: Kajol Jain" > > Commit 57dc0eed73ca ("KVM: PPC: Book3S HV P9: Implement PMU save/restore > in C") removed the PMU save/restore functions from assembly code and > implemented these functions in C, for power9 and later platforms. > >

Re: [PATCH v2 1/2] powerpc/kvm: Remove unused macros from asm-offset

2022-09-20 Thread Nicholas Piggin
On Fri Sep 16, 2022 at 8:57 PM AEST, Disha Goel wrote: > The kvm code was refactored to convert some of kvm assembly routines to C. > This includes commits which moved code path for the kvm guest entry/exit > for p7/8 from aseembly to C. As part of the code changes, usage of some of > the macros

Re: [PATCH 09/23] asm-generic: compat: Support BE for long long args in 32-bit ABIs

2022-09-20 Thread Arnd Bergmann
On Fri, Sep 16, 2022, at 7:32 AM, Rohan McLure wrote: > 32-bit ABIs support passing 64-bit integers by registers via argument > translation. Commit 59c10c52f573 ("riscv: compat: syscall: Add > compat_sys_call_table implementation") implements the compat_arg_u64 > macro for efficiently defining

Re: [PATCH 1/6] powerpc/code-patching: Implement generic text patching function

2022-09-20 Thread Benjamin Gray
On Tue, 2022-09-20 at 05:44 +, Christophe Leroy wrote: > > As far as I know, cachelines are minimum 64 bytes on PPC64 aren't > they ? In practice maybe. I don't know what the convention is in the kernel in cases where the ISA is less specific than what the supported machines do. > > Related

[PATCH] powerpc/irq: Modernise inline assembly in irq_soft_mask_{set,return}

2022-09-20 Thread Christophe Leroy
local_paca is declared as global register asm("r13"), it is therefore garantied to always ever be r13. It is therefore not required to opencode r13 in the assembly, use a reference to local_paca->irq_soft_mask instead. This also allows removing the 'memory' clobber in irq_soft_mask_set() as GCC

[PATCH] powerpc/irq: Refactor irq_soft_mask_{set,or}_return()

2022-09-20 Thread Christophe Leroy
This partialy reapply commit ef5b570d3700 ("powerpc/irq: Don't open code irq_soft_mask helpers") which was reverted by commit 684c68d92e2e ("Revert "powerpc/irq: Don't open code irq_soft_mask helpers"") irq_soft_mask_set_return() and irq_soft_mask_or_return() are overset of irq_soft_mask_set().