IPU3 ImgU driver parameter struct fixes
Subsystems (3)
Sakari Ailus
maintainercover IPU3 ImgU driver parameter struct fixes
Hi all,
This set addresses parameter struct memory layout changes introduced by seemingly innocent patches, and adds a sanity check for the struct size to avoid this from happening again. This only touches the uAPI, not the ipu3-abi.h that deals with ABI not visible in the driver uAPI. That should be addressed as well going forward.
The first patch does not probably entirely fix the issues, but with the second patch added, pahole agrees the struct memory layout is unchanged from the previous state.
Sakari Ailus (3):
Revert "staging: imgu: Address a compiler warning on alignment"
staging: ipu3-imgu: Move alignment attribute to field
staging: ipu3-imgu: Add a sanity check for the parameter struct size
drivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.c | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1
Sakari Ailus
maintainerPATCH 1/3 Revert "staging: imgu: Address a compiler warning on alignment"
This reverts commit ef4104f3d81d8f0d897d7f0cd5d01b006c3caf80.
The patch being reverted changed the memory layout of struct ipu3_uapi_acc_param. Revert it, and address the compiler warning issues in further patches.
--- drivers/staging/media/ipu3/include/intel-ipu3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu3/include/intel-ipu3.h +1 -1
@@ -2477,7 +2477,7 @@ struct ipu3_uapi_acc_param { struct ipu3_uapi_yuvp1_yds_config yds2 __attribute__((aligned(32))); struct ipu3_uapi_yuvp2_tcc_static_config tcc __attribute__((aligned(32)));struct ipu3_uapi_anr_config anr; - struct ipu3_uapi_awb_fr_config_s awb_fr __attribute__((aligned(32))); +struct ipu3_uapi_awb_fr_config_s awb_fr;struct ipu3_uapi_ae_config ae;struct ipu3_uapi_af_config_s af;struct ipu3_uapi_awb_config awb;
Signature · 1 line
2.20.1
Sakari Ailus
maintainerPATCH 1/3 Revert "staging: imgu: Address a compiler warning on alignment"
This reverts commit c9d52c114a9fcc61c30512c7f810247a9f2812af.
The patch being reverted changed the memory layout of struct ipu3_uapi_acc_param. Revert it, and address the compiler warning issues in further patches.
---
since v1:
- Fixed upstream commit id.
drivers/staging/media/ipu3/include/intel-ipu3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu3/include/intel-ipu3.h +1 -1
@@ -2477,7 +2477,7 @@ struct ipu3_uapi_acc_param { struct ipu3_uapi_yuvp1_yds_config yds2 __attribute__((aligned(32))); struct ipu3_uapi_yuvp2_tcc_static_config tcc __attribute__((aligned(32)));struct ipu3_uapi_anr_config anr; - struct ipu3_uapi_awb_fr_config_s awb_fr __attribute__((aligned(32))); +struct ipu3_uapi_awb_fr_config_s awb_fr;struct ipu3_uapi_ae_config ae;struct ipu3_uapi_af_config_s af;struct ipu3_uapi_awb_config awb;
Signature · 1 line
2.20.1
Sakari Ailus
maintainerPATCH 2/3 staging: ipu3-imgu: Move alignment attribute to field
In reply to Sakari AilusMove the alignment attribute of struct ipu3_uapi_awb_fr_config_s to the field in struct ipu3_uapi_4a_config, the other location where the struct is used.
--- drivers/staging/media/ipu3/include/intel-ipu3.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/media/ipu3/include/intel-ipu3.h +3 -2
@@ -450,7 +450,7 @@ struct ipu3_uapi_awb_fr_config_s {__u32 bayer_sign;__u8 bayer_nf;__u8 reserved2[7 ]; -} __attribute__((aligned(32))) __packed; +} __packed;/** * struct ipu3_uapi_4a_config - 4A config
@@ -466,7 +466,8 @@ struct ipu3_uapi_4a_config {struct ipu3_uapi_ae_grid_config ae_grd_config;__u8 padding[20 ];struct ipu3_uapi_af_config_s af_config; -struct ipu3_uapi_awb_fr_config_s awb_fr_config; + struct ipu3_uapi_awb_fr_config_s awb_fr_config + __attribute__((aligned(32))); } __packed;/**
Signature · 1 line
2.20.1
Sakari Ailus
maintainerPATCH 3/3 staging: ipu3-imgu: Add a sanity check for the parameter struct size
In reply to Sakari AilusThere have been cases where seemingly innocuous patches have broken the uAPI by changing the memory layout of the parameter struct. Generally such changes also introduce a change in the size of the entire struct. This patch adds a sanity check to avoid such cases happening in the future.
--- drivers/staging/media/ipu3/ipu3-css.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/staging/media/ipu3/ipu3-css.c +7 -0
@@ -1911,6 +1911,13 @@ int imgu_css_meta_fmt_set(struct v4l2_meta_format *fmt)switch (fmt->dataformat) {case V4L2_META_FMT_IPU3_PARAMS : fmt->buffersize =sizeof (struct ipu3_uapi_params ); + +/* +* Sanity check for the parameter struct size. This must +* not change! +*/ +BUILD_BUG_ON (sizeof (struct ipu3_uapi_params ) !=39328 ); +break ;case V4L2_META_FMT_IPU3_STAT_3A : fmt->buffersize =sizeof (struct ipu3_uapi_stats_3a );
Signature · 1 line
2.20.1
Quoted 21 lines · Sakari Ailus
Hi all,
This set addresses parameter struct memory layout changes introduced by seemingly innocent patches, and adds a sanity check for the struct size to avoid this from happening again. This only touches the uAPI, not the
ipu3-abi.hthat deals with ABI not visible in the driver uAPI. That should be addressed as well going forward.The first patch does not probably entirely fix the issues, but with the second patch added, pahole agrees the struct memory layout is unchanged from the previous state.
Sakari Ailus (3):
Revert "staging: imgu: Address a compiler warning on alignment"
staging: ipu3-imgu: Move alignment attribute to field
staging: ipu3-imgu: Add a sanity check for the parameter struct sizedrivers/staging/media/ipu3/include/intel-ipu3.h | 7 ++++--- drivers/staging/media/ipu3/ipu3-css.c | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
Signature · 2 lines
Best regards, Bingbu Cao
Sakari Ailus
maintainerQuoted 1 line · Bingbu Cao
Tested-by Bingbu Cao <[email protected]>
Thanks, Bingbu!
Signature · 1 line
Sakari Ailus