[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/device-tree: Allow exact match for overlapping regions


  • To: Julien Grall <julien@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 13 Nov 2024 16:52:51 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1sQFyZQFtnGoRqBplKJRTT9kx/TP/CUgJLrPAUz1Iq8=; b=RYcmRMy20HZ8XXcdhlFUv/N3d9ttSvUV87wQDKyY+8X5B4k1Re8OWUa6ZZHNCsxH3H8Nx6QLMn2PuaA0930BZqOwTNPt7FVYuEyTnOH5EYBjKsPxfBrWEOvy220CmzjeDMFaitJNey3wl+Y3/bETNDorl2TXDyCw8QS1OHSAqUMhYDxgFT+oWJ3hjMOnfkkdmjL0k5zOKnt1wvJCA6MD7lx/XUN0zw4i5GuvnyOoGXMfE1ZJm/9LfkQZvWBOAjregIxj3ieDnReohbhdY0WR+KI8Q+zkgVRR8N/9m22pSpbWi5Da5CKUcwwobXbMy8bpq8RNLPngtQbZtK6MVtesaA==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=1sQFyZQFtnGoRqBplKJRTT9kx/TP/CUgJLrPAUz1Iq8=; b=hNgBzbh0MgGlSAHPdG6hSEALJ89m8dbcYt5v8U85hyGjAaWaoPIKcUZQA7bJwvx8ETvEV/1tRHA4FPHYpUPKFEz0WFbupdtnrHuACS25ZdrpHbsKgf4dXAw4uVDVXg8TCtSaYe3J1KYegrnFpi2x2bnndzs/7ckig6wrPlVcqsx6c0fdLMI8opWZHnlqTH4WLt6RDBQXbF6WBD8BuFYwt6PWw7Bvzohi5oSlybE8bZievoEzfc9kUsRxRr9gKCtQerpS1jrs9EcPv+WFq0Mb1lAZ/0hKDN9Ws34ulPsOVAYvJJDTXCMNsopw/XIj9Pu3QG6QalexGNRrPZkl0jCfFQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=B4MvkENbA8QZoRxjA8muN+8lcNCp0P4rnTTsS6dJt2u9JfvD1TeANjQx6rRc6knfU63U7BWyn3twMiAE103QWZSBr/NWDWOj4o4ekb6vmgdSAGUMOuMTkJXcKEJuoRi0Fn22DHDrS0b++2/tPV+4nJKJtJOUTkMNpCpyD6/5JpxMXgEgbC4biaRu2Tog/zDbiykArH03c9Hdsb02BuSw9CA46tfup8JZ8JZc7tOxqN6Jwlq52YCGpS9iHmyUraa2r8ItTC1iMiNdbjAN9mZIEkyEaEf7s6m1qRe0p6B9RY/Z66F9HqSKHqTlKppMrZLGzBbToSsyllys3z9trNnfpg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V4aa8YtVDB5EZ0wVczMztNYHyDZsa5d6C6CTx/uqHzcHyQ7+af2ghznlKPulJwi+F1cJKapc8W9uEoVbNhN7bgsNi2Xvz0Sm/ApcsA/CBY86rtgh52JL0L5qSBf7oSMnwRQUbQpDkHotFal96NpdBMGNlJ5R7Zx/yN35/bJtAlN0diNkmeGWFJdcSTxFHmFZByr0eGBII2RfCE9WeLDXx4V+hytNSPFXG1rfmkgPvCaQNOF8huq0uC40c8wLIfiu4nKCXVbH2t1gHfvQTFe4cHjCKxPxZeo9hhHSms1EV+BNoP2D/dewZQdTA4Tq9V4LZFJNGZXICU7zR1mFy+WH9A==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Delivery-date: Wed, 13 Nov 2024 16:53:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHbNdR4b2V2aTQ740yGxnKF6IdbXLK1RlIAgAALhoCAABtMgA==
  • Thread-topic: [PATCH] xen/device-tree: Allow exact match for overlapping regions

Hi Julien,


>>>> -        }
>>>> +
>>>> +        if ( (allow_match_type != MEMBANK_NONE) &&
>>>> +             (region_start == bank_start) && (region_end == bank_end) &&
>>> 
>>> Why is this only an exact match?
>> Apparently what we are fixing is only a case where memreserve regions 
>> matches exactly modules or reserved_mem nodes.
> 
> TBH, as I replied to Michal, I don't understand why we are just focusing on 
> just one issue. It would be good to provide some rationale.

I’m not sure why some DT out there are providing memory ranges reserved in both 
resvmem and reserved_memory node, could it be
that it was needed because some firmware was reading only one of the two before 
starting linux? I’m just thinking out loud.

Is your point that we should allow instead not only exact matching but also 
partial matching?

>>>> 
>>>> +
>>>> +#ifdef CONFIG_STATIC_SHM
>>>> +        /*
>>>> +         * Static shared memory banks don't have a type, so for them 
>>>> disable
>>>> +         * the exact match check.
>>>> +         */
>>> 
>>> This feels a bit of a hack. Why can't we had a default type like you did in 
>>> meminfo_add_bank()?
>> This is the structure:
>> struct membank {
>>     paddr_t start;
>>     paddr_t size;
>>     union {
>>         enum membank_type type;
>> #ifdef CONFIG_STATIC_SHM
>>         struct shmem_membank_extra *shmem_extra;
>> #endif
>>     };
>> };
> 
> Anonymous union are really annoying... So effectively in 
> check_reserved_regions_overlap() we are hoping that the caller will not set 
> allow_match_type to another value than MEMBANK_NONE for static memory. This 
> is extremely fragile.
> 
> I can't think of another solution right now, but I am definitely not happy 
> with this approach.

I agree it’s not nice, but the issue is not in 
check_reserved_regions_overlap(), it is in meminfo_overlap_check() which is 
static and so confined to that module.

Anyway I’m trying to think about another solution.

> 
>> we did that in order to save space when static shared memory is not enabled, 
>> so we can’t have the
>> type for these banks because we are already writing shmem_extra.
>> We could remove the union but in that case we would waste space when static 
>> shared memory is
>> enabled.
> 
> Can you remind me how much memory this is going to save?

The space issue comes from:

#define NR_MEM_BANKS 256

[…]

struct meminfo {
    struct membanks_hdr common;
    struct membank bank[NR_MEM_BANKS];
};

struct bootinfo {
    struct meminfo mem;
    /* The reserved regions are only used when booting using Device-Tree */
    struct meminfo reserved_mem;

    […]

#ifdef CONFIG_ACPI
    struct meminfo acpi;
#endif
    […]
};

So in case we remove the union and CONFIG_STATIC_SHM=y and so we allow type and 
*shmem_extra to coexist, we have 256 * 2 * sizeof(pointer) byte.
Additionaly if CONFIG_ACPI=y, we have 256 * sizeof(pointer) byte more not used 
space.

Cheers,
Luca


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.