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

Re: [PATCH for-4.19] xen/arm: static-shmem: fix "gbase/pbase used uninitialized" build failure


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 19 Jun 2024 14:06:28 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=+RtgDtAPbd+xYchkX/zQp44H7l0HbIK1trRzkvXzwJI=; b=GCIMNP5dE6In674IXqlyodZ2loZ3MYpSpU3fineVLhujYliB6fyVmYBBO+HUH8oJgKYHWum/PTfcWEUu59tkdWRyPIEhzMCH11xKmuQZSvwSyD1GdvGGhF2Gl8gz4e3GVJbMFqSUzGDT0BlX7gbRoLb2dfYRyq7wE15KLoSwMNi42l1o6R66z+1gzB2ZiT5KmsrjytEjRUrVdgf+OOovGtBrvMkN9++X+xVS8rzHTP2q9TwEGg/NlsvJpMh0HTZ1lKngxGldZDhoDUM7dk1r1sA6iWMFLGtZ9ctZP7fn02tDG/GZmbTlT3+ntpAAFu0An1saP407hUMlXDdFU6W76w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fc0GhekVQZU5qYJyRs/SUr4Xu0dEViyzikumWRe8q3mgxyGyTcMJjBylFNEtUZZL24Cxx5vMfLJxWpEWDkJl2HbQ/qgcIGjO56YPdg+sN0AfTBTqjYZ+DxOu/2TrvoZjBWLbLLBeZivM7jIx0k7hbMCBtz+EWVM+vcXhCZQovhye4eLqjRjykmSs/+nRhg1MNbFICwBEtbgwn/2+K5DrllQ0nTPF8tSPKiFKFUAEvKbWsMmPYyCoGwsPjERwf8D7S6zeMF1JkwSsf5lnNoaLPQGvRMvpx4unbOdzUsR/pbyLDB4YiiQixwbPqfEuhN8pqf0ti/rtGYu+PcUbXayfmA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 19 Jun 2024 12:06:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 19/06/2024 13:55, Julien Grall wrote:
> 
> 
> Hi Michal,
> 
> On 19/06/2024 07:46, Michal Orzel wrote:
>> Building Xen with CONFIG_STATIC_SHM=y results in a build failure:
>>
>> arch/arm/static-shmem.c: In function 'process_shm':
>> arch/arm/static-shmem.c:327:41: error: 'gbase' may be used uninitialized 
>> [-Werror=maybe-uninitialized]
>>    327 |         if ( is_domain_direct_mapped(d) && (pbase != gbase) )
>> arch/arm/static-shmem.c:305:17: note: 'gbase' was declared here
>>    305 |         paddr_t gbase, pbase, psize;
>>
>> This is because the commit cb1ddafdc573 adds a check referencing
>> gbase/pbase variables which were not yet assigned a value. Fix it.
>>
>> Fixes: cb1ddafdc573 ("xen/arm/static-shmem: Static-shmem should be 
>> direct-mapped for direct-mapped domains")
>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>> ---
>> Rationale for 4.19: this patch fixes a build failure reported by CI:
>> https://gitlab.com/xen-project/xen/-/jobs/7131807878
>> ---
>>   xen/arch/arm/static-shmem.c | 13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/arm/static-shmem.c b/xen/arch/arm/static-shmem.c
>> index c434b96e6204..cd48d2896b7e 100644
>> --- a/xen/arch/arm/static-shmem.c
>> +++ b/xen/arch/arm/static-shmem.c
>> @@ -324,12 +324,6 @@ int __init process_shm(struct domain *d, struct 
>> kernel_info *kinfo,
>>               printk("%pd: static shared memory bank not found: '%s'", d, 
>> shm_id);
>>               return -ENOENT;
>>           }
>> -        if ( is_domain_direct_mapped(d) && (pbase != gbase) )
>> -        {
>> -            printk("%pd: physical address 0x%"PRIpaddr" and guest address 
>> 0x%"PRIpaddr" are not direct-mapped.\n",
>> -                   d, pbase, gbase);
>> -            return -EINVAL;
>> -        }
>>
>>           pbase = boot_shm_bank->start;
>>           psize = boot_shm_bank->size;
>> @@ -353,6 +347,13 @@ int __init process_shm(struct domain *d, struct 
>> kernel_info *kinfo,
>>               /* guest phys address is after host phys address */
>>               gbase = dt_read_paddr(cells + addr_cells, addr_cells);
>>
>> +            if ( is_domain_direct_mapped(d) && (pbase != gbase) )
>> +            {
>> +                printk("%pd: physical address 0x%"PRIpaddr" and guest 
>> address 0x%"PRIpaddr" are not direct-mapped.\n",
>> +                       d, pbase, gbase);
>> +                return -EINVAL;
>> +            }
>> +
> 
> Before this patch, the check was globally. I guess the intention was it
> covers the two part of the "if". But now, you only have it in when
> "paddr" is specified in the DT.
> 
>  From a brief look at the code, I can't figure out why we don't need a
> similar check on the else path. Is this because it is guarantee that
> will be paddr == gaddr?
The reason why I added this check only in the first case is due to what doc 
states.
It says that if a domain is 1:1, the shmem should be also 1:1 i.e. pbase == 
gbase. In the else
case the pbase is omitted and thus a user cannot know and has no guarantee what 
will be the backing physical address.
Thus, reading this doc makes me feel that for 1:1 guests user needs to specify 
pbase == gbase.

~Michal




 


Rackspace

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