Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3071033rdb; Wed, 15 Nov 2023 21:51:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvx77P+LGm9B8E4sWIpaiylKkNwvM5nfGX/kiTY3Xr94rwMqaAxAk1wHUOSeTAP3gr7eTh X-Received: by 2002:a05:6808:6541:b0:3b6:dc6f:2741 with SMTP id fn1-20020a056808654100b003b6dc6f2741mr17105365oib.19.1700113905958; Wed, 15 Nov 2023 21:51:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700113905; cv=none; d=google.com; s=arc-20160816; b=Ep9UQSJjlfO7Jaq5wJoRe9CEdtHH9CKLrz2abTPaZGGjaxmAa0qVzuzs+osKIZr1dE 9WQN/VeNecfcfPntpBTsYHu8NB77kEvyjD1HHAiC6yvuosOYzzKlpePoZVgftrvvNriZ OLJuGOM5vKQ997oxwfwIO5ly2Tj1GRFTRzMnj3rC7OEqlTDV86GeXwNeg7W8MGB68NUK ZoYwdJBZnUZmiWO1wzA1mWxbA0RcYbnzDxNa/UIUIH6/H6iPQxad7q5FwmEbO3PcV5su QPRcPG4PSBu0xDsFH1sfRkVw9SNWDcIel6B0cDNNnaUTG2CVauHOWLx0vESXx2FEBu/w A5+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature:dkim-filter; bh=Zo6SeTAF1Hkz5Nt+v04S4U19Noi+Vl6KiRux2UuD7MU=; fh=JyTljRUf35biO/ztB/Nkeh8y8bGwEzQjJCXTm3oSYH4=; b=OCllWDhXgTBcfUR1y1E9Uuw4BySQnSUiEKlPhXWB/iFl+p1vwXhYCPn9TRPPHCDgpB KIwhCO7t6OYlb1iusVVRW9H7SDRKUzZE1v2yJVjcDWIT4xFeYYi0DzDWrqzeT78ibElI jMYW0nBgtMJUywsK9PgonedLJPXNuj8KrGaGI+rNdbYSXq5dxeI5MUkA+ghPKQh6NMUh DdyZaxAr3iPUgAWDkbOkEHAwXlYkMU5kcPngwUDlYZjcEbRCDEj/btlI5xnk2dz5J05p MCpTpf1lfXdVHvyam01Q4a56UxuxH123Ll/eETKSlypx4YfX2YDsKUYbSHjxJJFW0C3+ fRGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2023111101 header.b=nrw9EdqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id 1-20020a631641000000b005b935872b48si11252982pgw.537.2023.11.15.21.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 21:51:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2023111101 header.b=nrw9EdqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 50185801D8D8; Wed, 15 Nov 2023 21:51:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230236AbjKPFvf (ORCPT + 99 others); Thu, 16 Nov 2023 00:51:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229786AbjKPFve (ORCPT ); Thu, 16 Nov 2023 00:51:34 -0500 Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398BD18B for ; Wed, 15 Nov 2023 21:51:31 -0800 (PST) Received: from [IPv6:::1] ([172.58.204.72]) (authenticated bits=0) by mail.zytor.com (8.17.1/8.17.1) with ESMTPSA id 3AG5owIE3896720 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Wed, 15 Nov 2023 21:51:00 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 3AG5owIE3896720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2023111101; t=1700113861; bh=Zo6SeTAF1Hkz5Nt+v04S4U19Noi+Vl6KiRux2UuD7MU=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=nrw9EdqTVcJW0ErdRH3ZGisI0o7N2tUIqJAJoicndB1w+lzptswHGtxcnULSaAcFn SkU+AddcOHpINBiOYuBp76DSYAOq9mmLq96iWbZrY8mGIclJMZZy0q8yx9Aly669tv Nm0SDI5G8P6/BHh0s7ysIFH7QgwhjKnwCyxRJiSVHhi3j+6G0jJxFG6HNEvoAFkIVt 2ACfypAznF+nOZRAKb4C03mXk8o++8/snfH9rXx2QabLgIbrHgv0/Zjcfoh7JBq61s DwXr7NRNGWJZEmTA5yb6tcpjLaqURqTli5hNTuoNxf2dv8jCPGRgtzvE2fPSdJ7p5r EDY/FqZkFuu3g== Date: Thu, 16 Nov 2023 00:50:46 -0500 From: "H. Peter Anvin" To: Michael Roth , Dave Hansen CC: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Tom Lendacky , Joerg Roedel , linux-kernel@vger.kernel.org Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v2=5D_x86=3A_Ensure_input_to_pfn?= =?US-ASCII?Q?=5Fto=5Fkaddr=28=29_is_treated_as_a_64-bit_type?= User-Agent: K-9 Mail for Android In-Reply-To: <20231115224231.xmxfktqcb4sls3fb@amd.com> References: <20231115201431.820278-1-michael.roth@amd.com> <20231115224231.xmxfktqcb4sls3fb@amd.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 21:51:43 -0800 (PST) On November 15, 2023 5:42:31 PM EST, Michael Roth wrote: >On Wed, Nov 15, 2023 at 12:48:58PM -0800, Dave Hansen wrote: >> On 11/15/23 12:14, Michael Roth wrote: >> > While it might be argued that the issue is on the caller side, other >> > archs/macros have taken similar approaches to deal with instances lik= e >> > this, such as commit e48866647b48 ("ARM: 8396/1: use phys_addr_t in >> > pfn_to_kaddr()")=2E >>=20 >> Gah, I really hope nobody is arguing that for real, or is even thinking >> about this as a valid argument=2E > >Not that I'm aware, but I did have my own doubts initially, which is >why I thought it warranted a note in the commit just in case it came up >from someone else=2E > >>=20 >> The helper should, well, help the caller=2E It makes zero sense to me >> that every single call site would need to know if the argument's type >> was big enough to hold the _return_ value=2E This nonsense can only ev= en >> happen with macros=2E Type promotion would just do the right thing for >> any sanely declared actual helper function=2E > >My thought was that it is easier to expect developers to know the pitfall= s >of bit-field types, since it is universally applicable to all C code, >whereas expecting developers to anticipate such issues when writing simil= ar >macros is potentially harder to enforce/audit and could lead to similar >issues popping up as things are refactored over time and new macros get >added that don't take such usages into account=2E > >But neither argument seems to hold up in reality=2E Experienced developer= s >obviously do fall victim to the subtleties of of bit-field types, and >kernel devs obviously do tend to address these instances in more robust >ways based on the various pfn-related macros I looked through=2E > >-Mike Now, if you are doing a cast, you are making the macro unusable for assemb= ly anyway; any reason not to make it an inline function at that point?