[PATCH 1/1] platform: generic: allwinner: avoid buffer overrun

Samuel Holland samuel at sholland.org
Tue Dec 27 11:12:05 PST 2022


On 12/27/22 12:52, Andreas Schwab wrote:
> On Dez 27 2022, Samuel Holland wrote:
> 
>> I am aware. However, this sort of change is not feasible for
>> plic_context_save()/plic_context_restore(). It would severely complicate
>> those functions with extra bit manipulation (thus wasting even more
>> space in code size).
> 
> If your compiler is so dumb you have a much bigger problem.

I'm disappointed that I even have to explain this...

"This sort of change" to avoid using space for IRQ 0, thus saving one
*bit* in the array used by plic_context_save(), would require combining
two registers into one array element with shifts:

	enable[i] = plic_get_ie(plic, context_id, i) >> 1 |
	            plic_get_ie(plic, context_id, i + 1) << 31;

and doing the opposite transformation in plic_context_restore(). The
compiler is not going to optimize that out.

If you really care about shaving off bytes, there is plenty of
low-hanging fruit elsewhere in OpenSBI. This bikeshed really does not
need painting.

Regards,
Samuel




More information about the opensbi mailing list