Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp119943pxb; Thu, 7 Apr 2022 00:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBQSSpp//mlDxia7y7Zo6yZ18AhrUVMqpsZBS6NLTlaQDZMdrszKWZA1fPykboqp0xqn4x X-Received: by 2002:a17:907:d16:b0:6d6:e3b6:9cd8 with SMTP id gn22-20020a1709070d1600b006d6e3b69cd8mr11815856ejc.94.1649316482716; Thu, 07 Apr 2022 00:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649316482; cv=none; d=google.com; s=arc-20160816; b=GCc+v8XO5t9wtYWGsAhDNJDsLXmc2qt0ZZl0ICzlFm3rysgyuEkoueudc+6+Mi7Eng JEbbzpG80uqQ6A3vR0fhg7q72vUwji+Svjc15FW1JDyetanhSIPgAMrbfLrgv5uU15AZ ldDCwD8lBc/qtsXdRk0XR99EDhK9zQad9uMxLtH1oy/1NNItzynvsFNMs+GJG4yFKl+B u4uiRAaG9hoFShOIUM2GC93YnxFcAjYMUknMZjZ1uWDiKu28/YHtyibMfKEIKLnhGkRx M2kRrOv3rRzDBBy15zJhjDg2YmKdo2tSQjT58PQgnrpvckDz1ieMQTY4cY+cNACIN5mn ONYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=687zhQ0j2vRVB+E4bKwXTFRfqRCZJMqkWqqI9jKsgDA=; b=OFSyjNPB7GgFB8kjxtMLSYf04Bxkuk9li9J1JoxIOYfhwTuvbE3m9chRej75/+L8fe 2C58oYyXAbRdFFtfysUuaym6ayIn1uTH8cdlaCkBbDkeQSYL8rzA4n842xrPQ5vO3epS iUTsTUfRJ9jU8IO8SpP9neQiPmNx5b41pMkKbVSz7c2QHf3om6GzFvrE5yc9Ake7HzJL NFrlfBI3g6hPioKSPVwjvZestyo+1zWbx/Dw+7pGrt4Oz1Sm6FuNy6IfHvu18MlKf758 rOokhBK5LjQSMceLtBSN0i2LfKt3f7MHLbJkmBgudzcmiZ2oNvgMdgQOimiKnkN0Hlyc fJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="L6Xqj/b6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a0564020f0400b0041d0996a04csi573158eda.324.2022.04.07.00.27.37; Thu, 07 Apr 2022 00:28:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="L6Xqj/b6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239132AbiDGCc1 (ORCPT + 99 others); Wed, 6 Apr 2022 22:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbiDGCcV (ORCPT ); Wed, 6 Apr 2022 22:32:21 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A36001F976F; Wed, 6 Apr 2022 19:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649298622; x=1680834622; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=3IwYZPATgkappCyO7E3fAkypHvxH0ctVxZsQ7qKYG8g=; b=L6Xqj/b6Xr5Nohvye9I30Ge52wO6s0gN6oA2CPZA3zeadLpdagbwpARC juaEv5oiSUzuvELGlZwwd9TCpR+cGodanLuATGefMHvFPjUqIA8egHZ65 AA+m6NuFxbkmDkpGHo5n/yj5+AIsMuyaHo/9UmktfyaYnW2cxWPHEPBGA 8rPd1C3Qn/y8I8wVNxJEZWEUDNUd/gdkzr7thvKlaCIdK0O/Csg8FHjNn XoI6PgLVS/F+Er62AYgqyNES+v8xrgwxJOPjZegwvSM12+tJSVTYgXQD2 RpxZlgJlISUm3Sps6tGT8TlTTVH2FdILvMrzeKG5rRSjJN8ZtJUsmi5i3 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="241802742" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="241802742" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:30:22 -0700 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="642303315" Received: from mgailhax-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.55.23]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:30:20 -0700 Message-ID: <7749a232f617a5474f1c362935ec459418e678a5.camel@intel.com> Subject: Re: [RFC PATCH v5 060/104] KVM: TDX: Create initial guest memory From: Kai Huang To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Paolo Bonzini , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Date: Thu, 07 Apr 2022 14:30:18 +1200 In-Reply-To: <676ece0bb9acb3bdc66c969c0f33520abbc1c265.1646422845.git.isaku.yamahata@intel.com> References: <676ece0bb9acb3bdc66c969c0f33520abbc1c265.1646422845.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-03-04 at 11:49 -0800, isaku.yamahata@intel.com 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;