[v2] tests: Check that no-breakpoints restore works

Submitted by Cyrill Gorcunov on April 27, 2016, 12:13 p.m.

Details

Message ID 20160427121308.GK12202@uranus.sw.swsoft.com
State Rejected
Series "tests: Check that no-breakpoints restore works"
Headers show

Commit Message

Cyrill Gorcunov April 27, 2016, 12:13 p.m.
On Wed, Apr 27, 2016 at 03:03:23PM +0300, Pavel Emelyanov wrote:
> v2: Don't clear_breakpoints too.
> 
> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>

Maybe something like?
---

Patch hide | download patch | download mbox

diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 8fd82ee674b6..3b79d74ac27a 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -649,6 +649,11 @@  int ptrace_set_breakpoint(pid_t pid, void *addr)
 {
 	int ret;
 
+	if (fault_injected(FI_NO_BREAKPOINTS)) {
+		pr_debug("Force disabling of HW breakpoints, skip arming\n");
+		return 0;
+	}
+
 	/* Set a breakpoint */
 	if (ptrace(PTRACE_POKEUSER, pid,
 			offsetof(struct user, u_debugreg[DR_FIRSTADDR]),
@@ -676,6 +681,11 @@  int ptrace_set_breakpoint(pid_t pid, void *addr)
 
 int ptrace_flush_breakpoints(pid_t pid)
 {
+	if (fault_injected(FI_NO_BREAKPOINTS)) {
+		pr_debug("Force disabling of HW breakpoints, skip flushing\n");
+		return 0;
+	}
+
 	/* Disable the breakpoint */
 	if (ptrace(PTRACE_POKEUSER, pid,
 			offsetof(struct user, u_debugreg[DR_CONTROL]),

Comments

Pavel Emelianov April 27, 2016, 12:41 p.m.
On 04/27/2016 03:13 PM, Cyrill Gorcunov wrote:
> On Wed, Apr 27, 2016 at 03:03:23PM +0300, Pavel Emelyanov wrote:
>> v2: Don't clear_breakpoints too.
>>
>> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
> 
> Maybe something like?

This will make fault injection not work when (if) we have them
implemented for other architectures.

Also my variant simply avoids pstree items loop in clear_breakpoints,
while yours will flood the logs with "... skip flushing" messages ;)

-- Pavel

> ---
> diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
> index 8fd82ee674b6..3b79d74ac27a 100644
> --- a/criu/arch/x86/crtools.c
> +++ b/criu/arch/x86/crtools.c
> @@ -649,6 +649,11 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
>  {
>  	int ret;
>  
> +	if (fault_injected(FI_NO_BREAKPOINTS)) {
> +		pr_debug("Force disabling of HW breakpoints, skip arming\n");
> +		return 0;
> +	}
> +
>  	/* Set a breakpoint */
>  	if (ptrace(PTRACE_POKEUSER, pid,
>  			offsetof(struct user, u_debugreg[DR_FIRSTADDR]),
> @@ -676,6 +681,11 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
>  
>  int ptrace_flush_breakpoints(pid_t pid)
>  {
> +	if (fault_injected(FI_NO_BREAKPOINTS)) {
> +		pr_debug("Force disabling of HW breakpoints, skip flushing\n");
> +		return 0;
> +	}
> +
>  	/* Disable the breakpoint */
>  	if (ptrace(PTRACE_POKEUSER, pid,
>  			offsetof(struct user, u_debugreg[DR_CONTROL]),
> .
>
Cyrill Gorcunov April 27, 2016, 12:54 p.m.
On Wed, Apr 27, 2016 at 03:41:04PM +0300, Pavel Emelyanov wrote:
> On 04/27/2016 03:13 PM, Cyrill Gorcunov wrote:
> > On Wed, Apr 27, 2016 at 03:03:23PM +0300, Pavel Emelyanov wrote:
> >> v2: Don't clear_breakpoints too.
> >>
> >> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
> > 
> > Maybe something like?
> 
> This will make fault injection not work when (if) we have them
> implemented for other architectures.
> 
> Also my variant simply avoids pstree items loop in clear_breakpoints,
> while yours will flood the logs with "... skip flushing" messages ;)

OK