On Fri, 2022-03-04 at 11:49 -0800, isaku.yamahata@xxxxxxxxx wrote: > + /* > + * In case of TDP MMU, fault handler can run concurrently. Note > + * 'source_pa' is a TD scope variable, meaning if there are multiple > + * threads reaching here with all needing to access 'source_pa', it > + * will break. However fortunately this won't happen, because below > + * TDH_MEM_PAGE_ADD code path is only used when VM is being created > + * before it is running, using KVM_TDX_INIT_MEM_REGION ioctl (which > + * always uses vcpu 0's page table and protected by vcpu->mutex). > + */ > + WARN_ON(kvm_tdx->source_pa == INVALID_PAGE); We can just KVM_BUG_ON() and return here. > + source_pa = kvm_tdx->source_pa & ~KVM_TDX_MEASURE_MEMORY_REGION; > + > + err = tdh_mem_page_add(kvm_tdx->tdr.pa, gpa, hpa, source_pa, &out); > + if (KVM_BUG_ON(err, kvm)) > + pr_tdx_error(TDH_MEM_PAGE_ADD, err, &out); > + else if ((kvm_tdx->source_pa & KVM_TDX_MEASURE_MEMORY_REGION)) > + tdx_measure_page(kvm_tdx, gpa); > + > + kvm_tdx->source_pa = INVALID_PAGE;