Skip to content

Commit 3907add

Browse files
committed
Merge tag 'pull-ppc-for-10.0-2-20250321' of https://gitlab.com/npiggin/qemu into staging
* Fix a KVM SMP guest hang. This is not completely trivial, but just small enough to merge it. If this causes any more problems, we can revert it and the timebase patch which exposed the underlying issue for release. * Fix a bunch of Coverity issues reported introduced in ppc, mostly in powernv code. * Fix a NetBSD boot bug on mac99 caused by VSX/VMX decodetree rewrite. * Fix the default CPU selection for older spapr machines. # -----BEGIN PGP SIGNATURE----- # # iQIzBAABCgAdFiEETkN92lZhb0MpsKeVZ7MCdqhiHK4FAmfdBbsACgkQZ7MCdqhi # HK50jxAAi38NfsYBXBFSStwQKTBfbuhjDP2A1wiJVDrcJydQXnZb/xCR+kgRdiZt # I5roIvD2bsbgHJtnCthLo0fQVGPIohsWUnnR6BlEAVN/gwW+8T+tNhLEZZ402+GK # bzc4pxqtFitS9m5gyAat2g8bfLEEpEmUr2uAJXnPMDDrzSwtbtlUgPKGXfppsyhp # P26Ut9M6dmPt+EMdJUTJ4RDOPuj53lXmDnbtpG9sA0zYXlG3sRe7nE9X0iKwXB4g # Yher/IHSyHVqFe3t9TX9m/DY1EU8fFX/GoShoIMLk8v5Sy1viIsUXpWiIn9O3h1E # WoAS6HvH3CdcHz3EC1XXSGEjEz2r75kPVvLC/wDy4DmXMxSnadodjGohbUkYs+26 # IV/Y3cnGTE2sPoP+vwmv7UKzBncKzTQO2luLkTQzX+x6XGr1MQPdAIm4WW9KfQVq # VMS06/oqlQQ8gspAWpNo86P+8/hpFlN42dEE+mzARJkm1JNrO+0yMj8OB/og1o92 # T585TOpPDLm8ZeY8fETpgJ0rR4AKb+5e9KnbmS7XuvIWPK/G7OOt5gF8YXiT9yKw # R77TPm7Evq6zJ9+TQ4KPBqn4LumphXiBWsSpsVcmZqTTf7nKqii0ZdO8asrtn8oN # pgJ9AgAlnlCUIn4a/sDJ6k/HhC19IxyfC+y4bgsevwGOmo8H43s= # =SYBy # -----END PGP SIGNATURE----- # gpg: Signature made Fri 21 Mar 2025 02:22:51 EDT # gpg: using RSA key 4E437DDA56616F4329B0A79567B30276A8621CAE # gpg: Good signature from "Nicholas Piggin <[email protected]>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 4E43 7DDA 5661 6F43 29B0 A795 67B3 0276 A862 1CAE * tag 'pull-ppc-for-10.0-2-20250321' of https://gitlab.com/npiggin/qemu: target/ppc: Fix e200 duplicate SPRs target/ppc: Fix facility interrupt checks for VSX ppc/spapr: fix default cpu for pre-9.0 machines. ppc/amigaone: Constify default_env ppc/amigaone: Check blk_pwrite return value ppc/pnv: Fix system symbols in HOMER structure definitions ppc/pnv: Move the PNOR LPC address into struct PnvPnor ppc/spapr: Fix possible pa_features memory overflow ppc/xive2: Fix logical / bitwise comparison typo pnv/xive: Fix possible undefined shift error in group size calculation ppc/xive: Fix typo in crowd block level calculation ppc/spapr: Fix RTAS stopped state Signed-off-by: Stefan Hajnoczi <[email protected]>
2 parents 5eb0849 + 73c0c90 commit 3907add

File tree

17 files changed

+194
-146
lines changed

17 files changed

+194
-146
lines changed

hw/intc/xive.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,31 +1662,52 @@ uint32_t xive_get_vpgroup_size(uint32_t nvp_index)
16621662
* (starting with the least significant bits) in the NVP index
16631663
* gives the size of the group.
16641664
*/
1665-
return 1 << (ctz32(~nvp_index) + 1);
1665+
int first_zero = cto32(nvp_index);
1666+
if (first_zero >= 31) {
1667+
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid group index 0x%08x",
1668+
nvp_index);
1669+
return 0;
1670+
}
1671+
1672+
return 1U << (first_zero + 1);
16661673
}
16671674

16681675
static uint8_t xive_get_group_level(bool crowd, bool ignore,
16691676
uint32_t nvp_blk, uint32_t nvp_index)
16701677
{
1678+
int first_zero;
16711679
uint8_t level;
16721680

16731681
if (!ignore) {
16741682
g_assert(!crowd);
16751683
return 0;
16761684
}
16771685

1678-
level = (ctz32(~nvp_index) + 1) & 0b1111;
1686+
first_zero = cto32(nvp_index);
1687+
if (first_zero >= 31) {
1688+
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid group index 0x%08x",
1689+
nvp_index);
1690+
return 0;
1691+
}
1692+
1693+
level = (first_zero + 1) & 0b1111;
16791694
if (crowd) {
16801695
uint32_t blk;
16811696

16821697
/* crowd level is bit position of first 0 from the right in nvp_blk */
1683-
blk = ctz32(~nvp_blk) + 1;
1698+
first_zero = cto32(nvp_blk);
1699+
if (first_zero >= 31) {
1700+
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid crowd block 0x%08x",
1701+
nvp_blk);
1702+
return 0;
1703+
}
1704+
blk = first_zero + 1;
16841705

16851706
/*
16861707
* Supported crowd sizes are 2^1, 2^2, and 2^4. 2^3 is not supported.
16871708
* HW will encode level 4 as the value 3. See xive2_pgofnext().
16881709
*/
1689-
switch (level) {
1710+
switch (blk) {
16901711
case 1:
16911712
case 2:
16921713
break;

hw/intc/xive2.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,13 +1153,15 @@ static bool xive2_vp_match_mask(uint32_t cam1, uint32_t cam2,
11531153

11541154
static uint8_t xive2_get_vp_block_mask(uint32_t nvt_blk, bool crowd)
11551155
{
1156-
uint8_t size, block_mask = 0b1111;
1156+
uint8_t block_mask = 0b1111;
11571157

11581158
/* 3 supported crowd sizes: 2, 4, 16 */
11591159
if (crowd) {
1160-
size = xive_get_vpgroup_size(nvt_blk);
1161-
if (size == 8) {
1162-
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid crowd size of 8n");
1160+
uint32_t size = xive_get_vpgroup_size(nvt_blk);
1161+
1162+
if (size != 2 && size != 4 && size != 16) {
1163+
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid crowd size of %d",
1164+
size);
11631165
return block_mask;
11641166
}
11651167
block_mask &= ~(size - 1);
@@ -1172,7 +1174,14 @@ static uint32_t xive2_get_vp_index_mask(uint32_t nvt_index, bool cam_ignore)
11721174
uint32_t index_mask = 0xFFFFFF; /* 24 bits */
11731175

11741176
if (cam_ignore) {
1175-
index_mask &= ~(xive_get_vpgroup_size(nvt_index) - 1);
1177+
uint32_t size = xive_get_vpgroup_size(nvt_index);
1178+
1179+
if (size < 2) {
1180+
qemu_log_mask(LOG_GUEST_ERROR, "XIVE: Invalid group size of %d",
1181+
size);
1182+
return index_mask;
1183+
}
1184+
index_mask &= ~(size - 1);
11761185
}
11771186
return index_mask;
11781187
}
@@ -1335,7 +1344,7 @@ static void xive2_router_end_notify(Xive2Router *xrtr, uint8_t end_blk,
13351344
return;
13361345
}
13371346

1338-
if (xive2_end_is_crowd(&end) & !xive2_end_is_ignore(&end)) {
1347+
if (xive2_end_is_crowd(&end) && !xive2_end_is_ignore(&end)) {
13391348
qemu_log_mask(LOG_GUEST_ERROR,
13401349
"XIVE: invalid END, 'crowd' bit requires 'ignore' bit\n");
13411350
return;

hw/ppc/amigaone.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const char dummy_fw[] = {
6363
#define NVRAM_ADDR 0xfd0e0000
6464
#define NVRAM_SIZE (4 * KiB)
6565

66-
static char default_env[] =
66+
static const char default_env[] =
6767
"baudrate=115200\0"
6868
"stdout=vga\0"
6969
"stdin=ps2kbd\0"
@@ -108,8 +108,8 @@ static void nvram_write(void *opaque, hwaddr addr, uint64_t val,
108108
uint8_t *p = memory_region_get_ram_ptr(&s->mr);
109109

110110
p[addr] = val;
111-
if (s->blk) {
112-
blk_pwrite(s->blk, addr, 1, &val, 0);
111+
if (s->blk && blk_pwrite(s->blk, addr, 1, &val, 0) < 0) {
112+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
113113
}
114114
}
115115

@@ -151,15 +151,17 @@ static void nvram_realize(DeviceState *dev, Error **errp)
151151
*c = cpu_to_be32(CRC32_DEFAULT_ENV);
152152
/* Also copies terminating \0 as env is terminated by \0\0 */
153153
memcpy(p + 4, default_env, sizeof(default_env));
154-
if (s->blk) {
155-
blk_pwrite(s->blk, 0, sizeof(crc) + sizeof(default_env), p, 0);
154+
if (s->blk &&
155+
blk_pwrite(s->blk, 0, sizeof(crc) + sizeof(default_env), p, 0) < 0
156+
) {
157+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
156158
}
157159
return;
158160
}
159161
if (*c == 0) {
160162
*c = cpu_to_be32(crc32(0, p + 4, NVRAM_SIZE - 4));
161-
if (s->blk) {
162-
blk_pwrite(s->blk, 0, 4, p, 0);
163+
if (s->blk && blk_pwrite(s->blk, 0, 4, p, 0) < 0) {
164+
error_report("%s: could not write %s", __func__, blk_name(s->blk));
163165
}
164166
}
165167
if (be32_to_cpu(*c) != crc) {

hw/ppc/pnv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ static void pnv_init(MachineState *machine)
11911191
* Since we can not reach the remote BMC machine with LPC memops,
11921192
* map it always for now.
11931193
*/
1194-
memory_region_add_subregion(pnv->chips[0]->fw_mr, PNOR_SPI_OFFSET,
1194+
memory_region_add_subregion(pnv->chips[0]->fw_mr, pnv->pnor->lpc_address,
11951195
&pnv->pnor->mmio);
11961196

11971197
/*

hw/ppc/pnv_bmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ static void hiomap_cmd(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len,
174174
{
175175
PnvPnor *pnor = PNV_PNOR(object_property_get_link(OBJECT(ibs), "pnor",
176176
&error_abort));
177+
uint32_t pnor_addr = pnor->lpc_address;
177178
uint32_t pnor_size = pnor->size;
178-
uint32_t pnor_addr = PNOR_SPI_OFFSET;
179179
bool readonly = false;
180180

181181
rsp_buffer_push(rsp, cmd[2]);
@@ -251,8 +251,8 @@ static const IPMINetfn hiomap_netfn = {
251251

252252
void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor)
253253
{
254+
uint32_t pnor_addr = pnor->lpc_address;
254255
uint32_t pnor_size = pnor->size;
255-
uint32_t pnor_addr = PNOR_SPI_OFFSET;
256256

257257
if (!pnv_bmc_is_simulator(bmc)) {
258258
return;

hw/ppc/pnv_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,25 @@ static void pnv_core_power10_xscom_write(void *opaque, hwaddr addr,
248248

249249
if (val & PPC_BIT(7 + 8 * i)) { /* stop */
250250
val &= ~PPC_BIT(7 + 8 * i);
251-
cpu_pause(cs);
252251
env->quiesced = true;
252+
ppc_maybe_interrupt(env);
253+
cpu_pause(cs);
253254
}
254255
if (val & PPC_BIT(6 + 8 * i)) { /* start */
255256
val &= ~PPC_BIT(6 + 8 * i);
256257
env->quiesced = false;
258+
ppc_maybe_interrupt(env);
257259
cpu_resume(cs);
258260
}
259261
if (val & PPC_BIT(4 + 8 * i)) { /* sreset */
260262
val &= ~PPC_BIT(4 + 8 * i);
261263
env->quiesced = false;
264+
ppc_maybe_interrupt(env);
262265
pnv_cpu_do_nmi_resume(cs);
263266
}
264267
if (val & PPC_BIT(3 + 8 * i)) { /* clear maint */
265268
env->quiesced = false;
269+
ppc_maybe_interrupt(env);
266270
/*
267271
* Hardware has very particular cases for where clear maint
268272
* must be used and where start must be used to resume a

0 commit comments

Comments
 (0)