public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/mprotect04: Use __builtin___clear_cache() to sync caches
Date: Mon, 1 Aug 2016 13:31:57 +0200	[thread overview]
Message-ID: <20160801113157.GD6899@rei.lan> (raw)
In-Reply-To: <1469550665-12918-1-git-send-email-peter.maydell@linaro.org>

Hi!
> +#include "config.h"
>  #include <signal.h>
>  #include <setjmp.h>
>  #include <sys/types.h>
> @@ -178,6 +179,16 @@ static int page_present(void *p)
>  	return 0;
>  }
>  
> +static void clear_cache(void *start, int len)
> +{
> +#if HAVE_BUILTIN_CLEAR_CACHE == 1
> +	__builtin___clear_cache(start, start + len);
> +#else
> +	tst_brkm(TCONF, cleanup,
> +		"compiler doesn't have __builtin___clear_cache()");
> +#endif
> +}
> +
>  /*
>   * Copy page where &exec_func resides. Also try to copy subsequent page
>   * in case exec_func is close to page boundary.
> @@ -189,10 +200,7 @@ static void *get_func(void *mem)
>  	uintptr_t func_page_offset = (uintptr_t)&exec_func & (page_sz - 1);
>  	void *func_copy_start = mem + func_page_offset;
>  	void *page_to_copy = (void *)((uintptr_t)&exec_func & page_mask);
> -#ifdef __powerpc__
>  	void *mem_start = mem;
> -	uintptr_t i;
> -#endif
>  
>  	/* copy 1st page, if it's not present something is wrong */
>  	if (!page_present(page_to_copy)) {
> @@ -210,11 +218,7 @@ static void *get_func(void *mem)
>  	else
>  		memset(mem, 0, page_sz);
>  
> -#ifdef __powerpc__
> -	for (i = 0; i < copy_sz; i += 4)
> -		__asm__ __volatile__("dcbst 0,%0; sync; icbi 0,%0; sync; isync"
> -			:: "r"(mem_start + i));
> -#endif
> +	clear_cache(mem_start, copy_sz);

As far as I can tell this is not needed on x86 machines so maybe we
should do something as:

...

#else
# if !defined(__x86_64__) && !defined(__i386__)
	tst_brkm(TCONF, cleanup,
		"compiler doesn't have __builtin___clear_cache()");
# endif
#endif


So that the test is not disabled on older x86 machines.


Otherwise it looks good to me.

-- 
Cyril Hrubis
chrubis@suse.cz

  parent reply	other threads:[~2016-08-01 11:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 16:31 [LTP] [PATCH] syscalls/mprotect04: Use __builtin___clear_cache() to sync caches Peter Maydell
2016-08-01 10:29 ` Jan Stancek
2016-08-01 11:06   ` Peter Maydell
2016-08-01 11:31 ` Cyril Hrubis [this message]
2016-08-01 12:23   ` Peter Maydell
2016-08-01 16:17     ` Cyril Hrubis
2016-08-05 10:08       ` Peter Maydell
2016-08-09 12:13         ` Cyril Hrubis
2016-08-09 12:25           ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160801113157.GD6899@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox