On 06.09.2024 20:06, Andrew Cooper wrote:
> On 04/09/2024 2:30 pm, Jan Beulich wrote:
>> @@ -1094,13 +1094,13 @@ static int hvmemul_linear_mmio_access(
>>      if ( cache == NULL )
>>          return X86EMUL_UNHANDLEABLE;
>>  
>> -    chunk = min_t(unsigned int, size, PAGE_SIZE - offset);
>> +    ASSERT(size <= PAGE_SIZE - offset);
> 
> Do we really want a plain assert, or should we go with
> 
>     if ( size > PAGE_SIZE - offset )
>     {
>         /* Callers should have arranged not to cross a page boundary */
>         ASSERT_UNREACHABLE();
>         return X86EMUL_UNHANDLEABLE;
>     }
> 
> This is hardly a fastpath, and it's rather safer.

I can switch, sure, yet to be honest it was already feeling a little
like going too far to have the assertion, considering the obviousness
of all callers guaranteeing this. The only reason I decided to add
one is the remaining concern of there, at some point, possibly being
single memory operands exceeding PAGE_SIZE. Yet nothing comes
anywhere near that right now; whole AMX tiles are 1k "only", and tile
rows / columns are even further restricted. Of course, if and when we
add XSAVE/XRSTORE emulation ...

Jan

Reply via email to