Re: [PATCH v5 28/65] i386/tdx: Disable pmu for TD guest

2024-04-16 Thread Chenyi Qiang
On 2/29/2024 2:36 PM, Xiaoyao Li wrote: > Current KVM doesn't support PMU for TD guest. It returns error if TD is > created with PMU bit being set in attributes. > > Disable PMU for TD guest on QEMU side. > > Signed-off-by: Xiaoyao Li > --- > target/i386/kvm/tdx.c | 2 ++ > 1 file changed,

Re: [PATCH v2 41/58] i386/tdx: handle TDG.VP.VMCALL

2023-08-30 Thread Chenyi Qiang
On 8/29/2023 6:25 PM, Daniel P. Berrangé wrote: > On Tue, Aug 29, 2023 at 01:31:37PM +0800, Chenyi Qiang wrote: >> >> >> On 8/22/2023 4:24 PM, Daniel P. Berrangé wrote: >>> On Tue, Aug 22, 2023 at 08:52:30AM +0200, Markus Armbruster wrote: >>>>

Re: [PATCH v2 41/58] i386/tdx: handle TDG.VP.VMCALL

2023-08-29 Thread Chenyi Qiang
On 8/22/2023 4:24 PM, Daniel P. Berrangé wrote: > On Tue, Aug 22, 2023 at 08:52:30AM +0200, Markus Armbruster wrote: >> Xiaoyao Li writes: >> >>> From: Isaku Yamahata >>> >>> For GetQuote, delegate a request to Quote Generation Service. Add property >>> of address of quote generation server

Re: [PATCH v2 43/58] i386/tdx: setup a timer for the qio channel

2023-08-24 Thread Chenyi Qiang
On 8/18/2023 5:50 PM, Xiaoyao Li wrote: > From: Chenyi Qiang > > To avoid no response from QGS server, setup a timer for the transaction. If > timeout, make it an error and interrupt guest. Define the threshold of time > to 30s at present, maybe change to other value if

Re: [PATCH v2 42/58] i386/tdx: register the fd read callback with the main loop to read the quote data

2023-08-24 Thread Chenyi Qiang
On 8/18/2023 5:50 PM, Xiaoyao Li wrote: > From: Chenyi Qiang > > When TD guest invokes getquote tdvmcall, QEMU will register a async qio > task with default context when the qio channel is connected. However, as > there is a blocking action (recvmsg()) in q

[PATCH] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop

2022-12-28 Thread Chenyi Qiang
It should be the variable rdl2 to revert the already-notified listeners. Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface") Signed-off-by: Chenyi Qiang --- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-

Re: [PATCH v10 2/9] KVM: Introduce per-page memory attributes

2022-12-28 Thread Chenyi Qiang
On 12/2/2022 2:13 PM, Chao Peng wrote: > In confidential computing usages, whether a page is private or shared is > necessary information for KVM to perform operations like page fault > handling, page zapping etc. There are other potential use cases for > per-page memory attributes, e.g. to

Re: [PATCH] virtio-mem: Fix the bitmap index of the section offset

2022-12-18 Thread Chenyi Qiang
On 12/16/2022 6:30 PM, David Hildenbrand wrote: > On 16.12.22 09:52, David Hildenbrand wrote: >> On 16.12.22 07:22, Chenyi Qiang wrote: >>> vmem->bitmap indexes the memory region of the virtio-mem backend at a >>> granularity of block_size. To calculate the inde

[PATCH] virtio-mem: Fix the bitmap index of the section offset

2022-12-15 Thread Chenyi Qiang
;) Signed-off-by: Chenyi Qiang --- hw/virtio/virtio-mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index ed170def48..e19ee817fe 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -235,7 +235,7

Re: [PATCH v3 4/8] target/i386/intel-pt: print special message for INTEL_PT_ADDR_RANGES_NUM

2022-12-13 Thread Chenyi Qiang
On 12/13/2022 8:09 PM, Xiaoyao Li wrote: > On 12/9/2022 2:43 PM, Chenyi Qiang wrote: >> >> >> On 12/8/2022 2:25 PM, Xiaoyao Li wrote: >>> Bit[2:0] of CPUID.14H_01H:EAX stands as a whole for the number of INTEL >>> PT ADDR RANGES. For unsupported value th

Re: [PATCH v3 7/8] target/i386/intel-pt: Define specific PT feature set for IceLake-server and Snowridge

2022-12-08 Thread Chenyi Qiang
On 12/8/2022 2:25 PM, Xiaoyao Li wrote: > For IceLake-server, it's just the same as using the default PT > feature set since the default one is exact taken from ICX. > > For Snowridge, define it according to real SNR silicon capabilities. > > Signed-off-by: Xiaoyao Li > --- >

Re: [PATCH v3 6/8] target/i386/intel-pt: Enable host pass through of Intel PT

2022-12-08 Thread Chenyi Qiang
On 12/8/2022 2:25 PM, Xiaoyao Li wrote: > commit e37a5c7fa459 ("i386: Add Intel Processor Trace feature support") > added the support of Intel PT by making CPUID[14] of PT as fixed feature > set (from ICX) for any CPU model on any host. This truly breaks the PT > exposure on Intel SPR platform

Re: [PATCH v3 4/8] target/i386/intel-pt: print special message for INTEL_PT_ADDR_RANGES_NUM

2022-12-08 Thread Chenyi Qiang
On 12/8/2022 2:25 PM, Xiaoyao Li wrote: > Bit[2:0] of CPUID.14H_01H:EAX stands as a whole for the number of INTEL > PT ADDR RANGES. For unsupported value that exceeds what KVM reports, > report it as a whole in mark_unavailable_features() as well. > Maybe this patch can be put before 3/8. >

Re: [PATCH v8 0/4] Enable notify VM exit

2022-09-29 Thread Chenyi Qiang
On 9/30/2022 1:28 AM, Paolo Bonzini wrote: On 9/29/22 09:03, Chenyi Qiang wrote: Notify VM exit is introduced to mitigate the potential DOS attach from malicious VM. This series is the userspace part to enable this feature through a new KVM capability KVM_CAP_X86_NOTIFY_VMEXIT. The detailed

[RESEND PATCH v8 1/4] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-09-29 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target

[RESEND PATCH v8 3/4] kvm: expose struct KVMState

2022-09-29 Thread Chenyi Qiang
Expose struct KVMState out of kvm-all.c so that the field of struct KVMState can be accessed when defining target-specific accelerator properties. Signed-off-by: Chenyi Qiang --- accel/kvm/kvm-all.c | 74 --- include/sysemu/kvm_int.h | 75

[RESEND PATCH v8 4/4] i386: add notify VM exit support

2022-09-29 Thread Chenyi Qiang
is set, raise a KVM internal error unconditionally. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- accel/kvm/kvm-all.c | 2 + qapi/run-state.json | 17 qemu-options.hx | 11 + target/i386/kvm/kvm.c | 98 +++ 4 files changed, 128

[RESEND PATCH v8 2/4] kvm: allow target-specific accelerator properties

2022-09-29 Thread Chenyi Qiang
From: Paolo Bonzini Several hypervisor capabilities in KVM are target-specific. When exposed to QEMU users as accelerator properties (i.e. -accel kvm,prop=value), they should not be available for all targets. Add a hook for targets to add their own properties to -accel kvm, for now no such

[RESEND PATCH v8 0/4] Enable notify VM exit

2022-09-29 Thread Chenyi Qiang
-> v6 - Add some info related to the valid range of notify_window in patch 2. (Peter Xu) - Add the doc in qemu-options.hx. (Peter Xu) - v5: https://lore.kernel.org/qemu-devel/20220817020845.21855-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (3): i386: kvm: extend kvm_{get, put}_vcpu_events t

[PATCH v8 0/4] Enable notify VM exit

2022-09-29 Thread Chenyi Qiang
ptions.hx. (Peter Xu) - v5: https://lore.kernel.org/qemu-devel/20220817020845.21855-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (3): i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault kvm: expose struct KVMState i386: add notify VM exit support Paolo Bonzini (1): k

[PATCH v8 1/4] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-09-29 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target

[PATCH v8 2/4] kvm: allow target-specific accelerator properties

2022-09-29 Thread Chenyi Qiang
From: Paolo Bonzini Several hypervisor capabilities in KVM are target-specific. When exposed to QEMU users as accelerator properties (i.e. -accel kvm,prop=value), they should not be available for all targets. Add a hook for targets to add their own properties to -accel kvm, for now no such

[PATCH v8 4/4] i386: add notify VM exit support

2022-09-29 Thread Chenyi Qiang
is set, raise a KVM internal error unconditionally. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- accel/kvm/kvm-all.c | 2 + qapi/run-state.json | 17 qemu-options.hx | 11 + target/i386/kvm/kvm.c | 97 +++ 4 files changed, 127

[PATCH v8 3/4] kvm: expose struct KVMState

2022-09-29 Thread Chenyi Qiang
Expose struct KVMState out of kvm-all.c so that the field of struct KVMState can be accessed when defining target-specific accelerator properties. Signed-off-by: Chenyi Qiang --- accel/kvm/kvm-all.c | 74 --- include/sysemu/kvm_int.h | 75

Re: [PATCH v7 2/2] i386: Add notify VM exit support

2022-09-27 Thread Chenyi Qiang
On 9/27/2022 9:43 PM, Paolo Bonzini wrote: On 9/23/22 09:33, Chenyi Qiang wrote: Because there are some concerns, e.g. a notify VM exit may happen with VM_CONTEXT_INVALID set in exit qualification (no cases are anticipated that would set this bit), which means VM context is corrupted

Re: [PATCH v7 1/2] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-09-27 Thread Chenyi Qiang
On 9/27/2022 9:14 PM, Paolo Bonzini wrote: On 9/23/22 09:33, Chenyi Qiang wrote: For the direct triple faults, i.e. hardware detected and KVM morphed to VM-Exit, KVM will never lose them. But for triple faults sythesized by KVM, e.g. the RSM path, if KVM exits to userspace before the request

[PATCH v7 1/2] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-09-23 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target

[PATCH v7 2/2] i386: Add notify VM exit support

2022-09-23 Thread Chenyi Qiang
by injecting a sythesized triple fault event. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 45 +++ include/hw/i386/x86.h | 5 + qemu-options.hx | 10 +- target/i386/kvm/kvm.c | 34

[PATCH v7 0/2] Enable notify VM exit

2022-09-23 Thread Chenyi Qiang
ENT to guard the extension of triple fault event save - v3: https://lore.kernel.org/qemu-devel/20220421074028.18196-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (2): i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault i386: Add notify VM exit support h

Re: [PATCH v6 2/2] i386: Add notify VM exit support

2022-09-20 Thread Chenyi Qiang
On 9/20/2022 9:59 PM, Peter Xu wrote: On Tue, Sep 20, 2022 at 01:55:20PM +0800, Chenyi Qiang wrote: @@ -5213,6 +5213,7 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) break; case KVM_EXIT_NOTIFY: ret = 0; +warn_report_once("KVM: n

Re: [PATCH v6 2/2] i386: Add notify VM exit support

2022-09-20 Thread Chenyi Qiang
On 9/19/2022 11:53 PM, Peter Xu wrote: On Mon, Sep 19, 2022 at 01:46:38PM +0800, Chenyi Qiang wrote: On 9/17/2022 5:57 AM, Peter Xu wrote: On Thu, Sep 15, 2022 at 05:28:39PM +0800, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event

Re: [PATCH v6 2/2] i386: Add notify VM exit support

2022-09-18 Thread Chenyi Qiang
On 9/17/2022 5:57 AM, Peter Xu wrote: On Thu, Sep 15, 2022 at 05:28:39PM +0800, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event window means

[PATCH v6 2/2] i386: Add notify VM exit support

2022-09-15 Thread Chenyi Qiang
by injecting a sythesized triple fault event. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 45 +++ include/hw/i386/x86.h | 5 + qemu-options.hx | 10 +- target/i386/kvm/kvm.c | 28 +++ 4 files changed, 87

[PATCH v6 1/2] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-09-15 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Acked-by: Peter Xu Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target

[PATCH v3 2/2] Update linux headers to v6.0-rc4

2022-09-15 Thread Chenyi Qiang
commit 7e18e42e4b280c85b76967a9106a13ca61c16179 Reviewed-by: Cornelia Huck Signed-off-by: Chenyi Qiang --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 73 +++- include/standard-headers/linux/ethtool.h | 29 +-- include

[PATCH v3 1/2] configure: Add -Wno-gnu-variable-sized-type-not-at-end

2022-09-15 Thread Chenyi Qiang
this clang warning. Suggested-by: Daniel P. Berrangé Reviewed-by: Richard Henderson Reviewed-by: Cornelia Huck Signed-off-by: Chenyi Qiang --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 575dde1c1f..7e0a1a4187 100755 --- a/configure +++ b/configure

[PATCH v6 0/2] Enable notify VM exit

2022-09-15 Thread Chenyi Qiang
avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (2): i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault i386: Add notify VM exit support hw/i386/x86

[PATCH v3 0/2] Update linux headers to v6.0-rc4 and fix the clang build error

2022-09-15 Thread Chenyi Qiang
tps://lore.kernel.org/qemu-devel/20220909035758.17434-1-chenyi.qi...@intel.com/ v1 -> v2: - Change the patch order. (Peter Maydell) - Expand the commit message in patch 1. (Peter Maydell) - v1: https://lore.kernel.org/qemu-devel/20220908080749.32211-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (2): con

Re: [PATCH v5 3/3] i386: Add notify VM exit support

2022-09-12 Thread Chenyi Qiang
On 9/10/2022 12:25 AM, Peter Xu wrote: On Wed, Aug 17, 2022 at 10:08:45AM +0800, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event window

[PATCH v2 2/2] Update linux headers to v6.0-rc4

2022-09-08 Thread Chenyi Qiang
commit 7e18e42e4b280c85b76967a9106a13ca61c16179 Signed-off-by: Chenyi Qiang --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 73 +++- include/standard-headers/linux/ethtool.h | 29 +-- include/standard-headers/linux/input.h

[PATCH v2 0/2] Update linux headers to v6.0-rc4 and fix the clang build error

2022-09-08 Thread Chenyi Qiang
h 1. (Peter Maydell) - v1: https://lore.kernel.org/qemu-devel/20220908080749.32211-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (2): configure: Add -Wno-gnu-variable-sized-type-not-at-end Update linux headers to v6.0-rc4 configure | 1 + include/stand

[PATCH v2 1/2] configure: Add -Wno-gnu-variable-sized-type-not-at-end

2022-09-08 Thread Chenyi Qiang
warning. Suggested-by: Daniel P. Berrangé Reviewed-by: Richard Henderson Signed-off-by: Chenyi Qiang --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 575dde1c1f..7e0a1a4187 100755 --- a/configure +++ b/configure @@ -1258,6 +1258,7 @@ add_to

Re: [PATCH 2/2] configure: Add -Wno-gnu-variable-sized-type-not-at-end

2022-09-08 Thread Chenyi Qiang
On 9/8/2022 6:54 PM, Peter Maydell wrote: On Thu, 8 Sept 2022 at 10:09, Daniel P. Berrangé wrote: On Thu, Sep 08, 2022 at 09:53:44AM +0100, Peter Maydell wrote: On Thu, 8 Sept 2022 at 09:08, Chenyi Qiang wrote: After updating linux headers to v6.0-rc, clang build on x86 target would

[PATCH 2/2] configure: Add -Wno-gnu-variable-sized-type-not-at-end

2022-09-08 Thread Chenyi Qiang
extension in QEMU (e.g. g_auto stuff), it is acceptable to turn off this warning, which is only relevant to people striving for fully portable C code. Suggested-by: Daniel P. Berrangé Signed-off-by: Chenyi Qiang --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b

[PATCH 0/2] Update linux headers to v6.0-rc4 and fix the clang build error

2022-09-08 Thread Chenyi Qiang
After updating linux headers to v6.0-rc, clang build on x86 target would generate warnings related to -Wgnu-variable-sized-type-not-at-end. Simply turn off this warning in this patch set. If not suitable to turn it off, any comments or suggestions are welcome. Chenyi Qiang (2): Update linux

[PATCH 1/2] Update linux headers to v6.0-rc4

2022-09-08 Thread Chenyi Qiang
commit 7e18e42e4b280c85b76967a9106a13ca61c16179 Signed-off-by: Chenyi Qiang --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 73 +++- include/standard-headers/linux/ethtool.h | 29 +-- include/standard-headers/linux/input.h

Re: [PATCH v5 3/3] i386: Add notify VM exit support

2022-09-04 Thread Chenyi Qiang
Hi Paolo, Any comment on patch 2-3? Thanks Chenyi On 8/17/2022 10:08 AM, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event window means

[PATCH] hw/pci-bridge: Fix brace Werror with clang 6.0.0

2022-09-01 Thread Chenyi Qiang
ions){ 0 }; ^ {} The original code is correct, just to work around clang's bogus warning. Signed-off-by: Chenyi Qiang --- hw/pci-bridge/cxl_downstream.c | 2 +- hw/pci-bridge/cxl_root_port.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pc

Re: [PATCH v5 1/3] Update linux headers to 6.0-rc1

2022-08-23 Thread Chenyi Qiang
On 8/22/2022 11:00 PM, Michal Prívozník wrote: On 8/17/22 04:08, Chenyi Qiang wrote: commit 568035b01cfb107af8d2e4bd2fb9aea22cf5b868 Signed-off-by: Chenyi Qiang --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 73

[PATCH v5 1/3] Update linux headers to 6.0-rc1

2022-08-16 Thread Chenyi Qiang
commit 568035b01cfb107af8d2e4bd2fb9aea22cf5b868 Signed-off-by: Chenyi Qiang --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 73 +++- include/standard-headers/linux/ethtool.h | 29 +-- include/standard-headers/linux/input.h

[PATCH v5 0/3] Enable notify VM exit

2022-08-16 Thread Chenyi Qiang
ENT_SHUTDOWN to KVM_VCPUEVENT_TRIPLE_FAULT. - Do the corresponding change to use the KVM_VCPUEVENTS_TRIPLE_FAULT to save/restore the triple fault event to avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qi...@intel.com/

[PATCH v5 2/3] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-08-16 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_X86_TRIPLE_FAULT_EVENT capability is enabled. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 20

[PATCH v5 3/3] i386: Add notify VM exit support

2022-08-16 Thread Chenyi Qiang
a SHUTDOWN event to the target vcpu. This is implemented by injecting a sythesized triple fault event. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 45 +++ include/hw/i386/x86.h | 5 + target/i386/kvm/kvm.c | 28

Re: [PATCH v1 08/40] i386/tdx: Adjust the supported CPUID based on TDX restrictions

2022-08-03 Thread Chenyi Qiang
ctifies the previous step); - add configurable bits (it covers the other part of type #1); - fix the ones in vmm_fixup; - filter the one has valid .supported field; What does .supported field filter mean here? (Calculated type is ignored since it's determined at runtime). Co-developed-by: Chen

Re: [PATCH v4 3/3] i386: Add notify VM exit support

2022-05-25 Thread Chenyi Qiang
On 5/25/2022 11:43 AM, Yuan Yao wrote: On Tue, May 24, 2022 at 10:03:02PM +0800, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event window

[PATCH v4 3/3] i386: Add notify VM exit support

2022-05-24 Thread Chenyi Qiang
a SHUTDOWN event to the target vcpu. This is implemented by injecting a sythesized triple fault event. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 45 + include/hw/i386/x86.h | 5 target/i386/kvm/kvm.c | 66

[PATCH v4 0/3] Enable notify VM exit

2022-05-24 Thread Chenyi Qiang
to avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (3): linux-header: update linux header i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault i386: Add

[PATCH v4 2/3] i386: kvm: extend kvm_{get, put}_vcpu_events to support pending triple fault

2022-05-24 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state if the KVM_CAP_TRIPLE_FAULT_EVENT capability is enabled. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 20

[PATCH v4 1/3] linux-header: update linux header

2022-05-24 Thread Chenyi Qiang
This linux-header update is only a reference to include some definitions related to notify VM exit. Signed-off-by: Chenyi Qiang --- linux-headers/asm-x86/kvm.h | 6 +- linux-headers/linux/kvm.h | 11 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/linux-headers

Re: [PATCH v5 1/1] virtio: fix the condition for iommu_platform not supported

2022-04-27 Thread Chenyi Qiang
On 4/22/2022 3:11 PM, Chenyi Qiang wrote: On 2/7/2022 7:28 PM, Halil Pasic wrote: The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but unsupported") claims to fail the device hotplug when iommu_platform is requested, but not supported by the (vhost) device. On

Re: [PATCH v5 1/1] virtio: fix the condition for iommu_platform not supported

2022-04-22 Thread Chenyi Qiang
On 2/7/2022 7:28 PM, Halil Pasic wrote: The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but unsupported") claims to fail the device hotplug when iommu_platform is requested, but not supported by the (vhost) device. On the first glance the condition for detecting that

[PATCH v3 1/3] linux-header: update linux header

2022-04-21 Thread Chenyi Qiang
This linux-header update is only a reference to include some definitions related to notify VM exit. Signed-off-by: Chenyi Qiang --- linux-headers/asm-x86/kvm.h | 4 +++- linux-headers/linux/kvm.h | 10 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/linux-headers

[PATCH v3 2/3] i386: kvm: Save triple fault event

2022-04-21 Thread Chenyi Qiang
KVM_VCPUEVENT_VALID_TRIPLE_FAULT is defined to signal that the event.triple_fault_pending field contains a valid state. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 8 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff

[PATCH v3 0/3] Enable notify VM exit

2022-04-21 Thread Chenyi Qiang
. - Do the corresponding change to use the KVM_VCPUEVENTS_TRIPLE_FAULT to save/restore the triple fault event to avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (3): linux-header: update linux

[PATCH v3 3/3] i386: Add notify VM exit support

2022-04-21 Thread Chenyi Qiang
a SHUTDOWN event to the target vcpu. This is implemented by injecting a sythesized triple fault event. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 45 +++ include/hw/i386/x86.h | 5 target/i386/kvm/kvm.c | 62

[PATCH v2 3/3] i386: Add notify VM exit support

2022-03-18 Thread Chenyi Qiang
by injecting a sythesized triple fault event to target vcpu. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 24 ++ include/hw/i386/x86.h | 3 +++ target/i386/kvm/kvm.c | 58 --- 3 files changed, 65 insertions(+), 20 deletions

[PATCH v2 2/3] i386: kvm: Save triple fault event

2022-03-18 Thread Chenyi Qiang
KVM_VCPUEVENT_TRIPLE_FAULT is defined to signal that there's triple fault event waiting to be serviced. Track it and save/restore during get/set_vcpu_events(). Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 10 ++ 3 files

[PATCH v2 0/3] Enable notify VM exit

2022-03-18 Thread Chenyi Qiang
ult event to avoid lose some synthesized triple fault from KVM. - v1: https://lore.kernel.org/qemu-devel/20220310090205.10645-1-chenyi.qi...@intel.com/ --- Chenyi Qiang (3): linux-headers: Sync the linux headers i386: kvm: Save triple fault event i386: Add notify VM exit support hw/i

[PATCH v2 1/3] linux-headers: Sync the linux headers

2022-03-18 Thread Chenyi Qiang
Signed-off-by: Chenyi Qiang --- linux-headers/asm-x86/kvm.h | 4 linux-headers/linux/kvm.h | 29 - 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 2da3316bb5..d8ef0d993e 100644

Re: [PATCH 2/2] i386: Add notify VM exit support

2022-03-10 Thread Chenyi Qiang
On 3/10/2022 5:17 PM, Daniel P. Berrangé wrote: On Thu, Mar 10, 2022 at 05:02:05PM +0800, Chenyi Qiang wrote: There are cases that malicious virtual machine can cause CPU stuck (due to event windows don't open up), e.g., infinite loop in microcode when nested #AC (CVE-2015-5307). No event

[PATCH 1/2] linux-headers: Sync the linux headers

2022-03-10 Thread Chenyi Qiang
Signed-off-by: Chenyi Qiang --- linux-headers/asm-x86/kvm.h | 4 linux-headers/linux/kvm.h | 29 - 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 2da3316bb5..44757bd612 100644

[PATCH 2/2] i386: Add notify VM exit support

2022-03-10 Thread Chenyi Qiang
by defining a new bit in flags field of kvm_vcpu_event in KVM_SET_VCPU_EVENTS ioctl. Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 24 ++ include/hw/i386/x86.h | 3 +++ target/i386/kvm/kvm.c | 58 --- 3 files changed, 65 insertions(+), 20

[PATCH 0/2] Enable notify VM exit

2022-03-10 Thread Chenyi Qiang
/20220310084001.10235-1-chenyi.qi...@intel.com/ Chenyi Qiang (2): linux-headers: Sync the linux headers i386: Add notify VM exit support hw/i386/x86.c | 24 +++ include/hw/i386/x86.h | 3 ++ linux-headers/asm-x86/kvm.h | 4 +++ linux-headers/linux/kvm.h | 29

Re: [PULL 31/53] KVM: x86: believe what KVM says about WAITPKG

2021-12-22 Thread Chenyi Qiang
On 7/7/2020 12:41 AM, Paolo Bonzini wrote: Currently, QEMU is overriding KVM_GET_SUPPORTED_CPUID's answer for the WAITPKG bit depending on the "-overcommit cpu-pm" setting. This is a bad idea because it does not even check if the host supports it, but it can be done in x86_cpu_realizefn just

Re: [PATCH v2 2/2] target/i386: Remove core-capability in Snowridge CPU model

2021-10-11 Thread Chenyi Qiang
Hi Eduardo, Ping for this minor change. On 8/27/2021 2:48 PM, Chenyi Qiang wrote: Because core-capability releated features are model-specific and KVM won't support it, remove the core-capability in CPU model to avoid the warning message. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c

[PATCH v2 2/2] target/i386: Remove core-capability in Snowridge CPU model

2021-08-27 Thread Chenyi Qiang
Because core-capability releated features are model-specific and KVM won't support it, remove the core-capability in CPU model to avoid the warning message. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c

[PATCH v2 0/2] Remove unsupported features in SNR CPU model

2021-08-27 Thread Chenyi Qiang
Patch 1: https://lore.kernel.org/qemu-devel/20210825195438.914387-2-ehabk...@redhat.com/ Patch 2 removes one more feature (core-capability) in Snowridge-v4 CPU model based on previous patch. Chenyi Qiang (2): target/i386: Remove split lock detect in Snowridge CPU model target/i386: Remove

[PATCH v2 1/2] target/i386: Remove split lock detect in Snowridge CPU model

2021-08-27 Thread Chenyi Qiang
At present, there's no mechanism intelligent enough to virtualize split lock detection correctly. Remove it in Snowridge CPU model to avoid the feature exposure. Signed-off-by: Chenyi Qiang Message-Id: <20210630012053.10098-1-chenyi.qi...@intel.com> Signed-off-by: Eduardo Habkost ---

Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest

2021-07-27 Thread Chenyi Qiang
On 7/27/2021 4:28 PM, Dr. David Alan Gilbert wrote: * Chenyi Qiang (chenyi.qi...@intel.com) wrote: A bus lock is acquired through either split locked access to writeback (WB) memory or any locked access to non-WB memory. It is typically >1000 cycles slower than an atomic operation wit

[PATCH] target/i386: Remove split lock detect in Snowridge CPU model

2021-06-29 Thread Chenyi Qiang
At present, there's no mechanism intelligent enough to virtualize split lock detection correctly. Remove it in Snowridge CPU model to avoid the feature exposure. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 8 1 file changed, 8 insertions(+) diff --git a/target/i386/cpu.c b

Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest

2021-06-01 Thread Chenyi Qiang
On 6/2/2021 4:10 AM, Eduardo Habkost wrote: On Tue, Jun 01, 2021 at 02:18:37PM -0400, Eduardo Habkost wrote: On Mon, May 31, 2021 at 01:14:54PM +0800, Chenyi Qiang wrote: On 5/28/2021 5:19 AM, Eduardo Habkost wrote: On Fri, May 21, 2021 at 12:38:20PM +0800, Chenyi Qiang wrote

Re: [PATCH v4] i386: Add ratelimit for bus locks acquired in guest

2021-05-30 Thread Chenyi Qiang
On 5/28/2021 5:19 AM, Eduardo Habkost wrote: On Fri, May 21, 2021 at 12:38:20PM +0800, Chenyi Qiang wrote: [...] @@ -4222,6 +4247,15 @@ void kvm_arch_pre_run(CPUState *cpu, struct kvm_run *run) } } +static void kvm_rate_limit_on_bus_lock(void) +{ +uint64_t delay_ns

[PATCH v4] i386: Add ratelimit for bus locks acquired in guest

2021-05-20 Thread Chenyi Qiang
uction-set-extensions-programming-reference.html Signed-off-by: Chenyi Qiang --- Changes from v3: - change bus_lock_ratelimit_ctrl to a static variable to avoid calling qdev_get_machine(). (Eduardo) - 4951967d84a0ratelimit is thread safe by commit 4951967d84a0, remove the ratelimit mutex in previo

Re: [PATCH v3] i386: Add ratelimit for bus locks acquired in guest

2021-05-19 Thread Chenyi Qiang
On 5/18/2021 3:46 AM, Eduardo Habkost wrote: +Stefan I have a question about ratelimit_set_speed() below: On Fri, Apr 30, 2021 at 06:33:05PM +0800, Chenyi Qiang wrote: A bus lock is acquired through either split locked access to writeback (WB) memory or any locked access to non-WB memory

Re: [PATCH v3] i386: Add ratelimit for bus locks acquired in guest

2021-05-13 Thread Chenyi Qiang
+Cc qemu-devel@nongnu.org On 5/14/2021 9:07 AM, Chenyi Qiang wrote: Hi Paolo, Eduardo Any comments on this version? On 4/30/2021 6:33 PM, Chenyi Qiang wrote: A bus lock is acquired through either split locked access to writeback (WB) memory or any locked access to non-WB memory

[PATCH v3] i386: Add ratelimit for bus locks acquired in guest

2021-04-30 Thread Chenyi Qiang
uction-set-extensions-programming-reference.html Signed-off-by: Chenyi Qiang --- Changes from v2: - do some rename work (bus-lock-ratelimit and BUS_LOCK_TIME_SLICE). (Eduardo) - change to register a class property at the x86_machine_class_init() and write the gettter/setter for the bus_lock

Re: [PATCH v2] i386: Add ratelimit for bus locks acquired in guest

2021-04-22 Thread Chenyi Qiang
On 4/21/2021 11:18 PM, Eduardo Habkost wrote: On Wed, Apr 21, 2021 at 10:50:10PM +0800, Xiaoyao Li wrote: On 4/21/2021 10:12 PM, Eduardo Habkost wrote: On Wed, Apr 21, 2021 at 02:26:42PM +0800, Chenyi Qiang wrote: Hi, Eduardo, thanks for your comments! On 4/21/2021 12:34 AM, Eduardo

Re: [PATCH v2] i386: Add ratelimit for bus locks acquired in guest

2021-04-21 Thread Chenyi Qiang
Hi, Eduardo, thanks for your comments! On 4/21/2021 12:34 AM, Eduardo Habkost wrote: Hello, Thanks for the patch. Comments below: On Tue, Apr 20, 2021 at 05:37:36PM +0800, Chenyi Qiang wrote: Virtual Machines can exploit bus locks to degrade the performance of system. To address this kind

[PATCH v2] i386: Add ratelimit for bus locks acquired in guest

2021-04-20 Thread Chenyi Qiang
w/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Signed-off-by: Chenyi Qiang --- Changes from RFC v1: - Remove the rip info output, as the rip can't reflect the bus lock position correctly. - RFC v1: https://lore.kernel.org/qemu-devel/20

Re: [RFC PATCH] i386: Add ratelimit for bus locks acquired in guest

2021-03-31 Thread Chenyi Qiang
Hi Paolo, Do we have any comment for this Bus lock VM exit QEMU patch? On 3/17/2021 4:47 PM, Chenyi Qiang wrote: Virtual Machines can exploit bus locks to degrade the performance of system. To address this kind of performance DOS attack, bus lock VM exit is introduced in KVM and it will report

Re: [RFC PATCH] i386: Add ratelimit for bus locks acquired in guest

2021-03-21 Thread Chenyi Qiang
On 3/19/2021 8:37 PM, Marcelo Tosatti wrote: On Fri, Mar 19, 2021 at 10:59:20AM +0800, Chenyi Qiang wrote: Hi Marcelo, Thank you for your comment. On 3/19/2021 1:32 AM, Marcelo Tosatti wrote: On Wed, Mar 17, 2021 at 04:47:09PM +0800, Chenyi Qiang wrote: Virtual Machines can exploit bus

Re: [RFC PATCH] i386: Add ratelimit for bus locks acquired in guest

2021-03-18 Thread Chenyi Qiang
On 3/19/2021 9:23 AM, Xiaoyao Li wrote: On 3/17/2021 4:47 PM, Chenyi Qiang wrote: [...]   MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run)   {   X86CPU *x86_cpu = X86_CPU(cpu); @@ -4236,6 +4271,11 @@ MemTxAttrs kvm_arch_post_run(CPUState *cpu, struct kvm_run *run

Re: [RFC PATCH] i386: Add ratelimit for bus locks acquired in guest

2021-03-18 Thread Chenyi Qiang
Hi Marcelo, Thank you for your comment. On 3/19/2021 1:32 AM, Marcelo Tosatti wrote: On Wed, Mar 17, 2021 at 04:47:09PM +0800, Chenyi Qiang wrote: Virtual Machines can exploit bus locks to degrade the performance of system. To address this kind of performance DOS attack, bus lock VM exit

[RFC PATCH] i386: Add ratelimit for bus locks acquired in guest

2021-03-17 Thread Chenyi Qiang
w/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Signed-off-by: Chenyi Qiang --- hw/i386/x86.c | 6 ++ include/hw/i386/x86.h | 7 +++ target/i386/kvm/kvm.c | 44 +++ 3 files changed, 57 insertions(

[PATCH 2/2] target/i386: Expose VMX entry/exit load pkrs control bits

2021-02-05 Thread Chenyi Qiang
Expose the VMX exit/entry load pkrs control bits in VMX_TRUE_EXIT_CTLS/VMX_TRUE_ENTRY_CTLS MSRs to guest, which supports the PKS in nested VM. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 4 ++-- target/i386/cpu.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git

[PATCH 0/2] Remaining work for PKS Implementation

2021-02-05 Thread Chenyi Qiang
implemention at: https://lore.kernel.org/qemu-devel/20210127093540.472624-1-pbonz...@redhat.com/ This patch series is just to add the remaining part, i.e. the support for save/load PKRS and expose the vmx entry/exit load controls to guest. Chenyi Qiang (2): target/i386: Add support for save/load

[PATCH 1/2] target/i386: Add support for save/load IA32_PKRS MSR

2021-02-05 Thread Chenyi Qiang
PKS introduces MSR IA32_PKRS(0x6e1) to manage the supervisor protection key rights. Page access and writes can be managed via the MSR update without TLB flushes when permissions change. Add the support to save/load IA32_PKRS MSR in guest. Signed-off-by: Chenyi Qiang --- target/i386/kvm/kvm.c

[PATCH] target/i386: Add bus lock debug exception support

2021-02-02 Thread Chenyi Qiang
off-by: Chenyi Qiang --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ae89024d36..55f3b5829f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -963,7 +963,7 @@ sta

[PATCH v6 2/3] target/i386: fix model number and add missing features for Icelake-Server CPU model

2020-07-14 Thread Chenyi Qiang
Add the missing features(sha_ni, avx512ifma, rdpid, fsrm, vmx-rdseed-exit, vmx-pml, vmx-eptp-switching) and change the model number to 106 in the Icelake-Server-v4 CPU model. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 14 ++ 1 file changed, 14 insertions(+) diff --git

[PATCH v6 3/3] target/i386: add the missing vmx features for Skylake-Server and Cascadelake-Server CPU models

2020-07-14 Thread Chenyi Qiang
Add the missing vmx features in Skylake-Server and Cascadelake-Server CPU models based on the output of Paolo's script. Signed-off-by: Chenyi Qiang --- target/i386/cpu.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6afc59d8ff

  1   2   >