From: Glenn Miles <mil...@linux.vnet.ibm.com> XIVE crowd sizes are encoded into a 2-bit field as follows: 0: 0b00 2: 0b01 4: 0b10 16: 0b11
A crowd size of 8 is not supported. Signed-off-by: Glenn Miles <mil...@linux.vnet.ibm.com> Signed-off-by: Michael Kowal <ko...@linux.ibm.com> --- hw/intc/xive.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/intc/xive.c b/hw/intc/xive.c index d5fbd9bbd8..565f0243bd 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -1687,7 +1687,26 @@ static uint8_t xive_get_group_level(bool crowd, bool ignore, uint8_t level = 0; if (crowd) { - level = ((ctz32(~nvp_blk) + 1) & 0b11) << 4; + /* crowd level is bit position of first 0 from the right in nvp_blk */ + level = ctz32(~nvp_blk) + 1; + + /* + * Supported crowd sizes are 2^1, 2^2, and 2^4. 2^3 is not supported. + * HW will encode level 4 as the value 3. See xive2_pgofnext(). + */ + switch (level) { + case 1: + case 2: + break; + case 4: + level = 3; + break; + default: + g_assert_not_reached(); + } + + /* Crowd level bits reside in upper 2 bits of the 6 bit group level */ + level <<= 4; } if (ignore) { level |= (ctz32(~nvp_index) + 1) & 0b1111; -- 2.43.0