[RFC,v5,10/16] hdata/spira.c: Create ibm, ultravisor dt node
diff mbox series

Message ID 20200227204023.22125-11-grimm@linux.ibm.com
State New
Headers show
Series
  • Ultravisor support in skiboot
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot success Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (82aed17a5468aff6b600ee1694a10a60f942c018)

Commit Message

Ryan Grimm Feb. 27, 2020, 8:40 p.m. UTC
Create ibm,ultravisor node if secure memory exists.  See
doc/opal-uv-abi.rst for details.

Signed-off-by: Ryan Grimm <grimm@us.ibm.com>
---
 hdata/spira.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Alexey Kardashevskiy March 4, 2020, 7:44 a.m. UTC | #1
On 28/02/2020 07:40, Ryan Grimm wrote:
> Create ibm,ultravisor node if secure memory exists.  See
> doc/opal-uv-abi.rst for details.
> 
> Signed-off-by: Ryan Grimm <grimm@us.ibm.com>
> ---
>  hdata/spira.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/hdata/spira.c b/hdata/spira.c
> index 7c5918d2..1435d175 100644
> --- a/hdata/spira.c
> +++ b/hdata/spira.c
> @@ -1712,6 +1712,36 @@ static void update_spirah_addr(void)
>  #endif
>  }
>  
> +#define UV_LOAD_MAX_SIZE        0x200000

Oh it is another UV_LOAD_MAX_SIZE, the first one was in 02/16.


> +
> +static void add_uv(void)
> +{
> +	struct dt_node *uv_node, *secure_mem_node, *uv_fw_node;
> +	uint64_t uv_fw_start;
> +	char fw_name[64];
> +
> +	secure_mem_node = dt_find_compatible_node_on_chip(dt_root, NULL,
> +						"ibm,secure-memory", 0);
> +	if (!secure_mem_node) {
> +		prlog(PR_DEBUG, "HDAT: No ibm,secure-memory found\n");
> +		return;
> +	}
> +
> +	uv_node = dt_new_check(dt_root, "ibm,ultravisor");
> +	dt_add_property_string(uv_node, "compatible", "ibm,ultravisor");
> +	dt_add_property_cells(uv_node, "#address-cells", 2);
> +	dt_add_property_cells(uv_node, "#size-cells", 2);
> +
> +	uv_fw_start = dt_get_address(secure_mem_node, 0, NULL);
> +
> +	snprintf(fw_name, 64, "firmware@%llx", (unsigned long long)uv_fw_start);


(unsigned long long) seems unnecessary here.


> +	uv_fw_node = dt_new_check(uv_node, fw_name);
> +	dt_add_property_string(uv_fw_node, "compatible", "ibm,uv-firmware");
> +	dt_add_property_cells(uv_fw_node, "reg", uv_fw_start >> 32,
> +			uv_fw_start & 0xffffffff, UV_LOAD_MAX_SIZE >> 23,

s/23/32/ ?

> +			UV_LOAD_MAX_SIZE & 0xffffffff);


Just use dt_add_property_u64s().


> +}
> +
>  int parse_hdat(bool is_opal)
>  {
>  	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
> @@ -1753,6 +1783,9 @@ int parse_hdat(bool is_opal)
>  	/* Parse MS VPD */
>  	memory_parse();
>  
> +	/* Add UV node if secure memory exists */
> +	add_uv();
> +
>  	/* Add any FSPs */
>  	fsp_parse();
>  
>
Ryan Grimm March 23, 2020, 4:22 p.m. UTC | #2
On Wed, 2020-03-04 at 18:44 +1100, Alexey Kardashevskiy wrote:
> 
> On 28/02/2020 07:40, Ryan Grimm wrote:
> > Create ibm,ultravisor node if secure memory exists.  See
> > doc/opal-uv-abi.rst for details.
> > 
> > Signed-off-by: Ryan Grimm <grimm@us.ibm.com>
> > ---
> >  hdata/spira.c | 33 +++++++++++++++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> > 
> > diff --git a/hdata/spira.c b/hdata/spira.c
> > index 7c5918d2..1435d175 100644
> > --- a/hdata/spira.c
> > +++ b/hdata/spira.c
> > @@ -1712,6 +1712,36 @@ static void update_spirah_addr(void)
> >  #endif
> >  }
> >  
> > +#define UV_LOAD_MAX_SIZE        0x200000
> 
> Oh it is another UV_LOAD_MAX_SIZE, the first one was in 02/16.
> 

k.

> 
> > +
> > +static void add_uv(void)
> > +{
> > +	struct dt_node *uv_node, *secure_mem_node, *uv_fw_node;
> > +	uint64_t uv_fw_start;
> > +	char fw_name[64];
> > +
> > +	secure_mem_node = dt_find_compatible_node_on_chip(dt_root,
> > NULL,
> > +						"ibm,secure-memory",
> > 0);
> > +	if (!secure_mem_node) {
> > +		prlog(PR_DEBUG, "HDAT: No ibm,secure-memory found\n");
> > +		return;
> > +	}
> > +
> > +	uv_node = dt_new_check(dt_root, "ibm,ultravisor");
> > +	dt_add_property_string(uv_node, "compatible",
> > "ibm,ultravisor");
> > +	dt_add_property_cells(uv_node, "#address-cells", 2);
> > +	dt_add_property_cells(uv_node, "#size-cells", 2);
> > +
> > +	uv_fw_start = dt_get_address(secure_mem_node, 0, NULL);
> > +
> > +	snprintf(fw_name, 64, "firmware@%llx", (unsigned long
> > long)uv_fw_start);
> 
> 
> (unsigned long long) seems unnecessary here.
> 

k.

> 
> > +	uv_fw_node = dt_new_check(uv_node, fw_name);
> > +	dt_add_property_string(uv_fw_node, "compatible", "ibm,uv-
> > firmware");
> > +	dt_add_property_cells(uv_fw_node, "reg", uv_fw_start >> 32,
> > +			uv_fw_start & 0xffffffff, UV_LOAD_MAX_SIZE >>
> > 23,
> 
> s/23/32/ ?
> 
> > +			UV_LOAD_MAX_SIZE & 0xffffffff);
> 
> 
> Just use dt_add_property_u64s().
> 

OK, yikes!  Thanks, I've been learning how to use dt_* functions
properly and this squeeked through. :)


-Ryan

> 
> > +}
> > +
> >  int parse_hdat(bool is_opal)
> >  {
> >  	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
> > @@ -1753,6 +1783,9 @@ int parse_hdat(bool is_opal)
> >  	/* Parse MS VPD */
> >  	memory_parse();
> >  
> > +	/* Add UV node if secure memory exists */
> > +	add_uv();
> > +
> >  	/* Add any FSPs */
> >  	fsp_parse();
> >  
> > 
> 
>

Patch
diff mbox series

diff --git a/hdata/spira.c b/hdata/spira.c
index 7c5918d2..1435d175 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -1712,6 +1712,36 @@  static void update_spirah_addr(void)
 #endif
 }
 
+#define UV_LOAD_MAX_SIZE        0x200000
+
+static void add_uv(void)
+{
+	struct dt_node *uv_node, *secure_mem_node, *uv_fw_node;
+	uint64_t uv_fw_start;
+	char fw_name[64];
+
+	secure_mem_node = dt_find_compatible_node_on_chip(dt_root, NULL,
+						"ibm,secure-memory", 0);
+	if (!secure_mem_node) {
+		prlog(PR_DEBUG, "HDAT: No ibm,secure-memory found\n");
+		return;
+	}
+
+	uv_node = dt_new_check(dt_root, "ibm,ultravisor");
+	dt_add_property_string(uv_node, "compatible", "ibm,ultravisor");
+	dt_add_property_cells(uv_node, "#address-cells", 2);
+	dt_add_property_cells(uv_node, "#size-cells", 2);
+
+	uv_fw_start = dt_get_address(secure_mem_node, 0, NULL);
+
+	snprintf(fw_name, 64, "firmware@%llx", (unsigned long long)uv_fw_start);
+	uv_fw_node = dt_new_check(uv_node, fw_name);
+	dt_add_property_string(uv_fw_node, "compatible", "ibm,uv-firmware");
+	dt_add_property_cells(uv_fw_node, "reg", uv_fw_start >> 32,
+			uv_fw_start & 0xffffffff, UV_LOAD_MAX_SIZE >> 23,
+			UV_LOAD_MAX_SIZE & 0xffffffff);
+}
+
 int parse_hdat(bool is_opal)
 {
 	cpu_type = PVR_TYPE(mfspr(SPR_PVR));
@@ -1753,6 +1783,9 @@  int parse_hdat(bool is_opal)
 	/* Parse MS VPD */
 	memory_parse();
 
+	/* Add UV node if secure memory exists */
+	add_uv();
+
 	/* Add any FSPs */
 	fsp_parse();