Skip to content

Commit ce5a32d

Browse files
committed
ppc/pnv: Move the PNOR LPC address into struct PnvPnor
Rather than use the hardcoded define throughout the tree for the PNOR LPC address, keep it within the PnvPnor object. This should solve a dead code issue in the BMC HIOMAP checks where Coverity (correctly) reported that the sanity checks are dead code. We would like to keep the sanity checks without turning them into a compile time assert in case we would like to make them configurable in future. Fixes: 4c84a0a ("ppc/pnv: Add a PNOR address and size sanity checks") Resolves: Coverity CID 1593723 Reviewed-by: Cédric Le Goater <[email protected]> Signed-off-by: Nicholas Piggin <[email protected]>
1 parent 965797d commit ce5a32d

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

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_pnor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ static void pnv_pnor_realize(DeviceState *dev, Error **errp)
108108
memset(s->storage, 0xFF, s->size);
109109
}
110110

111+
s->lpc_address = PNOR_SPI_OFFSET;
112+
111113
memory_region_init_io(&s->mmio, OBJECT(s), &pnv_pnor_ops, s,
112114
TYPE_PNV_PNOR, s->size);
113115
}

include/hw/ppc/pnv_pnor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct PnvPnor {
2828
BlockBackend *blk;
2929

3030
uint8_t *storage;
31+
uint32_t lpc_address; /* Offset within LPC FW space */
3132
int64_t size;
3233
MemoryRegion mmio;
3334
};

0 commit comments

Comments
 (0)