On 7/2/2025 11:10 PM, Xiaoyao Li wrote:
On 7/2/2025 10:16 PM, Xiaoyao Li wrote:
On 5/23/2025 11:44 PM, Kirill Martynov wrote:
Certain error conditions can trigger x86_cpu_dump_state() to output CPU state
debug information e.g. KVM emulation failure due to misbehaving guest.
However, if the CPU is in System Management Mode (SMM) when the assertion
in cpu_asidx_from_attrs failure happens because:

1. In SMM mode (smm=1), the CPU must use multiple address spaces
    with a dedicated SMM address space
2. On machine types with softmmu, address spaces are hardcoded to 1
    (no multiple address spaces available)

The assertion occurs in cpu_asidx_from_attrs() when trying to
access memory in SMM mode with insufficient address spaces.

Fix this by:
1. If number of address spaces is 1 always use index 0
2. In other cases use attr.secure for identified proper index

This prevents the assertion while still providing useful debug
output during VM shutdown errors.

To me,  it's just a workaround to avoid the assertion.

When attrs.secure is 1, it means it's in SMM mode. As you describe above,

 > 1. In SMM mode (smm=1), the CPU must use multiple address spaces
 >     with a dedicated SMM address space

So I think we need to first figure out why it gets attrs.secure as 1 when there is only 1 address space.

Ah, with KVM, QEMU can only support 1 address space.

In fact, KVM does support different address space for supporting SMM mode. There is KVM_CAP_MULTI_ADDRESS_SPACE to report how many address space is supported by KVM.

(It turns out my memory on KVM is correct. I was misled by QEMU code and comment)

QEMU allocates separate KVM address space for SMM in register_smram_listener(). But the address space doesn't associated with cpu's address space.

I think this patch can only avoid the assertion in you case when vcpu is in SMM mode with KVM. But with this patch, do you get the correct info of SMM mode dumped? I guess no, since the info is of address space 0, not the SMM address space.

If there is no reason of cannot associate KVM's address space with cpu's address space, I think the right fix is to enable the association with them.


Reviewed-by: Xiaoyao Li <xiaoyao...@intel.com>

Based on above, I need to withdraw my Reviewed-by.


  }
  static inline AddressSpace *cpu_addressspace(CPUState *cs, MemTxAttrs attrs)





Reply via email to