qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] memory: Align and add helper for comparing


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 1/2] memory: Align and add helper for comparing MemoryRegionSections
Date: Wed, 14 Aug 2019 19:35:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 8/14/19 7:25 PM, Dr. David Alan Gilbert wrote:
> * Philippe Mathieu-Daudé (address@hidden) wrote:
>> Hi David,
>>
>> On 8/13/19 12:29 PM, Dr. David Alan Gilbert (git) wrote:
>>> From: "Dr. David Alan Gilbert" <address@hidden>
>>>
>>> MemoryRegionSection includes an Int128 'size' field;
>>> on some platforms the compiler causes an alignment of this to
>>> a 128bit boundary, leaving 8 bytes of dead space.
>>> This deadspace can be filled with junk.
>>>
>>> Move the size field to the top avoiding unnecsssary alignment
>>
>> "unnecessary"
> 
> Oops thanks.
> 
>> This is enough change to be in its own commit.
>>
>> ---
>>
>>> and provide an 'eq' routine to safely compare MRS's.
>>
>> This is another change, and should be squashed in the next patch IMO.
> 
> OK, what I'll do is I'll split this one into two ; I feel better
> having the extra function here separate from the next commit.

Thanks, feel free to add to both:
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>

>> Doesn't Clang warn about unused 'static inline' btw?
> 
> I was using gcc; but we seem to have loads of static inline's - what
> would make this one different?

I guess I was confused with 'static (no-inline)' :)

>>>
>>> Signed-off-by: Dr. David Alan Gilbert <address@hidden>
>>> ---
>>>  include/exec/memory.h | 14 +++++++++++++-
>>>  1 file changed, 13 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/exec/memory.h b/include/exec/memory.h
>>> index 606250172a..ce62e847bd 100644
>>> --- a/include/exec/memory.h
>>> +++ b/include/exec/memory.h
>>> @@ -487,15 +487,27 @@ static inline FlatView 
>>> *address_space_to_flatview(AddressSpace *as)
>>>   * @nonvolatile: this section is non-volatile
>>>   */
>>>  struct MemoryRegionSection {
>>> +    Int128 size;
>>>      MemoryRegion *mr;
>>>      FlatView *fv;
>>>      hwaddr offset_within_region;
>>> -    Int128 size;
>>>      hwaddr offset_within_address_space;
>>>      bool readonly;
>>>      bool nonvolatile;
>>>  };
>>>  
>>> +static inline bool MemoryRegionSection_eq(MemoryRegionSection *a,
>>> +                                          MemoryRegionSection *b)
>>> +{
>>> +    return a->mr == b->mr &&
>>> +           a->fv == b->fv &&
>>> +           a->offset_within_region == b->offset_within_region &&
>>> +           a->offset_within_address_space == 
>>> b->offset_within_address_space &&
>>> +           int128_eq(a->size, b->size) &&
>>> +           a->readonly == b->readonly &&
>>> +           a->nonvolatile == b->nonvolatile;
>>> +}
>>> +
>>>  /**
>>>   * memory_region_init: Initialize a memory region
>>>   *
>>>
> --
> Dr. David Alan Gilbert / address@hidden / Manchester, UK
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]