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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68B91C636CD for ; Tue, 7 Feb 2023 10:59:41 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.491013.759945 (Exim 4.92) (envelope-from ) id 1pPLh6-00034v-Nu; Tue, 07 Feb 2023 10:59:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 491013.759945; Tue, 07 Feb 2023 10:59:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pPLh6-00034o-KW; Tue, 07 Feb 2023 10:59:24 +0000 Received: by outflank-mailman (input) for mailman id 491013; Tue, 07 Feb 2023 10:59:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pPLh5-00034i-7c for xen-devel@lists.xenproject.org; Tue, 07 Feb 2023 10:59:23 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061f.outbound.protection.outlook.com [2a01:111:f400:7eab::61f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 79132d81-a6d6-11ed-933c-83870f6b2ba8; Tue, 07 Feb 2023 11:59:21 +0100 (CET) Received: from SN6PR12MB2621.namprd12.prod.outlook.com (2603:10b6:805:73::15) by DS7PR12MB6118.namprd12.prod.outlook.com (2603:10b6:8:9a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Tue, 7 Feb 2023 10:59:18 +0000 Received: from SN6PR12MB2621.namprd12.prod.outlook.com ([fe80::a3a7:87d9:60f1:7eb1]) by SN6PR12MB2621.namprd12.prod.outlook.com ([fe80::a3a7:87d9:60f1:7eb1%4]) with mapi id 15.20.6064.032; Tue, 7 Feb 2023 10:59:17 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 79132d81-a6d6-11ed-933c-83870f6b2ba8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QgVOz6Iry52/6xOV86Xhb5PEoR/2eEj02/qPFkJnR7i6k047DVMB3szSKVHs8oEUWgYHAIZmI/ycKVetSugnDB8MR7Ey9vOF5bo/0e6B5YBmW7YGKcvbVXti/goaEFGQYzyNooDKraHEpIhpQbq0QjWfj4PXGnTUT5j0g8wsqQ45bN92zIX978Oc9Hx4fj2jQdYNRf1y61IqYhvIlRtuxPhLrryO3qJy7s/5guv1DdSeeh6pi2tt5f4EGJ4q/gHqvHyaX2+zgYI+YkWrPapyJAGsM/5yiZBZJ7Mr2AwzquUSrlU1dPuN9y8AA/bck92ZOohE/z4TKnpJLVcRTn8BOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WCAtXlg2sBMSsdC3I4UNEaw5IkdMVpwGhBPHqAs9fGs=; b=LP0WmEawFm6V3CWUYCWvMaP0Ch5Na92MFRD1kMG0roh5mKkxcK7gnlJUAzcew0MsveonJ3AhNg3XchgnA40GRBHlcMER5XvdDegDtoOXt48688BS1BnXA7jCAd3dFeSh/vp0Cm+J9gnrXv3ozvEGvYnPbf7/MwqqmfCIlyaAhDfOcGihjHeIQGzNfUqVVBPkOat12UcXz1yQwjewlWulJ2IK0nvdKITiMbrIlbEeSIORJ899BkVF4xENXgvffrVe1cxubpx98EC/qrvwmWtNse2jHi3jn3ol+L7auuRE1em1rDAAe097JtfcW0uUj554wSaLduDz2agz2LQCck6PHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WCAtXlg2sBMSsdC3I4UNEaw5IkdMVpwGhBPHqAs9fGs=; b=U6VoxvnT3+TOdmC2lcXF9LyiF662tmWzwmwbxJzLSAB49Ub3T2f8KESI5gTDSkl4MrX/UQJCD7cmvoOkvzhXzD+amELkqmhaXcja83/DY8ai/5SAaPxfz/qooW1BydBnqjxdlkQq/mkVl40pwydysOcd4EtH7JCi/z8gR9PX3/Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Message-ID: Date: Tue, 7 Feb 2023 10:59:11 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [XEN v2 05/11] xen/arm: Use paddr_t instead of u64 for address/size To: Julien Grall , Stefano Stabellini , Ayan Kumar Halder Cc: xen-devel@lists.xenproject.org, stefano.stabellini@amd.com, Volodymyr_Babchuk@epam.com, bertrand.marquis@arm.com References: <20230117174358.15344-1-ayan.kumar.halder@amd.com> <20230117174358.15344-6-ayan.kumar.halder@amd.com> <8144403d-0899-5b25-f1b0-f798d4b371a6@amd.com> <4f98390c-1cf3-99f3-5131-a42a7ed4387a@xen.org> From: Ayan Kumar Halder In-Reply-To: <4f98390c-1cf3-99f3-5131-a42a7ed4387a@xen.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO3P265CA0024.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:387::19) To SN6PR12MB2621.namprd12.prod.outlook.com (2603:10b6:805:73::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN6PR12MB2621:EE_|DS7PR12MB6118:EE_ X-MS-Office365-Filtering-Correlation-Id: a4b052a1-77c3-4a93-daa4-08db08fa5b63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4hQlAL1SEK8xDvtsLXq28ROMlUXS2U2dt0BPMkaXdVb3tEHshILKRUp+O/LrjRsNzboiY4xx+wPepAEyij4HKAKKn7uephcC3Pty9tF5WzQXDQCVNapDI/+WmdeABvxHpw88cXMYo7AiPrPiin/GyE/1r+czcRq2bAYiEt6xgi+ct4gBALi7PfUCDvyouCVNSyZkEZQTaRupOhbWsmCa0439Y9OTVEawyYNwF/f08ltuQlmaew69/vy/pNtQPl1v1NQJ5vwyRHw5UXXj/aU7v3MykGI7odJ2IFVIS7MBQzIo73C3xsdPUnuFt9SijFxP/NlODJNwKOJa+ZOD7xjoC/B1QOFZ+7Cqxdo8387eCwHWIZGYzEmyDMqg9/OJpoT2FOOmvYLQHGbxbj2A7s4WHS5xr8EUr/SNxW4vymP3TeFbw7W+uatKo9xtUk0ZTa86flENjpjxzqIk6HrBCZ8S7qnLcHpEQWP0wn6iNUm7DHhmeGWya0BTKNnRICK5PNxA0kOrV29JbU1Z1nF1HXp+rEroVZrYUe3TWP1bL/kkwO9A1qDtoDb9s6FbG8r3uGTI6q4/2II4GBNsYquF84dlyEKR274dOjEDNijk/jFknS939EZ5tNvEZDF5CNy3U+rX1YpjBB8QemFG/Os4d+/2nDLaDuT+ISUowbESLB3ZPpz/dkg9lDEUtq8691ZcACouhd5VWcTvuHnftYbw3rUlazANiyNHtZ0j8vUI6l7IJ6ep/1ZmmA+zp1lTOC9xRNIXJaKFGNh5qaoebVD++M9ijg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2621.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(136003)(366004)(39860400002)(396003)(376002)(451199018)(31686004)(41300700001)(36756003)(6512007)(83380400001)(31696002)(26005)(2616005)(186003)(8676002)(6506007)(6666004)(478600001)(110136005)(6636002)(6486002)(316002)(66946007)(8936002)(66556008)(38100700002)(4326008)(53546011)(5660300002)(66476007)(2906002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eXl4QW1ycUYvWXhsaDlZaitKTzJjRHFNNndnOWdrajV6ZTZHc3BjN0NPMUUw?= =?utf-8?B?R2tHK01wQU51WnE3RXNPeVoyWm1KYWVTOHQxTjVYUGJUQmtIN0djRDZKTWxZ?= =?utf-8?B?SlErT2VqMUhrK0dBSzZKREJXZ2QxUmxXcDBoeXg2a1BLNWJ1RlNPVlNmZjc5?= =?utf-8?B?ZkthZnpFWHlFOFdESUVnTmtSSkY4ZS9aZVRHN0pSbkZyclpuM2wzZkExandK?= =?utf-8?B?MXkvemNRNSt4ekplWUdnL0U5VFNhSWViR09yVHVzRjZ2ZGV4aVplcTAra0Z1?= =?utf-8?B?REdtZVo0aHI3OERscGplQVJBZ2RUeHFrUkNiZHRaV1JtUnR5VVM3aTFuNVh4?= =?utf-8?B?U1plUEx4MnRjaStQVDZoMUFvVmVJVGVrc01rVTFzM0grakdETkQ1ZTNiQURw?= =?utf-8?B?TnZGZ2kwdWw0MUcwSyttY20ydklRSllqWmJzNWM0VUdOMGtZVmJmam9uUUQ3?= =?utf-8?B?N1F2bURLZC9SdE9LK3hDdllGWWp0aU9qalJvdUJ0NTJ3eFhrNzVwKz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INzRKY253MFM5SzQ3K0JETnBpNjZOMVRW?= =?utf-8?B?Q0Fnb1Z0K0hGMDVVdjZsSU55UlFPa2hVMVVqbnM4ZUhGQTBBMVgyWnh2aFR5?= =?utf-8?B?c3gwSGR5OHkxQjlxUG1HM1l2a1dzRlhjZFU4bjR1d2FRc2pBZExyQjZZczFX?= =?utf-8?B?WEc5ZFdyZzJaZ3FYQzBON08zVWEreWNDNjBaQkxYS2E1NHliNWFTREtTcGJJ?= =?utf-8?B?VW1IQ2NTaDFFNC9Rc3FUOEZqRzVRcEllcE5pTmVCNW03ZUg0cFdXcGdHK2Jo?= =?utf-8?B?cmJJeVRSTCtSNERQaC9wNjRCZ0dCaStxNnQzL0FEZ1lPSloyUjl2eE1ZbnhK?= =?utf-8?B?dmhBVy9vcm5maUFRWUJGYW9HSzBrbTFPTUdLbTJCRWZMWVFaako2Z0lEcnJr?= =?utf-8?B?TzFOZHZHeGFFZVRWUXVwY3AzSTlyY2hGMmFCb1R0RWdzK1pSTEI5am9OS0E4?= =?utf-8?B?RkdoMHA0NmsyZEdHemNkWmtjRkFkVW5Eek12aERFYTFOYzN3cEQyMlIwc05W?= =?utf-8?B?RzZTaXQ1NUNTTTRZVk4wMGxldWp5REJ2cndrTEc0WkVxYmtiNlE1Wjg2Q0I0?= =?utf-8?B?Lzl0bGpOaXRNQnFnOU9kTFdkbm9BNFhNT1VyVGd4V1Q5Ti9MR3RUY21Udkdw?= =?utf-8?B?aGJhZ0VUZ0N6MnBzVHlBd1RLQWJNUWJjeml1Q3F5RWQ0eUcyYzlmSVlIandE?= =?utf-8?Q?6AbatUHsoU8n3Pm6GtiiGSUX1?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4b052a1-77c3-4a93-daa4-08db08fa5b63 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2621.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2023 10:59:17.3517 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QIfDX0c6GUeebht15l1ucXjS8apWTu7PJoN7DY55cQTG9U2dMrgk8CGw8OXaSDJllWhdk3x8xCXwVZMgRS+c1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6118 Hi Julien, On 07/02/2023 09:03, Julien Grall wrote: > > > On 06/02/2023 19:21, Ayan Kumar Halder wrote: >> Hi Stefano, >> >> On 19/01/2023 23:24, Stefano Stabellini wrote: >>> On Tue, 17 Jan 2023, Ayan Kumar Halder wrote: >>>> One should now be able to use 'paddr_t' to represent address and size. >>>> Consequently, one should use 'PRIpaddr' as a format specifier for >>>> paddr_t. >>>> >>>> Signed-off-by: Ayan Kumar Halder >>>> --- >>>> >>>> Changes from - >>>> >>>> v1 - 1. Rebased the patch. >>>> >>>>   xen/arch/arm/domain_build.c        |  9 +++++---- >>>>   xen/arch/arm/gic-v3.c              |  2 +- >>>>   xen/arch/arm/platforms/exynos5.c   | 26 +++++++++++++------------- >>>>   xen/drivers/char/exynos4210-uart.c |  2 +- >>>>   xen/drivers/char/ns16550.c         |  8 ++++---- >>>>   xen/drivers/char/omap-uart.c       |  2 +- >>>>   xen/drivers/char/pl011.c           |  4 ++-- >>>>   xen/drivers/char/scif-uart.c       |  2 +- >>>>   xen/drivers/passthrough/arm/smmu.c |  6 +++--- >>>>   9 files changed, 31 insertions(+), 30 deletions(-) >>>> >>>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c >>>> index 72b9afbb4c..cf8ae37a14 100644 >>>> --- a/xen/arch/arm/domain_build.c >>>> +++ b/xen/arch/arm/domain_build.c >>>> @@ -1666,7 +1666,7 @@ static int __init find_memory_holes(const >>>> struct kernel_info *kinfo, >>>>       dt_for_each_device_node( dt_host, np ) >>>>       { >>>>           unsigned int naddr; >>>> -        u64 addr, size; >>>> +        paddr_t addr, size; >>>>           naddr = dt_number_of_address(np); >>>> @@ -2445,7 +2445,7 @@ static int __init handle_device(struct domain >>>> *d, struct dt_device_node *dev, >>>>       unsigned int naddr; >>>>       unsigned int i; >>>>       int res; >>>> -    u64 addr, size; >>>> +    paddr_t addr, size; >>>>       bool own_device = !dt_device_for_passthrough(dev); >>>>       /* >>>>        * We want to avoid mapping the MMIO in dom0 for the >>>> following cases: >>>> @@ -2941,9 +2941,10 @@ static int __init >>>> handle_passthrough_prop(struct kernel_info *kinfo, >>>>           if ( res ) >>>>           { >>>>               printk(XENLOG_ERR "Unable to permit to dom%d access to" >>>> -                   " 0x%"PRIx64" - 0x%"PRIx64"\n", >>>> +                   " 0x%"PRIpaddr" - 0x%"PRIpaddr"\n", >>>>                      kinfo->d->domain_id, >>>> -                   mstart & PAGE_MASK, PAGE_ALIGN(mstart + size) - >>>> 1); >>>> +                   (paddr_t) (mstart & PAGE_MASK), >>>> +                   (paddr_t) (PAGE_ALIGN(mstart + size) - 1)); >>> Why do you need the casts here? mstart is already defined as paddr_t >> >> Actually, this is because the PAGE_MASK is defined as 'long'. See >> xen/include/xen/page-size.h :- >> >> #define PAGE_SIZE           (_AC(1,L) << PAGE_SHIFT) >> #define PAGE_MASK           (~(PAGE_SIZE-1)) >> >> So, the resultant type inferred is 'long unsigned int'. Thus, we need >> to add an explicit cast. > > Hmmm... I am a bit confused with this statement. If the resultant type > inferred is actually 'long unsigned int', then why was the current > specifier worked before ('long unsigned int' is 32-bit on Arm32)? Before this change, mstart was of type paddr_t (ie u64 ie unsigned long long on Arm_32). When 'unsigned long long' was operated with 'long' (ie PAGE_SIZE), then the resultant type is 'unsigned long long'. The rule from 'C Standard 2011' (https://web.cs.dal.ca/~vlado/pl/C_Standard_2011-n1570.pdf) , page 53 (Section 6.3.1.8 Usual arithmetic conversions) is :- "Otherwise, if the operand that has unsigned integer type has rank greater or equal to the rank of the type of the other operand, then the operand with signed integer type is converted to the type of the operand with unsigned integer type." And from 6.3.1.1 "The rank of long long int shall be greater than the rank of long int, which shall be greater than the rank of int, which shall be greater than the rank of short int, which shall be greater than the rank of signed char. The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type, if any." And using 'PRIx64' to print 'unsigned long long' will not require any cast. Now with the change, mstart is of paddr_t (ie 'unsigned int'). 'unsigned int' operated with 'long', then  the result is 'unsigned long int'. As the rank of 'unsigned long int' > 'int', thus it cannot be printed using PRIx32 (integer format specifier) without an explicit cast. Please let me know if this makes sense. -Ayan > > Cheers, >