[PATCH v3 9/9] hvf: remove the need to lookup memory slots when clearing dirty-bits

2022-03-02 Thread Yan-Jie Wang
`section` passed by the caller to determine the pages that need to be write-protected. Compared to the original method, this saves time. Moreover, this makes only pages whose dirty-bits are cleared write-protected instead of making the whole memory slot write-protected. Signed-off-by: Yan-Jie Wang

[PATCH v3 5/9] hvf: fix memory dirty-tracking

2022-03-02 Thread Yan-Jie Wang
work properly. Buglink: https://bugs.launchpad.net/qemu/+bug/1827005 Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 62 include/sysemu/hvf_int.h | 14 + target/arm/hvf/hvf.c | 5 target/i386/hvf/hvf.c| 25

[PATCH v3 6/9] hvf: add a lock for memory related functions

2022-03-02 Thread Yan-Jie Wang
We follow how KVM accel does in its memory listener (kvm-all.c) and add a lock for the memory related functions. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/accel/hvf/hvf-mem.c b/accel/hvf/hvf-mem.c index 896e718374

[PATCH v3 8/9] hvf: only consider directly writeable memory regions for dirty-tracking

2022-03-02 Thread Yan-Jie Wang
It is no need to dirty-track MMIO regions or other readonly regions. Before we start or stop to dirty-track a memory region, check the type of the memory region. The region must be a writeable ram to be dirty-tracked. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 6 ++ 1 file

[PATCH v3 1/9] hvf: move memory related functions from hvf-accel-ops.c to hvf-mem.c

2022-03-02 Thread Yan-Jie Wang
Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-accel-ops.c | 220 + accel/hvf/hvf-mem.c | 252 ++ accel/hvf/meson.build | 1 + include/sysemu/hvf_int.h | 2 + 4 files changed, 256 insertions(+), 219 deletions

[PATCH v3 4/9] hvf: rename struct hvf_slot to HVFSlot

2022-03-02 Thread Yan-Jie Wang
Follow the QEMU coding style. Structured type names are in CamelCase. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 14 +++--- include/sysemu/hvf_int.h | 8 target/i386/hvf/hvf.c| 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/accel

[PATCH v3 3/9] hvf: use correct data types for addresses in memory related functions

2022-03-02 Thread Yan-Jie Wang
Follow the QEMU coding style. Use hwaddr for guest physical address. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 2 +- include/sysemu/hvf_int.h | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/hvf/hvf-mem.c b/accel/hvf/hvf-mem.c index 32452696b6

[PATCH v2 9/9] hvf: remove the need to lookup memory slots when clearing dirty-bits

2022-03-02 Thread Yan-Jie Wang
`section` passed by the caller to determine the pages that need to be write-protected. Compared to the original method, this saves time. Moreover, this makes only pages whose dirty-bits are cleared write-protected instead of making the whole memory slot write-protected. Signed-off-by: Yan-Jie Wang

[PATCH v2 5/9] hvf: fix memory dirty-tracking

2022-03-02 Thread Yan-Jie Wang
work properly. Buglink: https://bugs.launchpad.net/qemu/+bug/1827005 Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 62 include/sysemu/hvf_int.h | 14 + target/arm/hvf/hvf.c | 5 target/i386/hvf/hvf.c| 25

[PATCH v2 0/9] Many improvements to HVF memory-related codes

2022-03-02 Thread Yan-Jie Wang
es instead of arrays to store in-kernel KVM memory slots. 5. Add a lock to protect the data structures of HVF memory slots Patches have been tested on Apple Silicon Macs and Intel Macs. Yan-Jie Wang (9): hvf: move memory related functions from hvf-accel-ops.c to hvf-mem.c hvf: sim

[PATCH v2 3/9] hvf: use correct data types for addresses in memory related functions

2022-03-02 Thread Yan-Jie Wang
Follow the QEMU coding style. Use hwaddr for guest physical address. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 2 +- include/sysemu/hvf_int.h | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accel/hvf/hvf-mem.c b/accel/hvf/hvf-mem.c index 32452696b6

[PATCH v2 1/9] hvf: move memory related functions from hvf-accel-ops.c to hvf-mem.c

2022-03-02 Thread Yan-Jie Wang
Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-accel-ops.c | 220 + accel/hvf/hvf-mem.c | 252 ++ accel/hvf/meson.build | 1 + include/sysemu/hvf_int.h | 2 + 4 files changed, 256 insertions(+), 219 deletions

[PATCH v2 7/9] hvf: use GTree to store memory slots instead of fixed-size array

2022-03-02 Thread Yan-Jie Wang
Currently, there are only 32 memory slots in the fixed size array. It is not scalable. Instead of using fixed size array, use GTree (from glib library) and dynamically-allocated structures to store memory slots. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 63

[PATCH v2 6/9] hvf: add a lock for memory related functions

2022-03-02 Thread Yan-Jie Wang
We follow how KVM accel does in its memory listener (kvm-all.c) and add a lock for the memory related functions. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/accel/hvf/hvf-mem.c b/accel/hvf/hvf-mem.c index 896e718374

[PATCH v2 4/9] hvf: rename struct hvf_slot to HVFSlot

2022-03-02 Thread Yan-Jie Wang
Follow the QEMU coding style. Structured type names are in CamelCase. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 14 +++--- include/sysemu/hvf_int.h | 8 target/i386/hvf/hvf.c| 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/accel

[PATCH v3 7/9] hvf: use GTree to store memory slots instead of fixed-size array

2022-03-02 Thread Yan-Jie Wang
Currently, there are only 32 memory slots in the fixed size array. It is not scalable. Instead of using fixed size array, use GTree (from glib library) and dynamically-allocated structures to store memory slots. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 63

[PATCH v2 2/9] hvf: simplify data structures and codes of memory related functions

2022-03-02 Thread Yan-Jie Wang
not overlap with existing sections. - Try to align memory sections first before giving up sections that are not aligned to host page size. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-accel-ops.c | 1 - accel/hvf/hvf-mem.c | 211 +++--- include/sysemu

[PATCH v3 2/9] hvf: simplify data structures and codes of memory related functions

2022-03-02 Thread Yan-Jie Wang
not overlap with existing sections. - Try to align memory sections first before giving up sections that are not aligned to host page size. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-accel-ops.c | 1 - accel/hvf/hvf-mem.c | 211 +++--- include/sysemu

[PATCH v3 0/9] Many improvements to HVF memory-related codes

2022-03-02 Thread Yan-Jie Wang
t the data structures of HVF memory slots Patches have been tested on Apple Silicon Macs and Intel Macs. Yan-Jie Wang (9): hvf: move memory related functions from hvf-accel-ops.c to hvf-mem.c hvf: simplify data structures and codes of memory related functions hvf: use correct data types for

[PATCH v2 8/9] hvf: only consider directly writeable memory regions for dirty-tracking

2022-03-02 Thread Yan-Jie Wang
It is no need to dirty-track MMIO regions or other readonly regions. Before we start or stop to dirty-track a memory region, check the type of the memory region. The region must be a writeable ram to be dirty-tracked. Signed-off-by: Yan-Jie Wang --- accel/hvf/hvf-mem.c | 5 + 1 file

Re: [PATCH qemu 0/7] Many improvements to HVF memory-related codes

2022-03-01 Thread Yan-Jie Wang
Sorry, I made a mistake. The last line in the function, hvf_find_free_slot, introduced in this commit "hvf: simplify data structures and codes of memory related functions" should be "return NULL;" static hvf_slot *hvf_find_free_slot(void) { hvf_slot *slot; int x; for (x = 0; x <

Re: [PATCH qemu 0/7] Many improvements to HVF memory-related codes

2022-03-01 Thread Yan-Jie Wang
For the dirty-tracking part in my patch series, the major difference between this patch and Alex's patch is that the dirty-tracking logic in my patch will only mark the page being written dirty instead of marking the whole memory slot dirty, and will only restore the write permission to the

[Qemu-devel] [PATCH] block/file-posix: fix the wrong result of find_allocation() in macOS.

2018-09-08 Thread Yan-Jie Wang
as input may create corrupted images in macOS especially for large files, and qemu-img map may also report wrong things. This patch fixes this undesired behaviors. Signed-off-by: Yan-Jie Wang --- block/file-posix.c | 59 ++ 1 file changed, 59 insertions

[Qemu-devel] [Bug 1776920] Re: qemu-img convert on Mac OSX creates corrupt images

2018-09-07 Thread Yan-Jie Wang
I have done some experiments and find out that the behavior of lseek with whence set to SEEK_DATA is different from the behavior of Linux's lseek. If the supplied offset is in the middle of a data region, it returns the start of the next data region. There may be many data regions in a big