2012-06-28 16:55:59

by Srinivas_G_Gowda

[permalink] [raw]
Subject: [PATCH 1/1 v2 ] ipmi: Setting OS name as Linux in BMC


functions that will send the Set System Info command
and its corresponding handler

Signed-off-by: Srinivas Gowda G <[email protected]>
---
drivers/char/ipmi/ipmi_msghandler.c | 73 +++++++++++++++++++++++++++++++++++
include/linux/ipmi_msgdefs.h | 1 +
2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d0abb3a..b1a98b5 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2709,6 +2709,79 @@ get_guid(ipmi_smi_t intf)
intf->null_user_handler = NULL;
}

+static int
+send_set_os_name_cmd(ipmi_smi_t intf)
+{
+ unsigned char param_select;
+ unsigned char set_selector;
+ unsigned char string_encode;
+ unsigned char str_len;
+ unsigned char data[9];
+
+ struct kernel_ipmi_msg msg;
+ struct ipmi_system_interface_addr si;
+
+ si.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
+ si.channel = IPMI_BMC_CHANNEL;
+ si.lun = 0;
+
+ param_select = 4; /* parameter number for volatile OS name */
+ set_selector = 0; /* set selector, block 0 */
+ string_encode = 0; /* ASCII Encoding */
+ str_len = 5; /* length of ASCII string - "Linux" */
+
+ data[0] = param_select;
+ data[1] = set_selector;
+ data[2] = string_encode;
+ data[3] = str_len;
+ data[4] = 'L';
+ data[5] = 'i';
+ data[6] = 'n';
+ data[7] = 'u';
+ data[8] = 'x';
+
+ msg.netfn = IPMI_NETFN_APP_REQUEST;
+ msg.cmd = IPMI_SET_SYSTEM_INFO;
+ msg.data = data;
+ msg.data_len = 9;
+ return i_ipmi_request(NULL,
+ intf,
+ (struct ipmi_addr *) &si,
+ 0,
+ &msg,
+ intf,
+ NULL,
+ NULL,
+ 0,
+ intf->channels[0].address,
+ intf->channels[0].lun,
+ -1, 0);
+}
+
+/*
+ * msg handler for Set_System_Info cmd - set OS name
+ */
+static void
+set_os_name_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
+{
+ if ((msg->addr.addr_type != IPMI_SYSTEM_INTERFACE_ADDR_TYPE)
+ || (msg->msg.netfn != IPMI_NETFN_APP_RESPONSE)
+ || (msg->msg.cmd != IPMI_SET_SYSTEM_INFO))
+ /* Not for me */
+ return;
+
+ if (msg->msg.data[0] != 0)
+ /* Error setting OS name as Linux in BMC. */
+ printk(KERN_WARNING PFX
+ "Failed to set OS name as Linux: 0x%X\n", msg->msg.data[0]);
+ else
+ printk(KERN_INFO PFX
+ "OS Name successfully set as Linux\n");
+
+ os_name_set = 1;
+ wake_up(&intf->waitq);
+}
+
/*
* Set the Operating System Name as "Linux" in BMC
* using "Set System Info" command.
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
index df97e6e..b5ea664 100644
--- a/include/linux/ipmi_msgdefs.h
+++ b/include/linux/ipmi_msgdefs.h
@@ -57,6 +57,7 @@
#define IPMI_GET_BMC_GLOBAL_ENABLES_CMD 0x2f
#define IPMI_READ_EVENT_MSG_BUFFER_CMD 0x35
#define IPMI_GET_CHANNEL_INFO_CMD 0x42
+#define IPMI_SET_SYSTEM_INFO 0x58

/* Bit for BMC global enables. */
#define IPMI_BMC_RCV_MSG_INTR 0x01
--
1.7.1


Thanks,
G-


2012-06-29 00:01:59

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2 ] ipmi: Setting OS name as Linux in BMC

<[email protected]> writes:
> +
> + data[0] = param_select;
> + data[1] = set_selector;
> + data[2] = string_encode;
> + data[3] = str_len;
> + data[4] = 'L';
> + data[5] = 'i';
> + data[6] = 'n';
> + data[7] = 'u';
> + data[8] = 'x';

Not sure that's all that useful. I can just see BMC's making the ACPI
mistake of trying to work around specific issues, by checking for
Linux.

But since there are so many different Linux that will never work
because "Linux" does not describe a fixed release or code base.

Probably dangerous.

-Andi


--
[email protected] -- Speaking for myself only

2012-06-29 03:06:41

by Corey Minyard

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2 ] ipmi: Setting OS name as Linux in BMC

Srinivas, what is your use case?

-corey

On 06/28/2012 07:01 PM, Andi Kleen wrote:
> <[email protected]> writes:
>> +
>> + data[0] = param_select;
>> + data[1] = set_selector;
>> + data[2] = string_encode;
>> + data[3] = str_len;
>> + data[4] = 'L';
>> + data[5] = 'i';
>> + data[6] = 'n';
>> + data[7] = 'u';
>> + data[8] = 'x';
> Not sure that's all that useful. I can just see BMC's making the ACPI
> mistake of trying to work around specific issues, by checking for
> Linux.
>
> But since there are so many different Linux that will never work
> because "Linux" does not describe a fixed release or code base.
>
> Probably dangerous.
>
> -Andi
>
>

2012-06-29 12:30:12

by Matthew Garrett

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2 ] ipmi: Setting OS name as Linux in BMC

On Thu, Jun 28, 2012 at 05:01:54PM -0700, Andi Kleen wrote:
> Not sure that's all that useful. I can just see BMC's making the ACPI
> mistake of trying to work around specific issues, by checking for
> Linux.
>
> But since there are so many different Linux that will never work
> because "Linux" does not describe a fixed release or code base.
>
> Probably dangerous.

Agreed. Linux doesn't make interface guarantees to hardware, and where
we've implied that we do it's ended up breaking things.

--
Matthew Garrett | [email protected]

2012-06-29 14:27:16

by Corey Minyard

[permalink] [raw]
Subject: Re: [PATCH 1/1 v2 ] ipmi: Setting OS name as Linux in BMC

On 06/29/2012 07:30 AM, Matthew Garrett wrote:
> On Thu, Jun 28, 2012 at 05:01:54PM -0700, Andi Kleen wrote:
>> Not sure that's all that useful. I can just see BMC's making the ACPI
>> mistake of trying to work around specific issues, by checking for
>> Linux.

I'm not sure I see that happening, but I suppose you never know.

>>
>> But since there are so many different Linux that will never work
>> because "Linux" does not describe a fixed release or code base.
>>
>> Probably dangerous.
> Agreed. Linux doesn't make interface guarantees to hardware, and where
> we've implied that we do it's ended up breaking things.
>

This is not really about making interface guarantees to hardware. This
is more of a management discovery thing, so that system management
software talking to the BMC can know what is running on the target.
Something where management software can say "Hey, why is Linux running
on that box? It's supposed to be BSD." or "That box has booted Linux but
hasn't started its maintenance software". According to the spec, the
information is supposed to be cleared if the system powers down or resets.

It seems to me that it's better to directly query what is running on the
target to know what is running on it, but perhaps that's a security
problem waiting to happen. And perhaps it's better to have a small
program set this at startup, since this operation will currently fail on
the majority of systems out there.

-corey