qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH 06/16] target/arm: Add sve infrastructure for page lookup


From: Richard Henderson
Subject: Re: [PATCH 06/16] target/arm: Add sve infrastructure for page lookup
Date: Fri, 17 Apr 2020 20:11:35 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 4/16/20 6:03 AM, Peter Maydell wrote:
>> +#ifdef CONFIG_USER_ONLY
>> +    memset(&info->attrs, 0, sizeof(info->attrs));
> 
> Could just write "info->attrs = {};" ?

Not quite.  Correct syntax would be attrs = (MemTxAttrs){ }.
I don't see that as an improvement over memset though.

>> +    int16_t mem_off_first[2];
>> +    int16_t reg_off_first[2];
>> +    int16_t reg_off_last[2];
> 
> It would be helpful to document what these actually are,
> and in particular what the behaviour is if the whole thing
> fits in a single page. (Judging by the code, the elements
> at index 1 for the 2nd page are set to -1 ?)

Yes, that's right.  I've added some more detail here.

>> +    intptr_t reg_off_first = -1, reg_off_last = -1, reg_off_split;
>> +    intptr_t mem_off_last, mem_off_split;
>> +    intptr_t page_split, elt_split;
>> +    intptr_t i;
> 
> intptr_t seems like a funny type to be using here, since these
> aren't actually related to pointers as far as I can tell.

They're used as array indexes.  If we use "int", the compiler keeps
re-extending the value.

>> +    memset(info, -1, offsetof(SVEContLdSt, page));
> 
> I guess this isn't conceptually much different from zeroing
> out integer struct fields, but it feels a bit less safe somehow.

It seems easier than setting 9 fields separately...

>> +    page_split = -(addr | TARGET_PAGE_MASK);
> 
> What is the negation for ?

Computation of remaining bytes in the page:

    -(x | TARGET_PAGE_MASK)
  = -(x | -TARGET_PAGE_SIZE)
  = TARGET_PAGE_SIZE - (x & -TARGET_PAGE_SIZE)

We use this all over qemu.


r~



reply via email to

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