diff mbox

[4/4] spapr: Add RTAS sysparm SPLPAR Characteristics

Message ID 53A8C4DE.6090408@au1.ibm.com
State New
Headers show

Commit Message

Sam Bobroff June 24, 2014, 12:22 a.m. UTC
Add support for the SPLPAR Characteristics parameter to the emulated
RTAS call ibm,get-system-parameter.

The support provides just enough information to allow "cat
/proc/powerpc/lparcfg" to succeed without generating a kernel error
message.

Without this patch the above command will produce the following kernel
message: arch/powerpc/platforms/pseries/lparcfg.c \
parse_system_parameter_string Error calling get-system-parameter \
(0xfffffffd)

Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
---
 hw/ppc/spapr_rtas.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Alexander Graf June 24, 2014, 12:03 p.m. UTC | #1
On 24.06.14 02:22, Sam Bobroff wrote:
> Add support for the SPLPAR Characteristics parameter to the emulated
> RTAS call ibm,get-system-parameter.
>
> The support provides just enough information to allow "cat
> /proc/powerpc/lparcfg" to succeed without generating a kernel error
> message.
>
> Without this patch the above command will produce the following kernel
> message: arch/powerpc/platforms/pseries/lparcfg.c \
> parse_system_parameter_string Error calling get-system-parameter \
> (0xfffffffd)
>
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
> ---
>   hw/ppc/spapr_rtas.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
> index 8d94845..4270e7a 100644
> --- a/hw/ppc/spapr_rtas.c
> +++ b/hw/ppc/spapr_rtas.c
> @@ -224,6 +224,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, sPAPREnvironment *spapr,
>       env->msr = 0;
>   }
>   
> +#define SPLPAR_CHARACTERISTICS      20
>   #define DIAGNOSTICS_RUN_MODE        42
>   #define UUID                        48
>   
> @@ -238,8 +239,20 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
>       target_ulong length = rtas_ld(args, 2);
>       target_ulong ret = RTAS_OUT_SUCCESS;
>       uint8_t zero = 0;
> +    uint8_t param_buf[64];
> +    int param_len;
>   
>       switch (parameter) {
> +    case SPLPAR_CHARACTERISTICS:
> +        param_len = snprintf((char *)param_buf, sizeof param_buf,
> +                             "MaxEntCap=%d,MaxPlatProcs=%d",
> +                             max_cpus, smp_cpus);

We have a nice g_strdup_printf() helper function that allocates memory 
for us automatically based on the printf size. Just use that one here ;).


Alex
diff mbox

Patch

diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
index 8d94845..4270e7a 100644
--- a/hw/ppc/spapr_rtas.c
+++ b/hw/ppc/spapr_rtas.c
@@ -224,6 +224,7 @@  static void rtas_stop_self(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     env->msr = 0;
 }
 
+#define SPLPAR_CHARACTERISTICS      20
 #define DIAGNOSTICS_RUN_MODE        42
 #define UUID                        48
 
@@ -238,8 +239,20 @@  static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
     target_ulong length = rtas_ld(args, 2);
     target_ulong ret = RTAS_OUT_SUCCESS;
     uint8_t zero = 0;
+    uint8_t param_buf[64];
+    int param_len;
 
     switch (parameter) {
+    case SPLPAR_CHARACTERISTICS:
+        param_len = snprintf((char *)param_buf, sizeof param_buf,
+                             "MaxEntCap=%d,MaxPlatProcs=%d",
+                             max_cpus, smp_cpus);
+        if (param_len >= 0) {
+            rtas_st_buffer(buffer, length, param_buf, param_len);
+        } else {
+            ret = RTAS_OUT_HW_ERROR;
+        }
+        break;
     case DIAGNOSTICS_RUN_MODE:
         rtas_st_buffer(buffer, length, &zero, sizeof zero);
         break;