[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 05/10] ipmi: fix SDR length value
From: |
Cédric Le Goater |
Subject: |
[Qemu-devel] [PATCH v3 05/10] ipmi: fix SDR length value |
Date: |
Mon, 25 Jan 2016 15:07:30 +0100 |
The IPMI BMC simulator populates the SDR table with a set of initial
SDRs. The length of each SDR is taken from the record itself (byte 4)
which does not include the size of the header. But, the full length
(header + data) is required by the sdr_add_entry() routine.
Signed-off-by: Cédric Le Goater <address@hidden>
---
Changes since v2:
- the patch does not use the struct ipmi_sdr_header anymore as it was
moved the patch forward in the patchset
hw/ipmi/ipmi_bmc_sim.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 2c540c0782c9..dee2190ce059 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -358,7 +358,7 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t recid,
while (pos < sdr->next_free) {
uint16_t trec = sdr->sdr[pos] | (sdr->sdr[pos + 1] << 8);
- unsigned int nextpos = pos + sdr->sdr[pos + 4];
+ unsigned int nextpos = pos + sdr->sdr[pos + 4] + 5;
if (trec == recid) {
if (nextrec) {
@@ -1166,7 +1166,7 @@ static void get_sdr(IPMIBmcSim *ibs,
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return;
}
- if (cmd[6] > (ibs->sdr.sdr[pos + 4])) {
+ if (cmd[6] > (ibs->sdr.sdr[pos + 4] + 5)) {
rsp[2] = IPMI_CC_PARM_OUT_OF_RANGE;
return;
}
@@ -1175,7 +1175,7 @@ static void get_sdr(IPMIBmcSim *ibs,
IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff);
if (cmd[7] == 0xff) {
- cmd[7] = ibs->sdr.sdr[pos + 4] - cmd[6];
+ cmd[7] = ibs->sdr.sdr[pos + 4] + 5 - cmd[6];
}
if ((cmd[7] + *rsp_len) > max_rsp_len) {
@@ -1649,17 +1649,17 @@ static void ipmi_sim_init(Object *obj)
error_report("Problem with recid 0x%4.4x", i);
return;
}
- len = init_sdrs[i + 4];
+ len = init_sdrs[i + 4] + 5;
recid = init_sdrs[i] | (init_sdrs[i + 1] << 8);
if (recid == 0xffff) {
break;
}
- if ((i + len + 5) > sizeof(init_sdrs)) {
+ if ((i + len) > sizeof(init_sdrs)) {
error_report("Problem with recid 0x%4.4x", i);
return;
}
sdr_add_entry(ibs, init_sdrs + i, len, NULL);
- i += len + 5;
+ i += len;
}
ipmi_init_sensors_from_sdrs(ibs);
--
2.1.4
- [Qemu-devel] [PATCH v3 00/10] ipmi: a couple of enhancements to the BMC simulator, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 01/10] ppc: add IPMI support, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 02/10] ipmi: replace goto by a return statement, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 04/10] ipmi: cleanup error_report messages, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 03/10] ipmi: replace *_MAXCMD defines, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 06/10] ipmi: introduce a struct ipmi_sdr_compact, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 09/10] ipmi: add ACPI power and GUID commands, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 08/10] ipmi: add GET_SYS_RESTART_CAUSE chassis command, Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 05/10] ipmi: fix SDR length value,
Cédric Le Goater <=
- [Qemu-devel] [PATCH v3 10/10] ipmi: add SET_SENSOR_READING command (tentative try), Cédric Le Goater, 2016/01/25
- [Qemu-devel] [PATCH v3 07/10] ipmi: add get and set SENSOR_TYPE commands, Cédric Le Goater, 2016/01/25