[RFC PATCH v3 1/2] mm: restrictedmem: Allow userspace to specify mount for memfd_restricted

2023-03-31 Thread Ackerley Tng
By default, the backing shmem file for a restrictedmem fd is created on shmem's kernel space mount. With this patch, an optional tmpfs mount can be specified via an fd, which will be used as the mountpoint for backing the shmem file associated with a restrictedmem fd. This will help restrictedmem

[RFC PATCH v3 0/2] Providing mount in memfd_restricted() syscall

2023-03-31 Thread Ackerley Tng
Hello, This patchset builds upon the memfd_restricted() system call that was discussed in the ‘KVM: mm: fd-based approach for supporting KVM’ patch series, at https://lore.kernel.org/lkml/20221202061347.1070246-1-chao.p.p...@linux.intel.com/T/ The tree can be found at: https://github.com/googlepr

[RFC PATCH v3 2/2] selftests: restrictedmem: Check hugepage-ness of shmem file backing restrictedmem fd

2023-03-31 Thread Ackerley Tng
For memfd_restricted() calls without a userspace mount, the backing file should be the shmem mount in the kernel, and the size of backing pages should be as defined by system-wide shmem configuration. If a userspace mount is provided, the size of backing pages should be as defined in the mount. A

Re: [RFC PATCH v2 1/2] mm: restrictedmem: Allow userspace to specify mount for memfd_restricted

2023-03-31 Thread Ackerley Tng
Christian Brauner writes: On Tue, Mar 21, 2023 at 08:15:32PM +, Ackerley Tng wrote: By default, the backing shmem file for a restrictedmem fd is created on shmem's kernel space mount. ... Thanks for reviewing this patch! This looks like you can just pass in some tmpfs fd and you ju

Re: [PATCH v4 3/8] target/riscv: Fix target address to update badaddr

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: Compute the target address before storing it into badaddr when mis-aligned exception is triggered. Use a target_pc temp to store the target address to avoid the confusing operation that udpate target address into cpu_pc before misalign check, then update it int

Re: [PATCH v4 4/8] target/riscv: Add support for PC-relative translation

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: Add a base save_pc For PC-relative translation(CF_PCREL). Diable the directly sync pc from tb by riscv_cpu_synchronize_from_tb. Sync pc before it's used or updated from tb related pc: real_pc = (old)env->pc + target_pc(from tb) - ctx->save_pc Signed-off-by:

Re: [PATCH v4 5/8] accel/tcg: Fix overwrite problems of tcg_cflags

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: CPUs often set CF_PCREL in tcg_cflags before qemu_init_vcpu(), in which tcg_cflags will be overwrited by tcg_cpu_init_cflags(). Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang --- accel/tcg/tcg-accel-ops.c | 2 +- 1 file changed, 1 insertion(+), 1 dele

Re: [PATCH v4 6/8] accel/tcg: Fix tb mis-matched problem when CF_PCREL is enabled

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: A corner case is triggered when tb block with first_pc = 0x8008 and first_pc = 0x80200 has the same jump cache hash, and share the same tb entry with the same tb information except PC. The executed sequence is as follows: tb(0x8008) -> tb(0x8008

Re: [PATCH v4 5/8] accel/tcg: Fix overwrite problems of tcg_cflags

2023-03-31 Thread Richard Henderson
On 3/31/23 18:18, Richard Henderson wrote: On 3/31/23 08:06, Weiwei Li wrote: CPUs often set CF_PCREL in tcg_cflags before qemu_init_vcpu(), in which tcg_cflags will be overwrited by tcg_cpu_init_cflags(). Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang ---   accel/tcg/tcg-accel-ops.c | 2

Re: [PATCH v4 5/8] accel/tcg: Fix overwrite problems of tcg_cflags

2023-03-31 Thread Richard Henderson
On 3/31/23 18:33, Richard Henderson wrote: On 3/31/23 18:18, Richard Henderson wrote: On 3/31/23 08:06, Weiwei Li wrote: CPUs often set CF_PCREL in tcg_cflags before qemu_init_vcpu(), in which tcg_cflags will be overwrited by tcg_cpu_init_cflags(). Signed-off-by: Weiwei Li Signed-off-by: Junqi

Re: [PATCH v4 6/8] accel/tcg: Fix tb mis-matched problem when CF_PCREL is enabled

2023-03-31 Thread Richard Henderson
On 3/31/23 18:26, Richard Henderson wrote: On 3/31/23 08:06, Weiwei Li wrote: A corner case is triggered  when tb block with first_pc = 0x8008 and first_pc = 0x80200 has the same jump cache hash, and share the same tb entry with the same tb information except PC. The executed sequence is

Re: [PATCH v4 7/8] target/riscv: Enable PC-relative translation in system mode

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: The existence of CF_PCREL can improve performance with the guest kernel's address space randomization. Each guest process maps libc.so (et al) at a different virtual address, and this allows those translations to be shared. Signed-off-by: Weiwei Li Signed-off-

Re: [PATCH v4 8/8] target/riscv: Add pointer mask support for instruction fetch

2023-03-31 Thread Richard Henderson
On 3/31/23 08:06, Weiwei Li wrote: Transform the fetch address in cpu_get_tb_cpu_state() when pointer mask for instruction is enabled. Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang --- target/riscv/cpu.h| 1 + target/riscv/cpu_helper.c | 20 +++- target/riscv

Re: On integrating LoongArch EDK2 firmware into QEMU build process

2023-03-31 Thread gaosong
在 2023/3/31 下午8:12, Gerd Hoffmann 写道: On Fri, Mar 31, 2023 at 08:54:16AM +0800, maobibo wrote: Xuerui, Thanks for your mail, it is a good suggestion. Now we are planing to move LoongArch uefi bios from edk2-platform to edk2 repo, so that uefi bios supporting LoongArch can be auto compiled and

[PATCH 1/3] Revert "linux-user/arm: Take more care allocating commpage"

2023-03-31 Thread Richard Henderson
This reverts commit 4f5c67f8df7f26e559509c68c45e652709edd23f. This exposes bugs in target_mmap et al with respect to overflow with the final page of the guest address space. To be fixed in the next development cycle. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 37 ++

[PATCH for-8.0 0/3] last minute tcg fixes

2023-03-31 Thread Richard Henderson
Fix a bug just exposed concerning qemu-arm commpage, leading to an immediate crash on any 64k page host. Fix two bugs regressing pc-relative tb generation, found by Weiwei Li. r~ Richard Henderson (2): Revert "linux-user/arm: Take more care allocating commpage" accel/tcg: Fix jump cache se

[PATCH 3/3] accel/tcg: Fix jump cache set in cpu_exec_loop

2023-03-31 Thread Richard Henderson
Assign pc and use store_release to assign tb. Fixes: 2dd5b7a1b91 ("accel/tcg: Move jmp-cache `CF_PCREL` checks to caller") Reported-by: Weiwei Li Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/acce

[PATCH 2/3] accel/tcg: Fix overwrite problems of tcg_cflags

2023-03-31 Thread Richard Henderson
From: Weiwei Li CPUs often set CF_PCREL in tcg_cflags before qemu_init_vcpu(), in which tcg_cflags will be overwrited by tcg_cpu_init_cflags(). Fixes: 4be790263ffc ("accel/tcg: Replace `TARGET_TB_PCREL` with `CF_PCREL`") Reviewed-by: Richard Henderson Signed-off-by: Weiwei Li Signed-off-by: Ju

Re: [RFC PATCH v2 18/44] target/loongarch: Implement vsat

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: +static void gen_vsat_s(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm) +{ +TCGv_vec t1; +int64_t max = (1l << imm) - 1; This needed 1ull, but better to just use max = MAKE_64BIT_MASK(0, imm - 1); +int64_t min = ~max; Extra space. +

Re: [RFC PATCH v2 19/44] target/loongarch: Implement vexth

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: This patch includes: - VEXTH.{H.B/W.H/D.W/Q.D}; - VEXTH.{HU.BU/WU.HU/DU.WU/QU.DU}. Signed-off-by: Song Gao --- target/loongarch/disas.c| 9 ++ target/loongarch/helper.h | 9 ++ target/loongarch/insn_trans/trans

Re: [RFC PATCH v2 20/44] target/loongarch: Implement vsigncov

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: +static void gen_vsigncov(unsigned vece, TCGv_vec t, TCGv_vec a, TCGv_vec b) +{ +TCGv_vec t1, t2; + +t1 = tcg_temp_new_vec_matching(t); +t2 = tcg_temp_new_vec_matching(t); + +tcg_gen_neg_vec(vece, t1, b); +tcg_gen_dupi_vec(vece, t2, 0); tcg_

Re: On integrating LoongArch EDK2 firmware into QEMU build process

2023-03-31 Thread maobibo
On 2023/3/31 20:12, Gerd Hoffmann wrote: On Fri, Mar 31, 2023 at 08:54:16AM +0800, maobibo wrote: Xuerui, Thanks for your mail, it is a good suggestion. Now we are planing to move LoongArch uefi bios from edk2-platform to edk2 repo, so that uefi bios supporting LoongArch can be auto compiled

Re: [RFC PATCH v2 21/44] target/loongarch: Implement vmskltz/vmskgez/vmsknz

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: +void HELPER(vmskltz_b)(CPULoongArchState *env, uint32_t vd, uint32_t vj) +{ +VReg temp; +VReg *Vd = &(env->fpr[vd].vreg); +VReg *Vj = &(env->fpr[vj].vreg); + +temp.D(0) = 0; +temp.D(1) = 0; +temp.H(0) = do_vmskltz_b(Vj->D(0)); +temp.H

Re: [RFC PATCH v2 22/44] target/loongarch: Implement LSX logic instructions

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: +static void gen_vnori(unsigned vece, TCGv_vec t, TCGv_vec a, int64_t imm) +{ +TCGv_vec t1; + +t1 = tcg_temp_new_vec_matching(t); +tcg_gen_dupi_vec(vece, t1, imm); +tcg_gen_nor_vec(vece, t, a, t1); +} tcg_constant_vec_matching. + +static void

Re: [RFC PATCH v2 23/44] target/loongarch: Implement vsll vsrl vsra vrotr

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: This patch includes: - VSLL[I].{B/H/W/D}; - VSRL[I].{B/H/W/D}; - VSRA[I].{B/H/W/D}; - VROTR[I].{B/H/W/D}. Signed-off-by: Song Gao --- target/loongarch/disas.c| 36 + target/loongarch/insn_trans/trans_lsx.c.inc | 36

Re: [RFC PATCH v2 24/44] target/loongarch: Implement vsllwil vextl

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: This patch includes: - VSLLWIL.{H.B/W.H/D.W}; - VSLLWIL.{HU.BU/WU.HU/DU.WU}; - VEXTL.Q.D, VEXTL.QU.DU. Signed-off-by: Song Gao --- target/loongarch/disas.c| 9 + target/loongarch/helper.h | 9 + target/loongarc

Re: [RFC PATCH v2 25/44] target/loongarch: Implement vsrlr vsrar

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: This patch includes: - VSRLR[I].{B/H/W/D}; - VSRAR[I].{B/H/W/D}. Signed-off-by: Song Gao --- target/loongarch/disas.c| 18 target/loongarch/helper.h | 18 target/loongarch/insn_trans/trans_lsx.c.inc | 18 +++

Re: [RFC PATCH v2 26/44] target/loongarch: Implement vsrln vsran

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: This patch includes: - VSRLN.{B.H/H.W/W.D}; - VSRAN.{B.H/H.W/W.D}; - VSRLNI.{B.H/H.W/W.D/D.Q}; - VSRANI.{B.H/H.W/W.D/D.Q}. Signed-off-by: Song Gao --- target/loongarch/disas.c| 16 +++ target/loongarch/helper.h | 16 ++

Re: [RFC PATCH v2 27/44] target/loongarch: Implement vsrlrn vsrarn

2023-03-31 Thread Richard Henderson
On 3/27/23 20:06, Song Gao wrote: +temp.D(1) = int128_getlo(Vd->D(0)); Typo here. You should build i386 host. E.g. make docker-test-build@fedora-i386-cross r~

<    1   2