[Skiboot] [RFC PATCH 5/7] skiboot: Add opal call for nest IMA configuration
Madhavan Srinivasan
maddy at linux.vnet.ibm.com
Wed Nov 2 17:39:47 AEDT 2016
On Tuesday 25 October 2016 06:15 PM, Hemant Kumar wrote:
> Add a new opal call to control the nest IMA counters.
> opal_nest_ima_counters_control() is to start and stop OCC
> microcode for nest PMU counter collection based on the "operation"
> parameter.
Would prefer the title of the patch to be
"skiboot: Add opal call to enable/disable Nest IMA microcode"
OPAL Call is to start/stop the Nest microcode running in the OCC
complex.
Nest counters are configured by the microcode and not by OPAL
or kernel.
>
> Signed-off-by: Hemant Kumar <hemant at linux.vnet.ibm.com>
> ---
> hw/ima.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/opal-api.h | 3 ++-
> 2 files changed, 71 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ima.c b/hw/ima.c
> index 7dd8d8c..cce5473 100644
> --- a/hw/ima.c
> +++ b/hw/ima.c
> @@ -139,3 +139,72 @@ void ima_init(void)
> err:
> free(buf);
> }
> +
> +/*
> + * opal_nest_ima_counters_control : This call controls the nest IMA counters.
nest IMA "microcode" and not "counters".
> + *
> + * mode : For now, this call supports only NEST_IMA_PRODUCTION_MODE.
> + * This mode can start/stop the PORE SLW IMA engine for nest
Instead of "PORE SLW IMA", can it be "Nest IMA Microcode"?
> + * instrumentation from Host OS.
> + * operation : Start(0x0) or Stop(0x1) the engine.
> + *
> + * This call can be extended to include more operations, if needed and the
> + * other two parameters value_1 and value_2 are for the very same purpose.
> + * Right now, they are unused and should be zero.
> + */
> +static int64_t opal_nest_ima_counters_control(uint64_t mode,
> + uint64_t operation,
> + uint64_t value_1,
> + uint64_t value_2)
> +{
> + struct proc_chip *chip;
> + u64 op;
> + int ret;
> + uint64_t cb_loc;
> + struct ima_chip_cb *cb;
> +
> + if ((mode != NEST_IMA_PRODUCTION_MODE) || value_1 || value_2) {
> + ret = OPAL_PARAMETER;
> + goto nest_ret;
> + }
> +
> + chip = get_chip(this_cpu()->chip_id);
> +
> + /* Fetch the IMA control block structure */
> + cb_loc = chip->homer_base + CB_STRUCT_OFFSET;
> + cb = (struct ima_chip_cb *)cb_loc;
> +
> + switch (operation) {
> + case 0:
> + /* Check whether the engine is already stopped */
> + if (cb->ima_chip_run_status == SLW_IMA_PAUSE) {
Can it be "NEST_IMA_PAUSE" instead of "SLW_IMA_PAUSE"?
> + ret = OPAL_SUCCESS;
> + goto nest_ret;
> + }
> +
> + op = NEST_IMA_DISABLE;
> + break;
> + case 1:
> + /* Check whether the engine is already running */
> + if (cb->ima_chip_run_status == SLW_IMA_RESUME) {
Same here. Can it be NEST_IMA_RESUME instead of SLW_IMA_RESUME
> + ret = OPAL_SUCCESS;
> + goto nest_ret;
> + }
> +
> + op = NEST_IMA_ENABLE;
> + break;
> + default:
> + prerror("IMA: unknown operation for nest ima\n");
> + ret = OPAL_PARAMETER;
> + goto nest_ret;
> + }
> +
> + /* Write the command now to the control block */
> + cb->ima_chip_command = op;
> +
> + ret = OPAL_SUCCESS;
> +nest_ret:
> + return ret;
> +}
> +
> +opal_call(OPAL_NEST_IMA_COUNTERS_CONTROL, opal_nest_ima_counters_control, 4);
> diff --git a/include/opal-api.h b/include/opal-api.h
> index 05ff51d..cbb5dcf 100644
> --- a/include/opal-api.h
> +++ b/include/opal-api.h
> @@ -181,7 +181,8 @@
> #define OPAL_INT_SET_MFRR 125
> #define OPAL_PCI_TCE_KILL 126
> #define OPAL_NMMU_SET_PTCR 127
> -#define OPAL_LAST 127
> +#define OPAL_NEST_IMA_COUNTERS_CONTROL 128
> +#define OPAL_LAST 128
>
> /* Device tree flags */
>
More information about the Skiboot
mailing list