This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337)
- From: Martin Jambor <mjambor at suse dot cz>
- To: Martin LiÅka <mliska at suse dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 21 Mar 2016 19:23:25 +0100
- Subject: Re: [HSA, PATCH] Allocate memory for shadow arg (PR hsa/70337)
- Authentication-results: sourceware.org; auth=none
- References: <56EFEDD5 dot 8010508 at suse dot cz>
Hi,
On Mon, Mar 21, 2016 at 01:49:25PM +0100, Martin Liska wrote:
> Hello.
>
> Following patch fixes an invalid write in HSA plug-in.
> I've been running bootstrap and regression tests on x86-linux-gnu.
>
> Ready after it finishes?
> Thanks,
> Martin
> From 2674ceb5fddeaeb26ff87d26a43bddaf40060ea2 Mon Sep 17 00:00:00 2001
> From: marxin <mliska@suse.cz>
> Date: Mon, 21 Mar 2016 13:34:04 +0100
> Subject: [PATCH] Allocate memory for shadow arg (PR hsa/70337)
>
> libgomp/ChangeLog:
>
> 2016-03-21 Martin Liska <mliska@suse.cz>
>
> PR hsa/70337
> * plugin/plugin-hsa.c (create_single_kernel_dispatch): Allocate
> memory for hsa_kernel_runtime * argument.
> ---
> libgomp/plugin/plugin-hsa.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
> index d888493..36b3cf4 100644
> --- a/libgomp/plugin/plugin-hsa.c
> +++ b/libgomp/plugin/plugin-hsa.c
> @@ -884,9 +884,10 @@ create_single_kernel_dispatch (struct kernel_info *kernel,
> shadow->private_segment_size = kernel->private_segment_size;
> shadow->group_segment_size = kernel->group_segment_size;
>
> - status
> - = hsa_memory_allocate (agent->kernarg_region, kernel->kernarg_segment_size,
> - &shadow->kernarg_address);
> + size_t kernarg_size = kernel->kernarg_segment_size
> + + sizeof (struct hsa_kernel_runtime *);
This is strange. The pointer to the shadow data structure is, from
the HSA perspective, a normal kernel argument and therefore should
already be included in the kernel->kernarg_segment_size. Have you
checked that the values are indeed off?
Martin
> + status = hsa_memory_allocate (agent->kernarg_region, kernarg_size,
> + &shadow->kernarg_address);
> if (status != HSA_STATUS_SUCCESS)
> hsa_fatal ("Could not allocate memory for HSA kernel arguments", status);
>
> --
> 2.7.1
>