Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1558255rdb; Wed, 20 Sep 2023 12:32:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCRxVgWt59Xf0AeF1dTtrYZZsJoT0sW/7wULaVsMEdcpNg/qPTBcL/6oitiE8tmXRP+cMn X-Received: by 2002:a05:6358:430c:b0:129:d242:f782 with SMTP id r12-20020a056358430c00b00129d242f782mr3634484rwc.0.1695238360502; Wed, 20 Sep 2023 12:32:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695238360; cv=none; d=google.com; s=arc-20160816; b=fBvNTXO8UvupqNFDFwfSFZC2gj0UtX55pB5Ewdg9Ufe5NP1bmY63YN2OseUTXR2iRR ijhqnL//yMKQT0T+1dAKOJBGE+uLo3V1MHfp9VU0TKv1xQLVoTYnt0lwxYo/gBkRhpyp xB9epB10w1FzfrnO3V4O2S0YqrscyK+IEc1bjBNHt92eGS5NCw9pCUQrrvKEqvdaRhU3 0TIADOknywUs/gJGxL9fsWjemeNpByThJti4aazZ3wzW+j31tOF8uS7rxDVu+qmVcEqU 39na80aMG+qeP8UAW7+BTIa6i+XoKzjxBxfJd49qMFlonhLEKim/+DIgNNJtkN4PkoJ4 i9Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6XXtXtlUcDJ+4vhbej+qThcFmLlRD1LV1+Q4af8lSLQ=; fh=eCG3jbs+eLMdOqpyI8r2I98gfcYXx1T645hWeDuk4eQ=; b=W6GWggzvOWIhs+z1Scm6T27QfhoHJMWs9IY5VPImY5lFZlJPMCuT4dD7SqC242YCdN LRAtZTAodXsR84Hfd2MDn6J3ygUJNz5FqTjyVts61F6ER4e+XXVau0vWV4c4VxHy81g+ 2we5K2N0hp2Iji65J3BLcNTBBLuASuQDDYltkXLHfR9rLCJVAVvxdXAqfKXORBzoyYww 12HZzCxaDkivQq1j5hBnixNFRnS0yY2wpu8yvZxdRdORBuR2KtF/71luBZs43YOU78pU kg1cM0iWxO0ahctnFbCPwaZ/Sxec6IyXLYf1Zy8cU1Rt/2+qU7IPqNG/PEVIwADsRnr3 4K3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hCX952Ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l10-20020a654c4a000000b0056aea4cc1c9si12228735pgr.653.2023.09.20.12.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:32:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hCX952Ui; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 06B9E8028B96; Wed, 20 Sep 2023 08:27:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235241AbjITP1s (ORCPT + 99 others); Wed, 20 Sep 2023 11:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234467AbjITP1q (ORCPT ); Wed, 20 Sep 2023 11:27:46 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7364D8F for ; Wed, 20 Sep 2023 08:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695223660; x=1726759660; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KijHtpRJFl9wBZjIYL7/l4jdXyNhLusYqik2sns1Gmg=; b=hCX952Uiz5ton0qgd+P/pBfuEokmBSWqRLzsDlxb+p/Z1ZtsxYRob5Dg +j8+93CSEJulMWQoD0z8xyZkDlOpSL8rYBHxeQswNJERfnoU9V1d+xmw4 1kB5FtdZjieOnIB47ajXvBYyZmFCJvbxdxtUWb8rMSdcW7BYo1vhu6lef xC0itopQ85oPyN5iveKOx9+ftrxxnufSuV5ESff/KF1xD7MNKmIoyrqN6 5YDjjJYBt8rEJmK7qXP5LBDPVjX2Gtn/r50dKUtm4jhKzczpAFvmLvGFC 63QBqLXygxWXJ7u3vp3f4LG13LG8KZ0k3pfeuglLJZAJSZSyKw7mZtt8R g==; X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="370566109" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="370566109" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 08:27:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10839"; a="889970093" X-IronPort-AV: E=Sophos;i="6.03,162,1694761200"; d="scan'208";a="889970093" Received: from pkmanna-mobl3.amr.corp.intel.com (HELO [10.209.53.192]) ([10.209.53.192]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2023 08:26:50 -0700 Message-ID: <0031e031-10a8-43b1-a29c-8e1cf913eaad@linux.intel.com> Date: Wed, 20 Sep 2023 08:27:39 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] virt: tdx-guest: Add Quote generation support using TSM_REPORTS Content-Language: en-US To: "Kirill A . Shutemov" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Dan Williams , "H . Peter Anvin" , Tony Luck , Wander Lairson Costa , Erdem Aktas , Dionna Amalie Glaze , Qinkun Bao , Guorui Yu , linux-coco@lists.linux.dev, x86@kernel.org, linux-kernel@vger.kernel.org References: <20230914031349.23516-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20230920131633.ig6ldmwavpu7uhss@box.shutemov.name> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20230920131633.ig6ldmwavpu7uhss@box.shutemov.name> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 20 Sep 2023 08:27:55 -0700 (PDT) On 9/20/2023 6:16 AM, Kirill A . Shutemov wrote: >> +static u8 *tdx_report_new(const struct tsm_desc *desc, void *data, size_t *outblob_len) >> +{ >> + struct tdx_quote_buf *quote_buf = quote_data; >> + int ret; >> + u8 *buf; >> + u64 err; >> + >> + if (mutex_lock_interruptible("e_lock)) >> + return ERR_PTR(-EINTR); >> + >> + /* >> + * If the previous request is timedout or interrupted, and the >> + * Quote buf status is still in GET_QUOTE_IN_FLIGHT (owned by >> + * VMM), don't permit any new request. >> + */ >> + if (quote_buf->status == GET_QUOTE_IN_FLIGHT) { >> + ret = -EBUSY; >> + goto done; >> + } >> + >> + if (desc->inblob_len != TDX_REPORTDATA_LEN) { >> + ret = -EINVAL; >> + goto done; >> + } >> + >> + /* TDX attestation only supports default format request */ >> + if (desc->outblob_format != TSM_FORMAT_DEFAULT) { >> + ret = -EINVAL; >> + goto done; >> + } >> + >> + u8 *reportdata __free(kfree) = kmalloc(TDX_REPORTDATA_LEN, GFP_KERNEL); > __free() is new to me. Good to know. > > But are we okay now with declaring variables in the middle of the > function? Any reason we can't do at the top? Declaring variables at the top is no longer a hard requirement. The main reason for declaring it here is to use __free cleanup function. If we use top declaration, then we have free it manually. -- Sathyanarayanan Kuppuswamy Linux Kernel Developer