Re: [PATCH v3 6/8] PCI/AER: Clear error device AER registers in aer_irq()

2021-10-04 Thread kernel test robot
suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Naveen-Naidu/Fix-long-standing-AER-Error-Handling-Issues/20211004-223758 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next conf

Re: [PATCH 2/3] Remove 256MB limit restriction for boot cpu paca allocation

2021-10-04 Thread kernel test robot
'--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Sourabh-Jain/Update-crashkernel-offset-to-allow-kernel-to-boot-on-large-config-LPARs/20211004-233345 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linu

Re: [PATCH 1/3] fixup mmu_features immediately after getting cpu pa features.

2021-10-04 Thread Mahesh J Salgaonkar
On 2021-10-04 21:02:21 Mon, Aneesh Kumar K.V wrote: > On 10/4/21 20:41, Sourabh Jain wrote: > > From: Mahesh Salgaonkar > > > > On system with radix support available, early_radix_enabled() starts > > returning true for a small window (until mmu_early_init_devtree() is > > called) even when radix

Re: [V2 1/4] powerpc/perf: Refactor the code definition of perf reg extended mask

2021-10-04 Thread Michael Ellerman
Athira Rajeev writes: > PERF_REG_PMU_MASK_300 and PERF_REG_PMU_MASK_31 defines the mask > value for extended registers. Current definition of these mask values > uses hex constant and does not use registers by name, making it less > readable. Patch refactor the macro values by or'ing together the

Re: [PATCH 3/9] powerpc/bpf: Remove unused SEEN_STACK

2021-10-04 Thread Christophe Leroy
Le 04/10/2021 à 20:11, Naveen N. Rao a écrit : Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : From: Ravi Bangoria SEEN_STACK is unused on PowerPC. Remove it. Also, have SEEN_TAILCALL use 0x4000. Why change SEEN_TAILCALL ? Would it be a problem to leave it as

Re: [PATCH 4/9] powerpc/bpf: Handle large branch ranges with BPF_EXIT

2021-10-04 Thread Christophe Leroy
Le 04/10/2021 à 20:24, Naveen N. Rao a écrit : Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : In some scenarios, it is possible that the program epilogue is outside the branch range for a BPF_EXIT instruction. Instead of rejecting such programs, emit an indirect bra

Re: [PATCH 6/9] powerpc/bpf: Fix BPF_SUB when imm == 0x80000000

2021-10-04 Thread Christophe Leroy
Le 04/10/2021 à 20:18, Naveen N. Rao a écrit : Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : We aren't handling subtraction involving an immediate value of 0x8000 properly. Fix the same. Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for ext

Re: [PATCH v3 6/8] PCI/AER: Clear error device AER registers in aer_irq()

2021-10-04 Thread kernel test robot
suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Naveen-Naidu/Fix-long-standing-AER-Error-Handling-Issues/20211004-223758 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next c

Re: [RFC PATCH 4/8] powerpc: add CPU field to struct thread_info

2021-10-04 Thread Michael Ellerman
Kees Cook writes: > On Thu, Sep 30, 2021 at 08:46:04AM +1000, Michael Ellerman wrote: >> Ard Biesheuvel writes: >> > On Tue, 28 Sept 2021 at 02:16, Michael Ellerman >> > wrote: >> >> >> >> Michael Ellerman writes: >> >> > Ard Biesheuvel writes: >> >> >> On Tue, 14 Sept 2021 at 14:11, Ard Bies

Re: [PATCH v6 07/11] PCI: Replace pci_dev::driver usage that gets the driver name

2021-10-04 Thread Ido Schimmel
On Mon, Oct 04, 2021 at 02:59:31PM +0200, Uwe Kleine-König wrote: > struct pci_dev::driver holds (apart from a constant offset) the same > data as struct pci_dev::dev->driver. With the goal to remove struct > pci_dev::driver to get rid of data duplication replace getting the > driver name by dev_dr

[PATCH 1/6] PCI/AER: Enable COR/UNCOR error reporting in set_device_error_reporting()

2021-10-04 Thread Naveen Naidu
The (PCIe r5.0, sec 7.6.4.3, Table 7-101) and (PCIe r5.0, sec 7.8.4.6, Table 7-104) states that the default values for the Uncorrectable Error Mask and Correctable Error Mask should be 0b. But the current code does not set the default value of these registers when the PCIe bus loads the AER servic

[PATCH 0/6] MIPS: OCTEON: Remove redundant AER code

2021-10-04 Thread Naveen Naidu
e8635b484f64 ("MIPS: Add Cavium OCTEON PCI support.") added MIPS specific code to enable PCIe and AER error reporting (*irrespective of CONFIG_PCIEAER value*) because PCI core didn't do that at the time. But currently, the PCI core clears and enables the AER status registers. So it's redundant for

[PATCH v3 8/8] PCI/AER: Include DEVCTL in aer_print_error()

2021-10-04 Thread Naveen Naidu
Print the contents of Device Control Register of the device which detected the error. This might help in faster error diagnosis. Sample output from dummy error injected by aer-inject: pcieport :00:03.0: AER: Corrected error received: :00:03.0 pcieport :00:03.0: PCIe Bus Error: sev

[PATCH v3 7/8] PCI/ERR: Remove redundant clearing of AER register in pcie_do_recovery()

2021-10-04 Thread Naveen Naidu
pcie_do_recovery() is shared across the following paths: - ACPI APEI - Native AER path - EDR - DPC ACPI APEI == ghes_handle_aer() aer_recover_queue() kfifo_in_spinlocked(aer_recover_ring) aer_recover_work_func() while (kfifo_get(aer_recover_ring)) pcie_do_reco

[PATCH v3 6/8] PCI/AER: Clear error device AER registers in aer_irq()

2021-10-04 Thread Naveen Naidu
Converge the APEI path and native AER path of clearing the AER registers of the error device. In APEI path, the system firmware clears the AER registers before handing off the record to OS. But in "native AER" path, the execution path of clearing the AER register is as follows: aer_isr_one_erro

[PATCH v3 5/8] PCI/DPC: Converge EDR and DPC Path of clearing AER registers

2021-10-04 Thread Naveen Naidu
In the EDR path, AER registers are cleared *after* DPC error event is processed. The process stack in EDR is: edr_handle_event() dpc_process_error() pci_aer_raw_clear_status() pcie_do_recovery() But in DPC path, AER status registers are cleared *while* processing the error. The proc

[PATCH v3 4/8] PCI/DPC: Use pci_aer_clear_status() in dpc_process_error()

2021-10-04 Thread Naveen Naidu
dpc_process_error() clears both AER fatal and non fatal status registers. Instead of clearing each status registers via a different function call use pci_aer_clear_status(). This helps clean up the code a bit. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 3 +-- 1 file changed, 1 ins

[PATCH v3 3/8] PCI/DPC: Initialize info->id in dpc_process_error()

2021-10-04 Thread Naveen Naidu
In the dpc_process_error() path, info->id isn't initialized before being passed to aer_print_error(). In the corresponding AER path, it is initialized in aer_isr_one_error(). The error message shown during Coverity Scan is: Coverity #1461602 CID 1461602 (#1 of 1): Uninitialized scalar variabl

[PATCH v3 2/8] PCI: Cleanup struct aer_err_info

2021-10-04 Thread Naveen Naidu
The id, status and the mask fields of the struct aer_err_info comes directly from the registers, hence their sizes should be explicit. The length of these registers are: - id: 16 bits - Represents the Error Source Requester ID - status: 32 bits - COR/UNCOR Error Status - mask: 32 bits - COR/

[PATCH v3 1/8] PCI/AER: Remove ID from aer_agent_string[]

2021-10-04 Thread Naveen Naidu
Before 010caed4ccb6 ("PCI/AER: Decode Error Source RequesterID") the AER error logs looked like: pcieport :00:03.0: AER: Corrected error received: id=0018 pcieport :00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, id=0018 (Receiver ID) pcieport :00:03.0: devi

[PATCH v3 0/8] Fix long standing AER Error Handling Issues

2021-10-04 Thread Naveen Naidu
This patch series aims at fixing some of the AER error handling issues we have. Currently we have the following issues: - Confusing message in aer_print_error() - aer_err_info not being initialized completely in DPC path before we print the AER logs - A bug [1] in clearing of AER registers i

[PATCH 8/8] PCI/AER: Include DEVCTL in aer_print_error()

2021-10-04 Thread Naveen Naidu
Print the contents of Device Control Register of the device which detected the error. This might help in faster error diagnosis. Sample output from dummy error injected by aer-inject: pcieport :00:03.0: AER: Corrected error received: :00:03.0 pcieport :00:03.0: PCIe Bus Error: sev

[PATCH 7/8] PCI/ERR: Remove redundant clearing of AER register in pcie_do_recovery()

2021-10-04 Thread Naveen Naidu
pcie_do_recovery() is shared across the following paths: - ACPI APEI - Native AER path - EDR - DPC ACPI APEI == ghes_handle_aer() aer_recover_queue() kfifo_in_spinlocked(aer_recover_ring) aer_recover_work_func() while (kfifo_get(aer_recover_ring)) pcie_do_reco

[PATCH 6/8] PCI/AER: Clear error device AER registers in aer_irq()

2021-10-04 Thread Naveen Naidu
Converge the APEI path and native AER path of clearing the AER registers of the error device. In APEI path, the system firmware clears the AER registers before handing off the record to OS. But in "native AER" path, the execution path of clearing the AER register is as follows: aer_isr_one_erro

[PATCH 5/8] PCI/DPC: Converge EDR and DPC Path of clearing AER registers

2021-10-04 Thread Naveen Naidu
In the EDR path, AER registers are cleared *after* DPC error event is processed. The process stack in EDR is: edr_handle_event() dpc_process_error() pci_aer_raw_clear_status() pcie_do_recovery() But in DPC path, AER status registers are cleared *while* processing the error. The proc

[PATCH 4/8] PCI/DPC: Use pci_aer_clear_status() in dpc_process_error()

2021-10-04 Thread Naveen Naidu
dpc_process_error() clears both AER fatal and non fatal status registers. Instead of clearing each status registers via a different function call use pci_aer_clear_status(). This helps clean up the code a bit. Signed-off-by: Naveen Naidu --- drivers/pci/pcie/dpc.c | 3 +-- 1 file changed, 1 ins

[PATCH 2/8] PCI: Cleanup struct aer_err_info

2021-10-04 Thread Naveen Naidu
The id, status and the mask fields of the struct aer_err_info comes directly from the registers, hence their sizes should be explicit. The length of these registers are: - id: 16 bits - Represents the Error Source Requester ID - status: 32 bits - COR/UNCOR Error Status - mask: 32 bits - COR/

[PATCH 1/8] PCI/AER: Remove ID from aer_agent_string[]

2021-10-04 Thread Naveen Naidu
Before 010caed4ccb6 ("PCI/AER: Decode Error Source RequesterID") the AER error logs looked like: pcieport :00:03.0: AER: Corrected error received: id=0018 pcieport :00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, id=0018 (Receiver ID) pcieport :00:03.0: devi

[PATCH 0/8] Fix long standing AER Error Handling Issues

2021-10-04 Thread Naveen Naidu
This patch series aims at fixing some of the AER error handling issues we have. Currently we have the following issues: - Confusing message in aer_print_error() - aer_err_info not being initialized completely in DPC path before we print the AER logs - A bug [1] in clearing of AER registers

[PATCH v6 00/11] PCI: Drop duplicated tracking of a pci_dev's bound driver

2021-10-04 Thread Uwe Kleine-König
Hello, this is v6 of the quest to drop the "driver" member from struct pci_dev which tracks the same data (apart from a constant offset) as dev.driver. Changes since v5: - Some Acks added - Some fixes in "PCI: Replace pci_dev::driver usage by pci_dev::dev.driver" to properly handle that t

Re: Add Apple M1 support to PASemi i2c driver

2021-10-04 Thread Christian Zigotzky
> On 3. Oct 2021, at 16:36, Sven Peter wrote: > > Hi, > > >> On Fri, Oct 1, 2021, at 06:47, Christian Zigotzky wrote: >>> On 27 September 2021 at 07:39 am, Sven Peter wrote: >>> Hi Christian, >>> >>> Thanks already for volunteering to test this! >>> >> Hello Sven, >> >> Damien (Hypex) has

Re: [PATCH v3 1/8] PCI/AER: Remove ID from aer_agent_string[]

2021-10-04 Thread Shuah Khan
On 10/4/21 8:29 AM, Naveen Naidu wrote: Before 010caed4ccb6 ("PCI/AER: Decode Error Source RequesterID") the AER error logs looked like: pcieport :00:03.0: AER: Corrected error received: id=0018 pcieport :00:03.0: PCIe Bus Error: severity=Corrected, type=Data Link Layer, id=0018 (

Re: [PATCH v5 00/14] PCI: Add support for Apple M1

2021-10-04 Thread Linus Walleij
On Mon, Oct 4, 2021 at 9:52 PM Rob Herring wrote: > FYI, I pushed patches 1-3 to kernelCI and didn't see any regressions. > I am a bit worried about changes to the DT interrupt parsing and > ancient platforms (such as PowerMacs). Most likely there wouldn't be > any report until -rc1 or months lat

Re: [PATCH 4/9] powerpc/bpf: Handle large branch ranges with BPF_EXIT

2021-10-04 Thread Naveen N. Rao
Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : In some scenarios, it is possible that the program epilogue is outside the branch range for a BPF_EXIT instruction. Instead of rejecting such programs, emit an indirect branch. We track the size of the bpf program emitted a

Re: [PATCH 0/9] powerpc/bpf: Various fixes

2021-10-04 Thread Naveen N. Rao
Hi Johan, Johan Almbladh wrote: On Fri, Oct 1, 2021 at 11:15 PM Naveen N. Rao wrote: Various fixes to the eBPF JIT for powerpc, thanks to some new tests added by Johan. This series fixes all failures in test_bpf on powerpc64. There are still some failures on powerpc32 to be looked into. Gre

Re: [PATCH 6/9] powerpc/bpf: Fix BPF_SUB when imm == 0x80000000

2021-10-04 Thread Naveen N. Rao
Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : We aren't handling subtraction involving an immediate value of 0x8000 properly. Fix the same. Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF") Signed-off-by: Naveen N. Rao --- arc

Re: [PATCH 3/9] powerpc/bpf: Remove unused SEEN_STACK

2021-10-04 Thread Naveen N. Rao
Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : From: Ravi Bangoria SEEN_STACK is unused on PowerPC. Remove it. Also, have SEEN_TAILCALL use 0x4000. Why change SEEN_TAILCALL ? Would it be a problem to leave it as is ? Signed-off-by: Ravi Bangoria Reviewed-by:

Re: [PATCH 2/9] powerpc/bpf: Validate branch ranges

2021-10-04 Thread Naveen N. Rao
Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : Add checks to ensure that we never emit branch instructions with truncated branch offsets. Suggested-by: Michael Ellerman Signed-off-by: Naveen N. Rao --- arch/powerpc/net/bpf_jit.h| 26

Re: [PATCH 1/9] powerpc/lib: Add helper to check if offset is within conditional branch range

2021-10-04 Thread Naveen N. Rao
Hi Christophe, Thanks for the reviews. Christophe Leroy wrote: Le 01/10/2021 à 23:14, Naveen N. Rao a écrit : Add a helper to check if a given offset is within the branch range for a powerpc conditional branch instruction, and update some sites to use the new helper. Signed-off-by: Naveen N

Re: [PATCH 1/9] powerpc/lib: Add helper to check if offset is within conditional branch range

2021-10-04 Thread Naveen N. Rao
Hi Song, Thanks for the reviews. Song Liu wrote: On Fri, Oct 1, 2021 at 2:16 PM Naveen N. Rao wrote: Add a helper to check if a given offset is within the branch range for a powerpc conditional branch instruction, and update some sites to use the new helper. Signed-off-by: Naveen N. Rao

Re: [PATCH 01/10] dt-bindings: i2c: Add Apple I2C controller bindings

2021-10-04 Thread Rob Herring
On Sun, 26 Sep 2021 11:58:38 +0200, Sven Peter wrote: > The Apple I2C controller is based on the PASemi I2C controller. > It is present on Apple SoCs such as the M1. > > Signed-off-by: Sven Peter > --- > .../devicetree/bindings/i2c/apple,i2c.yaml| 61 +++ > MAINTAINERS

Re: [PATCH 3/3] powerpc: Set crashkernel offset to mid of RMA region

2021-10-04 Thread Sourabh Jain
Hello Aneesh, @@ -1235,6 +1235,9 @@ int __init early_init_dt_scan_rtas(unsigned long node,   entryp = of_get_flat_dt_prop(node, "linux,rtas-entry", NULL);   sizep  = of_get_flat_dt_prop(node, "rtas-size", NULL);   +    if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL)) +

Re: [PATCH v3 2/2] powerpc/powermac: constify device_node in of_irq_parse_oldworld()

2021-10-04 Thread Rob Herring
On Fri, 24 Sep 2021 12:56:53 +0200, Krzysztof Kozlowski wrote: > The of_irq_parse_oldworld() does not modify passed device_node so make > it a pointer to const for safety. Drop the extern while modifying the > line. > > Signed-off-by: Krzysztof Kozlowski > > --- > > Changes since v1: > 1. Drop

Re: [PATCH 2/5] memory: fsl_ifc: populate child devices without relying on simple-bus

2021-10-04 Thread Rob Herring
On Thu, Sep 30, 2021 at 07:09:21PM -0500, Li Yang wrote: > After we update the binding to not use simple-bus compatible for the > controller, we need the driver to populate the child devices explicitly. > > Signed-off-by: Li Yang > --- > drivers/memory/fsl_ifc.c | 9 + > 1 file changed,

Re: [PATCH 3/3] powerpc: Set crashkernel offset to mid of RMA region

2021-10-04 Thread Aneesh Kumar K.V
On 10/4/21 20:41, Sourabh Jain wrote: On large config LPARs (having 192 and more cores), Linux fails to boot due to insufficient memory in the first memory block. It is due to the reserve crashkernel area starts at 128MB offset by default and which doesn't leave enough space in the first memory b

[RFC PATCH] KVM: PPC: Book3S HV P9: Move H_CEDE logic mostly to one place

2021-10-04 Thread Nicholas Piggin
Move the vcpu->arch.ceded, hrtimer, and blocking handling to one place, except the xive escalation rearm case. The only special case is the xive handling, as it is to be done before the xive context is pulled. This means the P9 path does not run with ceded==1 or the hrtimer armed except in the kvm

[PATCH v3 52/52] KVM: PPC: Book3S HV P9: Remove subcore HMI handling

2021-10-04 Thread Nicholas Piggin
On POWER9 and newer, rather than the complex HMI synchronisation and subcore state, have each thread un-apply the guest TB offset before calling into the early HMI handler. This allows the subcore state to be avoided, including subcore enter / exit guest, which includes an expensive divide that sh

[PATCH v3 51/52] KVM: PPC: Book3S HV P9: Stop using vc->dpdes

2021-10-04 Thread Nicholas Piggin
The P9 path uses vc->dpdes only for msgsndp / SMT emulation. This adds an ordering requirement between vcpu->doorbell_request and vc->dpdes for no real benefit. Use vcpu->doorbell_request directly. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 18 ++

[PATCH v3 50/52] KVM: PPC: Book3S HV P9: Tidy kvmppc_create_dtl_entry

2021-10-04 Thread Nicholas Piggin
This goes further to removing vcores from the P9 path. Also avoid the memset in favour of explicitly initialising all fields. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 61 +--- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a

[PATCH v3 49/52] KVM: PPC: Book3S HV P9: Remove most of the vcore logic

2021-10-04 Thread Nicholas Piggin
The P9 path always uses one vcpu per vcore, so none of the vcore, locks, stolen time, blocking logic, shared waitq, etc., is required. Remove most of it. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 147 --- 1 file changed, 85 insertions(+),

[PATCH v3 48/52] KVM: PPC: Book3S HV P9: Avoid cpu_in_guest atomics on entry and exit

2021-10-04 Thread Nicholas Piggin
cpu_in_guest is set to determine if a CPU needs to be IPI'ed to exit the guest and notice the need_tlb_flush bit. This can be implemented as a global per-CPU pointer to the currently running guest instead of per-guest cpumasks, saving 2 atomics per entry/exit. P7/8 doesn't require cpu_in_guest, no

[PATCH v3 47/52] KVM: PPC: Book3S HV P9: Add unlikely annotation for !mmu_ready

2021-10-04 Thread Nicholas Piggin
The mmu will almost always be ready. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 0bbef4587f41..6e072e2e130a 100644 --- a/arch/powerpc/kvm/book

[PATCH v3 46/52] KVM: PPC: Book3S HV P9: Avoid changing MSR[RI] in entry and exit

2021-10-04 Thread Nicholas Piggin
kvm_hstate.in_guest provides the equivalent of MSR[RI]=0 protection, and it covers the existing MSR[RI]=0 section in late entry and early exit, so clearing and setting MSR[RI] in those cases does not actually do anything useful. Remove the RI manipulation and replace it with comments. Make the in_

[PATCH v3 45/52] KVM: PPC: Book3S HV P9: Optimise hash guest SLB saving

2021-10-04 Thread Nicholas Piggin
slbmfee/slbmfev instructions are very expensive, moreso than a regular mfspr instruction, so minimising them significantly improves hash guest exit performance. The slbmfev is only required if slbmfee found a valid SLB entry. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry

[PATCH v3 44/52] KVM: PPC: Book3S HV P9: Improve mfmsr performance on entry

2021-10-04 Thread Nicholas Piggin
Rearrange the MSR saving on entry so it does not follow the mtmsrd to disable interrupts, avoiding a possible RAW scoreboard stall. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s_64.h | 2 + arch/powerpc/kvm/book3s_hv.c | 18 ++- arch/powerpc/kvm/book3s_h

[PATCH v3 43/52] KVM: PPC: Book3S HV Nested: Avoid extra mftb() in nested entry

2021-10-04 Thread Nicholas Piggin
mftb() is expensive and one can be avoided on nested guest dispatch. If the time checking code distinguishes between the L0 timer and the nested HV timer, then both can be tested in the same place with the same mftb() value. This also nicely illustrates the relationship between the L0 and nested

[PATCH v3 42/52] KVM: PPC: Book3S HV P9: Avoid tlbsync sequence on radix guest exit

2021-10-04 Thread Nicholas Piggin
Use the existing TLB flushing logic to IPI the previous CPU and run the necessary barriers before running a guest vCPU on a new physical CPU, to do the necessary radix GTSE barriers for handling the case of an interrupted guest tlbie sequence. This results in more IPIs than the TLB flush logic req

[PATCH v3 41/52] KVM: PPC: Book3S HV P9: Don't restore PSSCR if not needed

2021-10-04 Thread Nicholas Piggin
This also moves the PSSCR update in nested entry to avoid a SPR scoreboard stall. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 7 +-- arch/powerpc/kvm/book3s_hv_p9_entry.c | 26 +++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff

[PATCH v3 40/52] KVM: PPC: Book3S HV P9: Test dawr_enabled() before saving host DAWR SPRs

2021-10-04 Thread Nicholas Piggin
Some of the DAWR SPR access is already predicated on dawr_enabled(), apply this to the remainder of the accesses. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 34 --- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/arch/powerp

[PATCH v3 39/52] KVM: PPC: Book3S HV P9: Comment and fix MMU context switching code

2021-10-04 Thread Nicholas Piggin
Tighten up partition switching code synchronisation and comments. In particular, hwsync ; isync is required after the last access that is performed in the context of a partition, before the partition is switched away from. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_64_entry.S

[PATCH v3 38/52] KVM: PPC: Book3S HV P9: Use Linux SPR save/restore to manage some host SPRs

2021-10-04 Thread Nicholas Piggin
Linux implements SPR save/restore including storage space for registers in the task struct for process context switching. Make use of this similarly to the way we make use of the context switching fp/vec save restore. This improves code reuse, allows some stack space to be saved, and helps with av

[PATCH v3 37/52] KVM: PPC: Book3S HV P9: Demand fault TM facility registers

2021-10-04 Thread Nicholas Piggin
Use HFSCR facility disabling to implement demand faulting for TM, with a hysteresis counter similar to the load_fp etc counters in context switching that implement the equivalent demand faulting for userspace facilities. This speeds up guest entry/exit by avoiding the register save/restore when a

[PATCH v3 36/52] KVM: PPC: Book3S HV P9: Demand fault EBB facility registers

2021-10-04 Thread Nicholas Piggin
Use HFSCR facility disabling to implement demand faulting for EBB, with a hysteresis counter similar to the load_fp etc counters in context switching that implement the equivalent demand faulting for userspace facilities. This speeds up guest entry/exit by avoiding the register save/restore when a

[PATCH v3 35/52] KVM: PPC: Book3S HV P9: More SPR speed improvements

2021-10-04 Thread Nicholas Piggin
This avoids more scoreboard stalls and reduces mtSPRs. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 73 --- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_p9_entry.c b/arch/powerpc/kvm/book3s_hv_p9

[PATCH v3 34/52] KVM: PPC: Book3S HV P9: Restrict DSISR canary workaround to processors that require it

2021-10-04 Thread Nicholas Piggin
Use CPU_FTR_P9_RADIX_PREFETCH_BUG to apply the workaround, to test for DD2.1 and below processors. This saves a mtSPR in guest entry. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 3 ++- arch/powerpc/kvm/book3s_hv_p9_entry.c | 6 -- 2 files changed, 6 insertions(

[PATCH v3 33/52] KVM: PPC: Book3S HV P9: Switch PMU to guest as late as possible

2021-10-04 Thread Nicholas Piggin
This moves PMU switch to guest as late as possible in entry, and switch back to host as early as possible at exit. This helps the host get the most perf coverage of KVM entry/exit code as possible. This is slightly suboptimal for SPR scheduling point of view when the PMU is enabled, but when perf

[PATCH v3 32/52] KVM: PPC: Book3S HV P9: Implement TM fastpath for guest entry/exit

2021-10-04 Thread Nicholas Piggin
If TM is not active, only TM register state needs to be saved and restored, avoiding several mfmsr/mtmsrd instructions and improving performance. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 27 +++ 1 file changed, 23 insertions(+), 4 deletio

[PATCH v3 31/52] KVM: PPC: Book3S HV P9: Move remaining SPR and MSR access into low level entry

2021-10-04 Thread Nicholas Piggin
Move register saving and loading from kvmhv_p9_guest_entry() into the HV and nested entry handlers. Accesses are scheduled to reduce mtSPR / mfSPR interleaving which reduces SPR scoreboard stalls. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 79 ++--

[PATCH v3 30/52] KVM: PPC: Book3S HV P9: Move nested guest entry into its own function

2021-10-04 Thread Nicholas Piggin
Move the part of the guest entry which is specific to nested HV into its own function. This is just refactoring. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 125 +++ 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/arch/powerpc

[PATCH v3 29/52] KVM: PPC: Book3S HV P9: Move host OS save/restore functions to built-in

2021-10-04 Thread Nicholas Piggin
Move the P9 guest/host register switching functions to the built-in P9 entry code, and export it for nested to use as well. This allows more flexibility in scheduling these supervisor privileged SPR accesses with the HV privileged and PR SPR accesses in the low level entry code. Signed-off-by: Ni

[PATCH v3 28/52] KVM: PPC: Book3S HV P9: Move vcpu register save/restore into functions

2021-10-04 Thread Nicholas Piggin
This should be no functional difference but makes the caller easier to read. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 65 +++- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/

[PATCH v3 27/52] KVM: PPC: Book3S HV P9: Juggle SPR switching around

2021-10-04 Thread Nicholas Piggin
This juggles SPR switching on the entry and exit sides to be more symmetric, which makes the next refactoring patch possible with no functional change. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch

[PATCH v3 26/52] KVM: PPC: Book3S HV P9: Only execute mtSPR if the value changed

2021-10-04 Thread Nicholas Piggin
Keep better track of the current SPR value in places where they are to be loaded with a new context, to reduce expensive mtSPR operations. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 51 ++-- 1 file changed, 31 insertions(+), 20 deletions(-)

[PATCH v3 25/52] KVM: PPC: Book3S HV P9: Avoid SPR scoreboard stalls

2021-10-04 Thread Nicholas Piggin
Avoid interleaving mfSPR and mtSPR to reduce SPR scoreboard stalls. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 8 arch/powerpc/kvm/book3s_hv_p9_entry.c | 19 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/arch/powerp

[PATCH v3 24/52] KVM: PPC: Book3S HV P9: Optimise timebase reads

2021-10-04 Thread Nicholas Piggin
Reduce the number of mfTB executed by passing the current timebase around entry and exit code rather than read it multiple times. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s_64.h | 2 +- arch/powerpc/kvm/book3s_hv.c | 88 +--- arch/powe

[PATCH v3 23/52] KVM: PPC: Book3S HV P9: Move TB updates

2021-10-04 Thread Nicholas Piggin
Move the TB updates between saving and loading guest and host SPRs, to improve scheduling by keeping issue-NTC operations together as much as possible. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv_p9_entry.c | 36 +-- 1 file changed, 18 insertions(+), 18

[PATCH v3 22/52] KVM: PPC: Book3S HV: Change dec_expires to be relative to guest timebase

2021-10-04 Thread Nicholas Piggin
Change dec_expires to be relative to the guest timebase, and allow it to be moved into low level P9 guest entry functions, to improve SPR access scheduling. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/kvm_book3s.h | 6 +++ arch/powerpc/include/asm/kvm_host.h | 2 +- arch/

[PATCH v3 21/52] KVM: PPC: Book3S HV P9: Add kvmppc_stop_thread to match kvmppc_start_thread

2021-10-04 Thread Nicholas Piggin
Small cleanup makes it a bit easier to match up entry and exit operations. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/b

[PATCH v3 20/52] KVM: PPC: Book3S HV P9: Improve mtmsrd scheduling by delaying MSR[EE] disable

2021-10-04 Thread Nicholas Piggin
Moving the mtmsrd after the host SPRs are saved and before the guest SPRs start to be loaded can prevent an SPR scoreboard stall (because the mtmsrd is L=1 type which does not cause context synchronisation. This is also now more convenient to combined with the mtmsrd L=0 instruction to enable faci

[PATCH v3 19/52] KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs

2021-10-04 Thread Nicholas Piggin
This reduces the number of mtmsrd required to enable facility bits when saving/restoring registers, by having the KVM code set all bits up front rather than using individual facility functions that set their particular MSR bits. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/switch_

[PATCH v3 18/52] KVM: PPC: Book3S HV P9: Move SPRG restore to restore_p9_host_os_sprs

2021-10-04 Thread Nicholas Piggin
Move the SPR update into its relevant helper function. This will help with SPR scheduling improvements in later changes. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/pow

[PATCH v3 17/52] KVM: PPC: Book3S HV: CTRL SPR does not require read-modify-write

2021-10-04 Thread Nicholas Piggin
Processors that support KVM HV do not require read-modify-write of the CTRL SPR to set/clear their thread's runlatch. Just write 1 or 0 to it. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c| 2 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 15 ++- 2 files

[PATCH v3 16/52] KVM: PPC: Book3S HV P9: Factor out yield_count increment

2021-10-04 Thread Nicholas Piggin
Factor duplicated code into a helper function. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c in

[PATCH v3 15/52] KVM: PPC: Book3S HV P9: Demand fault PMU SPRs when marked not inuse

2021-10-04 Thread Nicholas Piggin
The pmcregs_in_use field in the guest VPA can not be trusted to reflect what the guest is doing with PMU SPRs, so the PMU must always be managed (stopped) when exiting the guest, and SPR values set when entering the guest to ensure it can't cause a covert channel or otherwise cause other guests or

[PATCH v3 14/52] KVM: PPC: Book3S HV P9: Factor PMU save/load into context switch functions

2021-10-04 Thread Nicholas Piggin
Rather than guest/host save/retsore functions, implement context switch functions that take care of details like the VPA update for nested. The reason to split these kind of helpers into explicit save/load functions is mainly to schedule SPR access nicely, but PMU is a special case where the load

[PATCH v3 13/52] KVM: PPC: Book3S HV P9: Implement PMU save/restore in C

2021-10-04 Thread Nicholas Piggin
Implement the P9 path PMU save/restore code in C, and remove the POWER9/10 code from the P7/8 path assembly. Cc: Madhavan Srinivasan Reviewed-by: Athira Jajeev Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/asm-prototypes.h | 5 - arch/powerpc/kvm/book3s_hv.c | 221

[PATCH v3 12/52] powerpc/64s: Implement PMU override command line option

2021-10-04 Thread Nicholas Piggin
It can be useful in simulators (with very constrained environments) to allow some PMCs to run from boot so they can be sampled directly by a test harness, rather than having to run perf. A previous change freezes counters at boot by default, so provide a boot time option to un-freeze (plus a bit m

[PATCH v3 11/52] powerpc/64s: Always set PMU control registers to frozen/disabled when not in use

2021-10-04 Thread Nicholas Piggin
KVM PMU management code looks for particular frozen/disabled bits in the PMU registers so it knows whether it must clear them when coming out of a guest or not. Setting this up helps KVM make these optimisations without getting confused. Longer term the better approach might be to move guest/host P

[PATCH v3 10/52] KVM: PPC: Book3S HV: Don't always save PMU for guest capable of nesting

2021-10-04 Thread Nicholas Piggin
Provide a config option that controls the workaround added by commit 63279eeb7f93 ("KVM: PPC: Book3S HV: Always save guest pmu for guest capable of nesting"). The option defaults to y for now, but is expected to go away within a few releases. Nested capable guests running with the earlier commit (

[PATCH v3 09/52] powerpc/64s: Keep AMOR SPR a constant ~0 at runtime

2021-10-04 Thread Nicholas Piggin
This register controls supervisor SPR modifications, and as such is only relevant for KVM. KVM always sets AMOR to ~0 on guest entry, and never restores it coming back out to the host, so it can be kept constant and avoid the mtSPR in KVM guest entry. Reviewed-by: Fabiano Rosas Signed-off-by: Nic

[PATCH v3 08/52] KVM: PPC: Book3S HV: POWER10 enable HAIL when running radix guests

2021-10-04 Thread Nicholas Piggin
HV interrupts may be taken with the MMU enabled when radix guests are running. Enable LPCR[HAIL] on ISA v3.1 processors for radix guests. Make this depend on the host LPCR[HAIL] being enabled. Currently that is always enabled, but having this test means any issue that might require LPCR[HAIL] to be

[PATCH v3 07/52] powerpc/time: add API for KVM to re-arm the host timer/decrementer

2021-10-04 Thread Nicholas Piggin
Rather than have KVM look up the host timer and fiddle with the irq-work internal details, have the powerpc/time.c code provide a function for KVM to re-arm the Linux timer code when exiting a guest. This is implementation has an improvement over existing code of marking a decrementer interrupt as

[PATCH v3 06/52] KVM: PPC: Book3S HV P9: Reduce mftb per guest entry/exit

2021-10-04 Thread Nicholas Piggin
mftb is serialising (dispatch next-to-complete) so it is heavy weight for a mfspr. Avoid reading it multiple times in the entry or exit paths. A small number of cycles delay to timers is tolerable. Reviewed-by: Fabiano Rosas Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c

[PATCH v3 05/52] KVM: PPC: Book3S HV P9: Use large decrementer for HDEC

2021-10-04 Thread Nicholas Piggin
On processors that don't suppress the HDEC exceptions when LPCR[HDICE]=0, this could help reduce needless guest exits due to leftover exceptions on entering the guest. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 2 ++ arch/powerpc

[PATCH v3 04/52] KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer read

2021-10-04 Thread Nicholas Piggin
There is no need to save away the host DEC value, as it is derived from the host timer subsystem which maintains the next timer time, so it can be restored from there. Signed-off-by: Nicholas Piggin --- arch/powerpc/include/asm/time.h | 5 + arch/powerpc/kernel/time.c | 1 + arch/powe

[PATCH v3 03/52] KMV: PPC: Book3S HV P9: Use set_dec to set decrementer to host

2021-10-04 Thread Nicholas Piggin
The host Linux timer code arms the decrementer with the value 'decrementers_next_tb - current_tb' using set_dec(), which stores val - 1 on Book3S-64, which is not quite the same as what KVM does to re-arm the host decrementer when exiting the guest. This shouldn't be a significant change, but it m

[PATCH v3 02/52] powerpc/64s: guard optional TIDR SPR with CPU ftr test

2021-10-04 Thread Nicholas Piggin
The TIDR SPR only exists on POWER9. Avoid accessing it when the feature bit for it is not set. Signed-off-by: Nicholas Piggin --- arch/powerpc/kvm/book3s_hv.c | 12 arch/powerpc/xmon/xmon.c | 10 -- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/pow

[PATCH v3 01/52] powerpc/64s: Remove WORT SPR from POWER9/10 (take 2)

2021-10-04 Thread Nicholas Piggin
This removes a missed remnant of the WORT SPR. Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/idle.c | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c index e3ffdc8e8567..86e787502e42 100644 --- a/

[PATCH v3 00/52] KVM: PPC: Book3S HV P9: entry/exit optimisations

2021-10-04 Thread Nicholas Piggin
This reduces radix guest full entry/exit latency on POWER9 and POWER10 by 2x. Nested HV guests should see smaller improvements in their L1 entry/exit, but this is also combined with most L0 speedups also applying to nested entry. nginx localhost throughput test in a SMP nested guest is improved ab

Re: [PATCH 5/5] powerpc/64s: Fix unrecoverable MCE calling async handler from NMI

2021-10-04 Thread Cédric Le Goater
On 10/4/21 16:56, Nicholas Piggin wrote: The machine check handler is not considered NMI on 64s. The early handler is the true NMI handler, and then it schedules the machine_check_exception handler to run when interrupts are enabled. This works fine except the case of an unrecoverable MCE, where

  1   2   >