diff mbox series

[2/3] ipmi: Don't set the timestamp on add events that don't have it

Message ID 1503178840-21512-3-git-send-email-minyard@acm.org
State Superseded
Headers show
Series [1/3] ipmi: Fix SEL get/set time commands | expand

Commit Message

Corey Minyard Aug. 19, 2017, 9:40 p.m. UTC
From: Corey Minyard <cminyard@mvista.com>


According to the spec, event types from 0x0e to 0xff do not have a
timestamp.  So don't set it when adding those types.  This required
putting the timestamp in a temporary buffer, since it's still required
to set the last addition time.

Signed-off-by: Corey Minyard <cminyard@mvista.com>

---
 hw/ipmi/ipmi_bmc_sim.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.7.4

Comments

Cédric Le Goater Aug. 20, 2017, 7:51 a.m. UTC | #1
On 08/19/2017 11:40 PM, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>

> 

> According to the spec, event types from 0x0e to 0xff do not have a

> timestamp.  


From section "32.3 OEM SEL Record - Type E0h-FFh"

> So don't set it when adding those types.  This required

> putting the timestamp in a temporary buffer, since it's still required

> to set the last addition time.

> 

> Signed-off-by: Corey Minyard <cminyard@mvista.com>


Reviewed-by: Cédric Le Goater <clg@kaod.org>


> ---

>  hw/ipmi/ipmi_bmc_sim.c | 8 ++++++--

>  1 file changed, 6 insertions(+), 2 deletions(-)

> 

> diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c

> index 1c732aa..0f191e8 100644

> --- a/hw/ipmi/ipmi_bmc_sim.c

> +++ b/hw/ipmi/ipmi_bmc_sim.c

> @@ -443,16 +443,20 @@ static void sel_inc_reservation(IPMISel *sel)

>  /* Returns 1 if the SEL is full and can't hold the event. */

>  static int sel_add_event(IPMIBmcSim *ibs, uint8_t *event)

>  {

> +    uint8_t ts[4];

> +

>      event[0] = 0xff;

>      event[1] = 0xff;

> -    set_timestamp(ibs, event + 3);

> +    set_timestamp(ibs, ts);

> +    if (event[2] < 0xe0) /* Don't set timestamps for these, per the spec. */

> +        memcpy(event + 3, ts, 4);

>      if (ibs->sel.next_free == MAX_SEL_SIZE) {

>          ibs->sel.overflow = 1;

>          return 1;

>      }

>      event[0] = ibs->sel.next_free & 0xff;

>      event[1] = (ibs->sel.next_free >> 8) & 0xff;

> -    memcpy(ibs->sel.last_addition, event + 3, 4);

> +    memcpy(ibs->sel.last_addition, ts, 4);

>      memcpy(ibs->sel.sel[ibs->sel.next_free], event, 16);

>      ibs->sel.next_free++;

>      sel_inc_reservation(&ibs->sel);

>
diff mbox series

Patch

diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index 1c732aa..0f191e8 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -443,16 +443,20 @@  static void sel_inc_reservation(IPMISel *sel)
 /* Returns 1 if the SEL is full and can't hold the event. */
 static int sel_add_event(IPMIBmcSim *ibs, uint8_t *event)
 {
+    uint8_t ts[4];
+
     event[0] = 0xff;
     event[1] = 0xff;
-    set_timestamp(ibs, event + 3);
+    set_timestamp(ibs, ts);
+    if (event[2] < 0xe0) /* Don't set timestamps for these, per the spec. */
+        memcpy(event + 3, ts, 4);
     if (ibs->sel.next_free == MAX_SEL_SIZE) {
         ibs->sel.overflow = 1;
         return 1;
     }
     event[0] = ibs->sel.next_free & 0xff;
     event[1] = (ibs->sel.next_free >> 8) & 0xff;
-    memcpy(ibs->sel.last_addition, event + 3, 4);
+    memcpy(ibs->sel.last_addition, ts, 4);
     memcpy(ibs->sel.sel[ibs->sel.next_free], event, 16);
     ibs->sel.next_free++;
     sel_inc_reservation(&ibs->sel);