Small IPMI fixes
PATCH v2 1/1 Small IPMI fixes
These are some fixes I've had for a while (mostly). They are small fixes and additions for various things. It would be nice to be able to get these into the upcoming release.
I also add myself as the maintainer for the IPMI code, since that seemed appropriate.
Changes in v2:
I removed the "other" fixes (the one to vl.c) from the previous patch set, these are all IPMI-related changes. I also moved adding myself as the IPMI maintainer to the first patch, per Marc-André.
PATCH 4/7 ipmi: Add the platform event message command
From: Corey Minyard <[email protected]>
This lets an event be added to the SEL as if a sensor had generated it. The OpenIPMI driver uses it for storing panic event information.
--- hw/ipmi/ipmi_bmc_sim.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
hw/ipmi/ipmi_bmc_sim.c +24 -0
@@ -38,6 +38,7 @@#define IPMI_NETFN_SENSOR_EVENT 0x04 +#define IPMI_CMD_PLATFORM_EVENT_MSG 0x02#define IPMI_CMD_SET_SENSOR_EVT_ENABLE 0x28#define IPMI_CMD_GET_SENSOR_EVT_ENABLE 0x29#define IPMI_CMD_REARM_SENSOR_EVTS 0x2a
@@ -1581,6 +1582,28 @@ static void set_sel_time(IPMIBmcSim *ibs, ibs->sel.time_offset = now.tv_sec - ((long ) val); } +static void platform_event_msg (IPMIBmcSim *ibs, +uint8_t *cmd,unsigned int cmd_len, +RspBuffer *rsp) +{ +uint8_t event[16 ]; + + event[2 ] =2 ;/* System event record */ + event[7 ] = cmd[2 ];/* Generator ID */ + event[8 ] =0 ; + event[9 ] = cmd[3 ];/* EvMRev */ + event[10 ] = cmd[4 ];/* Sensor type */ + event[11 ] = cmd[5 ];/* Sensor number */ + event[12 ] = cmd[6 ];/* Event dir / Event type */ + event[13 ] = cmd[7 ];/* Event data 1 */ + event[14 ] = cmd[8 ];/* Event data 2 */ + event[15 ] = cmd[9 ];/* Event data 3 */ + +if (sel_add_event (ibs, event)) { +rsp_buffer_set_error (rsp,IPMI_CC_OUT_OF_SPACE ); + } +} +static void set_sensor_evt_enable (IPMIBmcSim *ibs,uint8_t *cmd,unsigned int cmd_len,RspBuffer *rsp)
@@ -1757,6 +1780,7 @@ static const IPMINetfn chassis_netfn = { };static const IPMICmdHandler sensor_event_cmds[] = { + [IPMI_CMD_PLATFORM_EVENT_MSG ] = { platform_event_msg,10 }, [IPMI_CMD_SET_SENSOR_EVT_ENABLE ] = { set_sensor_evt_enable,4 }, [IPMI_CMD_GET_SENSOR_EVT_ENABLE ] = { get_sensor_evt_enable,3 }, [IPMI_CMD_REARM_SENSOR_EVTS ] = { rearm_sensor_evts,4 },
Signature · 1 line
2.7.4
PATCH 1/7 Add maintainer for the IPMI code
In reply to [email protected]From: Corey Minyard <[email protected]>
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -932,6 +932,15 @@ F: tests/ahci-test.c F: tests/libqos/ahci* T: git git://github.com/jnsnow/qemu.git ide +IPMI +M: Corey Minyard <[email protected]> +S: Maintained +F: include/hw/ipmi/* +F: hw/ipmi/* +F: hw/smbios/smbios_type_38.c +F: tests/ipmi* +T: git git://github.com/cminyard/qemu.git master-ipmi-rebase + Floppy M: John Snow <[email protected]> L: [email protected]
Signature · 1 line
2.7.4
PATCH 2/7 ipmi: Fix SEL get/set time commands
In reply to [email protected]From: Corey Minyard <[email protected]>
The minimum message size was on the wrong commands, for getting the time it's zero and for setting the time it's 6.
--- hw/ipmi/ipmi_bmc_sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ipmi/ipmi_bmc_sim.c +2 -2
@@ -1802,8 +1802,8 @@ static const IPMICmdHandler storage_cmds[] = { [IPMI_CMD_GET_SEL_ENTRY] = { get_sel_entry, 8 }, [IPMI_CMD_ADD_SEL_ENTRY] = { add_sel_entry, 18 }, [IPMI_CMD_CLEAR_SEL] = { clear_sel, 8 }, - [IPMI_CMD_GET_SEL_TIME] = { get_sel_time, 6 }, - [IPMI_CMD_SET_SEL_TIME] = { set_sel_time }, + [IPMI_CMD_GET_SEL_TIME] = { get_sel_time }, + [IPMI_CMD_SET_SEL_TIME] = { set_sel_time, 6 }, };static const IPMINetfn storage_netfn = {
Signature · 1 line
2.7.4
PATCH 3/7 ipmi: Don't set the timestamp on add events that don't have it
In reply to [email protected]From: Corey Minyard <[email protected]>
According to the spec, from section "32.3 OEM SEL Record - Type E0h-FFh", 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.
--- hw/ipmi/ipmi_bmc_sim.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
hw/ipmi/ipmi_bmc_sim.c +7 -2
@@ -443,16 +443,21 @@ 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 type 0xe0-0xff. */ +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);
Signature · 1 line
2.7.4
PATCH 5/7 ipmi: Fix macro issues
In reply to [email protected]From: Corey Minyard <[email protected]>
Macro parameters should almost always have () around them when used. llvm reported an error on this.
Remove redundant parenthesis and put parenthesis around the entire macros with assignments in case they are used in an expression.
The macros were doing ((v) & 1) for a binary input, but that only works if v == 0 or if v & 1. Changed to !!(v) so they work for all values.
Remove some unused macros.
Reported in https://bugs.launchpad.net/bugs/1651167
An audit of these changes found no semantic changes; this is just cleanups for proper style and to avoid a compiler warning.
--- hw/ipmi/isa_ipmi_bt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ipmi/isa_ipmi_bt.c +6 -6
@@ -45,21 +45,21 @@#define IPMI_BT_B2H_ATN_MASK (1 << IPMI_BT_B2H_ATN_BIT)#define IPMI_BT_GET_B2H_ATN (d) (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)#define IPMI_BT_SET_B2H_ATN (d, v) ((d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \ - (((v) & 1) << IPMI_BT_B2H_ATN_BIT))) + (!!(v) << IPMI_BT_B2H_ATN_BIT)))#define IPMI_BT_SMS_ATN_MASK (1 << IPMI_BT_SMS_ATN_BIT)#define IPMI_BT_GET_SMS_ATN (d) (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)#define IPMI_BT_SET_SMS_ATN (d, v) ((d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \ - (((v) & 1) << IPMI_BT_SMS_ATN_BIT))) + (!!(v) << IPMI_BT_SMS_ATN_BIT)))#define IPMI_BT_HBUSY_MASK (1 << IPMI_BT_HBUSY_BIT)#define IPMI_BT_GET_HBUSY (d) (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)#define IPMI_BT_SET_HBUSY (d, v) ((d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \ - (((v) & 1) << IPMI_BT_HBUSY_BIT))) + (!!(v) << IPMI_BT_HBUSY_BIT)))#define IPMI_BT_BBUSY_MASK (1 << IPMI_BT_BBUSY_BIT)#define IPMI_BT_SET_BBUSY (d, v) ((d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \ - (((v) & 1) << IPMI_BT_BBUSY_BIT))) + (!!(v) << IPMI_BT_BBUSY_BIT)))/* Mask register */
@@ -69,12 +69,12 @@#define IPMI_BT_B2H_IRQ_EN_MASK (1 << IPMI_BT_B2H_IRQ_EN_BIT)#define IPMI_BT_GET_B2H_IRQ_EN (d) (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1)#define IPMI_BT_SET_B2H_IRQ_EN (d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) |\ - (((v) & 1) << IPMI_BT_B2H_IRQ_EN_BIT))) + (!!(v) << IPMI_BT_B2H_IRQ_EN_BIT)))#define IPMI_BT_B2H_IRQ_MASK (1 << IPMI_BT_B2H_IRQ_BIT)#define IPMI_BT_GET_B2H_IRQ (d) (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1)#define IPMI_BT_SET_B2H_IRQ (d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \ - (((v) & 1) << IPMI_BT_B2H_IRQ_BIT))) + (!!(v) << IPMI_BT_B2H_IRQ_BIT))) typedef struct IPMIBT { IPMIBmc *bmc;
Signature · 1 line
2.7.4
PATCH 7/7 ipmi: Allow BMC device properties to be set
In reply to [email protected]From: Corey Minyard <[email protected]>
--- hw/ipmi/ipmi_bmc_sim.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
hw/ipmi/ipmi_bmc_sim.c +14 -7
@@ -214,8 +214,8 @@ struct IPMIBmcSim {uint8_t device_rev;uint8_t fwrev1;uint8_t fwrev2; -uint8_t mfg_id[3 ]; -uint8_t product_id[2 ]; +uint32_t mfg_id; +uint16_t product_id;uint8_t restart_cause;
@@ -867,11 +867,11 @@ static void get_device_id(IPMIBmcSim *ibs,rsp_buffer_push (rsp, ibs->fwrev2);rsp_buffer_push (rsp, ibs->ipmi_version);rsp_buffer_push (rsp,0x07 );/* sensor, SDR, and SEL. */ -rsp_buffer_push (rsp, ibs->mfg_id[0 ]); -rsp_buffer_push (rsp, ibs->mfg_id[1 ]); -rsp_buffer_push (rsp, ibs->mfg_id[2 ]); -rsp_buffer_push (rsp, ibs->product_id[0 ]); -rsp_buffer_push (rsp, ibs->product_id[1 ]); +rsp_buffer_push (rsp, ibs->mfg_id &0xff ); +rsp_buffer_push (rsp, (ibs->mfg_id >>8 ) &0xff ); +rsp_buffer_push (rsp, (ibs->mfg_id >>16 ) &0xff ); +rsp_buffer_push (rsp, ibs->product_id &0xff ); +rsp_buffer_push (rsp, (ibs->product_id >>8 ) &0xff ); }static void set_global_enables (IPMIBmcSim *ibs,uint8_t val)
@@ -1997,6 +1997,13 @@ static Property ipmi_sim_properties[] = {DEFINE_PROP_UINT16 ("fruareasize" , IPMIBmcSim, fru.areasize,1024 ),DEFINE_PROP_STRING ("frudatafile" , IPMIBmcSim, fru.filename),DEFINE_PROP_STRING ("sdrfile" , IPMIBmcSim, sdr_filename), +DEFINE_PROP_UINT8 ("device_id" , IPMIBmcSim, device_id,0x20 ), +DEFINE_PROP_UINT8 ("ipmi_version" , IPMIBmcSim, ipmi_version,0x02 ), +DEFINE_PROP_UINT8 ("device_rev" , IPMIBmcSim, device_rev,0 ), +DEFINE_PROP_UINT8 ("fwrev1" , IPMIBmcSim, fwrev1,0 ), +DEFINE_PROP_UINT8 ("fwrev2" , IPMIBmcSim, fwrev2,0 ), +DEFINE_PROP_UINT32 ("mfg_id" , IPMIBmcSim, mfg_id,0 ), +DEFINE_PROP_UINT16 ("product_id" , IPMIBmcSim, product_id,0 ), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.7.4
PATCH 6/7 ipmi: disable IRQ and ATN on an external disconnect
In reply to [email protected]From: Corey Minyard <[email protected]>
Otherwise there's no way to clear them without an external command, and it could lock the OS in the VM if they were stuck.
--- hw/ipmi/ipmi_bmc_extern.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/ipmi/ipmi_bmc_extern.c +5 -0
@@ -424,6 +424,11 @@ static void chr_event(void *opaque, int event)return ; } ibe->connected = false; +/* +* Don't hang the OS trying to handle the ATN bit, other end will +* resend on a reconnect. +*/ + k->set_atn (s,0 ,0 );if (ibe->waiting_rsp) { ibe->waiting_rsp = false; ibe->inbuf[1 ] = ibe->outbuf[1 ] |0x04 ;
Signature · 1 line
2.7.4
Michael? Anyone? Can we get these in?
Thanks
-corey
Quoted 13 lines · On 01/15/2018 06:57 PM, [email protected] wrote:
These are some fixes I've had for a while (mostly). They are small fixes and additions for various things. It would be nice to be able to get these into the upcoming release.
I also add myself as the maintainer for the IPMI code, since that seemed appropriate.
Changes in v2:
I removed the "other" fixes (the one to
vl.c) from the previous patch set, these are all IPMI-related changes. I also moved adding myself as the IPMI maintainer to the first patch, per Marc-André.
Quoted 2 lines · On Tue, 23 Jan 2018 10:55:15 -0600 Corey Minyard <[email protected]> wrote:
Michael? Anyone? Can we get these in?
Since you're adding yourself as a maintainer for IPMI, why not just sending a pull request ?
Quoted 20 lines
Thanks
-corey
Quoted 13 lines · On 01/15/2018 06:57 PM, [email protected] wrote:
These are some fixes I've had for a while (mostly). They are small fixes and additions for various things. It would be nice to be able to get these into the upcoming release.
I also add myself as the maintainer for the IPMI code, since that seemed appropriate.
Changes in v2:
I removed the "other" fixes (the one to
vl.c) from the previous patch set, these are all IPMI-related changes. I also moved adding myself as the IPMI maintainer to the first patch, per Marc-André.
Quoted 8 lines · Greg Kurz
Quoted 2 lines · On Tue, 23 Jan 2018 10:55:15 -0600 Corey Minyard <[email protected]> wrote:
Michael? Anyone? Can we get these in?
Since you're adding yourself as a maintainer for IPMI, why not just sending a pull request ?
Alternatively if you want others to merge it, pls Cc the relevant people.
Quoted 20 lines
Quoted 20 lines
Thanks
-corey
Quoted 13 lines · On 01/15/2018 06:57 PM, [email protected] wrote:
These are some fixes I've had for a while (mostly). They are small fixes and additions for various things. It would be nice to be able to get these into the upcoming release.
I also add myself as the maintainer for the IPMI code, since that seemed appropriate.
Changes in v2:
I removed the "other" fixes (the one to
vl.c) from the previous patch set, these are all IPMI-related changes. I also moved adding myself as the IPMI maintainer to the first patch, per Marc-André.