All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@fr.ibm.com>
To: Greg Kurz <gkurz@linux.vnet.ibm.com>
Cc: Corey Minyard <cminyard@mvista.com>,
	qemu-devel@nongnu.org,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 5/9] ipmi: fix SDR length value
Date: Fri, 22 Jan 2016 12:15:45 +0100	[thread overview]
Message-ID: <56A20F61.6020300@fr.ibm.com> (raw)
In-Reply-To: <20160122115620.5ff7f257@bahia.huguette.org>

On 01/22/2016 11:56 AM, Greg Kurz wrote:
> On Thu, 21 Jan 2016 18:18:50 +0100
> Cédric Le Goater <clg@fr.ibm.com> wrote:
>> 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 <clg@fr.ibm.com>
> 
> The patch is good but IMHO it should come before patch 4 because this is bugfix
> that could be applied right away, while patch 4 is code cleanup that may need
> some more discussion.

OK. I am fine with that. It should be the patch from v1.

Thanks,

C.


>> ---
>>  hw/ipmi/ipmi_bmc_sim.c | 18 +++++++++---------
>>  include/hw/ipmi/ipmi.h |  1 +
>>  2 files changed, 10 insertions(+), 9 deletions(-)
>>
>> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
>> index 31f990199154..803c7e5130c0 100644
>> --- a/hw/ipmi/ipmi_bmc_sim.c
>> +++ b/hw/ipmi/ipmi_bmc_sim.c
>> @@ -327,11 +327,11 @@ static int sdr_add_entry(IPMIBmcSim *ibs, const uint8_t *entry,
>>      struct ipmi_sdr_header *sdrh =
>>          (struct ipmi_sdr_header *) &ibs->sdr.sdr[ibs->sdr.next_free];
>>
>> -    if ((len < 5) || (len > 255)) {
>> +    if ((len < IPMI_SDR_HEADER_SIZE) || (len > 255)) {
>>          return 1;
>>      }
>>
>> -    if (sdrh_entry->rec_length != len - 5) {
>> +    if (ipmi_sdr_length(sdrh_entry) != len) {
>>          return 1;
>>      }
>>
>> @@ -364,7 +364,7 @@ static int sdr_find_entry(IPMISdr *sdr, uint16_t recid,
>>          struct ipmi_sdr_header *sdrh =
>>              (struct ipmi_sdr_header *) &sdr->sdr[pos];
>>          uint16_t trec = ipmi_sdr_recid(sdrh);
>> -        unsigned int nextpos = pos + sdrh->rec_length;
>> +        unsigned int nextpos = pos + ipmi_sdr_length(sdrh);
>>
>>          if (trec == recid) {
>>              if (nextrec) {
>> @@ -1179,7 +1179,7 @@ static void get_sdr(IPMIBmcSim *ibs,
>>
>>      sdrh = (struct ipmi_sdr_header *) &ibs->sdr.sdr[pos];
>>
>> -    if (cmd[6] > sdrh->rec_length) {
>> +    if (cmd[6] > ipmi_sdr_length(sdrh)) {
>>          rsp[2] = IPMI_CC_PARM_OUT_OF_RANGE;
>>          return;
>>      }
>> @@ -1188,7 +1188,7 @@ static void get_sdr(IPMIBmcSim *ibs,
>>      IPMI_ADD_RSP_DATA((nextrec >> 8) & 0xff);
>>
>>      if (cmd[7] == 0xff) {
>> -        cmd[7] = sdrh->rec_length - cmd[6];
>> +        cmd[7] = ipmi_sdr_length(sdrh) - cmd[6];
>>      }
>>
>>      if ((cmd[7] + *rsp_len) > max_rsp_len) {
>> @@ -1659,22 +1659,22 @@ static void ipmi_sim_init(Object *obj)
>>      for (i = 0;;) {
>>          struct ipmi_sdr_header *sdrh;
>>          int len;
>> -        if ((i + 5) > sizeof(init_sdrs)) {
>> +        if ((i + IPMI_SDR_HEADER_SIZE) > sizeof(init_sdrs)) {
>>              error_report("Problem with recid 0x%4.4x", i);
>>              return;
>>          }
>>          sdrh = (struct ipmi_sdr_header *) &init_sdrs[i];
>> -        len = sdrh->rec_length;
>> +        len = ipmi_sdr_length(sdrh);
>>          recid = ipmi_sdr_recid(sdrh);
>>          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);
>> diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
>> index 7e142e241dcb..74a2b5af9613 100644
>> --- a/include/hw/ipmi/ipmi.h
>> +++ b/include/hw/ipmi/ipmi.h
>> @@ -219,6 +219,7 @@ struct ipmi_sdr_header {
>>  #define IPMI_SDR_HEADER_SIZE     sizeof(struct ipmi_sdr_header)
>>
>>  #define ipmi_sdr_recid(sdr) ((sdr)->rec_id[0] | ((sdr)->rec_id[1] << 8))
>> +#define ipmi_sdr_length(sdr) ((sdr)->rec_length + IPMI_SDR_HEADER_SIZE)
>>
>>  /*
>>   * 43.2 SDR Type 02h. Compact Sensor Record
> 

  reply	other threads:[~2016-01-22 11:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 17:18 [Qemu-devel] [PATCH v2 0/9] ipmi: a couple of enhancements to the BMC simulator Cédric Le Goater
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 1/9] ppc: add IPMI support Cédric Le Goater
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 2/9] ipmi: replace goto by a return statement Cédric Le Goater
2016-01-22  5:49   ` Marcel Apfelbaum
2016-01-22  6:28   ` Greg Kurz
2016-01-22 12:56   ` Corey Minyard
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 3/9] ipmi: replace *_MAXCMD defines Cédric Le Goater
2016-01-22  8:05   ` Greg Kurz
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 4/9] ipmi: introduce a struct ipmi_sdr_compact Cédric Le Goater
2016-01-22 10:49   ` Greg Kurz
2016-01-22 11:10     ` Cédric Le Goater
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 5/9] ipmi: fix SDR length value Cédric Le Goater
2016-01-22 10:56   ` Greg Kurz
2016-01-22 11:15     ` Cédric Le Goater [this message]
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 6/9] ipmi: add get and set SENSOR_TYPE commands Cédric Le Goater
2016-01-22 11:07   ` Greg Kurz
2016-01-22 11:13     ` Cédric Le Goater
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 7/9] ipmi: add GET_SYS_RESTART_CAUSE chassis command Cédric Le Goater
2016-01-22 11:09   ` Greg Kurz
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 8/9] ipmi: add ACPI power and GUID commands Cédric Le Goater
2016-01-22 11:24   ` Greg Kurz
2016-01-22 11:58     ` Cédric Le Goater
2016-01-22 13:04   ` Corey Minyard
2016-01-21 17:18 ` [Qemu-devel] [PATCH v2 9/9] ipmi: add SET_SENSOR_READING command (tentative try) Cédric Le Goater
2016-01-22 11:28   ` Greg Kurz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56A20F61.6020300@fr.ibm.com \
    --to=clg@fr.ibm.com \
    --cc=cminyard@mvista.com \
    --cc=gkurz@linux.vnet.ibm.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.