Page MenuHomeFreeBSD

arm64: Fix off-by-one in its_init_cpu_lpi
ClosedPublic

Authored by cperciva on Thu, Mar 27, 8:31 PM.
Tags
None
Referenced Files
F113515465: D49542.id.diff
Sun, Mar 30, 10:31 PM
F113489323: D49542.id152771.diff
Sun, Mar 30, 2:46 PM
F113484686: D49542.id152762.diff
Sun, Mar 30, 1:12 PM
F113474725: D49542.id152805.diff
Sun, Mar 30, 10:06 AM
Unknown Object (File)
Sun, Mar 30, 3:06 AM
Unknown Object (File)
Fri, Mar 28, 5:58 PM
Unknown Object (File)
Thu, Mar 27, 10:44 PM

Details

Summary

The low bits of GICR_PROPBASER are defined as

The number of bits of LPI INTID supported, minus one, by the LPI
Configuration table starting at Physical_Address.

but flsl(1 << n) returns n + 1; use ilog2_long instead.

PR: 285677
Reported by: Julien Grall
Sponsored by: Amazon

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/arm64/arm64/gicv3_its.c
804

It looks like this would also work, and make it more obvious what is intended.

FWIW I don't have any particular way to test this, except that I've booted an EC2 instance with this patch and everything seems to be working fine. But it seems like an obviously-correct change per the documentation.

This revision is now accepted and ready to land.Fri, Mar 28, 8:04 AM
This revision was automatically updated to reflect the committed changes.

Not finding a documentation for the likes of ilog2_long, I gather that (trying to reference mostly mathematics, not programming language implementation details):

Given 1<n for the context here (see later note related to "size" vs. "ilog2" lower bounds):
Given positive integer N is (unsigned long) n:
Given integer ilog2 is ilog2_long(n):

ilog2 is such that: 1 <= ilog2 && Power(2,ilog2) <= N < Power(2,ilog2+1)
Does that seem right for ilog2, other than possibly n and ilog2's lower bounds?

Then, given non-negative integer size is ilog2-1:
(Note: 0<ilog2 is then required if I got ilog2's relationships to n correct above)

size is such that: 0<=size && Power(2,size+1) <= N < Power(2,size+2)
Does that seem right for the end result for the size value that is intended in this code?