From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50A21ECAAA1 for ; Tue, 1 Nov 2022 13:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbiKANfK (ORCPT ); Tue, 1 Nov 2022 09:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiKANfG (ORCPT ); Tue, 1 Nov 2022 09:35:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5378B2192 for ; Tue, 1 Nov 2022 06:34:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667309651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PKW8Pf1E15nZeyxIsBODYnAk76ngwldQbrSOxueGd64=; b=ZX9XDB86TWIacEWeuNTFMQQtTR/pD94MmPBEry2AhfW2XMApeqTgd3y4esNy+SxD3cF52x /wtdWUT9Wpww6qmfVA/IODg/49/2qICwRjLNZIM/YQ8mFEKOJ8GJxnSxUg5Q7amarOLsVH ZMCqbbxPcDV1oVXCIf//IJooWldHlU8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-fCgu297eO-KoonOoEZ4tQw-1; Tue, 01 Nov 2022 09:34:06 -0400 X-MC-Unique: fCgu297eO-KoonOoEZ4tQw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2716D1C0896B; Tue, 1 Nov 2022 13:34:05 +0000 (UTC) Received: from fedora (unknown [10.22.32.201]) by smtp.corp.redhat.com (Postfix) with SMTP id 62B504B4011; Tue, 1 Nov 2022 13:34:00 +0000 (UTC) Date: Tue, 1 Nov 2022 10:33:59 -0300 From: Wander Lairson Costa To: Greg Kroah-Hartman Cc: Sathyanarayanan Kuppuswamy , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Shuah Khan , Jonathan Corbet , "H . Peter Anvin" , "Kirill A . Shutemov" , Tony Luck , Kai Huang , 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 v16 2/3] virt: Add TDX guest driver Message-ID: <20221101133359.r572wy7pku6e65dr@fedora> References: <20221028002820.3303030-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20221028002820.3303030-3-sathyanarayanan.kuppuswamy@linux.intel.com> <01f437c1-9330-6fb5-d692-6cd500d8adf8@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 30, 2022 at 07:53:19AM +0100, Greg Kroah-Hartman wrote: > On Sat, Oct 29, 2022 at 04:17:39PM -0700, Sathyanarayanan Kuppuswamy wrote: > > Hi Greg > > > > On 10/27/22 11:25 PM, Greg Kroah-Hartman wrote: > > > On Thu, Oct 27, 2022 at 05:28:19PM -0700, Kuppuswamy Sathyanarayanan wrote: > > > > >> + > > >> +static long tdx_guest_ioctl(struct file *file, unsigned int cmd, > > >> + unsigned long arg) > > >> +{ > > >> + switch (cmd) { > > >> + case TDX_CMD_GET_REPORT: > > >> + return tdx_get_report((void __user *)arg); > > > > > > You know the type of this pointer here, why not cast it instead of > > > having to cast it from void * again? > > > > The only place we use arg pointer is in copy_from_user() function, > > which expects void __user * pointer. So why cast it as struct > > tdx_report_req * here? > > Because then your function will show the true type and you don't have to > cast it again. > If we are taking this route, isn't better to move the copy_from_user call to tdx_guest_ioctl and pass the resulting struct tdx_report_req pointer to tdx_get_report?