[Qemu-commits] [qemu/qemu] 121531: target/i386: Fix calculation of LOCK NEG eflags
Branch: refs/heads/master Home: https://github.com/qemu/qemu Commit: 121531751087ad3f8d87ad17068835bbcd14fb02 https://github.com/qemu/qemu/commit/121531751087ad3f8d87ad17068835bbcd14fb02 Author: Qi Hu Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M target/i386/tcg/translate.c Log Message: --- target/i386: Fix calculation of LOCK NEG eflags After: lock negl -0x14(%rbp) pushf pop%rax %rax will contain the wrong value because the "lock neg" calculates the wrong eflags. Simple test: #include int main() { __volatile__ unsigned test = 0x2363a; __volatile__ char cond = 0; asm( "lock negl %0 \n\t" "sets %1" : "=m"(test), "=r"(cond)); assert(cond & 1); return 0; } Reported-by: Jinyang Shen Co-Developed-by: Xuehai Chen Signed-off-by: Xuehai Chen Signed-off-by: Qi Hu Signed-off-by: Paolo Bonzini Commit: c891c24b1a4f5496cdb5f6afff9dae146334c7d3 https://github.com/qemu/qemu/commit/c891c24b1a4f5496cdb5f6afff9dae146334c7d3 Author: Claudio Imbrenda Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: A include/qemu/async-teardown.h M meson.build M os-posix.c M qemu-options.hx A util/async-teardown.c M util/meson.build Log Message: --- os-posix: asynchronous teardown for shutdown on Linux This patch adds support for asynchronously tearing down a VM on Linux. When qemu terminates, either naturally or because of a fatal signal, the VM is torn down. If the VM is huge, it can take a considerable amount of time for it to be cleaned up. In case of a protected VM, it might take even longer than a non-protected VM (this is the case on s390x, for example). Some users might want to shut down a VM and restart it immediately, without having to wait. This is especially true if management infrastructure like libvirt is used. This patch implements a simple trick on Linux to allow qemu to return immediately, with the teardown of the VM being performed asynchronously. If the new commandline option -async-teardown is used, a new process is spawned from qemu at startup, using the clone syscall, in such way that it will share its address space with qemu.The new process will have the name "cleanup/". It will wait until qemu terminates completely, and then it will exit itself. This allows qemu to terminate quickly, without having to wait for the whole address space to be torn down. The cleanup process will exit after qemu, so it will be the last user of the address space, and therefore it will take care of the actual teardown. The cleanup process will share the same cgroups as qemu, so both memory usage and cpu time will be accounted properly. If possible, close_range will be used in the cleanup process to close all open file descriptors. If it is not available or if it fails, /proc will be used to determine which file descriptors to close. If the cleanup process is forcefully killed with SIGKILL before the main qemu process has terminated completely, the mechanism is defeated and the teardown will not be asynchronous. This feature can already be used with libvirt by adding the following to the XML domain definition to pass the parameter to qemu directly: http://libvirt.org/schemas/domain/qemu/1.0";> Signed-off-by: Claudio Imbrenda Reviewed-by: Murilo Opsfelder Araujo Tested-by: Murilo Opsfelder Araujo Message-Id: <20220812133453.82671-1-imbre...@linux.ibm.com> Signed-off-by: Paolo Bonzini Commit: 19e2a9fb9da067acba95b3be83588bda5a3f6a99 https://github.com/qemu/qemu/commit/19e2a9fb9da067acba95b3be83588bda5a3f6a99 Author: Zeng Guang Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M hw/i386/x86.c M target/i386/kvm/kvm-stub.c M target/i386/kvm/kvm.c M target/i386/kvm/kvm_i386.h Log Message: --- target/i386: Set maximum APIC ID to KVM prior to vCPU creation Specify maximum possible APIC ID assigned for current VM session to KVM prior to the creation of vCPUs. By this setting, KVM can set up VM-scoped data structure indexed by the APIC ID, e.g. Posted-Interrupt Descriptor pointer table to support Intel IPI virtualization, with the most optimal memory footprint. It can be achieved by calling KVM_ENABLE_CAP for KVM_CAP_MAX_VCPU_ID capability once KVM has enabled it. Ignoring the return error if KVM doesn't support this capability yet. Signed-off-by: Zeng Guang Acked-by: Peter Xu Acked-by: Michael S. Tsirkin Message-Id: <20220825025246.26618-1-guang.z...@intel.com> Signed-off-by: Paolo Bonzini Commit: eff3de52f265df39c6fc668415ad317ec1f24051 https://github.com/qemu/qemu/commit/eff3de52f265df39c6fc668415ad317ec1f24051 Author: Greg Kurz Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M util/log.c Log Message: --- util/log: Close per-thread log file on thread ter
[Qemu-commits] [qemu/qemu] 121531: target/i386: Fix calculation of LOCK NEG eflags
Branch: refs/heads/staging Home: https://github.com/qemu/qemu Commit: 121531751087ad3f8d87ad17068835bbcd14fb02 https://github.com/qemu/qemu/commit/121531751087ad3f8d87ad17068835bbcd14fb02 Author: Qi Hu Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M target/i386/tcg/translate.c Log Message: --- target/i386: Fix calculation of LOCK NEG eflags After: lock negl -0x14(%rbp) pushf pop%rax %rax will contain the wrong value because the "lock neg" calculates the wrong eflags. Simple test: #include int main() { __volatile__ unsigned test = 0x2363a; __volatile__ char cond = 0; asm( "lock negl %0 \n\t" "sets %1" : "=m"(test), "=r"(cond)); assert(cond & 1); return 0; } Reported-by: Jinyang Shen Co-Developed-by: Xuehai Chen Signed-off-by: Xuehai Chen Signed-off-by: Qi Hu Signed-off-by: Paolo Bonzini Commit: c891c24b1a4f5496cdb5f6afff9dae146334c7d3 https://github.com/qemu/qemu/commit/c891c24b1a4f5496cdb5f6afff9dae146334c7d3 Author: Claudio Imbrenda Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: A include/qemu/async-teardown.h M meson.build M os-posix.c M qemu-options.hx A util/async-teardown.c M util/meson.build Log Message: --- os-posix: asynchronous teardown for shutdown on Linux This patch adds support for asynchronously tearing down a VM on Linux. When qemu terminates, either naturally or because of a fatal signal, the VM is torn down. If the VM is huge, it can take a considerable amount of time for it to be cleaned up. In case of a protected VM, it might take even longer than a non-protected VM (this is the case on s390x, for example). Some users might want to shut down a VM and restart it immediately, without having to wait. This is especially true if management infrastructure like libvirt is used. This patch implements a simple trick on Linux to allow qemu to return immediately, with the teardown of the VM being performed asynchronously. If the new commandline option -async-teardown is used, a new process is spawned from qemu at startup, using the clone syscall, in such way that it will share its address space with qemu.The new process will have the name "cleanup/". It will wait until qemu terminates completely, and then it will exit itself. This allows qemu to terminate quickly, without having to wait for the whole address space to be torn down. The cleanup process will exit after qemu, so it will be the last user of the address space, and therefore it will take care of the actual teardown. The cleanup process will share the same cgroups as qemu, so both memory usage and cpu time will be accounted properly. If possible, close_range will be used in the cleanup process to close all open file descriptors. If it is not available or if it fails, /proc will be used to determine which file descriptors to close. If the cleanup process is forcefully killed with SIGKILL before the main qemu process has terminated completely, the mechanism is defeated and the teardown will not be asynchronous. This feature can already be used with libvirt by adding the following to the XML domain definition to pass the parameter to qemu directly: http://libvirt.org/schemas/domain/qemu/1.0";> Signed-off-by: Claudio Imbrenda Reviewed-by: Murilo Opsfelder Araujo Tested-by: Murilo Opsfelder Araujo Message-Id: <20220812133453.82671-1-imbre...@linux.ibm.com> Signed-off-by: Paolo Bonzini Commit: 19e2a9fb9da067acba95b3be83588bda5a3f6a99 https://github.com/qemu/qemu/commit/19e2a9fb9da067acba95b3be83588bda5a3f6a99 Author: Zeng Guang Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M hw/i386/x86.c M target/i386/kvm/kvm-stub.c M target/i386/kvm/kvm.c M target/i386/kvm/kvm_i386.h Log Message: --- target/i386: Set maximum APIC ID to KVM prior to vCPU creation Specify maximum possible APIC ID assigned for current VM session to KVM prior to the creation of vCPUs. By this setting, KVM can set up VM-scoped data structure indexed by the APIC ID, e.g. Posted-Interrupt Descriptor pointer table to support Intel IPI virtualization, with the most optimal memory footprint. It can be achieved by calling KVM_ENABLE_CAP for KVM_CAP_MAX_VCPU_ID capability once KVM has enabled it. Ignoring the return error if KVM doesn't support this capability yet. Signed-off-by: Zeng Guang Acked-by: Peter Xu Acked-by: Michael S. Tsirkin Message-Id: <20220825025246.26618-1-guang.z...@intel.com> Signed-off-by: Paolo Bonzini Commit: eff3de52f265df39c6fc668415ad317ec1f24051 https://github.com/qemu/qemu/commit/eff3de52f265df39c6fc668415ad317ec1f24051 Author: Greg Kurz Date: 2022-10-31 (Mon, 31 Oct 2022) Changed paths: M util/log.c Log Message: --- util/log: Close per-thread log file on thread te