This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/6792

-- gerrit

commit e7ab402f70744572350dcde672bd326e16480697
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Fri Dec 24 11:27:25 2021 +0100

    arm_adi_v5: instrument valgrind to find uninitialized values
    
    The pointer passed to a queued read don't hold a value until the
    queue is flushed successfully.
    Tell valgrind that the pointer points to an uninitialized value.
    Valgrind will signal any use of the value until it get written by
    the read's callback.
    
    Change-Id: I659f395c07bcc6498644db9d1684eec1ee85f8ab
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 8d6d6618b..fff97a7c2 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -83,6 +83,7 @@
 #include <helper/time_support.h>
 #include <helper/list.h>
 #include <helper/jim-nvp.h>
+#include <helper/oocd_valgrind.h>
 
 /* ARM ADI Specification requires at least 10 bits used for TAR autoincrement  
*/
 
@@ -243,6 +244,8 @@ int mem_ap_read_u32(struct adiv5_ap *ap, target_addr_t 
address,
 {
        int retval;
 
+       VALGRIND_MAKE_MEM_UNDEFINED(value, sizeof(*value));
+
        /* Use banked addressing (REG_BDx) to avoid some link traffic
         * (updating TAR) when reading several consecutive addresses.
         */
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h
index 5c598f16e..acc605de0 100644
--- a/src/target/arm_adi_v5.h
+++ b/src/target/arm_adi_v5.h
@@ -30,6 +30,7 @@
  */
 
 #include <helper/list.h>
+#include <helper/oocd_valgrind.h>
 #include "arm_jtag.h"
 #include "helper/bits.h"
 
@@ -451,6 +452,7 @@ static inline int dap_queue_dp_read(struct adiv5_dap *dap,
                unsigned reg, uint32_t *data)
 {
        assert(dap->ops);
+       VALGRIND_MAKE_MEM_UNDEFINED(data, sizeof(*data));
        return dap->ops->queue_dp_read(dap, reg, data);
 }
 
@@ -486,6 +488,7 @@ static inline int dap_queue_ap_read(struct adiv5_ap *ap,
                unsigned reg, uint32_t *data)
 {
        assert(ap->dap->ops);
+       VALGRIND_MAKE_MEM_UNDEFINED(data, sizeof(*data));
        return ap->dap->ops->queue_ap_read(ap, reg, data);
 }
 

-- 

Reply via email to