[PATCH v5 7/9] powerpc/pseries/vas: Reopen windows with DLPAR core add

2022-02-27 Thread Haren Myneni
VAS windows can be closed in the hypervisor due to lost credits when the core is removed and the kernel gets fault for NX requests on these inactive windows. If the NX requests are issued on these inactive windows, OS gets page faults and the paste failure will be returned to the user space. If

[PATCH v5 4/9] powerpc/vas: Return paste instruction failure if no active window

2022-02-27 Thread Haren Myneni
The VAS window may not be active if the system looses credits and the NX generates page fault when it receives request on unmap paste address. The kernel handles the fault by remap new paste address if the window is active again, Otherwise return the paste instruction failure if the executed

[PATCH v4 3/3] powerpc/pseries/vas: Add VAS migration handler

2022-02-27 Thread Haren Myneni
Since the VAS windows belong to the VAS hardware resource, the hypervisor expects the partition to close them on source partition and reopen them after the partition migrated on the destination machine. This handler is called before pseries_suspend() to close these windows and again invoked

[PATCH v4 2/3] powerpc/pseries/vas: Modify reconfig open/close functions for migration

2022-02-27 Thread Haren Myneni
VAS is a hardware engine stays on the chip. So when the partition migrates, all VAS windows on the source system have to be closed and reopen them on the destination after migration. The kernel has to consider both DLPAR CPU and migration events to take action on VAS windows. So using

[PATCH v4 1/3] powerpc/pseries/vas: Define global hv_cop_caps struct

2022-02-27 Thread Haren Myneni
The coprocessor capabilities struct is used to get default and QoS capabilities from the hypervisor during init, DLPAR event and migration. So instead of allocating this struct for each event, define global struct and reuse it which allows the migration code to avoid adding an error path. Also

[PATCH v5 7/9] powerpc/pseries/vas: Reopen windows with DLPAR core add

2022-02-27 Thread Haren Myneni
VAS windows can be closed in the hypervisor due to lost credits when the core is removed and the kernel gets fault for NX requests on these inactive windows. If the NX requests are issued on these inactive windows, OS gets page faults and the paste failure will be returned to the user space. If

[PATCH v4 0/3] powerpc/pseries/vas: VAS/NXGZIP support with LPM

2022-02-27 Thread Haren Myneni
Virtual Accelerator Switchboard (VAS) is an engine stays on the chip. So all windows opened on a specific engine belongs to VAS the chip. The hypervisor expects the partition to close all active windows on the sources system and reopen them after migration on the destination machine. This patch

[PATCH v5 9/9] powerpc/pseries/vas: Add 'update_total_credits' entry for QoS capabilities

2022-02-27 Thread Haren Myneni
pseries supports two types of credits - Default (uses normal priority FIFO) and Qality of service (QoS uses high priority FIFO). The user decides the number of QoS credits and sets this value with HMC interface. The total credits for QoS capabilities can be changed dynamically with HMC interface

[PATCH v5 8/9] powerpc/pseries/vas: sysfs interface to export capabilities

2022-02-27 Thread Haren Myneni
The hypervisor provides the available VAS GZIP capabilities such as default or QoS window type and the target available credits in each type. This patch creates sysfs entries and exports the target, used and the available credits for each feature. This interface can be used by the user space to

[PATCH v5 6/9] powerpc/pseries/vas: Close windows with DLPAR core removal

2022-02-27 Thread Haren Myneni
The hypervisor assigns vas credits (windows) for each LPAR based on the number of cores configured in that system. The OS is expected to release credits when cores are removed, and may allocate more when cores are added. So there is a possibility of using excessive credits (windows) in the LPAR

[PATCH v5 5/9] powerpc/vas: Map paste address only if window is active

2022-02-27 Thread Haren Myneni
The paste address mapping is done with mmap() after the window is opened with ioctl. The partition has to close VAS windows in the hypervisor if it lost credits due to DLPAR core removal. But the kernel marks these windows inactive until the previously lost credits are available later. If the

[PATCH v5 4/9] powerpc/vas: Return paste instruction failure if no active window

2022-02-27 Thread Haren Myneni
The VAS window may not be active if the system looses credits and the NX generates page fault when it receives request on unmap paste address. The kernel handles the fault by remap new paste address if the window is active again, Otherwise return the paste instruction failure if the executed

[PATCH v5 3/9] powerpc/vas: Add paste address mmap fault handler

2022-02-27 Thread Haren Myneni
The user space opens VAS windows and issues NX requests by pasting CRB on the corresponding paste address mmap. When the system lost credits due to core removal, the kernel has to close the window in the hypervisor and make the window inactive by unmapping this paste address. Also the OS has to

[PATCH v5 2/9] powerpc/pseries/vas: Save PID in pseries_vas_window struct

2022-02-27 Thread Haren Myneni
The kernel sets the VAS window with PID when it is opened in the hypervisor. During DLPAR operation, windows can be closed and reopened in the hypervisor when the credit is available. So saves this PID in pseries_vas_window struct when the window is opened initially and reuse it later during

[PATCH v5 1/9] powerpc/pseries/vas: Use common names in VAS capability structure

2022-02-27 Thread Haren Myneni
nr_total/nr_used_credits provides credits usage to user space via sysfs and the same interface can be used on PowerNV in future. Changed with proper naming so that applicable on both pseries and PowerNV. Signed-off-by: Haren Myneni Reviewed-by: Nicholas Piggin ---

[PATCH v5 0/9] powerpc/pseries/vas: NXGZIP support with DLPAR

2022-02-27 Thread Haren Myneni
PowerPC provides HW compression with NX coprocessor. This feature is available on both PowerNV and PowerVM and included in Linux. Since each powerpc chip has one NX coprocessor, the VAS introduces the concept of windows / credits to manage access to this hardware resource. On powerVM, these

RE: [PATCH V7 03/20] compat: consolidate the compat_flock{,64} definition

2022-02-27 Thread David Laight
From: guo...@kernel.org > Sent: 27 February 2022 16:28 > > From: Christoph Hellwig > > Provide a single common definition for the compat_flock and > compat_flock64 structures using the same tricks as for the native > variants. Another extra define is added for the packing required on > x86.

Question about update_persistent_clock() routine

2022-02-27 Thread Jimmie Mayfield
Hi, I'm investigating a timekeeping problem on an old PPC-based embedded device and am curious about the update_persistent_clock() routine.   This device runs a 3.10-era kernel but a similar (deprecated) function exists in the 5.16 kernels so I'll refer to the latter: In

RE: [PATCH 08/11] swiotlb: make the swiotlb_init interface more useful

2022-02-27 Thread Michael Kelley (LINUX)
From: Christoph Hellwig Sent: Sunday, February 27, 2022 6:31 AM > > Pass a bool to pass if swiotlb needs to be enabled based on the > addressing needs and replace the verbose argument with a set of > flags, including one to force enable bounce buffering. > > Note that this patch removes the

Re: [PATCH] powerpc: Avoid nmi_enter/nmi_exit in real mode interrupt.

2022-02-27 Thread Christophe Leroy
Le 25/02/2022 à 11:24, Mahesh Salgaonkar a écrit : > nmi_enter()/nmi_exit() touches per cpu variables which can lead to kernel > crash when invoked during real mode interrupt handling (e.g. early HMI/MCE > interrupt handler) if percpu allocation comes from vmalloc area. > > Early HMI/MCE

Re: [PATCH 08/11] swiotlb: make the swiotlb_init interface more useful

2022-02-27 Thread Christophe Leroy
Le 27/02/2022 à 15:30, Christoph Hellwig a écrit : > Pass a bool to pass if swiotlb needs to be enabled based on the > addressing needs and replace the verbose argument with a set of > flags, including one to force enable bounce buffering. > > Note that this patch removes the possibility to

[PATCH V7 20/20] riscv: compat: Add COMPAT Kbuild skeletal support

2022-02-27 Thread guoren
From: Guo Ren Adds initial skeletal COMPAT Kbuild (Running 32bit U-mode on 64bit S-mode) support. - Setup kconfig & dummy functions for compiling. - Implement compat_start_thread by the way. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann Cc: Palmer Dabbelt ---

[PATCH V7 19/20] riscv: compat: ptrace: Add compat_arch_ptrace implement

2022-02-27 Thread guoren
From: Guo Ren Now, you can use native gdb on riscv64 for rv32 app debugging. $ uname -a Linux buildroot 5.16.0-rc4-00036-gbef6b82fdf23-dirty #53 SMP Mon Dec 20 23:06:53 CST 2021 riscv64 GNU/Linux $ cat /proc/cpuinfo processor : 0 hart: 0 isa : rv64imafdcsuh mmu

[PATCH V7 18/20] riscv: compat: signal: Add rt_frame implementation

2022-02-27 Thread guoren
From: Guo Ren Implement compat_setup_rt_frame for sigcontext save & restore. The main process is the same with signal, but the rv32 pt_regs' size is different from rv64's, so we needs convert them. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Palmer Dabbelt Cc: Arnd Bergmann

[PATCH V7 17/20] riscv: compat: vdso: Add setup additional pages implementation

2022-02-27 Thread guoren
From: Guo Ren Reconstruct __setup_additional_pages() by appending vdso info pointer argument to meet compat_vdso_info requirement. And change vm_special_mapping *dm, *cm initialization into static. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Palmer Dabbelt Cc: Arnd Bergmann

[PATCH V7 16/20] riscv: compat: vdso: Add COMPAT_VDSO base code implementation

2022-02-27 Thread guoren
From: Guo Ren There is no vgettimeofday supported in rv32 that makes simple to generate rv32 vdso code which only needs riscv64 compiler. Other architectures need change compiler or -m (machine parameter) to support vdso32 compiling. If rv32 support vgettimeofday (which cause C compile) in

[PATCH V7 15/20] riscv: compat: Add hw capability check for elf

2022-02-27 Thread guoren
From: Guo Ren Detect hardware COMPAT (32bit U-mode) capability in rv64. If not support COMPAT mode in hw, compat_elf_check_arch would return false by compat_binfmt_elf.c Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann Cc: Christoph Hellwig --- arch/riscv/include/asm/elf.h |

[PATCH V7 14/20] riscv: compat: Add elf.h implementation

2022-02-27 Thread guoren
From: Guo Ren Implement necessary type and macro for compat elf. See the code comment for detail. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann --- arch/riscv/include/asm/elf.h | 46 +++- 1 file changed, 45 insertions(+), 1

[PATCH V7 13/20] riscv: compat: process: Add UXL_32 support in start_thread

2022-02-27 Thread guoren
From: Guo Ren If the current task is in COMPAT mode, set SR_UXL_32 in status for returning userspace. We need CONFIG _COMPAT to prevent compiling errors with rv32 defconfig. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann Cc: Palmer Dabbelt --- arch/riscv/kernel/process.c |

[PATCH V7 12/20] riscv: compat: syscall: Add entry.S implementation

2022-02-27 Thread guoren
From: Guo Ren Implement the entry of compat_sys_call_table[] in asm. Ref to riscv-privileged spec 4.1.1 Supervisor Status Register (sstatus): BIT[32:33] = UXL[1:0]: - 1:32 - 2:64 - 3:128 Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Palmer Dabbelt Cc: Arnd Bergmann ---

[PATCH V7 11/20] riscv: compat: syscall: Add compat_sys_call_table implementation

2022-02-27 Thread guoren
From: Guo Ren Implement compat sys_call_table and some system call functions: truncate64, ftruncate64, fallocate, pread64, pwrite64, sync_file_range, readahead, fadvise64_64 which need argument translation. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann Cc: Palmer

[PATCH V7 10/20] riscv: compat: Re-implement TASK_SIZE for COMPAT_32BIT

2022-02-27 Thread guoren
From: Guo Ren Make TASK_SIZE from const to dynamic detect TIF_32BIT flag function. Refer to arm64 to implement DEFAULT_MAP_WINDOW_64 for efi-stub. Limit 32-bit compatible process in 0-2GB virtual address range (which is enough for real scenarios), because it could avoid address sign extend

[PATCH V7 09/20] riscv: compat: Add basic compat data type implementation

2022-02-27 Thread guoren
From: Guo Ren Implement riscv asm/compat.h for struct compat_xxx, is_compat_task, compat_user_regset, regset convert. The rv64 compat.h has inherited most of the structs from the generic one. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Cc: Arnd Bergmann Cc: Palmer Dabbelt ---

[PATCH V7 08/20] riscv: Fixup difference with defconfig

2022-02-27 Thread guoren
From: Guo Ren Let's follow the origin patch's spirit: The only difference between rv32_defconfig and defconfig is that rv32_defconfig has CONFIG_ARCH_RV32I=y. This is helpful to compare rv64-compat-rv32 v.s. rv32-linux. Fixes: 1b937e8faa87ccfb ("RISC-V: Add separate defconfig for 32bit

[PATCH V7 07/20] syscalls: compat: Fix the missing part for __SYSCALL_COMPAT

2022-02-27 Thread guoren
From: Guo Ren Make "uapi asm unistd.h" could be used for architectures' COMPAT mode. The __SYSCALL_COMPAT is first used in riscv. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann Reviewed-by: Christoph Hellwig --- include/uapi/asm-generic/unistd.h | 4 ++--

[PATCH V7 06/20] asm-generic: compat: Cleanup duplicate definitions

2022-02-27 Thread guoren
From: Guo Ren There are 7 64bit architectures that support Linux COMPAT mode to run 32bit applications. A lot of definitions are duplicate: - COMPAT_USER_HZ - COMPAT_RLIM_INFINITY - COMPAT_OFF_T_MAX - __compat_uid_t, __compat_uid_t - compat_dev_t - compat_ipc_pid_t - struct compat_flock

[PATCH V7 05/20] fs: stat: compat: Add __ARCH_WANT_COMPAT_STAT

2022-02-27 Thread guoren
From: Guo Ren RISC-V doesn't neeed compat_stat, so using __ARCH_WANT_COMPAT_STAT to exclude unnecessary SYSCALL functions. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Reviewed-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Cc: Palmer Dabbelt --- arch/arm64/include/asm/unistd.h | 1 +

[PATCH V7 04/20] kconfig: Add SYSVIPC_COMPAT for all architectures

2022-02-27 Thread guoren
From: Guo Ren The existing per-arch definitions are pretty much historic cruft. Move SYSVIPC_COMPAT into init/Kconfig. Signed-off-by: Guo Ren Signed-off-by: Guo Ren Acked-by: Arnd Bergmann Reviewed-by: Christoph Hellwig Cc: Palmer Dabbelt --- arch/arm64/Kconfig | 4

[PATCH V7 03/20] compat: consolidate the compat_flock{, 64} definition

2022-02-27 Thread guoren
From: Christoph Hellwig Provide a single common definition for the compat_flock and compat_flock64 structures using the same tricks as for the native variants. Another extra define is added for the packing required on x86. Signed-off-by: Christoph Hellwig Signed-off-by: Guo Ren Reviewed-by:

[PATCH V7 02/20] uapi: always define F_GETLK64/F_SETLK64/F_SETLKW64 in fcntl.h

2022-02-27 Thread guoren
From: Christoph Hellwig The F_GETLK64/F_SETLK64/F_SETLKW64 fcntl opcodes are only implemented for the 32-bit syscall APIs, but are also needed for compat handling on 64-bit kernels. Consolidate them in unistd.h instead of definining the internal compat definitions in compat.h, which is rather

[PATCH V7 01/20] uapi: simplify __ARCH_FLOCK{,64}_PAD a little

2022-02-27 Thread guoren
From: Christoph Hellwig Don't bother to define the symbols empty, just don't use them. That makes the intent a little more clear. Remove the unused HAVE_ARCH_STRUCT_FLOCK64 define and merge the 32-bit mips struct flock into the generic one. Add a new __ARCH_FLOCK_EXTRA_SYSID macro following

[PATCH V7 00/20] riscv: compat: Add COMPAT mode support for rv64

2022-02-27 Thread guoren
From: Guo Ren Currently, most 64-bit architectures (x86, parisc, powerpc, arm64, s390, mips, sparc) have supported COMPAT mode. But they all have history issues and can't use standard linux unistd.h. RISC-V would be first standard __SYSCALL_COMPAT user of include/uapi/asm-generic /unistd.h. The

[PATCH 01/11] dma-direct: use is_swiotlb_active in dma_direct_map_page

2022-02-27 Thread Christoph Hellwig
Use the more specific is_swiotlb_active check instead of checking the global swiotlb_force variable. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- kernel/dma/direct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/direct.h

[PATCH 11/11] x86: remove cruft from

2022-02-27 Thread Christoph Hellwig
gets pulled in by all drivers using the DMA API. Remove x86 internal variables and unnecessary includes from it. Signed-off-by: Christoph Hellwig --- arch/x86/include/asm/dma-mapping.h | 11 --- arch/x86/include/asm/iommu.h | 2 ++ 2 files changed, 2 insertions(+), 11

[PATCH 10/11] swiotlb: merge swiotlb-xen initialization into swiotlb

2022-02-27 Thread Christoph Hellwig
Allow to pass a remap argument to the swiotlb initialization functions to handle the Xen/x86 remap case. ARM/ARM64 never did any remapping from xen_swiotlb_fixup, so we don't even need that quirk. Signed-off-by: Christoph Hellwig --- arch/arm/xen/mm.c | 23 +++---

[PATCH 08/11] swiotlb: make the swiotlb_init interface more useful

2022-02-27 Thread Christoph Hellwig
Pass a bool to pass if swiotlb needs to be enabled based on the addressing needs and replace the verbose argument with a set of flags, including one to force enable bounce buffering. Note that this patch removes the possibility to force xen-swiotlb use using swiotlb=force on the command line on

[PATCH 09/11] swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction

2022-02-27 Thread Christoph Hellwig
Power SVM wants to allocate a swiotlb buffer that is not restricted to low memory for the trusted hypervisor scheme. Consolidate the support for this into the swiotlb_init interface by adding a new flag. Signed-off-by: Christoph Hellwig --- arch/powerpc/include/asm/svm.h | 4

[PATCH 07/11] x86: remove the IOMMU table infrastructure

2022-02-27 Thread Christoph Hellwig
The IOMMU table tries to separate the different IOMMUs into different backends, but actually requires various cross calls. Rewrite the code to do the generic swiotlb/swiotlb-xen setup directly in pci-dma.c and then just call into the IOMMU drivers. Signed-off-by: Christoph Hellwig ---

[PATCH 06/11] MIPS/octeon: use swiotlb_init instead of open coding it

2022-02-27 Thread Christoph Hellwig
Use the generic swiotlb initialization helper instead of open coding it. Signed-off-by: Christoph Hellwig --- arch/mips/cavium-octeon/dma-octeon.c | 15 ++- arch/mips/pci/pci-octeon.c | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git

[PATCH 05/11] swiotlb: pass a gfp_mask argument to swiotlb_init_late

2022-02-27 Thread Christoph Hellwig
Let the caller chose a zone to allocate from. This will be used later on by the xen-swiotlb initialization on arm. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- arch/x86/pci/sta2x11-fixup.c | 2 +- include/linux/swiotlb.h | 2 +- kernel/dma/swiotlb.c | 4

[PATCH 03/11] swiotlb: simplify swiotlb_max_segment

2022-02-27 Thread Christoph Hellwig
Remove the bogus Xen override that was usually larger than the actual size and just calculate the value on demand. Note that swiotlb_max_segment still doesn't make sense as an interface and should eventually be removed. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual ---

[PATCH 04/11] swiotlb: rename swiotlb_late_init_with_default_size

2022-02-27 Thread Christoph Hellwig
swiotlb_late_init_with_default_size is an overly verbose name that doesn't even catch what the function is doing, given that the size is not just a default but the actual requested size. Rename it to swiotlb_init_late. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual ---

cleanup swiotlb initialization v2

2022-02-27 Thread Christoph Hellwig
Hi all, this series tries to clean up the swiotlb initialization, including that of swiotlb-xen. To get there is also removes the x86 iommu table infrastructure that massively obsfucates the initialization path. Git tree: git://git.infradead.org/users/hch/misc.git swiotlb-init-cleanup

[PATCH 02/11] swiotlb: make swiotlb_exit a no-op if SWIOTLB_FORCE is set

2022-02-27 Thread Christoph Hellwig
If force bouncing is enabled we can't release the buffers. Signed-off-by: Christoph Hellwig Reviewed-by: Anshuman Khandual --- kernel/dma/swiotlb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index f1e7ea160b433..36fbf1181d285 100644 ---