Re: [PATCH v2 4/4] fpga: zynqmp: support loading authenticated images

2021-11-02 Thread Oleksandr Suvorov
Hi Michal,

On Mon, Nov 1, 2021 at 2:06 PM Michal Simek  wrote:
>
>
>
> On 11/1/21 11:47, Oleksandr Suvorov wrote:
> > Add supporting new compatible string "u-boot,zynqmp-fpga-ddrauth" to
> > handle loading authenticated images (DDR).
> >
> > Based on solution by Jorge Ramirez-Ortiz 
> > Signed-off-by: Oleksandr Suvorov 
> > Co-developed-by: Ricardo Salveti 
> > Signed-off-by: Ricardo Salveti 
> > Tested-by: Ricardo Salveti 
> > ---
> >
> > Changes in v2:
> > - add function fit_fpga_load() to simplify calls of fpga_load()
> >from contexts without a compatible attribute.
> > - move all ZynqMP-specific logic to drivers/fpga/zynqmppl.c
> > - prepare for passing a "compatible" FDT property to any fpga driver.
> >
> >   drivers/fpga/zynqmppl.c | 21 +
> >   1 file changed, 21 insertions(+)
> >
> > diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
> > index 8ff12bf50a..ce25381890 100644
> > --- a/drivers/fpga/zynqmppl.c
> > +++ b/drivers/fpga/zynqmppl.c
> > @@ -9,6 +9,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -209,6 +210,26 @@ static int zynqmp_load(xilinx_desc *desc, const void 
> > *buf, size_t bsize,
> >   u32 buf_lo, buf_hi;
> >   u32 ret_payload[PAYLOAD_ARG_CNT];
> >   bool xilfpga_old = false;
> > + fpga_desc *fdesc = container_of((void *)desc, fpga_desc, devdesc);
> > +
> > + if (fdesc && fdesc->compatible &&
> > + !strcmp(fdesc->compatible, "u-boot,zynqmp-fpga-ddrauth")) {
> > +#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
> > + struct fpga_secure_info info = { 0 };
> > +
> > + if (!desc->operations->loads) {
> > + printf("%s: Missing load operation\n", __func__);
> > + return FPGA_FAIL;
> > + }
> > + /* DDR authentication */
> > + info.authflag = 1;
> > + info.encflag = 2;
> > + return desc->operations->loads(desc, buf, bsize, );
> > +#else
> > + printf("No support for %s\n", fdesc->compatible);
> > + return FPGA_FAIL;
> > +#endif
> > + }
> >
> >   if (zynqmp_firmware_version() <= PMUFW_V1_0) {
> >   puts("WARN: PMUFW v1.0 or less is detected\n");
> >
>
> This is fine but I would like to also see update in documentation to
> describe that possible/supported types.

Thanks, I've just updated the documentation in the 3rd version of the patchset.
>
> Thanks,
> Michal
>


-- 
Best regards,

Oleksandr Suvorov
Software Engineer
T: +380 63 8489656
E: oleksandr.suvo...@foundries.io
W: www.foundries.io


Re: [PATCH v2 4/4] fpga: zynqmp: support loading authenticated images

2021-11-01 Thread Michal Simek




On 11/1/21 11:47, Oleksandr Suvorov wrote:

Add supporting new compatible string "u-boot,zynqmp-fpga-ddrauth" to
handle loading authenticated images (DDR).

Based on solution by Jorge Ramirez-Ortiz 
Signed-off-by: Oleksandr Suvorov 
Co-developed-by: Ricardo Salveti 
Signed-off-by: Ricardo Salveti 
Tested-by: Ricardo Salveti 
---

Changes in v2:
- add function fit_fpga_load() to simplify calls of fpga_load()
   from contexts without a compatible attribute.
- move all ZynqMP-specific logic to drivers/fpga/zynqmppl.c
- prepare for passing a "compatible" FDT property to any fpga driver.

  drivers/fpga/zynqmppl.c | 21 +
  1 file changed, 21 insertions(+)

diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
index 8ff12bf50a..ce25381890 100644
--- a/drivers/fpga/zynqmppl.c
+++ b/drivers/fpga/zynqmppl.c
@@ -9,6 +9,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -209,6 +210,26 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, 
size_t bsize,
u32 buf_lo, buf_hi;
u32 ret_payload[PAYLOAD_ARG_CNT];
bool xilfpga_old = false;
+   fpga_desc *fdesc = container_of((void *)desc, fpga_desc, devdesc);
+
+   if (fdesc && fdesc->compatible &&
+   !strcmp(fdesc->compatible, "u-boot,zynqmp-fpga-ddrauth")) {
+#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+   struct fpga_secure_info info = { 0 };
+
+   if (!desc->operations->loads) {
+   printf("%s: Missing load operation\n", __func__);
+   return FPGA_FAIL;
+   }
+   /* DDR authentication */
+   info.authflag = 1;
+   info.encflag = 2;
+   return desc->operations->loads(desc, buf, bsize, );
+#else
+   printf("No support for %s\n", fdesc->compatible);
+   return FPGA_FAIL;
+#endif
+   }
  
  	if (zynqmp_firmware_version() <= PMUFW_V1_0) {

puts("WARN: PMUFW v1.0 or less is detected\n");



This is fine but I would like to also see update in documentation to 
describe that possible/supported types.


Thanks,
Michal



[PATCH v2 4/4] fpga: zynqmp: support loading authenticated images

2021-11-01 Thread Oleksandr Suvorov
Add supporting new compatible string "u-boot,zynqmp-fpga-ddrauth" to
handle loading authenticated images (DDR).

Based on solution by Jorge Ramirez-Ortiz 
Signed-off-by: Oleksandr Suvorov 
Co-developed-by: Ricardo Salveti 
Signed-off-by: Ricardo Salveti 
Tested-by: Ricardo Salveti 
---

Changes in v2:
- add function fit_fpga_load() to simplify calls of fpga_load()
  from contexts without a compatible attribute.
- move all ZynqMP-specific logic to drivers/fpga/zynqmppl.c
- prepare for passing a "compatible" FDT property to any fpga driver.

 drivers/fpga/zynqmppl.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/drivers/fpga/zynqmppl.c b/drivers/fpga/zynqmppl.c
index 8ff12bf50a..ce25381890 100644
--- a/drivers/fpga/zynqmppl.c
+++ b/drivers/fpga/zynqmppl.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -209,6 +210,26 @@ static int zynqmp_load(xilinx_desc *desc, const void *buf, 
size_t bsize,
u32 buf_lo, buf_hi;
u32 ret_payload[PAYLOAD_ARG_CNT];
bool xilfpga_old = false;
+   fpga_desc *fdesc = container_of((void *)desc, fpga_desc, devdesc);
+
+   if (fdesc && fdesc->compatible &&
+   !strcmp(fdesc->compatible, "u-boot,zynqmp-fpga-ddrauth")) {
+#if CONFIG_IS_ENABLED(FPGA_LOAD_SECURE)
+   struct fpga_secure_info info = { 0 };
+
+   if (!desc->operations->loads) {
+   printf("%s: Missing load operation\n", __func__);
+   return FPGA_FAIL;
+   }
+   /* DDR authentication */
+   info.authflag = 1;
+   info.encflag = 2;
+   return desc->operations->loads(desc, buf, bsize, );
+#else
+   printf("No support for %s\n", fdesc->compatible);
+   return FPGA_FAIL;
+#endif
+   }
 
if (zynqmp_firmware_version() <= PMUFW_V1_0) {
puts("WARN: PMUFW v1.0 or less is detected\n");
-- 
2.31.1