Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4036196rwi; Wed, 12 Oct 2022 09:44:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gbxHCK5zR4QOeAgtCKXL9izQlbUGgFB2/sBrti02IdngvN8VSOmEzGLIG+FtjzrPOTOjX X-Received: by 2002:a17:902:ecc4:b0:180:3104:2fc0 with SMTP id a4-20020a170902ecc400b0018031042fc0mr27605015plh.56.1665593051702; Wed, 12 Oct 2022 09:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665593051; cv=none; d=google.com; s=arc-20160816; b=YVbyxzsxfDFfdBHcDQS4xynYRVphTXYJNif9m7tTIB9DQepmTYUAn9784paQqTb5au xRJDPLJUb+p8KC3qhGzM+ZLA5cIukWN9gNzFSiFNUrbivjLLjDYJnBHDm0Iz5EoafGvP oE7PFLhgYGyQkzoxsM6lWJLDdJGydxPkwn8G9CUaSziu/8pQuPY2TiHd3HGSJQ8Z6+gq pVyas8qytsBv798ZEWkmJJ2j29TkJqtd7f5OrAwZRorf4SjT9NrtXVp2rFfjSGWBYaQk 933gZ905TEkrYf6+8vLSy04gFLuF2jodc1VkVVPCCMpmxWsKmmBiguYuXB0AFnSM0o7J eurw== 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=g7mSi/mJsFGPEQcaEjtRxPErjnMPo2rt/g78+/99fsk=; b=mgPl17OI+UtaqzJgWgbCljcPjm5F3yGDTrpXoQt8xSr7R9K0zlXRkakTlEBOwm6Wi/ 81QahLhL4M5jUW91+w+Rzqu7+Ggfwwm1EaXCwmaqyKZ8X2Zu0q2Xf0OFnhP4pb4XcGkK HeyXWujpvz/MAC+dH82XUuA22upQLxlLZz3jbMW0a6DEJlQhXHk8yehS3bOBF1QfAvwM WY770K87prgLKeWsgZ+Roy9HnV0zD4EqPKRfLksjPJHO2J74GNU70O7FVChVoqjjZ5EO H4YA+tHzhomUh2TS8dEmb/doSQrEp9Wmn4rGtQ9N/hLexj8mh/4Foj7hMt82/O7P8obI Z0Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l46iHQyN; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a63dc52000000b00460a6ee5b53si14959511pgj.37.2022.10.12.09.43.42; Wed, 12 Oct 2022 09:44:11 -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=@linuxfoundation.org header.s=korg header.b=l46iHQyN; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbiJLQXT (ORCPT + 99 others); Wed, 12 Oct 2022 12:23:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbiJLQXJ (ORCPT ); Wed, 12 Oct 2022 12:23:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886E9F41A5; Wed, 12 Oct 2022 09:22:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AE4426153D; Wed, 12 Oct 2022 16:22:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92F2FC433D7; Wed, 12 Oct 2022 16:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665591767; bh=UjNgOOyW8/JL74ooqVzEOOqGR0npOCxfJs6SbJ73/wI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l46iHQyNjBQ6EU86JIYM2uyZ18tQwF/6wGiGuRSEzRyPeOOiJday862Gc4rb6DLWs VZiLZ0oE286XiZ9XGG8TvG0FWkLm+BkFQPeIH206m/CCWU5i8m13MNF9ICuNxNz7fw /NVgy9W5SpN3W6kWvx/8RIojMjHSjfAdBJWw5EyQ= Date: Wed, 12 Oct 2022 18:23:31 +0200 From: Greg Kroah-Hartman To: Sathyanarayanan Kuppuswamy Cc: Borislav Petkov , Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, Shuah Khan , Jonathan Corbet , "H . Peter Anvin" , "Kirill A . Shutemov" , Tony Luck , Kai Huang , Wander Lairson Costa , Isaku Yamahata , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v14 1/3] x86/tdx: Make __tdx_module_call() usable in driver module Message-ID: References: <20220928215535.26527-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20220928215535.26527-2-sathyanarayanan.kuppuswamy@linux.intel.com> <6759025f-fc08-74f0-efd7-2331110dec0c@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6759025f-fc08-74f0-efd7-2331110dec0c@linux.intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Wed, Oct 12, 2022 at 08:44:04AM -0700, Sathyanarayanan Kuppuswamy wrote: > > > On 10/12/22 7:27 AM, Borislav Petkov wrote: > > On Wed, Oct 12, 2022 at 06:35:56AM -0700, Sathyanarayanan Kuppuswamy wrote: > >> So we should create a new wrapper for this use case or use > > > > Yes, you got it - a new wrapper pls. > > Ok. I will add a new wrapper to get the TDREPORT. > > +/* > > + * Add a wrapper for TDG.MR.REPORT TDCALL. It is used in TDX guest > > + * driver module to get the TDREPORT. > > + */ > > +long tdx_mcall_get_report(void *reportdata, void *tdreport, u8 subtype) Why "long"? Why void *? Don't you have real types for these? > > +{ > > + if (subtype || !reportdata || !tdreport) > > + return -EINVAL; How could that happen if you control all callers? > > + > > + /* > > + * Generate TDREPORT using "TDG.MR.REPORT" TDCALL. > > + * > > + * Get the TDREPORT using REPORTDATA as input. Refer to > > + * section 22.3.3 TDG.MR.REPORT leaf in the TDX Module 1.0 > > + * specification for detailed information. > > + */ > > + return __tdx_module_call(TDX_GET_REPORT, virt_to_phys(tdreport), > > + virt_to_phys(reportdata), subtype, 0, NULL); If you check for NULL, why are you not validating that these are valid pointers as well? You can't have it both ways. thanks, greg k-h