Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2712572imn; Tue, 2 Aug 2022 13:08:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1utQolgkagJ4ECyySEhbOYt+OM2Lv4lZo2wwQqGNifS+EkJ+8nh8keNyx1563PloEISI4iO X-Received: by 2002:a17:906:7950:b0:72f:d4a4:564d with SMTP id l16-20020a170906795000b0072fd4a4564dmr17420114ejo.479.1659470937210; Tue, 02 Aug 2022 13:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659470937; cv=none; d=google.com; s=arc-20160816; b=tUPL+TFBHlzPm/Xhk/Iq8+KsE2iif2ZRz6+ahSpD0QRD7+MpAhXMN1epr9d1RDwTyA AwwnF44x4Z4gR618JGdzxP5cFjM9bE72xvcVCcBl0jbdcrcQcOzcMKw6yCo5HId2Rauv neaWYSNEUAx/RkdJ5b1qjakGp+1iMuEDu11hZqJShi4AhqNHAgFAsLQZtG3rs56mLQo4 NkKOYyFXnRXQBrb6eB3R3Ayr8OsxZRldDnMm0dl/6EXcISP1xxdG9AvZwqZnU1lZiMo5 qT02rzfRSuq+l9rb70dSbo4pJIGrY6Jtgc6LY47+0PS6exZxrGcMAMyZIpTd7Yo/Pd9E BFDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ifexnCMHYvvlc34nu1xb2qsCA6kxwpy+X5K2hbG8gi8=; b=qWzrRYpGjkR5pq//5InCWIVdLCBoOHgRFpiq5EHZjHRs0RzNvQhjOpAxKR1j/b+4+x FodUszSkIE08dFx4O0msA/HzTUkF6vw7+QkCW6JvFnSU5YtJqmA56OdGxtQh5HTQ4h+2 nlGGRU+4YKgOLEqVV1oAwLPrHlmH4QQWIY0qU3eBdQbyh0qhnC2K7zx1sMSnP9geQBXU Pj6TZ5zss4GEko2mS3ra7ZZlNfNZO+eUktifA+BWJEwqFQf5ZzL9/ktoKQYWVhbnwB40 IEKfgsdlq32OHw8IXSFy/LFMovNf8Xx9YPPi2++vkpsxTd6W5AxieJuZnaE40ltPMZ+L c+hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PHXYjGFl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a4-20020a17090640c400b0072b01ae9c69si12312841ejk.694.2022.08.02.13.08.31; Tue, 02 Aug 2022 13:08:57 -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=@google.com header.s=20210112 header.b=PHXYjGFl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232190AbiHBT4N (ORCPT + 99 others); Tue, 2 Aug 2022 15:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiHBT4L (ORCPT ); Tue, 2 Aug 2022 15:56:11 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1E7FD1A for ; Tue, 2 Aug 2022 12:56:10 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 206so9757429pgb.0 for ; Tue, 02 Aug 2022 12:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=ifexnCMHYvvlc34nu1xb2qsCA6kxwpy+X5K2hbG8gi8=; b=PHXYjGFlIIXjhXIBuPjNt53vqsnJaXzf/SlvkNEMo+ps28jBD6Ez/yl7i4fDsL/ODz RGKdOQr+K3zKh7Qn+pPq6ceQ3B7cbr7+M1Qfb3odpg8oYs/KZDQ8kjFzsTRDaU3/xtfs IgLMDz7I/u8hact9Ohz75x2gbWl1DKRhxV2dau4ueFhopzIfAUZUGBRROy8GnjHK9RKE SoFluR8JyeawX0BHnCOJ1RpyE56kC0uo/W+1r9hi/HWHJYr1P19Ngr5Bh/TN5EFhAElo mUBDlZQRgq5TYKts03lE/vTqHac2FwQeK495/HqSD0w3oAbcc21xMFG3+AgALrmD8X1X By4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=ifexnCMHYvvlc34nu1xb2qsCA6kxwpy+X5K2hbG8gi8=; b=gvP8u2SzRkCeRDkuBx7DtYY2/sldNEB/8VKqvJvopso57J3XI4ykfg+XUR+1pk43aX 0/IS4XLY7zuBnZUT1sHgZVY7spSwRSS1mI+MKuypRjfpS8u+SIYSMfqLOsTFmw0XwW6Q Ej/cEZJBFmUPUDnANbyy/ke8QSmsbVhITwfG2t2m6+fbfp8uoLE/dtkgOzyPV1deX57j xM/1NYwSrqFDyHsKiBWBiCejpJjdjoG9y3Tt/Zesb9I1JDNJhaWjOeC0OIZP+yKpRsJj BchG/PUA2zCc0WAn5hqGJGGWE75/TMKHu590JOcFDenJzuIBP97jiY4J9yQBDmep3TOF mX7Q== X-Gm-Message-State: AJIora+cCDI9jHyySVqmKPJLVxOXdBCGFS8y3yIy0at5VHvp7xP/8eUQ Nhih8ASzlA90dm1V9Ft7aVaGkg== X-Received: by 2002:a05:6a00:248b:b0:52b:f07b:796c with SMTP id c11-20020a056a00248b00b0052bf07b796cmr21929332pfv.47.1659470170306; Tue, 02 Aug 2022 12:56:10 -0700 (PDT) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id t14-20020aa7946e000000b0052d9b4bd8fasm4229798pfq.38.2022.08.02.12.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 12:56:09 -0700 (PDT) Date: Tue, 2 Aug 2022 19:56:05 +0000 From: Sean Christopherson To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini Subject: Re: [PATCH v7 028/102] KVM: TDX: allocate/free TDX vcpu structure Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Mon, Jun 27, 2022, isaku.yamahata@intel.com wrote: > +int tdx_vcpu_create(struct kvm_vcpu *vcpu) > +{ > + struct vcpu_tdx *tdx = to_tdx(vcpu); > + int ret, i; > + > + /* TDX only supports x2APIC, which requires an in-kernel local APIC. */ > + if (!vcpu->arch.apic) > + return -EINVAL; > + > + fpstate_set_confidential(&vcpu->arch.guest_fpu); > + > + ret = tdx_alloc_td_page(&tdx->tdvpr); > + if (ret) > + return ret; > + > + tdx->tdvpx = kcalloc(tdx_caps.tdvpx_nr_pages, sizeof(*tdx->tdvpx), > + GFP_KERNEL_ACCOUNT); > + if (!tdx->tdvpx) { > + ret = -ENOMEM; > + goto free_tdvpr; > + } > + for (i = 0; i < tdx_caps.tdvpx_nr_pages; i++) { > + ret = tdx_alloc_td_page(&tdx->tdvpx[i]); > + if (ret) > + goto free_tdvpx; > + } Similar to HKID allocation for intrahost migration, can the TDVPX allocations be moved to KVM_TDX_INIT_VCPU?