[PATCH v3 0/2] Enhance maximum priority support of PLIC

2022-10-02 Thread Jim Shu
This patchset fixes hard-coded maximum priority of interrupt priority register and also changes this register to WARL field to align the PLIC spec. Changelog: v3: * fix opposite of power-of-2 max priority checking expression. v2: * change interrupt priority register to WARL field. Jim Shu

[PATCH v3 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-10-02 Thread Jim Shu
PLIC spec [1] requires interrupt source priority registers are WARL field and the number of supported priority is power-of-2 to simplify SW discovery. Existing QEMU RISC-V machine (e.g. shakti_c) don't strictly follow PLIC spec, whose number of supported priority is not power-of-2. Just change

[PATCH v3 1/2] hw/intc: sifive_plic: fix hard-coded max priority level

2022-10-02 Thread Jim Shu
The maximum priority level is hard-coded when writing to interrupt priority register. However, when writing to priority threshold register, the maximum priority level is from num_priorities Property which is configured by platform. Also change interrupt priority register to use num_priorities

Re: [PATCH v2 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-10-02 Thread Jim Shu
Hi Clément, > > > @@ -180,7 +180,15 @@ static void sifive_plic_write(void *opaque, hwaddr > > > addr, uint64_t value, > > > if (addr_between(addr, plic->priority_base, plic->num_sources << 2)) > > > { > > > uint32_t irq = ((addr - plic->priority_base) >> 2) + 1; > > > > > > -

[RFC 7/7] migration: call qemu_savevm_state_pending_exact() with the guest stopped

2022-10-02 Thread Juan Quintela
HACK ahead. There are devices that require the guest to be stopped to tell us what is the size of its state. So we need to stop the vm "before" we cal the functions. It is a hack because: - we are "starting" the guest again to stop it in migration_complete() I know, I know, but it is not

[RFC 6/7] migration: simplify migration_iteration_run()

2022-10-02 Thread Juan Quintela
Signed-off-by: Juan Quintela --- migration/migration.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 97fefd579e..35e512887a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@

[RFC 2/7] migration: No save_live_pending() method uses the QEMUFile parameter

2022-10-02 Thread Juan Quintela
So remove it everywhere. Signed-off-by: Juan Quintela --- include/migration/register.h | 6 ++ migration/savevm.h | 2 +- hw/s390x/s390-stattrib.c | 2 +- hw/vfio/migration.c| 6 ++ migration/block-dirty-bitmap.c | 5 ++--- migration/block.c

[RFC 4/7] migration: Split save_live_pending() into state_pending_*

2022-10-02 Thread Juan Quintela
We split the function into to: - state_pending_estimate: We estimate the remaining state size without stopping the machine. - state pending_exact: We calculate the exact amount of remaining state. The only "device" that implements different functions for _estimate() and _exact() is ram.

[RFC 3/7] migration: Block migration comment or code is wrong

2022-10-02 Thread Juan Quintela
And it appears that what is wrong is the code. During bulk stage we need to make sure that some block is dirty, but no games with max_size at all. Signed-off-by: Juan Quintela --- migration/block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c

[RFC 5/7] migration: Remove unused threshold_size parameter

2022-10-02 Thread Juan Quintela
Until previous commit, save_live_pending() was used for ram. Now with the split into state_pending_estimate() and state_pending_exact() it is not needed anymore, so remove them. Signed-off-by: Juan Quintela --- include/migration/register.h | 7 +++ migration/savevm.h | 6

[RFC 1/7] migration: Remove res_compatible parameter

2022-10-02 Thread Juan Quintela
It was only used for RAM, and in that case, it means that this amount of data was sent for memory. Just delete the field in all callers. Signed-off-by: Juan Quintela --- include/migration/register.h | 20 ++-- migration/savevm.h | 4 +--- hw/s390x/s390-stattrib.c

[RFC 0/7] migration patches for VFIO

2022-10-02 Thread Juan Quintela
Hi VFIO migration has several requirements: - the size of the state is only known when the guest is stopped - they need to send possible lots of data. this series only address the 1st set of problems. What they do: - res_compatible parameter was not used anywhere, just add that information to

Re: [PATCH v1 1/7] contrib/gitdm: add Simon to individual contributors

2022-10-02 Thread Simon Safar
Hi Alex, On Mon, Sep 26, 2022, at 6:46 AM, Alex Bennée wrote: > Please confirm this is the correct mapping for you. it's the correct mapping, thanks for adding it! (... & sorry for the multi-day latency!) Reviewed-by: Simon Safar > > Signed-off-by: Alex Bennée > Cc: Simon Safar > --- >

Re: [PATCH v3 1/3] util/main-loop: Fix maximum number of wait objects for win32

2022-10-02 Thread Bin Meng
Hi Paolo, On Sun, Sep 25, 2022 at 9:07 AM Bin Meng wrote: > > Hi Paolo, > > On Tue, Sep 13, 2022 at 5:52 PM Marc-André Lureau > wrote: > > > > Hi > > > > On Wed, Aug 24, 2022 at 12:52 PM Bin Meng wrote: > >> > >> From: Bin Meng > >> > >> The maximum number of wait objects for win32 should be

Re: [PATCH] RISC-V: Add support for Ztso

2022-10-02 Thread Palmer Dabbelt
On Thu, 29 Sep 2022 12:16:48 PDT (-0700), dgilb...@redhat.com wrote: * Palmer Dabbelt (pal...@rivosinc.com) wrote: Ztso, the RISC-V extension that provides the TSO memory model, was recently frozen. This provides support for Ztso on targets that are themselves TSO. Signed-off-by: Palmer

[PATCH v2 9/9] target/i386: Use probe_access_full for final stage2 translation

2022-10-02 Thread Richard Henderson
Rather than recurse directly on mmu_translate, go through the same softmmu lookup that we did for the page table walk. This centralizes all knowledge of MMU_NESTED_IDX, with respect to setup of TranslationParams, to get_physical_address. Signed-off-by: Richard Henderson ---

[PATCH v2 8/9] target/i386: Use atomic operations for pte updates

2022-10-02 Thread Richard Henderson
Use probe_access_full in order to resolve to a host address, which then lets us use a host cmpxchg to update the pte. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/279 Signed-off-by: Richard Henderson --- target/i386/tcg/sysemu/excp_helper.c | 242 +++ 1 file

[PATCH v2 4/9] target/i386: Reorg GET_HPHYS

2022-10-02 Thread Richard Henderson
Replace with PTE_HPHYS for the page table walk, and a direct call to mmu_translate for the final stage2 translation. Hoist the check for HF2_NPT_MASK out to get_physical_address, which avoids the recursive call when stage2 is disabled. We can now return all the way out to x86_cpu_tlb_fill before

[PATCH v2 2/9] target/i386: Direct call get_hphys from mmu_translate

2022-10-02 Thread Richard Henderson
Use a boolean to control the call to get_hphys instead of passing a null function pointer. Signed-off-by: Richard Henderson --- target/i386/tcg/sysemu/excp_helper.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/target/i386/tcg/sysemu/excp_helper.c

[PATCH v2 5/9] target/i386: Add MMU_PHYS_IDX and MMU_NESTED_IDX

2022-10-02 Thread Richard Henderson
These new mmu indexes will be helpful for improving paging and code throughout the target. Signed-off-by: Richard Henderson --- target/i386/cpu-param.h | 2 +- target/i386/cpu.h| 3 + target/i386/tcg/sysemu/excp_helper.c | 82 ++--

[PATCH v2 3/9] target/i386: Introduce structures for mmu_translate

2022-10-02 Thread Richard Henderson
Create TranslateParams for inputs, TranslateResults for successful outputs, and TranslateFault for error outputs; return true on success. Move stage1 error paths from handle_mmu_fault to x86_cpu_tlb_fill; reorg the rest of handle_mmu_fault into get_physical_address. Signed-off-by: Richard

[PATCH v2 0/9] target/i386: Use atomic operations for pte updates

2022-10-02 Thread Richard Henderson
Use atomic operations for pte updates, which is a long-standing bug since our conversion to MTTCG. Modulo rebase, this has one change from v1, which is the new patch 9. r~ Based-on: 20220930212622.108363-1-richard.hender...@linaro.org ("[PATCH v6 00/18] tcg: CPUTLBEntryFull and

[PATCH v2 6/9] target/i386: Use MMU_NESTED_IDX for vmload/vmsave

2022-10-02 Thread Richard Henderson
Use MMU_NESTED_IDX for each memory access, rather than just a single translation to physical. Adjust svm_save_seg and svm_load_seg to pass in mmu_idx. This removes the last use of get_hphys so remove it. Signed-off-by: Richard Henderson --- target/i386/cpu.h| 2 -

[PATCH v2 7/9] target/i386: Combine 5 sets of variables in mmu_translate

2022-10-02 Thread Richard Henderson
We don't need one variable set per translation level, which requires copying into pte/pte_addr for huge pages. Standardize on pte/pte_addr for all levels. Signed-off-by: Richard Henderson --- target/i386/tcg/sysemu/excp_helper.c | 178 ++- 1 file changed, 91

[PATCH v2 1/9] target/i386: Use MMUAccessType across excp_helper.c

2022-10-02 Thread Richard Henderson
Replace int is_write1 and magic numbers with the proper MMUAccessType access_type and enumerators. Signed-off-by: Richard Henderson --- target/i386/tcg/sysemu/excp_helper.c | 28 +++- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git

Re: [PATCH v2] target/sh4: Fix TB_FLAG_UNALIGN

2022-10-02 Thread Richard Henderson
Ping, or should I create a PR myself? r~ On 9/1/22 07:15, Yoshinori Sato wrote: On Thu, 01 Sep 2022 19:15:09 +0900, Richard Henderson wrote: The value previously chosen overlaps GUSA_MASK. Rename all DELAY_SLOT_* and GUSA_* defines to emphasize that they are included in TB_FLAGs. Add

Re: access guest address from within instruction

2022-10-02 Thread Richard Henderson
On 10/2/22 07:52, BitFriends wrote: my bad, then I was mislead by "Which is, in general, what you want for implementing a custom instruction". Also the code around me is full of gen instructions, so I thought that's what I should use. So, when reading the doc I found out about the

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
thanks for the clarification, I will look at those insns. My instruction is for some more advanced logging between guest and host, that should be done quickly. Regards BitFriends Peter Maydell schrieb am So., 2. Okt. 2022, 16:45: > On Sun, 2 Oct 2022 at 10:22, BitFriends wrote: > > I now

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
my bad, then I was mislead by "Which is, in general, what you want for implementing a custom instruction". Also the code around me is full of gen instructions, so I thought that's what I should use. So, when reading the doc I found out about the cpu_{ld,st}*_mmu functions. That sounds more what I

Re: access guest address from within instruction

2022-10-02 Thread Peter Maydell
On Sun, 2 Oct 2022 at 10:22, BitFriends wrote: > I now came up with this code: > > TCGv_i64 res = 0; > TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); > > tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); > > env->regs[R_EAX] = (target_ulong)res; This is wrong, because you cannot read or write

Re: access guest address from within instruction

2022-10-02 Thread Richard Henderson
On 10/2/22 02:20, BitFriends wrote: I now came up with this code: TCGv_i64 res = 0; TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); env->regs[R_EAX] = (target_ulong)res; However this crashes afterwards in test_bit. Maybe this is caused by an invalid

Re: access guest address from within instruction

2022-10-02 Thread Alex Bennée
BitFriends writes: > Hello, > > I am trying to create a custom instruction that accesses guest memory > specified by an address in a register. I specifically > want to read from that address. So I tried to do that using > "tcg_gen_qemu_ld_i64(, env->regs[R_EDI], 0, > MO_LEUQ);", but that

Re: Commit 'iomap: add support for dma aligned direct-io' causes qemu/KVM boot failures

2022-10-02 Thread Keith Busch
On Sun, Oct 02, 2022 at 11:59:42AM +0300, Maxim Levitsky wrote: > On Thu, 2022-09-29 at 19:35 +0200, Paolo Bonzini wrote: > > On 9/29/22 18:39, Christoph Hellwig wrote: > > > On Thu, Sep 29, 2022 at 10:37:22AM -0600, Keith Busch wrote: > > > > > I am aware, and I've submitted the fix to qemu here:

Re: [PATCH] net: print a more actionable error when slirp is not found

2022-10-02 Thread Marc-André Lureau
Hi On Fri, Sep 30, 2022 at 11:49 PM Christian Schoenebeck wrote: > > On Donnerstag, 29. September 2022 18:32:37 CEST Marc-André Lureau wrote: > > From: Marc-André Lureau > > > > If slirp is not found during compile-time, and not manually disabled, > > print a friendly error message, as

[PATCH v2] m68k: write bootinfo as rom section and re-randomize on reboot

2022-10-02 Thread Jason A. Donenfeld
Rather than poking directly into RAM, add the bootinfo block as a proper ROM, so that it's restored when rebooting the system. This way, if the guest corrupts any of the bootinfo items, but then tries to reboot, it'll still be restored back to normal as expected. This assumes the bootinfo block

Re: [PATCH v5 2/2] block: Refactor get_tmp_filename()

2022-10-02 Thread Bin Meng
Hi Kevin, On Fri, Sep 30, 2022 at 6:13 PM Kevin Wolf wrote: > > Am 28.09.2022 um 16:41 hat Bin Meng geschrieben: > > From: Bin Meng > > > > At present there are two callers of get_tmp_filename() and they are > > inconsistent. > > > > One does: > > > > /* TODO: extra byte is a hack to ensure

Re: access guest address from within instruction

2022-10-02 Thread BitFriends
I now came up with this code: TCGv_i64 res = 0; TCGv_i64 addr = (TCGv_i64)(env->regs[R_EDI]); tcg_gen_qemu_ld_i64(res, addr, 0, MO_LEUQ); env->regs[R_EAX] = (target_ulong)res; However this crashes afterwards in test_bit. Maybe this is caused by an invalid access? Anything wrong about the code?

Re: Commit 'iomap: add support for dma aligned direct-io' causes qemu/KVM boot failures

2022-10-02 Thread Maxim Levitsky
On Thu, 2022-09-29 at 19:35 +0200, Paolo Bonzini wrote: > On 9/29/22 18:39, Christoph Hellwig wrote: > > On Thu, Sep 29, 2022 at 10:37:22AM -0600, Keith Busch wrote: > > > > I am aware, and I've submitted the fix to qemu here: > > > > > > > >