Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3079731pxb; Sat, 9 Oct 2021 00:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztk0q2pijJzjxFON0IfjBOiPF1X4id7ZAS9rTOlj+V0IqaMCg5kLqrwhu9jV4vqZi62HJI X-Received: by 2002:a17:906:7fc9:: with SMTP id r9mr9747467ejs.542.1633765976946; Sat, 09 Oct 2021 00:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633765976; cv=none; d=google.com; s=arc-20160816; b=x+4mQYNmAgGBk38XKcap8zgQfyH3HXQwIiafAWubJ9eMvGyXDHjvJOGeNPrWyVVAsV hE9kk7QP4cznXd1o6SJJn+rdJw09yI3aOx4hHyFH5Kq42J099XtsJ/5ApHt27Jy3J0dM GYdZC8GkcQobH3SJ9psrdibrUsDZAfwHLybvU+nmUvboe8CV6KCGbO6Rf5iPek+TVScF EI0C2lCf4Y6xpUPcMsadZbkTJMzv/etmHoGztPjR1wk5Aa4jPeqht8N+2BR2RVSrLVcn sFoTwBXCH/Lb+88Qxk6x/urVv8o4xk4KQF2AnKtYpWtNj/JLv427mc1RA6We/VRKmklP 8EpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :dlp-version:dlp-reaction:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=J3L0TZqExFAGCtFt7q9/rX+khp2WU4ew+AnIQF7VC/4=; b=nlf0AuObiuxDhB5GfboOQFHUycyrT7j+Mcq6h9N1k6bg3zE+GSNt0efl4lAEWmELEn lt8casENr1YaHJ4XBuyNP/pGW2gio0fq0h7Ym5/Fn6P+RwLHNkiQsKahcrtlMuf9T/Yd aibdJ72zFj0uUtGiasShXQQuCPaU1Ns4hdxXfiCqHOWGj0DC8fADH9luM2V+zoaQzbhH XQFJUxasfCenXKDFn/vkKFPxhn9UttwYMy5Xv6C+WFJEYAmlUZInreSFmIbbjuMiMvss twFytvkPNQDeuFGK7wBTcHB9WZyGwZG0b9giTgootkC/RFQ8c3OX8gxMbYkOQ/qE5Ntc eBjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x21si2403274eje.216.2021.10.09.00.52.32; Sat, 09 Oct 2021 00:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229885AbhJIHw7 convert rfc822-to-8bit (ORCPT + 99 others); Sat, 9 Oct 2021 03:52:59 -0400 Received: from mga02.intel.com ([134.134.136.20]:64852 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229683AbhJIHw6 (ORCPT ); Sat, 9 Oct 2021 03:52:58 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10131"; a="213786643" X-IronPort-AV: E=Sophos;i="5.85,360,1624345200"; d="scan'208";a="213786643" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2021 00:51:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,360,1624345200"; d="scan'208";a="440881816" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga003.jf.intel.com with ESMTP; 09 Oct 2021 00:51:00 -0700 Received: from shsmsx602.ccr.corp.intel.com (10.109.6.142) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Sat, 9 Oct 2021 00:50:59 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.109.6.141) by SHSMSX602.ccr.corp.intel.com (10.109.6.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Sat, 9 Oct 2021 15:50:58 +0800 Received: from shsmsx601.ccr.corp.intel.com ([10.109.6.141]) by SHSMSX601.ccr.corp.intel.com ([10.109.6.141]) with mapi id 15.01.2242.012; Sat, 9 Oct 2021 15:50:57 +0800 From: "Wang, Wei W" To: "Yamahata, Isaku" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , "erdemaktas@google.com" , "Connor Kuehl" , Sean Christopherson , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" CC: "Yamahata, Isaku" , "isaku.yamahata@gmail.com" , Sean Christopherson , Kai Huang , "Li, Xiaoyao" Subject: RE: [RFC PATCH v2 07/69] KVM: TDX: define and export helper functions for KVM TDX support Thread-Topic: [RFC PATCH v2 07/69] KVM: TDX: define and export helper functions for KVM TDX support Thread-Index: AQHXb45gwUyUjxU7oUmevY7jRUUgu6vK2P1A Date: Sat, 9 Oct 2021 07:50:57 +0000 Message-ID: References: <4fe4ce4faf5ad117f81d411deb00ef3b9657c842.1625186503.git.isaku.yamahata@intel.com> In-Reply-To: <4fe4ce4faf5ad117f81d411deb00ef3b9657c842.1625186503.git.isaku.yamahata@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.200.16 x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, July 3, 2021 6:04 AM, Isaku Yamahata wrote: > Subject: [RFC PATCH v2 07/69] KVM: TDX: define and export helper functions > for KVM TDX support > +/* > + * Setup one-cpu-per-pkg array to do package-scoped SEAMCALLs. The > +array is > + * only necessary if there are multiple packages. > + */ > +int __init init_package_masters(void) > +{ > + int cpu, pkg, nr_filled, nr_pkgs; > + > + nr_pkgs = topology_max_packages(); > + if (nr_pkgs == 1) > + return 0; > + > + tdx_package_masters = kcalloc(nr_pkgs, sizeof(int), GFP_KERNEL); Where is the corresponding kfree() invoked? (except the one invoked on error conditions below) > + if (!tdx_package_masters) > + return -ENOMEM; > + > + memset(tdx_package_masters, -1, nr_pkgs * sizeof(int)); > + > + nr_filled = 0; > + for_each_online_cpu(cpu) { > + pkg = topology_physical_package_id(cpu); > + if (tdx_package_masters[pkg] >= 0) > + continue; > + > + tdx_package_masters[pkg] = cpu; > + if (++nr_filled == topology_max_packages()) > + break; > + } > + > + if (WARN_ON(nr_filled != topology_max_packages())) { > + kfree(tdx_package_masters); > + return -EIO; > + } Best, Wei