lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 15 Nov 2019 10:19:45 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Shile Zhang <shile.zhang@...ux.alibaba.com>
Cc:     Josh Poimboeuf <jpoimboe@...hat.com>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Michal Marek <michal.lkml@...kovi.net>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H . Peter Anvin" <hpa@...or.com>,
        linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org
Subject: Re: [RFC PATCH v3 6/7] scripts/sorttable: Add ORC unwind tables sort
 concurrently

On Fri, Nov 15, 2019 at 02:47:49PM +0800, Shile Zhang wrote:

> @@ -141,21 +306,44 @@ static int do_sort(Elf_Ehdr *ehdr,
>  		if (r(&s->sh_type) == SHT_SYMTAB_SHNDX)
>  			symtab_shndx = (Elf32_Word *)((const char *)ehdr +
>  						      _r(&s->sh_offset));
> -	}
>  
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
> +		/* locate the ORC unwind tables */
> +		if (!strcmp(secstrings + idx, ".orc_unwind_ip")) {
> +			orctable.orc_ip_size = s->sh_size;
> +			g_orc_ip_table = (int *)((void *)ehdr +
> +						   s->sh_offset);
> +		}
> +		if (!strcmp(secstrings + idx, ".orc_unwind")) {
> +			orctable.orc_size = s->sh_size;
> +			g_orc_table = (struct orc_entry *)((void *)ehdr +
> +							     s->sh_offset);
> +		}
> +#endif
> +	} /* for loop */
> +
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)

Maybe something like:

	if (g_orc_table && g_orc_ip_table) {
		 if (pthread_create(...))
		...
	} else if (g_orc_table || g_orc_up_table) {
		fprintf(stderr, "incomplete ORC tables...\n");
	}

> +	/* create thread to sort ORC unwind tables concurrently */
> +	if (pthread_create(&orc_sort_thread, NULL, sort_orctable, &orctable)) {
> +		fprintf(stderr,
> +			"pthread_create orc_sort_thread failed '%s': %s\n",
> +			strerror(errno), fname);
> +		goto out;
> +	}
> +#endif
>  	if (!extab_sec) {
>  		fprintf(stderr,	"no __ex_table in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	if (!symtab_sec) {
>  		fprintf(stderr,	"no .symtab in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	if (!strtab_sec) {
>  		fprintf(stderr,	"no .strtab in file: %s\n", fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	extab_image = (void *)ehdr + _r(&extab_sec->sh_offset);
> @@ -192,7 +380,7 @@ static int do_sort(Elf_Ehdr *ehdr,
>  		fprintf(stderr,
>  			"no main_extable_sort_needed symbol in file: %s\n",
>  			fname);
> -		return -1;
> +		goto out;
>  	}
>  
>  	sort_needed_sec = &shdr[get_secindex(r2(&sym->st_shndx),
> @@ -205,6 +393,20 @@ static int do_sort(Elf_Ehdr *ehdr,
>  
>  	/* extable has been sorted, clear the flag */
>  	w(0, sort_needed_loc);
> +	rc = 0;
>  
> -	return 0;
> +out:
> +#if defined(SORTTABLE_64) && defined(UNWINDER_ORC_ENABLED)
> +	{ /* to avoid gcc warning about declaration */
> +	void *retval = NULL;

and then here:

	if (orc_sort_thread) {
		void *retval = NULL;
		pthread_join(...);
		...
	}

> +
> +	/* wait for ORC tables sort done */
> +	pthread_join(orc_sort_thread, &retval);
> +	if (retval) {
> +		fprintf(stderr, "%s in file: %s\n", (char *)retval, fname);
> +		rc = -1;
> +	}
> +	}
> +#endif
> +	return rc;
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ